This commit is contained in:
Alex Holliday committed 2026-02-10 21:54:31 +00:00
1 parent d1d96bd2ba
commit 1db5f4b70f
3 files changed
+24 -10

No files matched your search

@@ -1,8 +1,9 @@
import { Sidebar } from "@/Components/v2/sidebar";
import { Outlet } from "react-router";
import Stack from "@mui/material/Stack";
import { useMediaQuery } from "@mui/material";
import { useSidebar } from "@/Hooks/useSidebar";
// TEMP
import { useSelector } from "react-redux";
import type { RootState } from "@/Types/state";
import { lightTheme, darkTheme } from "@/Utils/Theme/v2Theme";
@@ -12,6 +13,9 @@ const RootLayout = () => {
const mode = useSelector((state: RootState) => state.ui.mode);
const v2theme = mode === "dark" ? darkTheme : lightTheme;
const theme = useTheme();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const { collapsedWidth } = useSidebar();
return (
<Stack flexDirection="row">
<ThemeProvider theme={v2theme}>
@@ -28,6 +32,7 @@ const RootLayout = () => {
: "rgba(0, 0, 0, 0.01)",
display: "flex",
alignItems: "center",
paddingLeft: isSmall ? `${collapsedWidth + 12}px` : 12,
}}
>
<Stack
+4 -4
View File
@@ -1,4 +1,4 @@
import Stack from "@mui/material/Stack";
import Stack, { type StackProps } from "@mui/material/Stack";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { useTheme } from "@mui/material/styles";
@@ -7,14 +7,13 @@ import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
import useSidebar from "@/Hooks/useSidebar";
export const Logo = () => {
export const Logo = (props: StackProps) => {
const { t } = useTranslation();
const theme = useTheme();
const dispatch = useDispatch();
const { collapsed } = useSidebar();
return (
<Stack
pb={theme.spacing(6)}
direction="row"
alignItems="center"
gap={theme.spacing(4)}
@@ -22,9 +21,10 @@ export const Logo = () => {
dispatch(toggleSidebar());
}}
sx={{ cursor: "pointer" }}
{...props}
>
<Typography
minWidth={39}
minWidth={theme.spacing(16)}
minHeight={theme.spacing(16)}
display={"flex"}
justifyContent={"center"}
+14 -5
View File
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import Stack from "@mui/material/Stack";
import List from "@mui/material/List";
import { useSidebar } from "@/Hooks/useSidebar.js";
@@ -5,25 +6,30 @@ import { Logo } from "@/Components/v2/sidebar/Logo";
import { getMenu } from "@/Components/v2/sidebar/Menu";
import { NavItem } from "@/Components/v2/sidebar/NavItem";
import { useNavigate } from "react-router";
import { useNavigate, useLocation } from "react-router";
import { useTranslation } from "react-i18next";
import { useTheme, useMediaQuery } from "@mui/material";
import { useDispatch } from "react-redux";
import { toggleSidebar } from "@/Features/UI/uiSlice";
import { setCollapsed } from "@/Features/UI/uiSlice";
export const Sidebar = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const location = useLocation();
const { t } = useTranslation();
const { width, transition } = useSidebar();
const theme = useTheme();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const menu = getMenu(t);
useEffect(() => {
dispatch(setCollapsed({ collapsed: isSmall }));
}, [isSmall, dispatch]);
return (
<Stack
component="aside"
position={{ xs: "fixed", md: "sticky" }}
position={isSmall ? "fixed" : "sticky"}
top={0}
left={0}
minHeight={"100vh"}
@@ -46,7 +52,10 @@ export const Sidebar = () => {
height: "100%",
}}
>
<Logo />
<Logo
pt={theme.spacing(8)}
pb={theme.spacing(10)}
/>
{menu.map((item) => {
const selected = location.pathname.startsWith(`/${item.path}`);
return (
@@ -57,7 +66,7 @@ export const Sidebar = () => {
onClick={() => {
navigate(`/${item.path}`);
if (isSmall) {
dispatch(toggleSidebar());
dispatch(setCollapsed({ collapsed: true }));
}
}}
/>