'use client'; import { Suspense, useState, useEffect, useCallback } from 'react'; import { StaticLink } from '@/components/ui/static-link'; import Image from 'next/image'; import { usePathname } from 'next/navigation'; import { Menu, X, MessageCircle } from 'lucide-react'; import { AnimatePresence, motion } from 'framer-motion'; import { Button } from '@/components/ui/button'; import { ThemeToggle } from '@/components/ui/theme-toggle'; import { useTheme } from '@/contexts/theme-context'; import { COMPANY_INFO, NAVIGATION_V2, MEGA_DROPDOWN_DATA, type NavigationItemV2 } from '@/lib/constants'; import { MegaDropdown } from '@/components/layout/mega-dropdown'; import { useFocusTrap } from '@/hooks/use-focus-trap'; function HeaderContent() { const [isOpen, setIsOpen] = useState(false); const [isScrolled, setIsScrolled] = useState(false); const [openDropdown, setOpenDropdown] = useState(null); const pathname = usePathname(); const focusTrapRef = useFocusTrap(isOpen); const { resolvedTheme } = useTheme(); useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 20); }; const handleGlobalKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' && isOpen) { setIsOpen(false); } }; window.addEventListener('scroll', handleScroll, { passive: true }); window.addEventListener('keydown', handleGlobalKeyDown); return () => { window.removeEventListener('scroll', handleScroll); window.removeEventListener('keydown', handleGlobalKeyDown); }; }, [isOpen]); const handleKeyDown = useCallback((e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setIsOpen(!isOpen); } if (e.key === 'Escape' && isOpen) { setIsOpen(false); } }, [isOpen]); const handleNavClick = useCallback((e: React.MouseEvent, item: NavigationItemV2) => { e.preventDefault(); window.location.href = item.href; setIsOpen(false); }, []); const isActive = useCallback((item: NavigationItemV2) => { if (item.id === 'contact') { return pathname === '/contact'; } if (item.id === 'home') { return pathname === '/'; } if (item.id === 'products') { return pathname === '/products' || pathname.startsWith('/products/'); } if (item.id === 'solutions') { return pathname === '/solutions' || pathname.startsWith('/solutions/'); } return pathname === `/${item.id}`; }, [pathname]); return ( <>
{COMPANY_INFO.name}
{isOpen && (
setIsOpen(false)} aria-hidden="true" /> )} ); } function HeaderFallback() { return (
); } export function Header() { return ( }> ); }