From 9e353ecc01a11ffb1055d587bd0a6f80bec219f6 Mon Sep 17 00:00:00 2001 From: Daniel Villatoro <57822891+DanielVillatoro@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:32:41 -0600 Subject: [PATCH] =?UTF-8?q?Developed=20User=20Menu=20with=20dynamic=20them?= =?UTF-8?q?e=20switching,=20language=20dropdown=20w=E2=80=A6=20(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Developed User Menu with dynamic theme switching, language dropdown with flags, updated icons, and improved UI consistency. -Integrated dynamic theme switching (Light/Dark mode) using next-themes with a Switch component and dynamic Sun/Moon icons. -Added language dropdown with flags (en-flag.svg and es-flag.svg) for English and Spanish, displaying the selected language in the menu trigger. -Replaced History icon with FileDollar for the Transactions option. -Improved alignment, spacing, and transitions. -Refactored imports logic for maintainability. * Changes on DropdownMenuSubContent for languaje. --- .../shared/header/action-buttons.tsx | 4 - .../components/shared/header/user-menu.tsx | 106 ++++++++++++++++-- 2 files changed, 99 insertions(+), 11 deletions(-) diff --git a/apps/frontend/app/components/shared/header/action-buttons.tsx b/apps/frontend/app/components/shared/header/action-buttons.tsx index 5a30930..13e27bf 100644 --- a/apps/frontend/app/components/shared/header/action-buttons.tsx +++ b/apps/frontend/app/components/shared/header/action-buttons.tsx @@ -3,7 +3,6 @@ import { Bell, ShoppingCart, Wallet } from "lucide-react"; import { Button } from "@/app/components/ui/button"; -import { ThemeToggle } from "../../ui/theme-toggle"; import { UserMenu } from "./user-menu"; import * as Tooltip from "@radix-ui/react-tooltip"; import { ConnectWalletModal } from "./connect-wallet-modal"; @@ -47,9 +46,6 @@ export const ActionButtons = () => { - - - diff --git a/apps/frontend/app/components/shared/header/user-menu.tsx b/apps/frontend/app/components/shared/header/user-menu.tsx index 4ecdaf7..22e289a 100644 --- a/apps/frontend/app/components/shared/header/user-menu.tsx +++ b/apps/frontend/app/components/shared/header/user-menu.tsx @@ -1,4 +1,8 @@ -import { History, List, Settings, User } from "lucide-react"; +"use client"; + +import { List, Settings, User, Moon, Sun, Globe, Receipt } from "lucide-react"; +import { useState } from "react"; +import { useTheme } from "next-themes"; import { Button } from "@/app/components/ui/button"; import { @@ -6,9 +10,17 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, + DropdownMenuSub, + DropdownMenuSubTrigger, + DropdownMenuSubContent, } from "@/app/components/ui/dropdown-menu"; +import { Switch } from "@/app/components/ui/switch"; export const UserMenu = () => { + const { theme, setTheme } = useTheme(); // Handles the light/dark mode logic + const isDarkMode = theme === "dark"; // Check current theme + const [language, setLanguage] = useState("EN"); + return ( @@ -16,23 +28,103 @@ export const UserMenu = () => { - + + {/* Profile Options */} - Profile + Profile - My Listings + My Products - - Transaction History + + Transactions - Settings + Settings + + + {/* Divider Line */} + + + {/* Dark Mode Toggle */} + + + + {isDarkMode ? ( + + ) : ( + + )} + {isDarkMode ? "Dark Mode" : "Light Mode"} + + + setTheme(checked ? "dark" : "light") + } + className="ml-2" + /> + + + {/* Language Dropdown */} + + + + + + Language + + + + {language} + + + + {/* */} + {/* */} + + + {/* */} + + + + + setLanguage("EN")}> + + + EN + + + setLanguage("ES")}> + + + ES + + + + );