-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cebd141
commit 5f73a49
Showing
5 changed files
with
67 additions
and
43 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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,42 @@ | ||
import classNames from 'classnames'; | ||
import { SnackbarProps } from '@material-ui/core/Snackbar'; | ||
import { allClasses } from '../utils/constants'; | ||
import { SnackbarItemProps } from './SnackbarItem'; | ||
import { Snack } from '../SnackbarProvider'; | ||
|
||
const DIRECTION = { | ||
right: 'left', | ||
left: 'right', | ||
bottom: 'up', | ||
top: 'down', | ||
} as const; | ||
export type DirectionType = typeof DIRECTION[keyof typeof DIRECTION] | ||
|
||
export const getTransitionDirection = (anchorOrigin: Snack['anchorOrigin']): DirectionType => { | ||
if (anchorOrigin.horizontal !== 'center') { | ||
return DIRECTION[anchorOrigin.horizontal]; | ||
} | ||
return DIRECTION[anchorOrigin.vertical]; | ||
}; | ||
|
||
/** | ||
* Omit all class keys except those allowed in material-ui snackbar | ||
*/ | ||
export const omitNonMuiKeys: (classes: { wrappedRoot: string } & SnackbarProps['classes']) => SnackbarProps['classes'] = (classes) => { | ||
const snackbarMuiClasses = Object.keys(classes) | ||
// @ts-ignore | ||
.filter(key => allClasses.mui[key] !== undefined).reduce((obj, key) => ({ ...obj, [key]: classes[key] }), {}); | ||
|
||
return { | ||
...snackbarMuiClasses, | ||
root: classNames(classes.root, classes.wrappedRoot), | ||
}; | ||
}; | ||
|
||
/** | ||
* Omit all class keys except what we need for collapse component | ||
*/ | ||
export const omitNonCollapseKeys = (classes: { collapseContainer: string; collapseWrapper: string; collapseWrapperDense: string }, dense: SnackbarItemProps['dense']): { container: string; wrapper: string } => ({ | ||
container: classes.collapseContainer, | ||
wrapper: classNames(classes.collapseWrapper, { [classes.collapseWrapperDense]: dense }), | ||
}); |
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