/* global React, Logo, useLocale, LanguageSwitch */ // Jullia — site header. Kit-local (not the DS-bundled SiteNav): five tabs // (Home, Car Audio, Home Audio, Philosophy, Contact), the real logo mark, a // language switch, and a small mobile menu. Fixed to the top, transparent // over black, a hairline once scrolled. function SiteHeader({ active, scrolled = false, onNavigate }) { const { t } = useLocale(); const [hoverKey, setHoverKey] = React.useState(null); const [aHover, setAHover] = React.useState(false); const [menuOpen, setMenuOpen] = React.useState(false); const navItems = [ { key: 'Home', label: t('nav.home') }, { key: 'CarAudio', label: t('nav.carAudio') }, { key: 'HomeAudio', label: t('nav.homeAudio') }, { key: 'Philosophy', label: t('nav.philosophy') }, { key: 'Contacts', label: t('nav.contacts') }, ]; const go = (key) => { setMenuOpen(false); onNavigate && onNavigate(key); }; // Close on Escape, and lock the page's own scroll container while the // mobile menu is open (the app scrolls a div, not the window). React.useEffect(() => { if (!menuOpen) return undefined; const scrollRoot = document.getElementById('jx-scroll-root'); const prevOverflow = scrollRoot ? scrollRoot.style.overflow : ''; if (scrollRoot) scrollRoot.style.overflow = 'hidden'; const onKey = (e) => { if (e.key === 'Escape') setMenuOpen(false); }; document.addEventListener('keydown', onKey); return () => { if (scrollRoot) scrollRoot.style.overflow = prevOverflow; document.removeEventListener('keydown', onKey); }; }, [menuOpen]); // If the viewport crosses back into desktop width, drop the mobile state // so it can't linger (and keep the scroll lock) behind the hidden burger. React.useEffect(() => { const onResize = () => { if (window.innerWidth > 780) setMenuOpen(false); }; window.addEventListener('resize', onResize); return () => window.removeEventListener('resize', onResize); }, []); return ( ); } window.SiteHeader = SiteHeader;