fix: simplify desktop search panel
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 25s

This commit is contained in:
TerryM
2026-05-31 03:21:23 +08:00
parent 345ccb0a25
commit c71ebba807
2 changed files with 54 additions and 53 deletions

View File

@@ -361,7 +361,8 @@ export function SearchPanel({
</section>
) : null}
<section className={cleanQuery ? "mt-6" : showInput ? "mt-5" : "mt-0"}>
{!cleanQuery ? (
<section className={showInput ? "mt-5" : "mt-0"}>
<div className="mb-3 flex items-center justify-between">
<h2 className="border-l-4 border-ark-gold pl-3 text-base font-bold text-neutral-100">
{t("currentTags")}
@@ -369,7 +370,9 @@ export function SearchPanel({
</div>
{isTagLoading ? (
<div className="py-3 text-sm text-neutral-500">{t("loading")}</div>
<div className="py-3 text-sm text-neutral-500">
{t("loading")}
</div>
) : tags.length > 0 ? (
<div className="flex flex-wrap gap-2">
{tags.map((tag) => {
@@ -396,6 +399,7 @@ export function SearchPanel({
</div>
)}
</section>
) : null}
{selectedTag ? (
<section className="mt-6">

View File

@@ -613,28 +613,26 @@ export function PublicLayout() {
<div className="flex min-w-0 flex-1 items-center justify-end gap-2 min-[1100px]:flex-none">
<div
ref={desktopSearchRef}
className="hidden h-10 min-w-0 flex-1 items-center gap-2 rounded-full border border-ark-line bg-[#1a1b20] py-2 pl-3 pr-3 shadow-inner md:flex min-[1100px]:w-44 min-[1100px]:flex-none lg:pr-4 xl:w-52"
className={`hidden md:block ${
desktopSearchOpen ? "pointer-events-none opacity-0" : ""
}`}
>
<button
type="button"
onClick={() => {
if (q.trim()) goSearch();
else setDesktopSearchOpen((value) => !value);
}}
className="shrink-0 rounded-full p-1 text-[#c6c7cf] transition hover:bg-white/5 hover:text-ark-gold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ark-gold/60"
aria-label={t("searchNow")}
>
<SearchIcon size={16} />
</button>
<input
value={q}
onFocus={() => setDesktopSearchOpen(true)}
onClick={() => setDesktopSearchOpen(true)}
onChange={(e) => setQ(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && goSearch()}
placeholder={t("searchPlaceholder")}
className="min-w-0 flex-1 rounded-md bg-transparent text-sm text-neutral-200 outline-none placeholder:text-[#777985] focus-visible:ring-2 focus-visible:ring-ark-gold/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[#1a1b20]"
/>
className="flex h-10 min-w-0 flex-1 items-center gap-2 rounded-full border border-ark-line bg-[#1a1b20] py-2 pl-3 pr-3 text-left shadow-inner outline-none transition hover:border-ark-gold/50 focus-visible:ring-2 focus-visible:ring-ark-gold/60 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg min-[1100px]:w-44 min-[1100px]:flex-none lg:pr-4 xl:w-52"
aria-label={t("searchNow")}
aria-expanded={desktopSearchOpen}
>
<SearchIcon size={16} className="shrink-0 text-[#c6c7cf]" />
<span
className={`min-w-0 flex-1 truncate text-sm ${
q.trim() ? "text-neutral-200" : "text-[#777985]"
}`}
>
{q.trim() || t("searchPlaceholder")}
</span>
</button>
</div>
<LanguageDropdown
lang={lang}
@@ -736,7 +734,6 @@ export function PublicLayout() {
onSearch={goSearch}
onResultClick={() => setDesktopSearchOpen(false)}
variant="desktop"
showInput={false}
/>
) : null}