freezmo/components/AppHeader.tsx
Martin Dvorak 9d204b85be One-pill study chrome, toggling chat pickers, readable homework steps
UI batch from feedback:

- The study/review/exam/homework chrome is now a single 58px pill: round
  close button, title + position over the progress bar, chips (or the exam
  timer) at the far end — everything on the centre line, so nothing crowds
  the rounded corners any more. Homework guide gets the same recipe.
- The immersive feeds carry z-[45] so they paint over the app chrome (on
  /exam the header used to cover the top of the chrome), and the page chrome
  behind an open overlay (.app-header, .segmented, .tabbar) is hidden while
  the transparent overlay is up, so it can no longer ghost through the glass.
  The guide's disclaimer moved inside the overlay with it.
- Chat: the context and model chips toggle their own popover (pressed state,
  aria-expanded), opening one closes the other, a press outside closes it —
  no more being forced to pick something to get out.
- Homework: the model's plain-text step explanations/hints/verdicts keep
  their line breaks (whitespace-pre-wrap) — a step used to collapse into one
  run-on paragraph with the whole solution inside it; the guide prompt now
  says the explanation is coaching, 2-4 sentences.
- The four glacier blobs are at 25% of their old opacity (0.045 light,
  0.1 dark).

Tests: phase-2 chrome geometry + exam layering checks (62), chat desktop
picker checks (101), the standing suites all green. README: decisions 54-56,
decision 23 updated. SW -> freezmo-v44.
2026-10-12 14:21:11 +00:00

91 lines
3.5 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 { IS_DEV_INSTANCE } from "@/lib/dev-mode";
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 app-header 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>
{IS_DEV_INSTANCE ? (
<span className="rounded-md border border-amber-400/60 bg-amber-400/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-700 dark:text-amber-300">
DEV
</span>
) : null}
{!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}
/>
</>
);
}