-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
Fix snackbars of different width being left-aligned #376
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 |
---|---|---|
@@ -1,5 +1,13 @@ | ||
Thanks to all contributers who improved notistack by opening an issue/PR. | ||
|
||
### `[email protected]` | ||
###### May 8, 2021 | ||
* **@whytspace** Multiple Snackbars always left aligned [#373](https://github.com/iamhosseindhv/notistack/issues/373) | ||
|
||
|
||
<br /> | ||
|
||
|
||
### `[email protected]` | ||
###### April 18, 2021 | ||
* **@rzmz** Snackbars should have equal width on XS screens [#367](https://github.com/iamhosseindhv/notistack/issues/367) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,37 +4,71 @@ import { makeStyles } from '@material-ui/core/styles'; | |
import { SNACKBAR_INDENTS } from './utils/constants'; | ||
import { SnackbarProviderProps } from '.'; | ||
|
||
const useStyle = makeStyles(theme => ({ | ||
const collapse = { | ||
container: '& > .MuiCollapse-container', | ||
wrapper: '& > .MuiCollapse-container > .MuiCollapse-wrapper', | ||
Comment on lines
+8
to
+9
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. Oh, I guess the problem is these two selectors. Those selectors do not appear in our DOM structure so |
||
}; | ||
|
||
const useStyle = makeStyles((theme) => ({ | ||
root: { | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
maxHeight: '100%', | ||
maxWidth: '100%', | ||
position: 'fixed', | ||
flexDirection: 'column', | ||
zIndex: theme.zIndex.snackbar, | ||
height: 'auto', | ||
width: 'auto', | ||
minWidth: 288, | ||
transition: theme.transitions.create(['top', 'right', 'bottom', 'left'], { easing: 'ease' }), | ||
transition: 'top 300ms ease 0ms, right 300ms ease 0ms, bottom 300ms ease 0ms, left 300ms ease 0ms, margin 300ms ease 0ms, max-width 300ms ease 0ms', | ||
// container itself is invisible and should not block clicks, clicks should be passed to its children | ||
pointerEvents: 'none', | ||
[collapse.container]: { | ||
pointerEvents: 'all', | ||
}, | ||
Comment on lines
+23
to
+26
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. I found this part is making the snack bar untouchable. |
||
[collapse.wrapper]: { | ||
padding: `${SNACKBAR_INDENTS.snackbar.default}px 0px`, | ||
}, | ||
maxWidth: `calc(100% - ${SNACKBAR_INDENTS.view.default * 2}px)`, | ||
[theme.breakpoints.down('xs')]: { | ||
left: '0 !important', | ||
right: '0 !important', | ||
left: '16px', | ||
right: '16px', | ||
width: '100%', | ||
maxWidth: 'calc(100% - 32px)', | ||
}, | ||
}, | ||
reverseColumns: { flexDirection: 'column-reverse' }, | ||
|
||
top: { top: SNACKBAR_INDENTS.view.default - SNACKBAR_INDENTS.snackbar.default }, | ||
rootDense: { | ||
maxWidth: `calc(100% - ${SNACKBAR_INDENTS.view.dense * 2}px)`, | ||
[collapse.wrapper]: { | ||
padding: `${SNACKBAR_INDENTS.snackbar.dense}px 0px`, | ||
}, | ||
}, | ||
|
||
top: { | ||
top: SNACKBAR_INDENTS.view.default - SNACKBAR_INDENTS.snackbar.default, | ||
flexDirection: 'column', | ||
}, | ||
topDense: { top: SNACKBAR_INDENTS.view.dense - SNACKBAR_INDENTS.snackbar.dense }, | ||
|
||
bottom: { bottom: SNACKBAR_INDENTS.view.default - SNACKBAR_INDENTS.snackbar.default }, | ||
bottom: { | ||
bottom: SNACKBAR_INDENTS.view.default - SNACKBAR_INDENTS.snackbar.default, | ||
flexDirection: 'column-reverse', | ||
}, | ||
bottomDense: { bottom: SNACKBAR_INDENTS.view.dense - SNACKBAR_INDENTS.snackbar.dense }, | ||
|
||
left: { left: SNACKBAR_INDENTS.view.default }, | ||
left: { | ||
left: SNACKBAR_INDENTS.view.default, | ||
[theme.breakpoints.up('sm')]: { | ||
alignItems: 'flex-start', | ||
}, | ||
}, | ||
leftDense: { left: SNACKBAR_INDENTS.view.dense }, | ||
|
||
right: { right: SNACKBAR_INDENTS.view.default }, | ||
right: { | ||
right: SNACKBAR_INDENTS.view.default, | ||
[theme.breakpoints.up('sm')]: { | ||
alignItems: 'flex-end', | ||
}, | ||
}, | ||
rightDense: { right: SNACKBAR_INDENTS.view.dense }, | ||
|
||
center: { | ||
|
@@ -43,6 +77,9 @@ const useStyle = makeStyles(theme => ({ | |
[theme.breakpoints.down('xs')]: { | ||
transform: 'translateX(0)', | ||
}, | ||
[theme.breakpoints.up('sm')]: { | ||
alignItems: 'center', | ||
}, | ||
}, | ||
})); | ||
|
||
|
@@ -59,14 +96,15 @@ const SnackbarContainer: React.FC<SnackbarContainerProps> = (props) => { | |
const { className, anchorOrigin, dense, ...other } = props; | ||
|
||
const combinedClassname = clsx( | ||
classes.root, | ||
classes[anchorOrigin.vertical], | ||
classes[anchorOrigin.horizontal], | ||
// @ts-ignore | ||
classes[`${anchorOrigin.vertical}${dense ? 'Dense' : ''}`], | ||
{ [classes[`${anchorOrigin.vertical}Dense`]]: dense }, | ||
// @ts-ignore | ||
{ [classes[`${anchorOrigin.horizontal}Dense`]]: dense }, | ||
// @ts-ignore | ||
classes[`${anchorOrigin.horizontal}${dense ? 'Dense' : ''}`], | ||
{ [classes.reverseColumns]: anchorOrigin.vertical === 'bottom' }, | ||
{ [classes.rootDense]: dense }, | ||
classes.root, // root should come after others to override maxWidth | ||
className, | ||
); | ||
|
||
|
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.
This CSS class is deprecated. See mui/material-ui#24084
And I guess it is removed in v5