'use client'; import { useState, useEffect } from 'react'; import { Menu, X } from 'lucide-react'; import { NAVIGATION } from '@/lib/constants'; import { cn } from '@/lib/utils'; import { useFocusTrap } from '@/hooks/use-focus-trap'; interface MobileMenuProps { className?: string; } export function MobileMenu({ className }: MobileMenuProps) { const [isOpen, setIsOpen] = useState(false); const focusTrapRef = useFocusTrap(isOpen); useEffect(() => { if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = 'unset'; } return () => { document.body.style.overflow = 'unset'; }; }, [isOpen]); const handleNavClick = (href: string) => { setIsOpen(false); const element = document.querySelector(href); if (element) { element.scrollIntoView({ behavior: 'smooth' }); } }; const handleKeyDown = (event: React.KeyboardEvent, href?: string) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); if (href) { handleNavClick(href); } else { setIsOpen(!isOpen); } } if (event.key === 'Escape' && isOpen) { setIsOpen(false); } }; return (
{isOpen && ( <>
setIsOpen(false)} aria-hidden="true" /> )}
); }