From 4193e455927a39b2a83a3df2e679d801673803ff Mon Sep 17 00:00:00 2001 From: Thatsaphorn Atchariyaphap Date: Sun, 6 Apr 2025 00:20:59 +0200 Subject: [PATCH] Enhance Navbar responsiveness and theming - Refactor `MobileNav` with theme context support and improved animations. - Adjust `DesktopNav` background behavior for better clarity. - Update `Hero` image style with scaling for visual impact. --- components/Home/Hero/Hero.tsx | 2 +- components/Navbar/DesktopNav.tsx | 6 ++-- components/Navbar/MobileNav.tsx | 60 ++++++++++++++++++++++---------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/components/Home/Hero/Hero.tsx b/components/Home/Hero/Hero.tsx index 3a9a949..f2e130f 100644 --- a/components/Home/Hero/Hero.tsx +++ b/components/Home/Hero/Hero.tsx @@ -16,7 +16,7 @@ const Hero = () => { alt="Rhein river aerial view" layout="fill" objectFit="cover" - className="blur-md" + className="blur-md scale-105" priority /> {/* Dark overlay for better text contrast */} diff --git a/components/Navbar/DesktopNav.tsx b/components/Navbar/DesktopNav.tsx index e7d8cf7..381d26e 100644 --- a/components/Navbar/DesktopNav.tsx +++ b/components/Navbar/DesktopNav.tsx @@ -40,9 +40,11 @@ const Nav = ({openNav}: Props) => { return (
diff --git a/components/Navbar/MobileNav.tsx b/components/Navbar/MobileNav.tsx index 853025d..331b6ff 100644 --- a/components/Navbar/MobileNav.tsx +++ b/components/Navbar/MobileNav.tsx @@ -1,7 +1,9 @@ import {navLinks} from "@/constant/Constant"; import Link from "next/link"; -import React from "react"; +import React, {useContext} from "react"; import {CgClose} from "react-icons/cg"; +import {ThemeContext} from "@/components/provider/ThemeProvider"; +import {themeColors} from "@/components/Helper/ThemeColors"; type Props = { showNav: boolean; @@ -9,32 +11,52 @@ type Props = { }; const MobileNav = ({closeNav, showNav}: Props) => { - const navOpen = showNav ? "translate-x-0" : "translate-x-[-100%]"; - + const navOpen = showNav ? "translate-y-0 opacity-100" : "-translate-y-20 opacity-0 pointer-events-none"; + const {theme, toggleTheme} = useContext(ThemeContext); + const colors = themeColors[theme]; return ( -
- {/* overlay */} +
+ {/* overlay background */}
- {/* Navlinks */} + className={`fixed inset-0 z-[10000] transition-opacity duration-500 ${ + showNav ? "opacity-60 bg-black" : "opacity-0 pointer-events-none" + }`} + onClick={closeNav} + /> + + {/* nav menu */}
- {navLinks.map((link) => { - return ( +
+ {/* Close icon */} + + + {navLinks.map((link) => ( -

+

{link.label}

- ); - })} - {/* Close icon */} - + ))} + + {/* Theme toggle button */} + +
);