-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs-infra] Improve demos toolbar #37762
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as React from 'react'; | ||
import Alert from '@mui/material/Alert'; | ||
import Stack from '@mui/material/Stack'; | ||
|
||
export default function DemoInDocs() { | ||
return ( | ||
<Stack sx={{ width: '100%' }} spacing={2}> | ||
<Alert severity="error">This is an error alert — check it out!</Alert> | ||
<Alert severity="warning">This is a warning alert — check it out!</Alert> | ||
<Alert severity="info">This is an info alert — check it out!</Alert> | ||
<Alert severity="success">This is a success alert — check it out!</Alert> | ||
</Stack> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Alert severity="error">This is an error alert — check it out!</Alert> | ||
<Alert severity="warning">This is a warning alert — check it out!</Alert> | ||
<Alert severity="info">This is an info alert — check it out!</Alert> | ||
<Alert severity="success">This is a success alert — check it out!</Alert> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import * as pageProps from './demos.md?@mui/markdown'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs {...pageProps} />; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Demos | ||
|
||
<p class="description">Demos</p> | ||
|
||
## Standard demo | ||
|
||
{{"demo": "DemoInDocs.js"}} | ||
|
||
## "bg": "inline" demo | ||
|
||
{{"demo": "DemoInDocs.js", "bg": "inline"}} | ||
|
||
## "bg": true | ||
|
||
{{"demo": "DemoInDocs.js", "bg": true}} | ||
|
||
## "hideToolbar": true | ||
|
||
{{"demo": "DemoInDocs.js", "hideToolbar": true}} | ||
|
||
## "hideToolbar": true, "bg": true | ||
|
||
{{"demo": "DemoInDocs.js", "hideToolbar": true, "bg": true}} | ||
|
||
## "hideToolbar": true, "bg": "inline" | ||
|
||
{{"demo": "DemoInDocs.js", "hideToolbar": true, "bg": "inline"}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ const DemoRootMaterial = styled('div', { | |
display: 'flex', | ||
justifyContent: 'center', | ||
[theme.breakpoints.up('sm')]: { | ||
borderRadius: '12px 12px 0 0', | ||
borderRadius: hiddenToolbar ? 12 : '12px 12px 0 0', | ||
...(bg === 'outlined' && { | ||
borderLeftWidth: 1, | ||
borderRightWidth: 1, | ||
|
@@ -219,9 +219,6 @@ const DemoRootMaterial = styled('div', { | |
...(bg === 'inline' && { | ||
padding: theme.spacing(0), | ||
}), | ||
...(hiddenToolbar && { | ||
paddingTop: theme.spacing(1), | ||
}), | ||
Comment on lines
-222
to
-224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This style seem irrelevant |
||
}, | ||
/* Isolate the demo with an outline. */ | ||
...(bg === 'outlined' && { | ||
|
@@ -233,10 +230,11 @@ const DemoRootMaterial = styled('div', { | |
}), | ||
/* Prepare the background to display an inner elevation. */ | ||
...(bg === true && { | ||
padding: theme.spacing(4), | ||
backgroundColor: (theme.vars || theme).palette.grey[100], | ||
padding: theme.spacing(3), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Match Joy UI |
||
backgroundColor: (theme.vars || theme).palette.grey[50], | ||
border: `1px solid ${(theme.vars || theme).palette.divider}`, | ||
...theme.applyDarkStyles({ | ||
backgroundColor: (theme.vars || theme).palette.grey[900], | ||
backgroundColor: alpha(theme.palette.primaryDark[700], 0.5), | ||
}), | ||
}), | ||
/* Mostly meant for introduction demos. */ | ||
|
@@ -282,9 +280,6 @@ const DemoRootMaterial = styled('div', { | |
)} 0px, transparent 50%);`, | ||
}), | ||
}), | ||
...(hiddenToolbar && { | ||
paddingTop: theme.spacing(2), | ||
}), | ||
Comment on lines
-285
to
-287
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This style seem irrelevant |
||
})); | ||
|
||
const DemoRootJoy = joyStyled('div', { | ||
|
@@ -296,11 +291,10 @@ const DemoRootJoy = joyStyled('div', { | |
display: 'flex', | ||
justifyContent: 'center', | ||
[theme.breakpoints.up('sm')]: { | ||
borderRadius: '12px 12px 0 0', | ||
borderRadius: hiddenToolbar ? 12 : '12px 12px 0 0', | ||
...(bg === 'outlined' && { | ||
borderLeftWidth: 1, | ||
borderRightWidth: 1, | ||
borderRadius: '12px 12px 0 0', | ||
}), | ||
/* Make no difference between the demo and the markdown. */ | ||
...(bg === 'inline' && { | ||
|
@@ -357,9 +351,6 @@ const DemoRootJoy = joyStyled('div', { | |
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23003A75' fill-opacity='0.15'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h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");`, | ||
}), | ||
}), | ||
...(hiddenToolbar && { | ||
paddingTop: theme.spacing(0), | ||
}), | ||
})); | ||
|
||
const DemoCodeViewer = styled(HighlightedCode)(({ theme }) => ({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,13 @@ import stylingSolutionMapping from 'docs/src/modules/utils/stylingSolutionMappin | |
import codeSandbox from '../sandbox/CodeSandbox'; | ||
import stackBlitz from '../sandbox/StackBlitz'; | ||
|
||
const Root = styled('div')(({ theme }) => [ | ||
const Root = styled('div', { | ||
shouldForwardProp: (prop) => prop !== 'demoOptions', | ||
})(({ theme, demoOptions }) => [ | ||
{ | ||
display: 'none', | ||
border: `1px solid ${(theme.vars || theme).palette.divider}`, | ||
marginTop: -1, | ||
marginTop: demoOptions.bg === 'inline' ? 8 : -1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The negative margin when the bg is inline is strange, see https://mui.com/x/react-data-grid/#mit-version and https://mui.com/x/react-date-pickers/shortcuts/#customization as two examples. |
||
marginBottom: 16, | ||
[theme.breakpoints.up('sm')]: { | ||
display: 'flex', | ||
|
@@ -538,7 +540,7 @@ export default function DemoToolbar(props) { | |
|
||
return ( | ||
<React.Fragment> | ||
<Root aria-label={t('demoToolbarLabel')} {...toolbarProps}> | ||
<Root aria-label={t('demoToolbarLabel')} {...toolbarProps} demoOptions={demoOptions}> | ||
{hasNonSystemDemos && ( | ||
<Button | ||
id="styling-solution" | ||
|
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.
Fix border-radius at the footer of https://mui.com/material-ui/react-grid/#interactive