// App entry — orchestrates sections, modals, scroll-spy nav. const { useState: useStateA, useEffect: useEffectA, useCallback: useCallbackA, useRef: useRefA } = React; function App(){ const [activeSection, setActiveSection] = useStateA(''); const [collectionId, setCollectionId] = useStateA(null); const [lightboxIdx, setLightboxIdx] = useStateA(null); const [formOpen, setFormOpen] = useStateA(false); const [formInitColl, setFormInitColl] = useStateA(''); // Scroll-spy useEffectA(()=>{ const ids = ['collections', 'designer', 'bespoke', 'lookbook', 'press', 'contact']; const onScroll = ()=>{ const y = window.scrollY + 200; let cur = ''; ids.forEach(id=>{ const el = document.getElementById(id); if(el && el.offsetTop <= y) cur = id; }); setActiveSection(cur); }; window.addEventListener('scroll', onScroll, {passive:true}); onScroll(); return ()=>window.removeEventListener('scroll', onScroll); },[]); const navigate = useCallbackA((id)=>{ if(id==='top'){ window.scrollTo({top:0, behavior:'smooth'}); return; } const el = document.getElementById(id); if(el){ window.scrollTo({top: el.offsetTop - 60, behavior:'smooth'}); } },[]); const openBook = useCallbackA((coll='')=>{ setFormInitColl(coll); setFormOpen(true); },[]); // Detect "light" nav when over light section const [navLight, setNavLight] = useStateA(false); useEffectA(()=>{ const lightIds = ['designer', 'press']; const onScroll = ()=>{ const top = window.scrollY + 50; let light=false; lightIds.forEach(id=>{ const el = document.getElementById(id); if(el){ const start = el.offsetTop; const end = start + el.offsetHeight; if(top >= start && top < end) light = true; } }); setNavLight(light); }; window.addEventListener('scroll', onScroll, {passive:true}); onScroll(); return ()=>window.removeEventListener('scroll', onScroll); },[]); return ( <>