"use client"; import { useState, useEffect } from "react"; const NAV_ITEMS = [ { label: "Over", id: "over" }, { label: "Ervaring", id: "ervaring" }, { label: "Skills", id: "skills" }, { label: "Apps", id: "apps" }, { label: "Contact", id: "contact" }, ]; export function Nav() { const [active, setActive] = useState("over"); const [scrolled, setScrolled] = useState(false); useEffect(() => { const handleScroll = () => { setScrolled(window.scrollY > 20); const sections = [...NAV_ITEMS].reverse(); for (const { id } of sections) { const el = document.getElementById(id); if (el && el.getBoundingClientRect().top < 200) { setActive(id); break; } } }; window.addEventListener("scroll", handleScroll, { passive: true }); return () => window.removeEventListener("scroll", handleScroll); }, []); const handleNav = (id: string) => { document.getElementById(id)?.scrollIntoView({ behavior: "smooth" }); }; return ( ); }