Skip to content

Commit f51b7d1

Browse files
committed
perf: dropdown menu style
1 parent 39870b0 commit f51b7d1

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/app/page.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import webui1 from "../../public/webui-1.webp";
55
import { useEffect, useState, useRef, useCallback } from "react";
66
import { useI18n } from "../components/i18n/I18nProvider";
77
import Reveal from "../components/Reveal";
8-
import { SparklesIcon, HeartIcon, PuzzlePieceIcon, EllipsisHorizontalIcon, ArrowRightIcon } from "@heroicons/react/24/solid";
8+
import { SparklesIcon, HeartIcon, PuzzlePieceIcon, EllipsisHorizontalIcon, ArrowRightIcon, ChevronDownIcon } from "@heroicons/react/24/solid";
99

1010
function formatCompactNumber(n: number): string {
1111
if (!Number.isFinite(n)) return "";
@@ -147,12 +147,12 @@ function Navbar() {
147147
</button>
148148
</li>
149149
<li ref={langRef} className="relative">
150-
<button aria-expanded={openLang} onClick={() => setOpenLang((v) => !v)} className="inline-flex items-center gap-2 h-9 px-3 rounded-full border border-ui opacity-80 hover:opacity-100 transition duration-200">
151-
<span className="current-language transition-colors duration-200 text-[var(--foreground)]">{langLabel}</span>
152-
<span aria-hidden className="transition-colors duration-200 text-[var(--foreground)]"></span>
150+
<button aria-expanded={openLang} onClick={() => setOpenLang((v) => !v)} className="inline-flex items-center gap-2 h-9 px-3 rounded-full border border-ui opacity-80 hover:opacity-100 transition-colors duration-200 text-[var(--foreground)]">
151+
<span className="current-language">{langLabel}</span>
152+
<ChevronDownIcon aria-hidden className={`w-4 h-4 transition-transform duration-200 ${openLang ? 'rotate-180' : ''}`} />
153153
</button>
154154
{openLang && (
155-
<ul className="absolute right-0 mt-2 w-36 rounded-lg border border-ui bg-background shadow">
155+
<ul className="absolute right-0 mt-5 w-28 rounded-lg border border-ui bg-background shadow-lg origin-top-right animate-dropdown">
156156
<li className="px-3 py-2 hover:bg-black/[.04] dark:hover:bg-white/[.06] cursor-pointer" onClick={() => { setLocale("zh-CN"); setOpenLang(false); }}>简体中文</li>
157157
<li className="px-3 py-2 hover:bg-black/[.04] dark:hover:bg-white/[.06] cursor-pointer" onClick={() => { setLocale("en-US"); setOpenLang(false); }}>English</li>
158158
<li className="px-3 py-2 hover:bg-black/[.04] dark:hover:bg-white/[.06] cursor-pointer" onClick={() => { setLocale("ja-JP"); setOpenLang(false); }}>日本語</li>
@@ -175,7 +175,7 @@ function Navbar() {
175175
{openMenu && (
176176
<div className="md:hidden absolute left-0 right-0 top-16 z-40">
177177
<div className="mx-auto max-w-6xl px-4 sm:px-6 pb-4 mt-2">
178-
<div className="rounded-2xl border border-ui bg-background/90 backdrop-blur shadow-lg p-4">
178+
<div className="rounded-2xl border border-ui bg-background/90 backdrop-blur shadow-lg p-4 animate-dropdown origin-top">
179179
<ul className="flex flex-col gap-2 text-sm">
180180
<li><a href="https://docs.astrbot.app" className="inline-flex items-center h-10 px-3 rounded-full border border-ui opacity-80 hover:opacity-100 transition">{t("nav.quickStart")}</a></li>
181181
<li><a href="https://plugins.astrbot.app/" className="inline-flex items-center h-10 px-3 rounded-full border border-ui opacity-80 hover:opacity-100 transition">{t("nav.plugin")}</a></li>
@@ -204,9 +204,7 @@ function Navbar() {
204204
<circle cx="12" cy="12" r="9" />
205205
<path d="M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18" />
206206
</svg>
207-
<svg className={`w-4 h-4 transition-transform ${openLangMobile ? 'rotate-180' : ''}`} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
208-
<path d="M6 9l6 6 6-6" />
209-
</svg>
207+
<ChevronDownIcon className={`w-4 h-4 transition-transform duration-200 ${openLangMobile ? 'rotate-180' : ''}`} aria-hidden />
210208
</button>
211209
{openLangMobile && (
212210
<div className="flex items-center gap-2 flex-wrap">

src/assets/globals.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,9 @@ a, button, input, textarea {
277277
}
278278
.reveal-init { opacity: 1 !important; transform: none !important; }
279279
}
280+
281+
@keyframes dropdown-in {
282+
from { opacity: 0; transform: scale(0.98) translateY(-6px); }
283+
to { opacity: 1; transform: scale(1) translateY(0); }
284+
}
285+
.animate-dropdown { animation: dropdown-in .16s ease-out; }

0 commit comments

Comments
 (0)