forked from mui/material-ui
/
sheet.tsx
145 lines (141 loc) · 4.83 KB
/
sheet.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
import Moon from '@mui/icons-material/DarkMode';
import Info from '@mui/icons-material/InfoOutlined';
import Sun from '@mui/icons-material/LightMode';
import Box from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import Sheet from '@mui/joy/Sheet';
import { CssVarsProvider, useColorScheme } from '@mui/joy/styles';
import Typography from '@mui/joy/Typography';
import { GlobalStyles } from '@mui/system';
import * as React from 'react';
const ColorSchemePicker = () => {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return null;
}
return (
<Button
variant="outlined"
onClick={() => {
if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
}}
sx={{ '--Button-paddingInline': '0.25rem', minWidth: 'var(--Button-minHeight)' }}
>
{mode === 'light' ? <Moon /> : <Sun />}
</Button>
);
};
export default function JoySheet() {
const SheetProps = {
variant: ['plain', 'outlined', 'soft', 'solid'],
color: ['primary', 'neutral', 'danger', 'info', 'success', 'warning'],
} as const;
return (
<CssVarsProvider>
<GlobalStyles
styles={{ body: { backgroundColor: 'var(--joy-palette-background-level1)' } }}
/>
<Box sx={{ py: 5, maxWidth: { md: 1152, xl: 1536 }, mx: 'auto' }}>
<Box sx={{ px: 3, pb: 4 }}>
<ColorSchemePicker />
</Box>
<Sheet sx={{ p: 2, display: 'flex', gap: 2, borderRadius: 'sm', alignItems: 'center' }}>
<Sheet variant="soft" color="primary" sx={{ p: 1, borderRadius: 'xs' }}>
<Sheet
variant="solid"
color="primary"
sx={{ borderRadius: 'xs', display: 'flex', p: 1 }}
>
<Info />
</Sheet>
</Sheet>
<Box>
<Typography sx={{ fontWeight: 'bold' }}>Read the documentation</Typography>
<Typography level="body2">
Discover the concepts, reference, guides and tutorials.
</Typography>
</Box>
</Sheet>
<br />
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 5 }}>
{Object.entries(SheetProps).map(([propName, propValue]) => (
<Box
key={propName}
sx={{ display: 'flex', flexDirection: 'column', gap: 5, p: 2, alignItems: 'center' }}
>
<Typography level="body2" sx={{ fontWeight: 'bold' }}>
{propName}
</Typography>
{propValue.map((value) => (
<Box key={value}>
<Sheet
{...{ [propName]: value }}
sx={{
width: 250,
height: 150,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography sx={{ color: 'inherit' }}>{value}</Typography>
</Sheet>
</Box>
))}
</Box>
))}
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 5 }}>
{Object.entries(SheetProps).map(([propName, propValue], index) =>
Object.entries(SheetProps).map(([propName2, propValue2], index2) => {
return index < index2 ? (
<Box
key={propName}
sx={{
display: 'flex',
flexDirection: 'column',
gap: 5,
p: 2,
alignItems: 'center',
}}
>
<Typography level="body2" sx={{ fontWeight: 'bold' }}>
{`${propName} && ${propName2}`}
</Typography>
{propValue.map((value) => {
return propValue2.map((value2) => (
<Box key={value}>
<Sheet
{...{ [propName]: value, [propName2]: value2 }}
sx={{
width: 250,
height: 150,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography
sx={{ color: 'inherit' }}
>{`${value} && ${value2}`}</Typography>
</Sheet>
</Box>
));
})}
</Box>
) : null;
}),
)}
</Box>
</Box>
</CssVarsProvider>
);
}