fix(home): reposition title and compact account entry

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 13:55:24 +08:00
1 parent 886b4589a1
commit a9fa221d7a
6 files changed
+80 -13

No files matched your search

+9 -6
View File
@@ -48,23 +48,26 @@ export function HomeAccountMenu({ accountName, avatarUrl, onOpenProfile }: {
if (!user) return null;
return <div className="relative w-64 max-w-full" data-testid="home-account-controls">
return <div className="relative h-[3.125rem] w-32 max-w-full" data-testid="home-account-controls">
<button ref={trigger} type="button" data-testid="home-account-menu-trigger"
aria-label={`打开账户菜单:${accountName}`} aria-haspopup="menu" aria-expanded={open} aria-controls="home-account-menu"
className="motion-press flex min-h-12 w-full items-center gap-3 rounded-2xl border border-border/80 bg-background px-4 py-2 text-left text-sm font-medium shadow-sm hover:bg-surface-subtle"
className="group motion-press relative h-full w-full text-left"
onClick={() => setOpen(value => !value)}
onKeyDown={event => {
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
event.preventDefault(); setOpen(true); focusItem(event.key === 'ArrowUp');
}
}}>
<UserAvatar src={avatarUrl} initial={initial} className="h-8 w-8 shrink-0" />
<span className="min-w-0 flex-1 truncate">{accountName}</span>
<ChevronUp aria-hidden="true" className={`h-4 w-4 shrink-0 transition-transform ${open ? 'rotate-180' : ''}`} />
<span data-testid="home-account-trigger-surface"
className="pointer-events-none absolute bottom-0 left-0 flex min-h-12 w-64 origin-bottom-left scale-50 items-center gap-3 rounded-2xl border border-border/80 bg-background px-4 py-2 text-sm font-medium shadow-sm group-hover:bg-surface-subtle">
<UserAvatar src={avatarUrl} initial={initial} className="h-8 w-8 shrink-0" />
<span className="min-w-0 flex-1 truncate">{accountName}</span>
<ChevronUp aria-hidden="true" className={`h-4 w-4 shrink-0 transition-transform ${open ? 'rotate-180' : ''}`} />
</span>
</button>
<DisclosureContent ref={menu} id="home-account-menu" open={open} role="menu" aria-label="账户菜单"
data-testid="home-account-menu"
className="glass-surface absolute bottom-[calc(100%+0.5rem)] left-0 z-50 w-72 max-w-[calc(100vw-2rem)] rounded-2xl border border-border/80 p-3 text-foreground shadow-float"
className="glass-surface absolute bottom-[2.0625rem] left-0 z-50 w-72 max-w-[calc(100vw-2rem)] rounded-2xl border border-border/80 p-3 text-foreground shadow-float"
innerClassName="max-h-[calc(100dvh-8rem)] overflow-y-auto"
onKeyDown={event => {
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return;