'use client'; import { Menu, X } from 'lucide-react'; import Link from 'next/link'; import { useEffect, useRef, useState } from 'react'; const LINKS = [ { href: '/#how', label: 'How it works' }, { href: '/templates', label: 'Templates' }, { href: '/pricing', label: 'Pricing' }, { href: '/docs', label: 'Docs' }, { href: '/guides', label: 'Guides' }, { href: '/changelog', label: 'Changelog' }, ]; /** Hamburger menu shown below the md breakpoint, where the inline nav is hidden. */ export function MarketingMobileMenu() { const [open, setOpen] = useState(false); const rootRef = useRef(null); // While the panel is open: lock body scroll, close on Escape and on any // pointerdown outside the menu subtree. All three effects unwind together // when the panel closes or the component unmounts. useEffect(() => { if (!open) return; const prevOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpen(false); }; const onPointerDown = (e: PointerEvent) => { if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false); }; document.addEventListener('keydown', onKey); document.addEventListener('pointerdown', onPointerDown); return () => { document.body.style.overflow = prevOverflow; document.removeEventListener('keydown', onKey); document.removeEventListener('pointerdown', onPointerDown); }; }, [open]); return (
{open && (
)}
); }