Skip to content

Commit

Permalink
move snackbar changes to another pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 30, 2019
1 parent 5ce86c4 commit d960cb9
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/pages/api/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
|:-----|:-----|:--------|:------------|
| <span class="prop-name">action</span> | <span class="prop-type">node</span> | | The action to display. |
| <span class="prop-name">anchorOrigin</span> | <span class="prop-type">{ horizontal: 'left'<br>&#124;&nbsp;'center'<br>&#124;&nbsp;'right', vertical: 'top'<br>&#124;&nbsp;'bottom' }</span> | <span class="prop-default">{ vertical: 'bottom', horizontal: 'center' }</span> | The anchor of the `Snackbar`. |
| <span class="prop-name">autoHideDuration</span> | <span class="prop-type">number</span> | <span class="prop-default">null</span> | The number of milliseconds to wait before automatically calling the `onClose` function. `onClose` should then set the state of the `open` prop to hide the Snackbar. This behavior is disabled by default with the `null` value. |
| <span class="prop-name">autoHideDuration</span> | <span class="prop-type">number</span> | | The number of milliseconds to wait before automatically calling the `onClose` function. `onClose` should then set the state of the `open` prop to hide the Snackbar. This behavior is disabled by default with the `null` value. |
| <span class="prop-name">children</span> | <span class="prop-type">element</span> | | Replace the `SnackbarContent` component. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">ClickAwayListenerProps</span> | <span class="prop-type">object</span> | | Props applied to the `ClickAwayListener` element. |
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/ConsecutiveSnackbars.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export default function ConsecutiveSnackbars() {
autoHideDuration={6000}
onClose={handleClose}
onExited={handleExited}
message={messageInfo ? messageInfo.message : undefined}
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">{messageInfo ? messageInfo.message : undefined}</span>}
action={[
<Button key="undo" color="secondary" size="small" onClick={handleClose}>
UNDO
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/ConsecutiveSnackbars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export default function ConsecutiveSnackbars() {
autoHideDuration={6000}
onClose={handleClose}
onExited={handleExited}
message={messageInfo ? messageInfo.message : undefined}
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">{messageInfo ? messageInfo.message : undefined}</span>}
action={[
<Button key="undo" color="secondary" size="small" onClick={handleClose}>
UNDO
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/DirectionSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export default function DirectionSnackbar() {
open={open}
onClose={handleClose}
TransitionComponent={transition}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/DirectionSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export default function DirectionSnackbar() {
open={open}
onClose={handleClose}
TransitionComponent={transition}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
7 changes: 5 additions & 2 deletions docs/src/pages/components/snackbars/FabIntegrationSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ export default function FabIntegrationSnackbar() {
</Fab>
<Snackbar
open
autoHideDuration={6000}
message="Archived"
autoHideDuration={4000}
ContentProps={{
'aria-describedby': 'snackbar-fab-message-id',
}}
message={<span id="snackbar-fab-message-id">Archived</span>}
action={
<Button color="inherit" size="small">
Undo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ export default function FabIntegrationSnackbar() {
</Fab>
<Snackbar
open
autoHideDuration={6000}
message="Archived"
autoHideDuration={4000}
ContentProps={{
'aria-describedby': 'snackbar-fab-message-id',
}}
message={<span id="snackbar-fab-message-id">Archived</span>}
action={
<Button color="inherit" size="small">
Undo
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/PositionedSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export default function PositionedSnackbar() {
key={`${vertical},${horizontal}`}
open={open}
onClose={handleClose}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/PositionedSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export default function PositionedSnackbar() {
key={`${vertical},${horizontal}`}
open={open}
onClose={handleClose}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/SimpleSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default function SimpleSnackbar() {
open={open}
autoHideDuration={6000}
onClose={handleClose}
message="Note archived"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">Note archived</span>}
action={[
<Button key="undo" color="secondary" size="small" onClick={handleClose}>
UNDO
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/SimpleSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export default function SimpleSnackbar() {
open={open}
autoHideDuration={6000}
onClose={handleClose}
message="Note archived"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">Note archived</span>}
action={[
<Button key="undo" color="secondary" size="small" onClick={handleClose}>
UNDO
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/TransitionsSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export default function TransitionsSnackbar() {
open={state.open}
onClose={handleClose}
TransitionComponent={state.Transition}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/snackbars/TransitionsSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export default function TransitionsSnackbar() {
open={state.open}
onClose={handleClose}
TransitionComponent={state.Transition}
message="I love snacks"
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">I love snacks</span>}
/>
</div>
);
Expand Down
21 changes: 14 additions & 7 deletions docs/src/pages/components/snackbars/snackbars.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ When multiple snackbar updates are necessary, they should appear one at a time.

Snackbars should appear above FABs (on mobile).

{{"demo": "pages/components/snackbars/FabIntegrationSnackbar.js", "iframe": true, "maxWidth": 400}}
{{"demo": "pages/components/snackbars/FabIntegrationSnackbar.js", "iframe": true, "maxWidth": 500}}

### Change Transition

Expand Down Expand Up @@ -86,20 +86,27 @@ It also enables you to **stack** them on top of one another (although this is di

(WAI-ARIA: https://www.w3.org/TR/wai-aria-1.1/#alert)

- By default, the toast won't auto-hide. However, if you decide to use the `autoHideDuration` prop, it's recommended giving users [enough time](https://www.w3.org/TR/UNDERSTANDING-WCAG20/time-limits.html).
- Since alerts are not required to receive focus, content authors should not require users to close a Snackbar if the role is set to `role="alert"` through the SnackbarContent. This is the default role.
- If a Snackbar requires focus to close it, then content authors should use `role= "alertdialog"`.
- Since alerts are not required to receive focus, content authors should not require users to close a Snackbar if the role is set to `alert` through the SnackbarContent `role` prop. This is the default role.
- If a Snackbar requires focus to close it, then content authors should use the `role` of `alertdialog`.

```jsx
<SnackbarContent role="alert" message="This is a Snackbar message." />
<SnackbarContent
message="This is a Snackbar message."
role="alert"
/>
```

```jsx
<Snackbar
ContentProps={{
'aria-describedby': 'snackbar-fab-message-id',
'role': 'alertdialog',
}}
message="Archived"
action={<Button color="inherit" size="small">Undo</Button>}
message={<span id="snackbar-fab-message-id">Archived</span>}
action={
<Button color="inherit" size="small">
Undo
</Button>
}
/>
```
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ function Snackbar(props) {
return (
<MuiSnackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
autoHideDuration={6000}
autoHideDuration={6e3}
transition={Transition}
ContentProps={{
'aria-describedby': 'snackbar',
classes: {
root: classes.content,
message: classes.contentMessage,
Expand All @@ -58,7 +59,7 @@ function Snackbar(props) {
message={
<React.Fragment>
<InfoIcon className={classes.info} />
<span>{message}</span>
<span id="snackbar">{message}</span>
</React.Fragment>
}
action={[
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Snackbar/Snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
const {
action,
anchorOrigin: { vertical, horizontal } = { vertical: 'bottom', horizontal: 'center' },
autoHideDuration = null,
autoHideDuration,
children,
classes,
className,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/test/typescript/components.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ const SnackbarTest = () => (
horizontal: 'left',
}}
open={true}
autoHideDuration={6000}
autoHideDuration={6e3}
onClose={e => log(e)}
ContentProps={
{
Expand Down

0 comments on commit d960cb9

Please sign in to comment.