forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layout.tsx
154 lines (147 loc) · 3.15 KB
/
Layout.tsx
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import * as React from 'react';
import Box, { BoxProps } from '@mui/joy/Box';
import Sheet from '@mui/joy/Sheet';
function Root(props: BoxProps) {
return (
<Box
{...props}
sx={[
{
display: 'grid',
gridTemplateColumns: {
xs: '1fr',
sm: 'minmax(64px, 200px) minmax(450px, 1fr)',
md: 'minmax(160px, 300px) minmax(300px, 500px) minmax(500px, 1fr)',
},
gridTemplateRows: '64px 1fr',
minHeight: '100vh',
},
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
/>
);
}
function Header(props: BoxProps) {
return (
<Box
component="header"
className="Header"
{...props}
sx={[
{
p: 2,
gap: 2,
bgcolor: 'background.surface',
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
gridColumn: '1 / -1',
borderBottom: '1px solid',
borderColor: 'divider',
position: 'sticky',
top: 0,
zIndex: 1100,
},
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
/>
);
}
function SideNav(props: BoxProps) {
return (
<Box
component="nav"
className="Navigation"
{...props}
sx={[
{
p: 2,
bgcolor: 'background.surface',
borderRight: '1px solid',
borderColor: 'divider',
display: {
xs: 'none',
sm: 'initial',
},
},
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
/>
);
}
function SidePane(props: BoxProps) {
return (
<Box
className="Inbox"
{...props}
sx={[
{
bgcolor: 'background.surface',
borderRight: '1px solid',
borderColor: 'divider',
display: {
xs: 'none',
md: 'initial',
},
},
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
/>
);
}
function Main(props: BoxProps) {
return (
<Box
component="main"
className="Main"
{...props}
sx={[{ p: 2 }, ...(Array.isArray(props.sx) ? props.sx : [props.sx])]}
/>
);
}
function SideDrawer({
onClose,
...props
}: BoxProps & { onClose: React.MouseEventHandler<HTMLDivElement> }) {
return (
<Box
{...props}
sx={[
{ position: 'fixed', zIndex: 1200, width: '100%', height: '100%' },
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
>
<Box
role="button"
onClick={onClose}
sx={{
position: 'absolute',
inset: 0,
bgcolor: (theme) =>
`rgba(${theme.vars.palette.neutral.darkChannel} / 0.8)`,
}}
/>
<Sheet
sx={{
minWidth: 256,
width: 'max-content',
height: '100%',
p: 2,
boxShadow: 'lg',
bgcolor: 'background.surface',
}}
>
{props.children}
</Sheet>
</Box>
);
}
export default {
Root,
Header,
SideNav,
SidePane,
SideDrawer,
Main,
};