Create shared useSidebar hook to centralize sidebar width and transition logic, addressing code review feedback about duplicated logic between Sidebar and HomeLayout components. Changes: - Add useSidebar hook with collapsed state, width, and transition values - Update Sidebar to use the hook instead of inline selectors and values - Update HomeLayout to use the hook for spacer element styling This ensures sidebar width logic is defined in one place and stays in sync.
33 lines
600 B
React
33 lines
600 B
React
import Sidebar from "../../Sidebar/index.jsx";
|
|
import { Outlet } from "react-router";
|
|
import { Box, Stack } from "@mui/material";
|
|
import { useSidebar } from "@/Hooks/useSidebar.js";
|
|
|
|
import "./index.css";
|
|
|
|
const HomeLayout = () => {
|
|
const { width, transition } = useSidebar();
|
|
|
|
return (
|
|
<Stack
|
|
className="home-layout"
|
|
flexDirection="row"
|
|
>
|
|
<Sidebar />
|
|
{/* Spacer for fixed sidebar */}
|
|
<Box
|
|
sx={{
|
|
width,
|
|
flexShrink: 0,
|
|
transition,
|
|
}}
|
|
/>
|
|
<Stack className="home-content-wrapper">
|
|
<Outlet />
|
|
</Stack>
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
export default HomeLayout;
|