"use client"; import { type ReactNode, useEffect, useRef, useState } from "react"; interface MobileNavProps { children: ReactNode; menuLabel?: string; closeLabel?: string; } export function MobileNav({ children, menuLabel = "Open menu", closeLabel = "Close menu", }: MobileNavProps) { const [open, setOpen] = useState(false); const panelRef = useRef(null); useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(false); }; document.addEventListener("keydown", onKey); return () => document.removeEventListener("keydown", onKey); }, [open]); return ( <> {open && (
setOpen(false)} style={{ backgroundColor: "rgba(0,0,0,0.6)" }} /> )} ); }