From 6f3c7181291c54a89762782da08d39021aee0735 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 --- package.json | 2 +- src/components/navbar/Navbar.tsx | 23 +++++++++++--- src/containers/footer/SocialIcon.tsx | 8 ++--- src/containers/nav/NavbarComponents.tsx | 42 ++++++++++++------------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 0cfb066..3be7aea 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,9 @@ "dependencies": { "@reduxjs/toolkit": "^2.2.5", "@types/react-redux": "^7.1.33", - "lucide-react": "^0.387.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-icons": "^5.2.1", "react-redux": "^9.1.2", "react-router-dom": "^6.23.1", "sass": "^1.77.2" 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/footer/SocialIcon.tsx b/src/containers/footer/SocialIcon.tsx index dd5e2d6..8407b7a 100644 --- a/src/containers/footer/SocialIcon.tsx +++ b/src/containers/footer/SocialIcon.tsx @@ -1,14 +1,14 @@ -import { Facebook, Instagram, Twitter } from "lucide-react" +import { FaFacebook, FaInstagram, FaXTwitter } from "react-icons/fa6"; const SocialIcon = ({ name }: { name: string }) => { switch (name) { case "facebook": - return ; + return ; case "instagram": - return ; + return ; case "twitter": - return ; + return ; default: return null; } 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} );