Files
Checkmate/client/src/Components/v2/Layouts/RootLayout.tsx
T

50 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-09-26 16:01:05 -07:00
import { useState, useEffect } from "react";
import useMediaQuery from "@mui/material/useMediaQuery";
2025-09-27 14:38:14 -07:00
import { useTheme } from "@mui/material/styles";
2025-09-26 16:01:05 -07:00
import { Outlet } from "react-router";
import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
const COLLAPSED_WIDTH = 50;
const EXPANDED_WIDTH = 250;
const SideBar = () => {
const theme = useTheme();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const [collapsed, setCollapsed] = useState(false);
useEffect(() => {
setCollapsed(isSmall);
}, [isSmall]);
return (
<Stack
border="1px solid red"
width={collapsed ? COLLAPSED_WIDTH : EXPANDED_WIDTH}
sx={{
transition: "width 0.3s ease",
}}
>
<Box
border="1px solid blue"
onClick={() => setCollapsed(!collapsed)}
>
Sidebar Content
</Box>
</Stack>
);
};
const RootLayout = ({ mode = "light" }) => {
return (
<Stack
direction="row"
minHeight="100vh"
>
<SideBar />
<Outlet />
</Stack>
);
};
export default RootLayout;