Polish the mobile menu

- Header: replaces the plain "Menu" title with the brand mark
  (animated, matching the dashboard hero) + wordmark and a short
  description line
- Nav rows get icons and an active-state background/icon tint instead
  of reusing the desktop tab strip's underline
- Desktop tabs also gain matching icons
- Theme toggle and Log out move from the cramped mobile header into
  labeled rows at the bottom of the drawer; desktop keeps them in the
  header
- The header hamburger button is now a self-contained, controlled
  toggle whose bars morph into an X on open/close, sized to match the
  drawer's built-in close button

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-01 19:23:38 +02:00
co-authored by Claude Sonnet 5
parent 69e4fb286c
commit f8f687af4e
+109 -17
View File
@@ -4,19 +4,19 @@ import { useState } from "react";
import Link from "next/link"; import Link from "next/link";
import { usePathname, useRouter } from "next/navigation"; import { usePathname, useRouter } from "next/navigation";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import { Menu, Moon, Sun, LogOut } from "lucide-react"; import { Moon, Sun, LogOut, Gauge, SlidersHorizontal, ListMusic, Bluetooth, BarChart3 } from "lucide-react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Sheet, SheetContent, SheetTitle, SheetTrigger } from "@/components/ui/sheet"; import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
import { ConnectionStatus } from "./ConnectionStatus"; import { ConnectionStatus } from "./ConnectionStatus";
import { BrandMark } from "./BrandMark"; import { BrandMark } from "./BrandMark";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
const LINKS = [ const LINKS = [
{ href: "/", label: "Dashboard" }, { href: "/", label: "Dashboard", icon: Gauge },
{ href: "/control", label: "Control" }, { href: "/control", label: "Control", icon: SlidersHorizontal },
{ href: "/sessions", label: "Sessions" }, { href: "/sessions", label: "Sessions", icon: ListMusic },
{ href: "/devices", label: "Devices" }, { href: "/devices", label: "Devices", icon: Bluetooth },
{ href: "/stats", label: "Stats" }, { href: "/stats", label: "Stats", icon: BarChart3 },
]; ];
function isActive(pathname: string, href: string): boolean { function isActive(pathname: string, href: string): boolean {
@@ -33,12 +33,13 @@ function NavLinks({ onNavigate }: { onNavigate?: () => void }) {
href={link.href} href={link.href}
onClick={onNavigate} onClick={onNavigate}
className={cn( className={cn(
"border-b-2 px-2.5 py-1.5 text-xs font-medium tracking-wide uppercase transition-colors", "flex items-center gap-1.5 border-b-2 px-2.5 py-1.5 text-xs font-medium tracking-wide uppercase transition-colors",
isActive(pathname, link.href) isActive(pathname, link.href)
? "border-primary text-foreground" ? "border-primary text-foreground"
: "border-transparent text-muted-foreground hover:text-foreground", : "border-transparent text-muted-foreground hover:text-foreground",
)} )}
> >
<link.icon className="size-3.5" />
{link.label} {link.label}
</Link> </Link>
))} ))}
@@ -46,6 +47,60 @@ function NavLinks({ onNavigate }: { onNavigate?: () => void }) {
); );
} }
/** Drawer rows for the mobile menu - icon + label, styled as tappable
* console rows rather than the desktop tab strip's underline treatment. */
function MobileNavLinks({ onNavigate }: { onNavigate: () => void }) {
const pathname = usePathname();
return (
<>
{LINKS.map((link) => {
const active = isActive(pathname, link.href);
return (
<Link
key={link.href}
href={link.href}
onClick={onNavigate}
className={cn(
"flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium transition-colors",
active ? "bg-accent text-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
)}
>
<link.icon className={cn("size-4 shrink-0", active && "text-primary")} />
{link.label}
</Link>
);
})}
</>
);
}
/** Hamburger that morphs into an X - the top/bottom bars rotate into place
* and the middle bar collapses, rather than a straight icon swap. */
function MenuToggleIcon({ open }: { open: boolean }) {
return (
<span className="relative flex size-4 shrink-0 flex-col items-center justify-center" aria-hidden>
<span
className={cn(
"absolute h-0.5 w-4 rounded-full bg-current transition-transform duration-300 ease-out motion-reduce:transition-none",
open ? "translate-y-0 rotate-45" : "-translate-y-[5px] rotate-0",
)}
/>
<span
className={cn(
"absolute h-0.5 w-4 rounded-full bg-current transition-all duration-200 ease-out motion-reduce:transition-none",
open ? "scale-x-0 opacity-0" : "scale-x-100 opacity-100",
)}
/>
<span
className={cn(
"absolute h-0.5 w-4 rounded-full bg-current transition-transform duration-300 ease-out motion-reduce:transition-none",
open ? "translate-y-0 -rotate-45" : "translate-y-[5px] rotate-0",
)}
/>
</span>
);
}
export function NavBar() { export function NavBar() {
const { theme, setTheme } = useTheme(); const { theme, setTheme } = useTheme();
const router = useRouter(); const router = useRouter();
@@ -71,6 +126,8 @@ export function NavBar() {
<div className="ml-auto flex items-center gap-2"> <div className="ml-auto flex items-center gap-2">
<ConnectionStatus /> <ConnectionStatus />
<div className="hidden items-center gap-2 md:flex">
<Button <Button
variant="ghost" variant="ghost"
size="icon" size="icon"
@@ -83,18 +140,53 @@ export function NavBar() {
<Button variant="ghost" size="icon" aria-label="Log out" onClick={handleLogout}> <Button variant="ghost" size="icon" aria-label="Log out" onClick={handleLogout}>
<LogOut className="size-4" /> <LogOut className="size-4" />
</Button> </Button>
</div>
<Button
variant="ghost"
size="icon-sm"
className="md:hidden"
aria-label={menuOpen ? "Close menu" : "Open menu"}
onClick={() => setMenuOpen((open) => !open)}
>
<MenuToggleIcon open={menuOpen} />
</Button>
<Sheet open={menuOpen} onOpenChange={setMenuOpen}> <Sheet open={menuOpen} onOpenChange={setMenuOpen}>
<SheetTrigger asChild> <SheetContent side="right" className="w-72 gap-0 p-0">
<Button variant="ghost" size="icon" className="md:hidden" aria-label="Open menu"> <div className="flex items-center gap-2 px-4 pt-4 pb-3">
<Menu className="size-4" /> <BrandMark size={24} animated />
</Button> <SheetTitle className="font-heading text-lg font-semibold">Sexy</SheetTitle>
</SheetTrigger> </div>
<SheetContent side="right" className="w-64"> <SheetDescription className="px-4 pb-3 text-xs">
<SheetTitle className="px-4 pt-4">Menu</SheetTitle> Jump to another page or manage your session.
<nav className="flex flex-col gap-1 p-4"> </SheetDescription>
<NavLinks onNavigate={() => setMenuOpen(false)} /> <div className="bp-hairline" />
<nav className="flex flex-1 flex-col gap-1 p-3">
<MobileNavLinks onNavigate={() => setMenuOpen(false)} />
</nav> </nav>
<div className="bp-hairline" />
<div className="flex flex-col gap-1 p-3">
<button
type="button"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"
>
<Sun className="hidden size-4 dark:block" />
<Moon className="block size-4 dark:hidden" />
{theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
</button>
<button
type="button"
onClick={() => void handleLogout()}
className="flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive"
>
<LogOut className="size-4" />
Log out
</button>
</div>
</SheetContent> </SheetContent>
</Sheet> </Sheet>
</div> </div>