-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][docs] Refine templates theme selector #43396
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
afc1d6b
Design NavBar
zanivan 1658fdb
Add fixes to Blog template
zanivan 6ec5633
Add NaVbar to checkout
zanivan 9823fe3
Add to Dashboard
zanivan 2d9f8e3
Add to Marketing Page
zanivan 7e00e88
Add to SignIn
zanivan 5c3bfcc
Add to SignInSide
zanivan a7b657e
Remove unused imports and blank lines
zanivan 0fb6a2d
Add to SignUp
zanivan 800db9a
Run pnpm docs:typescript:formatted
zanivan 60e4e5a
Fix lint
zanivan 835773a
Fix dashboard layout
zanivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those don't exist:
https://pagespeed.web.dev/analysis/https-mui-com-material-ui-getting-started-templates-dashboard/3z1h84d300?form_factor=desktop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback—it should be fixed in #43604