feat(back-button): add dark variant and update tests for BackButton component

This commit is contained in:
2026-07-13 16:10:10 +08:00
parent 3362fafa1c
commit 19857e8b9b
4 changed files with 40 additions and 26 deletions
+24 -24
View File
@@ -8,6 +8,7 @@
import type { ReactNode } from "react";
import { Lock, Menu } from "lucide-react";
import { BackButton } from "@/app/_components";
import { ROUTES } from "@/router/routes";
import { useAppNavigator } from "@/router/use-app-navigator";
@@ -19,9 +20,9 @@ export interface ChatHeaderProps {
export function ChatHeader({ isGuest, offerBanner }: ChatHeaderProps) {
const navigator = useAppNavigator();
if (isGuest) {
return (
<header className="flex shrink-0 flex-col items-stretch bg-transparent p-0">
return (
<header className="flex shrink-0 flex-col items-stretch bg-transparent p-0">
{isGuest ? (
<button
type="button"
className="flex w-full cursor-pointer items-center justify-center gap-(--spacing-sm,8px) border-0 bg-(--color-accent,#f84d96) px-(--spacing-md,12px) py-(--spacing-sm,8px) text-center text-(length:--responsive-caption,var(--font-size-sm,12px)) font-medium text-white"
@@ -35,29 +36,28 @@ export function ChatHeader({ isGuest, offerBanner }: ChatHeaderProps) {
/>
<span>Sign up to unlock more features</span>
</button>
</header>
);
}
) : (
offerBanner
)}
return (
<header className="flex shrink-0 flex-col items-stretch bg-transparent p-0">
{offerBanner}
<div className="ml-(--spacing-md,12px) flex items-center justify-between px-(--spacing-md,12px) py-(--spacing-sm,8px)">
{/* 菜单按钮(点击 → push 到 /sidebar,与 Dart MenuButton 一致) */}
<button
type="button"
className="flex cursor-pointer items-center justify-center rounded-(--radius-full,999px) border-0 bg-[rgba(13,11,20,0.7)] p-(--spacing-sm,8px) text-(--color-text-primary,#fff)"
onClick={() => navigator.push(ROUTES.sidebar)}
aria-label="Menu"
>
<Menu
className="size-(--icon-size-xl,32px)"
size={24}
aria-hidden="true"
{!isGuest ? (
<div className="flex items-center justify-between px-(--spacing-md,12px) py-(--spacing-sm,8px)">
<BackButton
href={ROUTES.splash}
variant="dark"
ariaLabel="Back to home"
/>
</button>
</div>
<button
type="button"
className="flex size-(--responsive-icon-button-size,42px) cursor-pointer items-center justify-center rounded-(--radius-full,999px) border border-[rgba(255,255,255,0.12)] bg-[rgba(13,11,20,0.7)] text-(--color-text-primary,#fff) shadow-[0_10px_24px_rgba(0,0,0,0.2)] backdrop-blur-md transition-[background,transform] duration-150 hover:bg-[rgba(28,24,39,0.82)] active:scale-96 focus-visible:outline-2 focus-visible:outline-offset-3 focus-visible:outline-[#f657a0]"
onClick={() => navigator.push(ROUTES.sidebar)}
aria-label="Menu"
>
<Menu size={24} aria-hidden="true" />
</button>
</div>
) : null}
</header>
);
}