-
-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathDashboardLayoutSidebarCollapsedProp.js
More file actions
110 lines (100 loc) · 2.74 KB
/
DashboardLayoutSidebarCollapsedProp.js
File metadata and controls
110 lines (100 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import * as React from 'react';
import PropTypes from 'prop-types';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import { createTheme } from '@mui/material/styles';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import BarChartIcon from '@mui/icons-material/BarChart';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import { Button } from '@mui/material';
const NAVIGATION = [
{
segment: 'dashboard',
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
segment: 'orders',
title: 'Orders',
icon: <ShoppingCartIcon />,
},
{
segment: 'reports',
title: 'Reports',
icon: <BarChartIcon />,
},
];
const demoTheme = createTheme({
cssVariables: {
colorSchemeSelector: 'data-toolpad-color-scheme',
},
colorSchemes: { light: true, dark: true },
breakpoints: {
values: {
xs: 0,
sm: 600,
md: 600,
lg: 1200,
xl: 1536,
},
},
});
function DemoPageContent({ pathname, toggleSidebar }) {
return (
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
textAlign: 'center',
}}
>
<Typography>Dashboard content for {pathname}</Typography>
<Button onClick={() => toggleSidebar()}>Toggle Sidebar</Button>
</Box>
);
}
DemoPageContent.propTypes = {
pathname: PropTypes.string.isRequired,
toggleSidebar: PropTypes.func.isRequired,
};
function DashboardLayoutSidebarCollapsedProp(props) {
const { window } = props;
const [pathname, setPathname] = React.useState('/dashboard');
const [navigationMenuOpen, toggleSidebar] = React.useState(true);
const router = React.useMemo(() => {
return {
pathname,
searchParams: new URLSearchParams(),
navigate: (path) => setPathname(String(path)),
};
}, [pathname]);
// Remove this const when copying and pasting into your project.
const demoWindow = window !== undefined ? window() : undefined;
return (
<AppProvider
navigation={NAVIGATION}
router={router}
theme={demoTheme}
window={demoWindow}
>
<DashboardLayout navigationMenuOpen={navigationMenuOpen}>
<DemoPageContent
pathname={pathname}
toggleSidebar={() => toggleSidebar(!navigationMenuOpen)}
/>
</DashboardLayout>
</AppProvider>
);
}
DashboardLayoutSidebarCollapsedProp.propTypes = {
/**
* Injected by the documentation to work in an iframe.
* Remove this when copying and pasting into your project.
*/
window: PropTypes.func,
};
export default DashboardLayoutSidebarCollapsedProp;