diff --git a/client/src/components/Navbar/index.css b/client/src/components/Navbar/index.css index 19539f9..fa13f85 100644 --- a/client/src/components/Navbar/index.css +++ b/client/src/components/Navbar/index.css @@ -3,6 +3,9 @@ width: 100%; background-color: rgb(65, 146, 223); display: flex; + align-items: center; + position: sticky; + top: 0; } .logo { @@ -10,11 +13,105 @@ width: 80px; } -.link { +nav ul { + display: flex; + /* position: relative; */ +} + +nav ul li { + list-style: none; +} + +nav ul li a { color: rgb(73, 7, 148); font-size: 20px; font-weight: bold; font-family: 'Courier New', Courier, monospace; cursor: pointer; text-decoration: none; + padding: 0.9rem; +} + +nav .menu { + display: none; + position: absolute; + top: 0.75rem; + right: 0.5rem; + flex-direction: column; + justify-content: space-between; + width: 2.25rem; + height: 2rem; + z-index: 999; +} +nav .menu span { + /* height: 0.4rem; */ + height: 0.3rem; + width: 100%; + background-color: #fff; + border-radius: 0.2rem; +} + +@media (max-width: 580px) { + nav .menu { + display: flex; + width: 2.5rem; + } + + nav { + flex-direction: column; + align-items: start; + } + + nav ul { + display: none; + flex-direction: column; + width: 100%; + margin-bottom: 0.25 rem; + margin-top: unset; + padding-top: 20px; + z-index: 99; + } + + nav ul.open { + display: flex; + background-color: rgb(96, 157, 227); + } + + nav ul li { + width: 100%; + text-align: center; + padding-bottom: 0.7rem; + } + + nav ul li a { + margin: 0.2rem 0.5rem; + } +} + +nav .menu.open span { + position: absolute; +} + +nav .menu.open span:nth-child(1) { + transform: rotate(45deg); + position: absolute; + top: 50%; +} + +nav .menu.open span:nth-child(2) { + opacity: 0; +} + +nav .menu.open span:nth-child(3) { + transform: rotate(-45deg); + + position: absolute; + top: 50%; +} + +nav .menu span { + transition: + transform 0.3s ease-in-out, + opacity 0.3s ease-in-out, + top 0.3s ease-in-out; } diff --git a/client/src/components/Navbar/index.tsx b/client/src/components/Navbar/index.tsx index 029ddd5..ce7ed0b 100644 --- a/client/src/components/Navbar/index.tsx +++ b/client/src/components/Navbar/index.tsx @@ -1,23 +1,34 @@ import './index.css'; import wharfLogo from '../../assets/wharf.png'; -import { useContext } from 'react'; +import { useContext, useState } from 'react'; import UserContext from '../../context/user/userContext'; import { Link, useLocation } from 'react-router-dom'; + const Navbar = () => { const userContext = useContext(UserContext); - const location = useLocation(); const currentPath = location.pathname; - if (userContext == null || userContext.curUser == null) { - return <>>; + const [menuOpen, setMenuOpen] = useState(false); + + if (!userContext || !userContext.curUser) { + return null; } return ( -