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.
This commit is contained in:
@@ -16,7 +16,7 @@ const Hero = () => {
|
|||||||
alt="Rhein river aerial view"
|
alt="Rhein river aerial view"
|
||||||
layout="fill"
|
layout="fill"
|
||||||
objectFit="cover"
|
objectFit="cover"
|
||||||
className="blur-md"
|
className="blur-md scale-105"
|
||||||
priority
|
priority
|
||||||
/>
|
/>
|
||||||
{/* Dark overlay for better text contrast */}
|
{/* Dark overlay for better text contrast */}
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ const Nav = ({openNav}: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`fixed ${navBg ? "shadow-md" : "fixed"} w-full transition-all duration-300 ease-in-out ${navHeight} z-[1000]`}
|
className={`fixed w-full transition-all duration-300 ease-in-out ${navHeight} z-[1000] ${
|
||||||
|
navBg ? "shadow-md" : ""
|
||||||
|
}`}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: navBg ? "var(--nav-bg)" : "var(--primary-bg)",
|
backgroundColor: navBg ? "var(--nav-bg)" : "transparent", // <-- changed
|
||||||
color: "var(--primary-text)",
|
color: "var(--primary-text)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import {navLinks} from "@/constant/Constant";
|
import {navLinks} from "@/constant/Constant";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import React from "react";
|
import React, {useContext} from "react";
|
||||||
import {CgClose} from "react-icons/cg";
|
import {CgClose} from "react-icons/cg";
|
||||||
|
import {ThemeContext} from "@/components/provider/ThemeProvider";
|
||||||
|
import {themeColors} from "@/components/Helper/ThemeColors";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
showNav: boolean;
|
showNav: boolean;
|
||||||
@@ -9,32 +11,52 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const MobileNav = ({closeNav, showNav}: 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 (
|
||||||
|
<div className="lg:hidden">
|
||||||
|
{/* overlay background */}
|
||||||
|
<div
|
||||||
|
className={`fixed inset-0 z-[10000] transition-opacity duration-500 ${
|
||||||
|
showNav ? "opacity-60 bg-black" : "opacity-0 pointer-events-none"
|
||||||
|
}`}
|
||||||
|
onClick={closeNav}
|
||||||
|
/>
|
||||||
|
|
||||||
return (
|
{/* nav menu */}
|
||||||
<div>
|
|
||||||
{/* overlay */}
|
|
||||||
<div
|
<div
|
||||||
className={`fixed ${navOpen} inset-0 transform transition-all duration-500 z-[10000] bg-black opacity-70 w-full h-screen`}
|
className={`fixed top-0 left-0 w-full z-[10006] transform ${navOpen} transition-all duration-500 ease-in-out text-[var(--primary-text)] shadow-md rounded-b-2xl`}
|
||||||
></div>
|
style={{
|
||||||
{/* Navlinks */}
|
backgroundColor: theme === "dark" ? "#2A2A2A" : "#ffffff",
|
||||||
<div
|
color: theme === "dark" ? "#f5f5f5" : "#1a1a1a"
|
||||||
className={`text-white ${navOpen} fixed justify-center flex flex-col h-full transform transition-all duration-500 delay-300 w-[80%] sm:w-[60%] bg-indigo-900 space-y-6 z-[10006]`}
|
}}
|
||||||
>
|
>
|
||||||
{navLinks.map((link) => {
|
<div className="flex flex-col items-center justify-center py-8 space-y-4 px-4 relative">
|
||||||
return (
|
|
||||||
<Link href={link.url} key={link.id}>
|
|
||||||
<p className="nav__link text-white text-[20px] ml-12 border-b-[1.5px] pb-1 border-white sm:text-[30px]">
|
|
||||||
{link.label}
|
|
||||||
</p>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{/* Close icon */}
|
{/* Close icon */}
|
||||||
<CgClose
|
<CgClose
|
||||||
onClick={closeNav}
|
onClick={closeNav}
|
||||||
className="absolute top-[0.7rem] right-[1.4rem] sm:w-8 sm:h-8 w-6 h-6"
|
className="absolute top-4 right-6 sm:right-8 sm:w-7 sm:h-7 w-6 h-6 cursor-pointer p-1"
|
||||||
|
style={{color: colors.primaryText}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{navLinks.map((link) => (
|
||||||
|
<Link href={link.url} key={link.id}>
|
||||||
|
<p className="nav__link uppercase text-[14px] sm:text-[16px] border-b pb-1 border-gray-400 transition-all duration-300 ease-in-out hover:scale-105">
|
||||||
|
{link.label}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* Theme toggle button */}
|
||||||
|
<button
|
||||||
|
onClick={toggleTheme}
|
||||||
|
className="mt-4 w-8 h-8 flex items-center justify-center rounded-full border border-gray-400 transition-all duration-300"
|
||||||
|
style={{backgroundColor: colors.secondaryBg, color: colors.primaryText}}
|
||||||
|
>
|
||||||
|
{theme === "dark" ? "🌙" : "☀️"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user