From 7514a23d7d15379d0cd6f709a1e21cdd0cd63f40 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 8 Jul 2023 22:16:19 +0200 Subject: [PATCH] Integrated mobile optimization into the Navigation.jsx --- .../components/Navigation/Navigation.jsx | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/common/components/Navigation/Navigation.jsx b/src/common/components/Navigation/Navigation.jsx index 7acfe87..74c44bf 100644 --- a/src/common/components/Navigation/Navigation.jsx +++ b/src/common/components/Navigation/Navigation.jsx @@ -1,13 +1,21 @@ import LogoDark from "@/common/assets/images/logo/dark.webp"; import LogoLight from "@/common/assets/images/logo/light.webp"; -import {AppBar, Button, CircularProgress, IconButton, Link, Stack, Typography, useMediaQuery, useTheme} from "@mui/material"; -import {Menu} from "@mui/icons-material"; +import { + AppBar, + Button, + CircularProgress, + Collapse, + IconButton, + Stack, + useMediaQuery, + useTheme +} from "@mui/material"; +import {Login, Menu} from "@mui/icons-material"; import {useNavigate} from "react-router-dom"; import routes from "@/common/routes"; import {useState} from "react"; - -const NAVBAR_HEIGHT = 80; +import LinkItem from "@components/Navigation/components/LinkItem/index.js"; export const Navigation = () => { const navigate = useNavigate(); @@ -16,6 +24,8 @@ export const Navigation = () => { const isMobile = useMediaQuery(theme.breakpoints.down("lg")); const isDarkMode = theme.palette.mode === "dark"; + const [menuOpen, setMenuOpen] = useState(false); + const [dashboardLoading, setDashboardLoading] = useState(false); const openDashboard = () => { @@ -24,35 +34,45 @@ export const Navigation = () => { return () => clearTimeout(timeout); } + const navigateMobile = (path) => { + setMenuOpen(false); + navigate(path); + } + return ( - + backdropFilter: "blur(5px)", WebkitBackdropFilter: "blur(5px)"}}> - Logo navigate("/")} style={{cursor: "pointer"}}/> {!isMobile && <> - {routes.map((route, index) => navigate(route.path)}> - - {route.name} - - )} + {routes.map((route, index) => navigate(route.path)}/>)} } - {isMobile && <> - console.log("Menu")} sx={{mx: 2}}> + {isMobile && + + {dashboardLoading ? : } + + setMenuOpen(!menuOpen)}> - } + } + + + + {routes.map((route, index) => navigateMobile(route.path)}/>)} + +