function Header() { const { lang, t, setLang } = useLang(); const [scrolled, setScrolled] = React.useState(false); const [open, setOpen] = React.useState(false); const [active, setActive] = React.useState('home'); const navItems = [ { id: 'home', label: t.nav.home }, { id: 'services', label: t.nav.services }, { id: 'taboor', label: t.nav.taboor }, { id: 'about', label: t.nav.about }, { id: 'contact', label: t.nav.contact }, ]; React.useEffect(() => { const onScroll = () => { setScrolled(window.scrollY > 24); // active section const sections = ['home', 'services', 'taboor', 'about', 'contact']; const offset = window.innerHeight * 0.4; let cur = 'home'; for (const id of sections) { const el = document.getElementById(id); if (el && el.getBoundingClientRect().top <= offset) cur = id; } setActive(cur); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); return () => window.removeEventListener('scroll', onScroll); }, []); const goTo = (id) => { setOpen(false); const el = document.getElementById(id); if (el) { const top = el.getBoundingClientRect().top + window.scrollY - 70; window.scrollTo({ top, behavior: 'smooth' }); } }; const toggleLang = () => setLang(lang === 'ar' ? 'en' : 'ar'); return (
{/* desktop nav */}
{/* mobile menu */}
{navItems.map((item) => ( ))}
{useTheme().theme === 'light' ? (lang === 'ar' ? 'الوضع الليلي' : 'Dark Mode') : (lang === 'ar' ? 'الوضع النهاري' : 'Light Mode')}
); } window.Header = Header;