diff --git a/src/components/userComponents/navBar/navBar.tsx b/src/components/userComponents/navBar/navBar.tsx index 3f0f0b84..46cbb9e9 100644 --- a/src/components/userComponents/navBar/navBar.tsx +++ b/src/components/userComponents/navBar/navBar.tsx @@ -1,12 +1,21 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import Link from 'next/link'; +import { HamburgerMenu, CloseMenu } from '../../../../public/icons'; /** * @returns The navigation bar for the web app */ -function NavBar() { +export default function NavBar() { const [showMenu, setShowMenu] = useState(false); + useEffect(() => { + if (showMenu) { + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = ''; + } + }, [showMenu]); + /** * Toggles the side menu */ @@ -14,111 +23,88 @@ function NavBar() { setShowMenu(!showMenu); } - /** - * @param event - Close the side menu when the escape key is pressed - */ - function handleKeyDown(event: React.KeyboardEvent) { - if (event.key === 'Escape') { - setShowMenu(false); - } - } - return ( - ); } - -export default NavBar;