'use client' import { useEffect, useRef, useState } from 'react' import { Link } from 'react-router-dom' import { AnimatePresence, motion } from 'framer-motion' import clsx from 'clsx' import { Button } from './Button' function NavLinks() { let [hoveredIndex, setHoveredIndex] = useState(null) let timeoutRef = useRef(null) return ( <> {[ ['Home', '/'], ['Cloud', '/cloud'], ['Network', '/network'], ['Agents', '/agents'], ].map(([label, href], index) => ( { if (timeoutRef.current) { window.clearTimeout(timeoutRef.current) } setHoveredIndex(index) }} onMouseLeave={() => { timeoutRef.current = window.setTimeout(() => { setHoveredIndex(null) }, 200) }} > {hoveredIndex === index && ( )} {label} ))} ) } export function Header() { const [isVisible, setIsVisible] = useState(true) const [lastScrollY, setLastScrollY] = useState(0) const controlHeader = () => { if (typeof window !== 'undefined') { if (window.scrollY > lastScrollY && window.scrollY > 100) { // Hides when scrolling down past 100px setIsVisible(false) } else { // Shows when scrolling up setIsVisible(true) } setLastScrollY(window.scrollY) } } useEffect(() => { if (typeof window !== 'undefined') { window.addEventListener('scroll', controlHeader) return () => { window.removeEventListener('scroll', controlHeader) } } }, [lastScrollY]) return (
Mycelium
) }