From 1b2e2c96ed6676014cf6c8a51408bf906c4abd39 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 31 Jul 2020 15:05:02 +0200 Subject: [PATCH] polish --- docs/pages/api-docs/snackbar.md | 2 +- .../snackbars/ConsecutiveSnackbars.js | 4 --- .../snackbars/ConsecutiveSnackbars.tsx | 4 --- .../components/snackbars/SimpleSnackbar.js | 36 +++++++++---------- .../components/snackbars/SimpleSnackbar.tsx | 36 +++++++++---------- .../pages/guides/migration-v4/migration-v4.md | 9 +++-- .../material-ui/src/Snackbar/Snackbar.d.ts | 3 +- packages/material-ui/src/Snackbar/Snackbar.js | 16 ++------- 8 files changed, 45 insertions(+), 65 deletions(-) diff --git a/docs/pages/api-docs/snackbar.md b/docs/pages/api-docs/snackbar.md index 983eca17eabff4..cf845370f2453e 100644 --- a/docs/pages/api-docs/snackbar.md +++ b/docs/pages/api-docs/snackbar.md @@ -29,7 +29,7 @@ The `MuiSnackbar` name can be used for providing [default props](/customization/ | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| | action | node | | The action to display. It renders after the message, at the end of the snackbar. | -| anchorOrigin | { horizontal: 'center'
| 'default'
| 'left'
| 'right', vertical: 'bottom'
| 'top' }
| { vertical: 'bottom', horizontal: 'default' } | The anchor of the `Snackbar`. The `Snackbar` is placed by default bottom center on Mobile and bottom left on Desktop | +| anchorOrigin | { horizontal: 'center'
| 'left'
| 'right', vertical: 'bottom'
| 'top' }
| { vertical: 'bottom', horizontal: 'left' } | The anchor of the `Snackbar`. | | autoHideDuration | number | null | 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. | | children | element | | Replace the `SnackbarContent` component. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | diff --git a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js index a666ab6f4f34fe..7b080a97b0ab5f 100644 --- a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js +++ b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js @@ -50,10 +50,6 @@ export default function ConsecutiveSnackbars() { Show message B + + + + + + ); + return (
- - - - - - } + action={action} />
); diff --git a/docs/src/pages/components/snackbars/SimpleSnackbar.tsx b/docs/src/pages/components/snackbars/SimpleSnackbar.tsx index d8ecff32e8d9aa..715be59c320c29 100644 --- a/docs/src/pages/components/snackbars/SimpleSnackbar.tsx +++ b/docs/src/pages/components/snackbars/SimpleSnackbar.tsx @@ -22,33 +22,31 @@ export default function SimpleSnackbar() { setOpen(false); }; + const action = ( + + + + + + + ); + return (
- - - - - - } + action={action} />
); diff --git a/docs/src/pages/guides/migration-v4/migration-v4.md b/docs/src/pages/guides/migration-v4/migration-v4.md index 146d575eb59429..164f32ee3b370d 100644 --- a/docs/src/pages/guides/migration-v4/migration-v4.md +++ b/docs/src/pages/guides/migration-v4/migration-v4.md @@ -120,10 +120,13 @@ This change affects almost all components where you're using the `component` pro ### Snackbar -- The default value of `anchorOrigin` on Desktop is changed from `bottom center` to `bottom left` +- The notification now displays at the bottom left on large screens. + It better matches the behavior of Gmail, Google Keep, material.io, etc. + You can restore the previous behavior with: + ```diff - - - + + - + + ``` ### TablePagination diff --git a/packages/material-ui/src/Snackbar/Snackbar.d.ts b/packages/material-ui/src/Snackbar/Snackbar.d.ts index b213a2a898262a..6d14b4727782f3 100644 --- a/packages/material-ui/src/Snackbar/Snackbar.d.ts +++ b/packages/material-ui/src/Snackbar/Snackbar.d.ts @@ -6,7 +6,7 @@ import { ClickAwayListenerProps } from '../ClickAwayListener'; export interface SnackbarOrigin { vertical: 'top' | 'bottom'; - horizontal: 'left' | 'center' | 'right' | 'default'; + horizontal: 'left' | 'center' | 'right'; } export type SnackbarCloseReason = 'timeout' | 'clickaway'; @@ -22,7 +22,6 @@ export interface SnackbarProps action?: SnackbarContentProps['action']; /** * The anchor of the `Snackbar`. - * The `Snackbar` is placed by default bottom center on Mobile and bottom left on Desktop */ anchorOrigin?: SnackbarOrigin; /** diff --git a/packages/material-ui/src/Snackbar/Snackbar.js b/packages/material-ui/src/Snackbar/Snackbar.js index 891ef4778e6e32..4b4501027b5b67 100644 --- a/packages/material-ui/src/Snackbar/Snackbar.js +++ b/packages/material-ui/src/Snackbar/Snackbar.js @@ -35,12 +35,6 @@ export const styles = (theme) => { right: 8, justifyContent: 'center', alignItems: 'center', - /* default ancohrOrigin */ - ...bottom1, - [theme.breakpoints.up('sm')]: { - ...bottom3, - ...left3, - }, }, /* Styles applied to the root element if `anchorOrigin={{ 'top', 'center' }}`. */ anchorOriginTopCenter: { @@ -104,7 +98,7 @@ export const styles = (theme) => { const Snackbar = React.forwardRef(function Snackbar(props, ref) { const { action, - anchorOrigin: { vertical, horizontal } = { vertical: 'bottom', horizontal: 'default' }, + anchorOrigin: { vertical, horizontal } = { vertical: 'bottom', horizontal: 'left' }, autoHideDuration = null, children, classes, @@ -229,10 +223,7 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {