'use client'; import { useState, useEffect } from 'react'; import { Menu, X } from 'lucide-react'; import { motion } from 'framer-motion'; import { usePathname, useRouter } from 'next/navigation'; import Image from 'next/image'; export function Header() { const pathname = usePathname(); const router = useRouter(); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [showHeader, setShowHeader] = useState(true); useEffect(() => { let lastScroll = 0; // Hide header on scroll down, show on scroll up const handleScroll = () => { const currentScrollY = window.scrollY; // Always show header at the top of the page if (currentScrollY < 10) { setShowHeader(true); } else if (currentScrollY > lastScroll) { // Scrolling down setShowHeader(false); } else { // Scrolling up setShowHeader(true); } lastScroll = currentScrollY; }; window.addEventListener('scroll', handleScroll, { passive: true }); return () => window.removeEventListener('scroll', handleScroll); }, []); // Empty dependency array - only set up once const handleNavigate = (path: string) => { setMobileMenuOpen(false); router.push(path); }; const navItems = [ { path: '/calculator', label: 'Calculator' }, { path: '/how-it-works', label: 'How it Works' }, { path: '/about', label: 'About' }, { path: '/contact', label: 'Contact' }, ]; return (
handleNavigate('/')} whileHover={{ scale: 1.02 }} transition={{ type: "spring", stiffness: 400, damping: 17 }} > Puffin Offset Logo Puffin Offset {/* Mobile menu button */} {/* Desktop navigation */}
{/* Mobile navigation */} {mobileMenuOpen && ( )}
); }