diff --git a/src/components/ui/NavigationBar.tsx b/src/components/ui/NavigationBar.tsx index c0c4f61..b66b120 100644 --- a/src/components/ui/NavigationBar.tsx +++ b/src/components/ui/NavigationBar.tsx @@ -1,6 +1,5 @@ import { cn } from "@/lib/utils"; import { AnimatePresence, motion } from "motion/react"; -import { Cross as HamburgerCross } from "hamburger-react"; import { useEffect, useState, useRef } from "react"; declare module "react" { @@ -23,7 +22,7 @@ export const HoverNavigation = ({ const [activeIndex, setActiveIndex] = useState(null); const [hamburgerOpen, setHamburgerOpen] = useState(false); const [theme, setTheme] = useState<"light" | "dark">("dark"); - const hamburgerRef = useRef(null); + const hamburgerRef = useRef(null); const menuRef = useRef(null); useEffect(() => { @@ -117,9 +116,26 @@ export const HoverNavigation = ({ } }; + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === "Escape") setHamburgerOpen(false); + }; + document.addEventListener("mousedown", handleClickOutside); + document.addEventListener("keydown", handleKeyDown); return () => { document.removeEventListener("mousedown", handleClickOutside); + document.removeEventListener("keydown", handleKeyDown); + }; + }, [hamburgerOpen]); + + useEffect(() => { + if (!hamburgerOpen) return; + + const previousOverflow = document.body.style.overflow; + document.body.style.overflow = "hidden"; + + return () => { + document.body.style.overflow = previousOverflow; }; }, [hamburgerOpen]); @@ -187,16 +203,63 @@ export const HoverNavigation = ({ -
- -
+ setHamburgerOpen(false)} + className="flex items-center gap-2.5 rounded-xl px-2 py-2 font-semibold tracking-tight" + aria-label="Go to home" > - + + RL + + Portfolio + +
+ +
@@ -205,33 +268,68 @@ export const HoverNavigation = ({ {hamburgerOpen && ( -