forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomizationExamplesNoSnap.js
More file actions
60 lines (56 loc) · 2.09 KB
/
CustomizationExamplesNoSnap.js
File metadata and controls
60 lines (56 loc) · 2.09 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
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import Stack from '@mui/material/Stack';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { BrandingProvider } from '@mui/internal-core-docs/branding';
import CustomizationPlayground from 'docsx/src/modules/components/CustomizationPlayground';
import CircularProgress from '@mui/material/CircularProgress';
import { pickerExamples } from './examplesConfig.styling';
export default function CustomizationExamplesNoSnap() {
const [selectedPicker, setSelectedPicker] = React.useState(0);
const handleSelectedPickerChange = (_e, newValue) => {
if (newValue !== null) {
setSelectedPicker(newValue);
}
};
if (!pickerExamples[selectedPicker]?.examples) {
return (
<BrandingProvider>
<CircularProgress />
</BrandingProvider>
);
}
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<Stack spacing={2} sx={{ mb: 2, width: '100%', px: { xs: 2, sm: 0 } }}>
<BrandingProvider>
<ToggleButtonGroup
value={selectedPicker}
exclusive
onChange={handleSelectedPickerChange}
aria-label="date picker components"
>
{pickerExamples.map(({ name }, index) => (
<ToggleButton value={index} aria-label={name} key={name}>
{name}
</ToggleButton>
))}
</ToggleButtonGroup>
</BrandingProvider>
<CustomizationPlayground
examples={pickerExamples[selectedPicker].examples}
componentName={pickerExamples[selectedPicker].name}
>
{pickerExamples.map(
(example, index) =>
String(index) === String(selectedPicker) && (
<example.component key={index} {...example?.componentProps} />
),
)}
</CustomizationPlayground>
</Stack>
</LocalizationProvider>
);
}