a b/src/components/Layout/Layout.tsx
1
import React, { useState } from 'react';
2
import { Box, CssBaseline, styled } from '@mui/material';
3
import { AppBar } from './AppBar';
4
import { Sidebar } from './Sidebar';
5
6
const Main = styled('main')(({ theme }) => ({
7
  flexGrow: 1,
8
  padding: theme.spacing(3),
9
  width: '100%',
10
  minHeight: '100vh',
11
  marginTop: 64, // AppBar height
12
  backgroundColor: theme.palette.background.default,
13
}));
14
15
interface LayoutProps {
16
  children: React.ReactNode;
17
}
18
19
export const Layout: React.FC<LayoutProps> = ({ children }) => {
20
  const [isSidebarOpen, setIsSidebarOpen] = useState(false);
21
22
  const handleSidebarToggle = () => {
23
    setIsSidebarOpen(!isSidebarOpen);
24
  };
25
26
  return (
27
    <Box sx={{ display: 'flex' }}>
28
      <CssBaseline />
29
      <AppBar onMenuClick={handleSidebarToggle} />
30
      <Sidebar open={isSidebarOpen} onClose={() => setIsSidebarOpen(false)} />
31
      <Main>
32
        {children}
33
      </Main>
34
    </Box>
35
  );
36
};