fix(web): tighten PublicLayout header on mobile
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 12s
Deploy / Build Web Image (push) Failing after 22s
Deploy / Build AI Services Image (push) Failing after 10s
E2E Tests / Playwright E2E (push) Failing after 21s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 4s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 1m32s
Deploy / Build API Image (push) Failing after 42s
Deploy / Deploy to Staging (push) Has been cancelled
Deploy / Smoke Test Staging (push) Has been cancelled
Deploy / Rollback Staging (push) Has been cancelled
Deploy / Smoke Test Production (push) Has been cancelled
Deploy / Rollback Production (push) Has been cancelled
Deploy / Deploy to Production (push) Has been cancelled
Security Scanning / Trivy Scan — Web Image (push) Has been cancelled
Security Scanning / Trivy Scan — AI Services Image (push) Has been cancelled
Security Scanning / Trivy Filesystem Scan (push) Has been cancelled
Security Scanning / Security Gate (push) Has been cancelled
Security Scanning / Trivy Scan — API Image (push) Has been cancelled

The header on <sm viewports was crowded for logged-in users: the
desktop Dashboard button, NotificationBell, and hamburger toggle all
rendered on the same row next to the LanguageSwitcher, which pushed
content to the edges on 375px screens and duplicated the Dashboard CTA
(the mobile hamburger menu already exposes it).

- Hide the Dashboard button in the header behind `hidden sm:inline-flex`
  — mobile users reach it through the hamburger menu's full-width CTA.
- Hide NotificationBell behind `hidden sm:block` for the same reason;
  the bell needs enough room for its popover which doesn't fit well on
  mobile widths.
- Switch the right-side container from `space-x-2` to `gap-1 sm:gap-2`
  so icon-only buttons don't touch on narrow screens.
- Clamp the `user.fullName` inline label with `max-w-[12rem] truncate`
  to stop extremely long names pushing the header out of shape on
  borderline-sm widths.
- Mark the hamburger button as `shrink-0` + `type="button"` +
  `aria-expanded`, and annotate the `min-w-0` on the right group so
  flex children can truncate correctly.

Verified at 375×812: header now shows logo | language | hamburger only;
tapping the hamburger opens the drawer which carries bell-adjacent
items and the Dashboard CTA.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-04-19 09:19:19 +07:00
parent 79e173938b
commit b93c62372d

View File

@@ -80,15 +80,19 @@ export default function PublicLayout({ children }: { children: React.ReactNode }
))} ))}
</nav> </nav>
<div className="ml-auto flex items-center space-x-2"> <div className="ml-auto flex min-w-0 items-center gap-1 sm:gap-2">
<LanguageSwitcher /> <LanguageSwitcher />
{user ? ( {user ? (
<> <>
<NotificationBell /> {/* Bell only on sm+ to avoid overcrowding mobile header */}
<span className="hidden text-sm text-muted-foreground sm:inline"> <div className="hidden sm:block">
<NotificationBell />
</div>
<span className="hidden max-w-[12rem] truncate text-sm text-muted-foreground sm:inline">
{user.fullName} {user.fullName}
</span> </span>
<Link href="/dashboard"> {/* Dashboard button is desktop-only; mobile users reach it via the hamburger menu */}
<Link href="/dashboard" className="hidden sm:inline-flex">
<Button size="sm">{t('common.dashboard')}</Button> <Button size="sm">{t('common.dashboard')}</Button>
</Link> </Link>
</> </>
@@ -106,8 +110,10 @@ export default function PublicLayout({ children }: { children: React.ReactNode }
)} )}
{/* Mobile menu toggle */} {/* Mobile menu toggle */}
<button <button
type="button"
aria-label={mobileMenuOpen ? t('nav.closeMenu') : t('nav.openMenu')} aria-label={mobileMenuOpen ? t('nav.closeMenu') : t('nav.openMenu')}
className="inline-flex items-center justify-center rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-accent-foreground sm:hidden" aria-expanded={mobileMenuOpen}
className="inline-flex shrink-0 items-center justify-center rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-accent-foreground sm:hidden"
onClick={() => setMobileMenuOpen(!mobileMenuOpen)} onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
> >
{mobileMenuOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />} {mobileMenuOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}