-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui][docs] Refine templates theme selector (#43396)
- Loading branch information
Showing
64 changed files
with
1,700 additions
and
1,099 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
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
100 changes: 100 additions & 0 deletions
100
docs/data/material/getting-started/templates/blog/NavBar.js
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,100 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { createTheme, ThemeProvider, styled } from '@mui/material/styles'; | ||
import Select from '@mui/material/Select'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import FormControl from '@mui/material/FormControl'; | ||
import Button from '@mui/material/Button'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import Box from '@mui/material/Box'; | ||
import AppBar from '@mui/material/AppBar'; | ||
import Toolbar from '@mui/material/Toolbar'; | ||
import Container from '@mui/material/Container'; | ||
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded'; | ||
import ToggleColorMode from './components/ToggleColorMode'; | ||
import getBlogTheme from './theme/getBlogTheme'; | ||
|
||
const StyledAppBar = styled(AppBar)(({ theme }) => ({ | ||
position: 'fixed', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
flexShrink: 0, | ||
borderBottom: '1px solid', | ||
borderColor: theme.palette.divider, | ||
backgroundColor: theme.palette.background.paper, | ||
boxShadow: theme.shadows[1], | ||
backgroundImage: 'none', | ||
padding: 4, | ||
})); | ||
|
||
function NavBar({ showCustomTheme, toggleCustomTheme, mode, toggleColorMode }) { | ||
const handleChange = (event) => { | ||
toggleCustomTheme(event.target.value === 'custom'); | ||
}; | ||
const blogTheme = createTheme(getBlogTheme(mode)); | ||
|
||
return ( | ||
<ThemeProvider theme={blogTheme}> | ||
<StyledAppBar> | ||
<Container maxWidth="lg"> | ||
<Toolbar | ||
variant="dense" | ||
disableGutters | ||
sx={{ display: 'flex', justifyContent: 'space-between' }} | ||
> | ||
<Button | ||
variant="text" | ||
size="small" | ||
aria-label="Back to templates" | ||
startIcon={<ArrowBackRoundedIcon />} | ||
component="a" | ||
href="/material-ui/getting-started/templates/" | ||
sx={{ display: { xs: 'none', sm: 'flex' } }} | ||
> | ||
Back to templates | ||
</Button> | ||
<IconButton | ||
size="small" | ||
aria-label="Back to templates" | ||
component="a" | ||
href="/material-ui/getting-started/templates/" | ||
sx={{ display: { xs: 'auto', sm: 'none' } }} | ||
> | ||
<ArrowBackRoundedIcon /> | ||
</IconButton> | ||
<Box sx={{ display: 'flex', gap: 1 }}> | ||
<FormControl variant="outlined" sx={{ minWidth: 180 }}> | ||
<Select | ||
size="small" | ||
labelId="theme-select-label" | ||
id="theme-select" | ||
value={showCustomTheme ? 'custom' : 'material'} | ||
onChange={handleChange} | ||
label="Design Language" | ||
> | ||
<MenuItem value="custom">Custom Theme</MenuItem> | ||
<MenuItem value="material">Material Design 2</MenuItem> | ||
</Select> | ||
</FormControl> | ||
<ToggleColorMode | ||
data-screenshot="toggle-mode" | ||
mode={mode} | ||
toggleColorMode={toggleColorMode} | ||
/> | ||
</Box> | ||
</Toolbar> | ||
</Container> | ||
</StyledAppBar> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
NavBar.propTypes = { | ||
mode: PropTypes.oneOf(['dark', 'light']).isRequired, | ||
showCustomTheme: PropTypes.bool.isRequired, | ||
toggleColorMode: PropTypes.func.isRequired, | ||
toggleCustomTheme: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default NavBar; |
Oops, something went wrong.