From 65c190cf5487aa380f3f96f2f29371c8eb7f09c0 Mon Sep 17 00:00:00 2001 From: John Schmidt Date: Sun, 22 Mar 2026 15:21:09 -0500 Subject: [PATCH] feat: enhance Navbar component with theme toggle and improved mobile menu --- Application/components/navbar.tsx | 93 +++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/Application/components/navbar.tsx b/Application/components/navbar.tsx index 35903a3..754c02a 100644 --- a/Application/components/navbar.tsx +++ b/Application/components/navbar.tsx @@ -1,38 +1,76 @@ "use client"; -import { Box, Flex, Text, IconButton, Stack, HStack } from "@chakra-ui/react"; -import { useState } from "react"; // Use standard React state +import { + Box, + Flex, + Text, + IconButton, + Stack, + HStack, + +} from "@chakra-ui/react"; +import { useState, useEffect } from "react"; import Link from "next/link"; -import { HiMenu, HiX } from "react-icons/hi"; +import { HiMenu, HiX, HiMoon, HiSun } from "react-icons/hi"; +import { useColorMode } from "@/components/ui/color-mode"; export default function Navbar() { const [isOpen, setIsOpen] = useState(false); + const { colorMode, toggleColorMode } = useColorMode(); + const [mounted, setMounted] = useState(false); + + // Prevent hydration mismatch by waiting for mount + useEffect(() => setMounted(true), []); return ( - + Coding United - {/* Hamburger Icon */} - setIsOpen(!isOpen)} - variant="solid" - aria-label="Toggle Menu" - > - {isOpen ? : } - - - {/* Desktop Links */} - - Home - About Us - FAQ - Contact + + {/* Desktop Links */} + + Home + About Us + FAQ + Contact + + + {/* Theme Toggle Button */} + {mounted && ( + + {colorMode === "light" ? : } + + )} + + {/* Hamburger Icon */} + setIsOpen(!isOpen)} + variant="outline" + aria-label="Toggle Menu" + > + {isOpen ? : } + - {/* Manual Mobile Menu (No snippets required) */} + {/* Mobile Menu */} {isOpen && ( @@ -47,9 +85,16 @@ export default function Navbar() { ); } -// Simple NavLink to avoid scope errors const NavLink = ({ href, children }: { href: string; children: React.ReactNode }) => ( - - {children} + + + {children} + ); \ No newline at end of file