diff --git a/src/common/components/navigation/NavBar.jsx b/src/common/components/navigation/NavBar.jsx index 3c8b54ea..5fa2381e 100644 --- a/src/common/components/navigation/NavBar.jsx +++ b/src/common/components/navigation/NavBar.jsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; +import { FiMenu, FiX } from 'react-icons/fi'; import { useLocation, useNavigate } from 'react-router-dom'; import styled from 'styled-components'; @@ -16,10 +17,8 @@ const StyledNav = styled.nav` border-bottom: 3px solid black; @media (max-width: 768px) { - flex-direction: column; - gap: 20px; - padding: 1.5rem; - align-items: center; + padding: 8px 32px; + align-items: space-between; } `; @@ -29,6 +28,21 @@ const LeftAligned = styled.div` gap: 10px; `; +const Menu = styled.div` + display: none; + + @media screen and (max-width: 768px) { + display: flex; + align-items: center; + z-index: 10; + + .exit-icon { + position: fixed; + right: 32px; + } + } +`; + const RightAligned = styled.div` display: flex; gap: 4.6rem; @@ -36,6 +50,10 @@ const RightAligned = styled.div` justify-content: flex-end; flex: 1; padding: 0 1.7rem; + + @media screen and (max-width: 768px) { + display: none; + } `; const LogoPlaceholder = styled(Button.Invisible)` @@ -43,6 +61,16 @@ const LogoPlaceholder = styled(Button.Invisible)` font-size: 1.7rem; font-weight: bold; font-family: monospace; + + img { + height: 200px; + } + + @media screen and (max-width: 768px) { + img { + height: 120px; + } + } `; const AnimatedLink = styled(Button.Invisible)` @@ -73,10 +101,34 @@ const AnimatedLink = styled(Button.Invisible)` &.active::after { transform: scaleX(1); } + + @media screen and (max-width: 768px) { + font-size: 1.5rem; + position: relative; + } +`; + +const MobileMenuOverlay = styled.div` + display: none; + @media screen and (max-width: 768px) { + padding-top: 200px; + position: fixed; + top: 0; + right: 0; + width: 100vw; + height: 100vh; + background: white; + z-index: 5; + display: flex; + flex-direction: column; + align-items: center; + gap: 48px; + } `; export default function NavBar() { const [isModalOpen, setIsModalOpen] = useState(false); + const [isMenuOpen, setIsMenuOpen] = useState(false); const navigate = useNavigate(); const { user, logout } = useUser(); const location = useLocation(); @@ -99,13 +151,60 @@ export default function NavBar() { } }; + const handleMenuToggle = () => setIsMenuOpen((open) => !open); + const handleMobileNav = (path) => { + navigate(path); + setIsMenuOpen(false); + }; + return ( navigate('/')}> - Sokana Logo + Sokana Logo + + {isMenuOpen ? ( + + ) : ( + + )} + + {isMenuOpen && ( + + handleMobileNav('/')} + > + Home + + handleMobileNav('/courses')} + > + Courses + + {user ? ( + { + handleLogoutClick(); + setIsMenuOpen(false); + }} + > + Log Out + + ) : ( + handleMobileNav('/login')} + > + Login + + )} + + )}