-
-
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
[docs] Add demo for actions in ExpansionPanelSummary #17969
Merged
oliviertassinari
merged 3 commits into
mui:master
from
ayliao:9427-actions-in-ExpansionPanelSummary
Oct 23, 2019
Merged
Changes from all commits
Commits
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
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
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.
Fix:
https://validator.w3.org/
Prior to this change, if you click the icon, the
space
key action didn't trigger the expansion panel.