diff --git a/src/Component/Navbar.jsx b/src/Component/Navbar.jsx index 2e9fa83..c7ac66e 100644 --- a/src/Component/Navbar.jsx +++ b/src/Component/Navbar.jsx @@ -1,10 +1,10 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { Link, NavLink } from "react-router-dom"; import { useSelector, useDispatch } from "react-redux"; import { logout } from "../service/oprations/authApi"; import logo from "../assets/Untitled design (1).png"; import { GiHamburgerMenu } from "react-icons/gi"; -import { motion } from "framer-motion"; // Import Framer Motion +import { motion } from "framer-motion"; // Animation Variants const menuVariants = { @@ -14,7 +14,7 @@ const menuVariants = { y: 0, transition: { duration: 0.5, - staggerChildren: 0.2, // Stagger effect + staggerChildren: 0.2, }, }, }; @@ -35,17 +35,34 @@ const Navbar = () => { }; const toggleMenu = () => { - setIsMenuOpen(!isMenuOpen); + setIsMenuOpen((prev) => !prev); }; + // Prevent scroll when menu is open + useEffect(() => { + document.body.style.overflow = isMenuOpen ? "hidden" : "auto"; + }, [isMenuOpen]); + + // Active link styling function + const getNavLinkClass = ({ isActive }) => + `hover:text-green-900 ${ + isActive ? "text-green-900 font-semibold underline" : "" + }`; + return (
-