const Nav = () => { const [activeSection, setActiveSection] = React.useState("approach"); const [isMenuOpen, setIsMenuOpen] = React.useState(false); const navItems = [ { id: "approach", label: "Approach" }, { id: "providers", label: "Providers" }, { id: "specialties", label: "Specialties" }, { id: "contact", label: "Contact" }, ]; React.useEffect(() => { const handleScroll = () => { let currentSection = "approach"; navItems.forEach((item) => { const section = document.getElementById(item.id); if (section) { const sectionTop = section.offsetTop - 140; if (window.scrollY >= sectionTop) { currentSection = item.id; } } }); setActiveSection(currentSection); }; window.addEventListener("scroll", handleScroll); handleScroll(); return () => window.removeEventListener("scroll", handleScroll); }, []); const handleNavClick = (id) => { setActiveSection(id); setIsMenuOpen(false); }; return ( ); }; Object.assign(window, { Nav });