"use client"; import Link from "next/link"; import { useEffect, useRef, useState } from "react"; import PackageIcon from "./Icons"; const Navbar = () => { const [activeLink, setActiveLink] = useState("home"); const [bgStyles, setBgStyles] = useState({}); const [scrolled, setScrolled] = useState(false); const linkRefs = useRef<{ [key: string]: HTMLAnchorElement | null }>({}); const updateBackground = (linkId: string) => { const linkElement = linkRefs.current[linkId]; if (linkElement) { setBgStyles({ padding: "1rem 0rem", width: `${linkElement.clientWidth - 12}px`, transform: `translateX(${linkElement.offsetLeft}px)`, opacity: 1, }); } }; // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { updateBackground(activeLink); const handleScroll = () => { const isScrolled = window.scrollY > 50; setScrolled(isScrolled); }; window.addEventListener("scroll", handleScroll); window.addEventListener("resize", () => updateBackground(activeLink)); return () => { window.removeEventListener("scroll", handleScroll); window.removeEventListener("resize", () => updateBackground(activeLink)); }; }, [activeLink]); return ( ); }; export default Navbar;