/* Motion · site navigation with mega dropdowns. Sticky header. Two mega-dropdowns: · "Funkcje" — every feature grouped by module (4-column grid) · "Cennik" / "Wsparcie" — flat single-column dropdowns Plus standard nav links, primary CTA, and a mobile drawer. Highlights an item if its slug matches `activeFeature` prop. */ const { useState: useNavState, useEffect: useNavEffect, useRef: useNavRef } = React; /* Click-outside / Escape close helper. */ function useDismiss(ref, onClose) { useNavEffect(() => { const onDocClick = (e) => { if (ref.current && !ref.current.contains(e.target)) onClose(); }; const onKey = (e) => { if (e.key === "Escape") onClose(); }; document.addEventListener("mousedown", onDocClick); document.addEventListener("keydown", onKey); return () => { document.removeEventListener("mousedown", onDocClick); document.removeEventListener("keydown", onKey); }; }, [ref, onClose]); } /* Clamp a dropdown into the viewport horizontally: if the natural left:0 positioning makes it spill off the right edge, shift it left by the overflow. Re-runs on resize. */ function useViewportClamp(ref) { useNavEffect(() => { const el = ref.current; if (!el) return; const adjust = () => { el.style.left = "0"; const r = el.getBoundingClientRect(); const margin = 12; if (r.right > window.innerWidth - margin) { const shift = r.right - (window.innerWidth - margin); el.style.left = `-${Math.round(shift)}px`; } else if (r.left < margin) { el.style.left = `${Math.round(margin - r.left)}px`; } }; adjust(); window.addEventListener("resize", adjust); return () => window.removeEventListener("resize", adjust); }, [ref]); } function MegaTrigger({ label, isOpen, onClick }) { return ( ); } function FunkcjeMega({ activeFeature, onClose }) { const ref = useNavRef(null); useViewportClamp(ref); return (
{mod.name}
{mod.features.map((f) => (Nie wiesz, od czego zacząć? Pokażemy Ci tylko te funkcje, których naprawdę potrzebujesz.
Umów prezentację