Commit 2eaaa50 1 parent f0611c7 commit 2eaaa50 Copy full SHA for 2eaaa50
File tree 3 files changed +40
-4
lines changed
3 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 9
9
capitalise ,
10
10
defaultAnchorOrigin ,
11
11
getTransitionDirection ,
12
+ muiClasses ,
12
13
TransitionComponent ,
13
14
variantIcon ,
14
15
} from './SnackbarItem.util' ;
@@ -66,13 +67,14 @@ class SnackbarItem extends Component {
66
67
{ ...other }
67
68
{ ...singleSnackProps }
68
69
open = { snack . open }
70
+ classes = { muiClasses ( classes ) }
69
71
onClose = { this . handleClose ( key ) }
70
72
onExited = { ( ) => onExited ( key ) }
71
73
>
72
74
< SnackbarContent
73
75
variant = "subtitle1"
74
76
className = { classNames (
75
- classes . root ,
77
+ classes . base ,
76
78
classes [ `variant${ capitalise ( variant ) } ` ] ,
77
79
className ,
78
80
) }
Original file line number Diff line number Diff line change 6
6
} from '../utils/constants' ;
7
7
8
8
const styles = theme => ( {
9
- root : {
9
+ root : { } ,
10
+ base : {
10
11
fontSize : '0.875rem' ,
11
12
lineHeight : '1.46429em' ,
12
13
fontWeight : theme . typography . fontWeightRegular ,
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ const InfoIcon = props => (
36
36
</ SvgIcon >
37
37
) ;
38
38
39
+ const TransitionComponent = props => < Slide { ...props } /> ;
40
+
39
41
const variantIcon = {
40
42
success : < CheckIcon /> ,
41
43
warning : < WarningIcon /> ,
@@ -55,21 +57,52 @@ const defaultAnchorOrigin = {
55
57
horizontal : 'left' ,
56
58
} ;
57
59
60
+ const notistackClasses = [
61
+ 'base' ,
62
+ 'variantSuccess' ,
63
+ 'variantError' ,
64
+ 'variantInfo' ,
65
+ 'variantWarning' ,
66
+ 'message' ,
67
+ 'iconVariant' ,
68
+ ] ;
69
+
70
+ /**
71
+ * returns transition direction according the the given anchor origin
72
+ * @param {object } anchorOrigin
73
+ */
58
74
const getTransitionDirection = ( anchorOrigin = defaultAnchorOrigin ) => {
59
75
if ( anchorOrigin . horizontal !== 'center' ) {
60
76
return DIRECTION [ anchorOrigin . horizontal ] ;
61
77
}
62
78
return DIRECTION [ anchorOrigin . vertical ] ;
63
79
} ;
64
80
65
- const capitalise = string => string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 ) ;
81
+ /**
82
+ * Capitalises a piece of string
83
+ * @param {string } text
84
+ */
85
+ const capitalise = text => text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) ;
66
86
67
- const TransitionComponent = props => < Slide { ...props } /> ;
87
+ /**
88
+ * Filteres classes object and returns the keys that are allowed
89
+ * in material-ui snackbar classes prop
90
+ * @param {object } classes
91
+ */
92
+ const muiClasses = classes => (
93
+ Object . keys ( classes )
94
+ . filter ( key => ! notistackClasses . includes ( key ) )
95
+ . reduce ( ( obj , key ) => ( {
96
+ ...obj ,
97
+ [ key ] : classes [ key ] ,
98
+ } ) , { } )
99
+ ) ;
68
100
69
101
export {
70
102
capitalise ,
71
103
defaultAnchorOrigin ,
72
104
getTransitionDirection ,
105
+ muiClasses ,
73
106
TransitionComponent ,
74
107
variantIcon ,
75
108
} ;
You can’t perform that action at this time.
0 commit comments