From 065bd6c939ee1f6a6ba79c462645714e8e5695eb Mon Sep 17 00:00:00 2001 From: kushalkumar1362 Date: Mon, 3 Jun 2024 19:54:44 +0530 Subject: [PATCH 1/2] Hamburger automatically close when user click on any menu --- frontend/src/components/Navbar.tsx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 2b08dcab..77e6018a 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -13,21 +13,26 @@ const Navbar = () => { setIsMenuOpen(!isMenuOpen); }; + const closeMenu = () => { + setIsMenuOpen(false); + }; + const handleLogout = () => { localStorage.removeItem("token"); setTokenState(""); + closeMenu(); }; - const getNavLinkClass = (path: string) => { + const getNavLinkClass = (path) => { return location.pathname === path ? "block py-2 px-3 bg-blue-700 rounded md:bg-transparent md:p-0 text-white md:text-blue-500" : "block py-2 px-3 rounded md:border-0 md:p-0 text-white md:hover:text-blue-500 hover:bg-gray-700 hover:text-white md:hover:bg-transparent"; }; - return ( + return (