From d4c5dbfc5738715e2b6e9211c8f28a132723c4a9 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Mon, 2 Feb 2026 12:39:17 +0800 Subject: [PATCH] feat: fine-tune user account dropdown menu with Radix UI and custom animations --- src/components/UnifiedNavigation.tsx | 96 +++++++++++++++++----------- tailwind.config.js | 26 ++++++++ 2 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/components/UnifiedNavigation.tsx b/src/components/UnifiedNavigation.tsx index a76bca4..104aad2 100644 --- a/src/components/UnifiedNavigation.tsx +++ b/src/components/UnifiedNavigation.tsx @@ -4,13 +4,14 @@ import Image from "next/image"; import { usePathname } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { useLanguage } from "../i18n/LanguageProvider"; -import { Menu, X, Sun, Moon, Monitor, Plus } from "lucide-react"; +import { Menu, X, Sun, Moon, Monitor, Plus, BarChart2 } from "lucide-react"; import { translations } from "../i18n/translations"; import LanguageToggle from "./LanguageToggle"; import { AskAIButton } from "./AskAIButton"; import ReleaseChannelSelector from "./ReleaseChannelSelector"; import { useUserStore } from "@lib/userStore"; import { useMoltbotStore } from "@lib/moltbotStore"; +import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; import { createNavConfig, filterNavItems, @@ -272,42 +273,65 @@ export default function UnifiedNavigation() { -
+
{user ? ( -
- - {accountMenuOpen ? ( -
-
-

- {user.username} -

-

{user.email}

-
-
- {accountNav.map((item) => ( - setAccountMenuOpen(false)} - > - {typeof item.label === "function" - ? item.label(language) - : item.label} - - ))} -
-
- ) : null} +
+ + + + + + + +
+

+ {user.username} +

+

+ {user.email} +

+
+ +
+ {accountNav.map((item) => ( + + setAccountMenuOpen(false)} + > + {item.icon && ( + + )} + + {typeof item.label === "function" + ? item.label(language) + : item.label} + + + + ))} +
+
+
+
) : (
diff --git a/tailwind.config.js b/tailwind.config.js index 27dbc20..ca94990 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -85,6 +85,32 @@ const tailwindConfig = { boxShadow: { soft: '0 35px 80px -45px rgba(37, 78, 219, 0.35), 0 25px 60px -40px rgba(15, 23, 42, 0.25)', }, + + // 自定义动效 + keyframes: { + 'fade-in': { + '0%': { opacity: '0' }, + '100%': { opacity: '1' }, + }, + 'fade-out': { + '0%': { opacity: '1' }, + '100%': { opacity: '0' }, + }, + 'scale-in': { + '0%': { transform: 'scale(0.95)' }, + '100%': { transform: 'scale(1)' }, + }, + 'scale-out': { + '0%': { transform: 'scale(1)' }, + '100%': { transform: 'scale(0.95)' }, + }, + }, + animation: { + 'fade-in': 'fade-in 120ms ease-out', + 'fade-out': 'fade-out 120ms ease-in', + 'zoom-in-95': 'scale-in 120ms ease-out', + 'zoom-out-95': 'scale-out 120ms ease-in', + }, }, },