-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7089ed
commit 012cf03
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import * as React from 'react'; | ||
import { | ||
Experimental_CssVarsProvider as CssVarsProvider, | ||
useColorScheme, | ||
} from '@mui/material/styles'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import Box from '@mui/material/Box'; | ||
import Button from '@mui/material/Button'; | ||
import Container from '@mui/material/Container'; | ||
import Moon from '@mui/icons-material/DarkMode'; | ||
import Sun from '@mui/icons-material/LightMode'; | ||
import Accordion from '@mui/material/Accordion'; | ||
import AccordionSummary from '@mui/material/AccordionSummary'; | ||
import AccordionDetails from '@mui/material/AccordionDetails'; | ||
import Typography from '@mui/material/Typography'; | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
|
||
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'); | ||
} | ||
}} | ||
> | ||
{mode === 'light' ? <Moon /> : <Sun />} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default function CssVarsTemplate() { | ||
return ( | ||
<CssVarsProvider> | ||
<CssBaseline /> | ||
<Container sx={{ my: 5 }}> | ||
<Box sx={{ pb: 2 }}> | ||
<ColorSchemePicker /> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: 'grid', | ||
gridTemplateColumns: 'repeat(auto-fill, minmax(256px, 1fr))', | ||
gridAutoRows: 'minmax(160px, auto)', | ||
gap: 2, | ||
'& > div': { | ||
placeSelf: 'center', | ||
}, | ||
}} | ||
> | ||
<Box> | ||
<Accordion> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel1a-content" | ||
id="panel1a-header" | ||
> | ||
<Typography>Accordion 1</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Typography> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada | ||
lacus ex, sit amet blandit leo lobortis eget. | ||
</Typography> | ||
</AccordionDetails> | ||
</Accordion> | ||
<Accordion> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel2a-content" | ||
id="panel2a-header" | ||
> | ||
<Typography>Accordion 2</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Typography> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada | ||
lacus ex, sit amet blandit leo lobortis eget. | ||
</Typography> | ||
</AccordionDetails> | ||
</Accordion> | ||
<Accordion disabled> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel3a-content" | ||
id="panel3a-header" | ||
> | ||
<Typography>Disabled Accordion</Typography> | ||
</AccordionSummary> | ||
</Accordion> | ||
</Box> | ||
</Box> | ||
</Container> | ||
</CssVarsProvider> | ||
); | ||
} |