From 07e5bab31f65582ff4df5674d248fa0e68dbf227 Mon Sep 17 00:00:00 2001 From: arraysid Date: Sun, 1 Jun 2025 07:36:40 +0700 Subject: [PATCH] feat: enhance Header component with mobile menu animations and improved navigation styling --- .../src/app/(public)/_components/header.tsx | 194 +++++++++++++----- 1 file changed, 143 insertions(+), 51 deletions(-) diff --git a/apps/landing/src/app/(public)/_components/header.tsx b/apps/landing/src/app/(public)/_components/header.tsx index 30b40d7..1f533a1 100644 --- a/apps/landing/src/app/(public)/_components/header.tsx +++ b/apps/landing/src/app/(public)/_components/header.tsx @@ -4,14 +4,15 @@ import { LogoSimple } from '@/app/_components/logo'; import NAVIGATIONS from '@/data/navigations.json'; import { Button } from '@components'; import { cn } from '@utils'; +import { AnimatePresence, motion } from 'framer-motion'; import Link from 'next/link'; -import { useRouter } from 'next/navigation'; +import { usePathname, useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { LuMenu, LuX } from 'react-icons/lu'; export function Header() { const router = useRouter(); - + const pathname = usePathname(); const [isScrolled, setIsScrolled] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); @@ -19,27 +20,45 @@ export function Header() { const handleScroll = () => { setIsScrolled(window.scrollY > 10); }; + window.addEventListener('scroll', handleScroll); - return () => window.removeEventListener('scroll', handleScroll); - }, []); + + // Lock body scroll when mobile menu is open + if (mobileMenuOpen) { + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = 'auto'; + } + + return () => { + window.removeEventListener('scroll', handleScroll); + document.body.style.overflow = 'auto'; + }; + }, [mobileMenuOpen]); + + // Close mobile menu when route changes + useEffect(() => { + setMobileMenuOpen(false); + }, [pathname]); return (
-
-
-
- - - -
-
+
+ {/* Logo */} + + + {/* Desktop Navigation */} -
+ {/* Desktop Auth Buttons */} +
- - {/* Mobile Menu Button */} -
-
- {/* Mobile Menu */} - {mobileMenuOpen && ( -
- -
- )} + {/* Auth Buttons */} + + + + + + )} + +
); }