/* ─── Gallery: tabbed image gallery ─────────────────────────── Content comes from window.HOOPOE_GALLERY (defined in index.html). Click a tab → its images show in a grid. Click an image → lightbox. ───────────────────────────────────────────────────────────── */ function Gallery() { const TABS = window.HOOPOE_GALLERY || []; const [active, setActive] = React.useState(0); const [lightbox, setLightbox] = React.useState(null); // { images, index } if (TABS.length === 0) return null; const activeTab = TABS[active] || TABS[0]; const images = activeTab.images || []; const openLightbox = (i) => setLightbox({ images, index: i }); const closeLightbox = () => setLightbox(null); const nav = (dir) => setLightbox(lb => { if (!lb) return lb; const n = lb.images.length; return { ...lb, index: (lb.index + dir + n) % n }; }); React.useEffect(() => { if (!lightbox) return; const onKey = (e) => { if (e.key === 'Escape') closeLightbox(); if (e.key === 'ArrowRight') nav(1); if (e.key === 'ArrowLeft') nav(-1); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [lightbox]); return ( ); } Object.assign(window, { Gallery });