"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useTranslations, useLocale } from "@/lib/i18n"; import { Github, Menu, X, Sun, Moon } from "lucide-react"; import { useState } from "react"; import { cn } from "@/lib/utils"; const NAV_ITEMS = [ { key: "timeline", href: "/timeline" }, { key: "compare", href: "/compare" }, { key: "layers", href: "/layers" }, ] as const; const LOCALES = [ { code: "en", label: "EN" }, { code: "zh", label: "中文" }, { code: "ja", label: "日本語" }, ]; export function Header() { const t = useTranslations("nav"); const pathname = usePathname(); const locale = useLocale(); const [mobileOpen, setMobileOpen] = useState(false); const [dark, setDark] = useState(() => { if (typeof window !== "undefined") { const stored = localStorage.getItem("theme"); if (stored) return stored === "dark"; return window.matchMedia("(prefers-color-scheme: dark)").matches; } return false; }); function toggleDark() { const next = !dark; setDark(next); document.documentElement.classList.toggle("dark", next); localStorage.setItem("theme", next ? "dark" : "light"); } function switchLocale(newLocale: string) { const newPath = pathname.replace(`/${locale}`, `/${newLocale}`); window.location.href = newPath; } return (
Learn Claude Code {/* Desktop nav */} {/* Mobile hamburger */}
{/* Mobile menu */} {mobileOpen && (
{NAV_ITEMS.map((item) => ( setMobileOpen(false)} > {t(item.key)} ))}
{LOCALES.map((l) => ( ))}
)}
); }