Skip to content

Commit

Permalink
implement basic Default layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-torabiv committed Jul 9, 2024
1 parent 865d6b7 commit 1029ddf
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/components/layouts/SidebarApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { Drawer, List, ListItem, ListItemText } from '@mui/material';
import { DRAWER_WIDTH } from '@/libs/constants';

function SidebarApp() {
return (
<div>
<Drawer
variant='permanent'
sx={{
width: DRAWER_WIDTH,
flexShrink: 0,
[`& .MuiDrawer-paper`]: { width: DRAWER_WIDTH, boxSizing: 'border-box' },
}}
>
<List>
<ListItem button>
<ListItemText primary="Item 1" />
</ListItem>
<ListItem button>
<ListItemText primary="Item 2" />
</ListItem>
</List>
</Drawer>
</div>
);
}

export default SidebarApp;
34 changes: 34 additions & 0 deletions src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { Box } from "@mui/material";
import { Outlet } from "react-router-dom";
import SidebarApp from "@/components/layouts/SidebarApp";

function DefaultLayout() {
return (
<Box sx={{ display: "flex", height: "100vh" }}>
<SidebarApp />
<Box
sx={{
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
overflowX: 'hidden',
}}
>
<Box
component="main"
sx={{
flexGrow: 1,
px: 3,
py: 2,
backgroundColor: theme => theme.palette.grey[50],
}}
>
<Outlet />
</Box>
</Box>
</Box>
);
}

export default DefaultLayout;
1 change: 1 addition & 0 deletions src/libs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DRAWER_WIDTH = 280;
10 changes: 9 additions & 1 deletion src/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import React from 'react';
import { createBrowserRouter } from 'react-router-dom';
import Dashboard from '@/pages/Dashboard';
import DefaultLayout from '@/layouts/DefaultLayout';

export const router = createBrowserRouter([
{
path: '/',
element: <Dashboard />,
element: <DefaultLayout />,
children: [
{
path: '/',
element: <Dashboard />,
index: true,
},
],
},
{
path: '*',
Expand Down

0 comments on commit 1029ddf

Please sign in to comment.