From acc26a423a773afe6f849932e945b9108bce5de0 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 27 Nov 2025 17:43:52 +0100 Subject: [PATCH] feat(nav): redesign mobile menu with fullscreen animations and active states --- components/Navbar.jsx | 164 +++++++++++++++++++++++++++++++++--------- 1 file changed, 130 insertions(+), 34 deletions(-) diff --git a/components/Navbar.jsx b/components/Navbar.jsx index 93eaa6e..2f248c3 100644 --- a/components/Navbar.jsx +++ b/components/Navbar.jsx @@ -1,11 +1,23 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { Menu, X } from "lucide-react"; import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { AnimatePresence, motion } from "framer-motion"; export default function Navbar() { const [open, setOpen] = useState(false); + const pathname = usePathname(); + + // this prevents the rest of the body/page scroll when menu is open + useEffect(() => { + if (open) { + document.body.style.overflow = "hidden"; + } else { + document.body.style.overflow = "unset"; + } + }, [open]); const links = [ { name: "Home", href: "/" }, @@ -18,53 +30,137 @@ export default function Navbar() { { name: "Login", href: "/login" }, ]; + const menuVars = { + initial: { + scaleY: 0, + }, + animate: { + scaleY: 1, + transition: { + duration: 0.5, + ease: [0.12, 0, 0.39, 0], + }, + }, + exit: { + scaleY: 0, + transition: { + delay: 0.5, + duration: 0.5, + ease: [0.22, 1, 0.36, 1], + }, + }, + }; + + const containerVars = { + initial: { + transition: { + staggerChildren: 0.09, + staggerDirection: -1, + }, + }, + open: { + transition: { + delayChildren: 0.3, + staggerChildren: 0.09, + staggerDirection: 1, + }, + }, + }; + + const mobileLinkVars = { + initial: { + y: "30vh", + transition: { + duration: 0.5, + ease: [0.37, 0, 0.63, 1], + }, + }, + open: { + y: 0, + transition: { + ease: [0, 0.55, 0.45, 1], + duration: 0.7, + }, + }, + }; + return ( ); } +