'use client' import { useEffect, useRef, useState, type MouseEvent } from 'react' import Link from 'next/link' import { usePathname } from 'next/navigation' import saws from '../assets/saws.png' import SocialMediaLinks from './social-media-links' import './site-header.css' const menuLinks = [ { label: 'Home', href: '/' }, { label: 'About', href: '/about-us' }, { label: 'Plans', href: '/plans' }, { label: 'Contact', href: '/contact' }, ] as const const ctaHref = '/contact' function isActivePath(pathname: string, href: string) { if (href === '/') return pathname === '/' return pathname === href || pathname.startsWith(`${href}/`) } export default function SiteHeader() { const pathname = usePathname() const menuToggleRef = useRef(null) const [scrolled, setScrolled] = useState(false) const [pendingPath, setPendingPath] = useState(null) const activePath = pendingPath ?? pathname useEffect(() => { setPendingPath(null) }, [pathname]) useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 24) onScroll() window.addEventListener('scroll', onScroll, { passive: true }) return () => window.removeEventListener('scroll', onScroll) }, []) const closeMobileMenu = () => { if (menuToggleRef.current) { menuToggleRef.current.checked = false } } const handleNavClick = (href: string) => (event: MouseEvent) => { setPendingPath(href) closeMobileMenu() event.currentTarget.blur() } return (
) }