diff --git a/client/src/Components/v2/layout/RootLayout.tsx b/client/src/Components/v2/layout/RootLayout.tsx index b0c0effe1..0b6defb91 100644 --- a/client/src/Components/v2/layout/RootLayout.tsx +++ b/client/src/Components/v2/layout/RootLayout.tsx @@ -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 ( @@ -28,6 +32,7 @@ const RootLayout = () => { : "rgba(0, 0, 0, 0.01)", display: "flex", alignItems: "center", + paddingLeft: isSmall ? `${collapsedWidth + 12}px` : 12, }} > { +export const Logo = (props: StackProps) => { const { t } = useTranslation(); const theme = useTheme(); const dispatch = useDispatch(); const { collapsed } = useSidebar(); return ( { dispatch(toggleSidebar()); }} sx={{ cursor: "pointer" }} + {...props} > { 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 ( { height: "100%", }} > - + {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 })); } }} />