'use client'; import Image from 'next/image'; import Link from 'next/link'; import React, { useEffect, useRef, useState } from 'react'; import { FiSearch, FiUser } from 'react-icons/fi'; import { HiShoppingBag } from 'react-icons/hi2'; // import logoWhite from '/public/images/logo-white.svg'; import logoBlack from '/public/images/logo-black.svg'; import styles from './navbar.module.css'; // components/Navbar.tsx export function Navbar() { const prevScrollY = useRef(0); const [navBarStyle, setNavBarStyle] = useState('initial'); const [isVisible, setIsVisible] = useState('false'); const [isExpanded, setIsExpanded] = useState(false); useEffect(() => { const handleScroll = () => { const currentScrollY = window.scrollY; if (currentScrollY > prevScrollY.current && currentScrollY > 100) { // Scrolling down and scrolled past 100px setNavBarStyle('initial'); } else if (currentScrollY < prevScrollY.current && currentScrollY > 100) { // Scrolling up and scrolled past 100px setNavBarStyle('scrolledUp'); } else if (currentScrollY <= 100) { setNavBarStyle('initial'); } prevScrollY.current = currentScrollY; }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); // Empty dependency array // const navClasses = `${styles.navBar} ${ // navBarStyle === 'scrolledUp' // ? styles.navBarScrolledUp // : styles.navBarInitial // }`; //Hack for now const navClasses = `${styles.navBar} ${ navBarStyle === 'scrolledUp' ? styles.navBarScrolledUp : styles.navBarScrolledUp }`; function toggleMenu() { if (isVisible === 'true') { setIsVisible('false'); setIsExpanded(false); } else { setIsVisible('true'); setIsExpanded(true); } } return (
); }