freezmo/components/AppHeader.tsx
Martin Dvorak 8557b04621 Navigation restructure: five-tab bottom bar, no phone drawer
Drawer removed (phones only; desktop rail untouched)
- MobileSidebar, sidebarOpen/useSidebarOpen, MenuIcon and the drawer's
  back-gesture layer are gone; the shared nav content now serves only
  the desktop rail (dead mobile branches deleted). No drawer-specific
  CSS existed; the three drawer strings (header.openMenu,
  sidebar.closeMenu, common.menu) and library.importAria are removed.
- The header drops the hamburger: logo + name on the left, the single
  theme chip on the right.

Five-tab bottom bar
- Library / Progress / New deck (prominent centre +) / Exam / Settings,
  in that order; Progress and Exam reuse the existing /stats and /exam
  screens, Settings keeps opening the dialog. Sliding pill, icon bounce,
  press feedback, re-tap-to-top and safe-area padding kept; every item
  is >=44px (72px wide at 360px).
- New short tab.* keys (EN + CS) so all five labels stay on one line at
  360px — 'Zkouškový režim' became 'Zkouška'. No ellipsis anywhere.
- The bar is mounted once in AppHeader so library, progress, exam and
  share get it; the wizards keep their own bottom action bar and the
  tab bar steps aside there, exactly as before.

Re-homed drawer destinations
- Smart Review card loses the Exam link (it is a tab now); Review due
  and Mistakes stay.
- New deck screen (and /homework) get a Study deck / Make my homework
  segmented switch; the library's homework empty-state button stays.
- The phone import icon becomes a ... button opening a sheet with
  Import JSON and New folder (back-gesture and Escape close it); folder
  chips still appear only once at least one folder exists, and folder
  creation stays in the New deck options step.

Verified: mobile suite 134 checks (no hamburger/drawer, tab order and
44px targets, label matrix at 360/390 x EN/CS x dark/light x reduced
motion, per-tab routing, deep links, Back from every tab, the ... sheet
with folder creation) plus regression 74/74, wizard 83/83, declutter
116/116, animation 8/8, native 35/35, i18n 25/25, phase1 38/38, phase2
43/43, phase3 20/20, freeze-loading 6/6. Key parity 740/740. Lint +
build clean. SW freezmo-v28.
2026-10-10 16:53:55 +00:00

85 lines
3.2 KiB
TypeScript

"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import { SettingsDialog } from "@/components/SettingsDialog";
import { TabBar } from "@/components/TabBar";
import { ThemeToggle } from "@/components/ThemeToggle";
import { useI18n } from "@/lib/i18n";
import { OPEN_SETTINGS_EVENT } from "@/lib/ui-events";
import { cn } from "@/lib/utils";
/**
* Minimal, sticky frosted top bar: brand on the left, theme chip on the
* right. Phones navigate with the bottom tab bar (also mounted here, so every
* screen that has a header gets it); the desktop rail carries navigation.
*/
export function AppHeader({ className, compact = false }: { className?: string; compact?: boolean }) {
const { t } = useI18n();
const [settingsOpen, setSettingsOpen] = useState(false);
const [settingsFocus, setSettingsFocus] = useState<{ field: "key"; nonce: number } | null>(null);
useEffect(() => {
const onOpen = (event: Event) => {
setSettingsOpen(true);
const focus = (event as CustomEvent<{ focus?: string }>).detail?.focus;
if (focus === "key") setSettingsFocus({ field: "key", nonce: Date.now() });
};
window.addEventListener(OPEN_SETTINGS_EVENT, onOpen);
return () => window.removeEventListener(OPEN_SETTINGS_EVENT, onOpen);
}, []);
// Restore the desktop sidebar width preference once, on the client.
useEffect(() => {
void import("@/components/Sidebar").then((module) => module.sidebarCollapse.hydrate());
}, []);
return (
<>
<header
className={cn(
// No negative margins here: the header is a direct child of <main>,
// which has no horizontal padding — the -mx-4 made it 16px wider
// than the viewport and caused a horizontal scroll on phones.
"glass sticky top-0 z-40 mb-6 px-4 lg:hidden sm:px-6",
className,
)}
>
<div className="mx-auto flex h-14 max-w-6xl items-center justify-between gap-3">
<Link
href="/"
className="group flex min-w-0 items-center gap-2.5 rounded-xl px-1 py-1"
aria-label={t("header.home")}
>
{/* eslint-disable-next-line @next/next/no-img-element -- static app icon, no optimisation needed */}
<img
src="/icons/icon-192.png"
alt=""
aria-hidden
className="size-8 shrink-0 rounded-[0.6rem] transition-transform group-hover:scale-[1.04]"
/>
<span className="flex min-w-0 items-baseline gap-2">
<span className="text-[15px] font-semibold tracking-[-0.01em] text-[var(--text)]">Freezmo</span>
{!compact ? (
<span className="hidden truncate text-[13px] text-[var(--text-subtle)] sm:inline">
{t("header.tagline")}
</span>
) : null}
</span>
</Link>
<div className="flex shrink-0 items-center gap-1">
<ThemeToggle />
</div>
</div>
</header>
<TabBar />
<SettingsDialog
open={settingsOpen}
onClose={() => setSettingsOpen(false)}
focusField={settingsFocus}
/>
</>
);
}