-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add demo for actions in ExpansionPanelSummary (#17969)
- Loading branch information
1 parent
cdc4b98
commit 33c1610
Showing
7 changed files
with
206 additions
and
20 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
docs/src/pages/components/expansion-panels/ActionsInExpansionPanelSummary.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,90 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import ExpansionPanel from '@material-ui/core/ExpansionPanel'; | ||
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; | ||
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; | ||
import Checkbox from '@material-ui/core/Checkbox'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
export default function ActionsInExpansionPanelSummary() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions1-content" | ||
id="additional-actions1-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should stop the click event propagation" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
The click event of the nested action will propagate up and expand the panel unless you | ||
explicitly stop it. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions2-content" | ||
id="additional-actions2-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should stop the focus event propagation" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
The focus event of the nested action will propagate up and also focus the expansion | ||
panel unless you explicitly stop it. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions3-content" | ||
id="additional-actions3-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should provide an aria-label on each action that I add" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
If you forget to put an aria-label on the nested action, the label of the action will | ||
also be included in the label of the parent button that controls the panel expansion. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
</div> | ||
); | ||
} |
90 changes: 90 additions & 0 deletions
90
docs/src/pages/components/expansion-panels/ActionsInExpansionPanelSummary.tsx
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,90 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import ExpansionPanel from '@material-ui/core/ExpansionPanel'; | ||
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; | ||
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; | ||
import Checkbox from '@material-ui/core/Checkbox'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
export default function ActionsInExpansionPanelSummary() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions1-content" | ||
id="additional-actions1-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should stop the click event propagation" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
The click event of the nested action will propagate up and expand the panel unless you | ||
explicitly stop it. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions2-content" | ||
id="additional-actions2-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should stop the focus event propagation" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
The focus event of the nested action will propagate up and also focus the expansion | ||
panel unless you explicitly stop it. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
<ExpansionPanel> | ||
<ExpansionPanelSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-label="Expand" | ||
aria-controls="additional-actions3-content" | ||
id="additional-actions3-header" | ||
> | ||
<FormControlLabel | ||
aria-label="Acknowledge" | ||
onClick={event => event.stopPropagation()} | ||
onFocus={event => event.stopPropagation()} | ||
control={<Checkbox />} | ||
label="I acknowledge that I should provide an aria-label on each action that I add" | ||
/> | ||
</ExpansionPanelSummary> | ||
<ExpansionPanelDetails> | ||
<Typography color="textSecondary"> | ||
If you forget to put an aria-label on the nested action, the label of the action will | ||
also be included in the label of the parent button that controls the panel expansion. | ||
</Typography> | ||
</ExpansionPanelDetails> | ||
</ExpansionPanel> | ||
</div> | ||
); | ||
} |
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
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
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