import { FileText, Home, LogOut, Menu, Settings, User, X, type LucideIcon } from 'lucide-react'; import { useState } from 'react'; import { Link, NavLink } from 'react-router-dom'; import { useAuth } from '../../auth'; import logo from '../../assets/logo.svg'; import { cn } from '../../lib/utils'; export interface HeaderProps { className?: string; } interface NavItem { to: string; label: string; icon: LucideIcon; /** Match the route exactly (used for "/"). */ end?: boolean; } const NAV_ITEMS: NavItem[] = [ { to: '/', label: 'Home', icon: Home, end: true }, { to: '/articles', label: 'Articles', icon: FileText }, { to: '/categories', label: 'Categories', icon: Settings }, ]; /** * Main navigation header. * * Uses react-router-dom (never plain anchors) so navigation stays * client-side. Lucide icons mark each item; the mobile menu collapses the * same links into a toggleable panel below breakpoints. */ export function Header({ className }: HeaderProps) { const [menuOpen, setMenuOpen] = useState(false); const { username, ready } = useAuth(); const closeMenu = () => setMenuOpen(false); const linkClasses = ({ isActive }: { isActive: boolean }): string => cn( 'inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors', 'text-slate-600 hover:bg-slate-100 hover:text-slate-900', isActive && 'bg-blue-50 text-blue-700 hover:bg-blue-100 hover:text-blue-800', ); const plainLinkClasses = 'inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium text-slate-600 hover:bg-slate-100 hover:text-slate-900'; // Auth links: sign-in/register when logged out, account/sign-out when // signed in (rendered once the session restore has settled). const renderAuthLinks = (onClick?: () => void) => ready && (username ? ( <>