From 4bdc709ceb55fadb65f7b06f9d5c10c9a61db9d4 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 15 Feb 2024 00:51:31 +0100 Subject: [PATCH] Created the Sidebar.jsx --- .../Root/components/Sidebar/Sidebar.jsx | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 webui/src/states/Root/components/Sidebar/Sidebar.jsx diff --git a/webui/src/states/Root/components/Sidebar/Sidebar.jsx b/webui/src/states/Root/components/Sidebar/Sidebar.jsx new file mode 100644 index 0000000..1087da6 --- /dev/null +++ b/webui/src/states/Root/components/Sidebar/Sidebar.jsx @@ -0,0 +1,67 @@ +import { + Divider, Drawer, + List, + ListItem, + ListItemButton, + ListItemIcon, + ListItemText, + Stack, + Toolbar, + Typography +} from "@mui/material"; +import {sidebar} from "@/common/routes/server.jsx"; +import {useLocation, useNavigate} from "react-router-dom"; + +const drawerWidth = 240; + +export const Sidebar = ({mobileOpen, toggleOpen, window: containerWindow}) => { + const location = useLocation(); + const navigate = useNavigate(); + + const container = containerWindow !== undefined ? () => containerWindow().document.body : undefined; + + const isSelected = (path) => { + if (path === "/") return location.pathname === "/"; + + return location.pathname.startsWith(path); + } + + const drawer = ( + <> + + + MCDash + MCDash + + + + + + + {sidebar.map((route) => ( + + navigate(route.path.replace("/*", ""))}> + {route.icon} + + + + ))} + + + + ); + + return ( + <> + + {drawer} + + + {drawer} + + + ) +} \ No newline at end of file