'use client' import Image from 'next/image' import { useEffect, useState, useCallback } from 'react' const NAV_SECTIONS = ['criteria', 'leaderboard', 'about', 'insights'] as const const NAV_LABELS: Record = { criteria: 'Overview', leaderboard: 'Results', about: 'Methodology', insights: 'Insights', } export default function Nav({ modelCount, lastUpdated }: { modelCount: number; lastUpdated: string }) { const [scrolled, setScrolled] = useState(false) const [showTitle, setShowTitle] = useState(false) const [activeSection, setActiveSection] = useState(null) const [menuOpen, setMenuOpen] = useState(false) useEffect(() => { const update = () => { setScrolled(window.scrollY > 20) const heroTitle = document.getElementById('hero-title') if (heroTitle) { const rect = heroTitle.getBoundingClientRect() setShowTitle(rect.bottom < 0) } const scrollMid = window.scrollY + window.innerHeight * 0.35 let current: string | null = null for (const id of NAV_SECTIONS) { const el = document.getElementById(id) if (el && el.offsetTop <= scrollMid) current = id } setActiveSection(current) } update() window.addEventListener('scroll', update, { passive: true }) return () => window.removeEventListener('scroll', update) }, []) const closeMenu = useCallback(() => setMenuOpen(false), []) return ( <>
{NAV_SECTIONS.map(id => ( {NAV_LABELS[id]} ))}
) }