From e3b48d953e2a87db22b30dbe97204f4d05a4a64a Mon Sep 17 00:00:00 2001 From: hozayves Date: Wed, 12 Jun 2024 17:23:13 +0200 Subject: [PATCH] fix-ui Navbar ui design bug fix --- src/components/navbar/Navbar.tsx | 23 +++++++++++--- src/containers/nav/NavbarComponents.tsx | 42 ++++++++++++------------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/components/navbar/Navbar.tsx b/src/components/navbar/Navbar.tsx index cf0fda9..4516326 100644 --- a/src/components/navbar/Navbar.tsx +++ b/src/components/navbar/Navbar.tsx @@ -7,25 +7,38 @@ function Navbar() { const closeBtn = document.getElementById('close'); const overlay = document.getElementById('overlay'); const container = document.getElementById('humbergerContainer'); + const hideScrollbar = () => { + document.body.style.overflow = 'hidden'; + }; + + const showScrollbar = () => { + document.body.style.overflow = 'auto'; + }; closeBtn?.addEventListener('click', () => { overlay?.classList.add('-translate-x-full'); container?.classList.add('-translate-x-full'); + showScrollbar() }); humbergurBtn?.addEventListener('click', () => { overlay?.classList.remove('-translate-x-full'); container?.classList.remove('-translate-x-full'); + hideScrollbar() }); - overlay?.addEventListener('click', () => { + overlay?.addEventListener('click', (e) => { + if (e.target !== e.currentTarget) { + return; + } overlay?.classList.add('-translate-x-full'); container?.classList.add('-translate-x-full'); + showScrollbar() }); }, []); return ( -
-
+
+
@@ -66,9 +79,9 @@ function Navbar() {
-
+
{/* close */} -
+
diff --git a/src/containers/nav/NavbarComponents.tsx b/src/containers/nav/NavbarComponents.tsx index 7e10733..9a0a0e2 100644 --- a/src/containers/nav/NavbarComponents.tsx +++ b/src/containers/nav/NavbarComponents.tsx @@ -4,52 +4,52 @@ import education from '../../assets/education.png' import suppliment from '../../assets/supplement.png' import shoes from '../../assets/shoes.png' import electronics from '../../assets/electronics.png' -import { Link } from 'react-router-dom' +import { Link, NavLink } from 'react-router-dom' export function PopularCategory({ title }: { title: string }) { return ( <> -
+

{title}

- - - - - - + + + + + + ) } -export function NavLink({ icon, name }: { icon: string, name: string }) { +export function SidebarLink({ icon, name, to }: { icon: string, name: string, to: string }) { return ( -
+

{name}

-
+
) } export function DesktopNav() { return ( -
+
- - - - - - - + + + + + + +
) } -function Navlink({ to, name }: { to: string, name: string }) { +function DeskNavLink({ to, name }: { to: string, name: string }) { return ( - + {name} );