@@ -4,86 +4,40 @@ import { NotificationStack } from 'react-notification'
44import * as actions from './actions'
55import state from './state'
66
7- const actionStyleFactory = ( index , style ) =>
8- Object . assign ( { } , style , {
9- color : '#ccc' ,
10- right : '-100%' ,
11- bottom : 'initial' ,
12- top : `${ 2 + index * 4 } rem` ,
13- zIndex : 20 ,
14- fontSize : '12px' ,
15- padding : '8px'
16- } )
17- const barStyleFactory = ( index , style ) =>
18- Object . assign ( { } , style , {
7+ const barStyleFactory = ( index , style ) => {
8+ return Object . assign ( { } , style , {
199 left : 'initial' ,
2010 right : '-100%' ,
2111 bottom : 'initial' ,
2212 top : `${ 2 + index * 4 } rem` ,
2313 zIndex : 20 ,
2414 fontSize : '12px' ,
25- padding : '8px'
15+ padding : '8px' ,
2616 } )
17+ }
2718
28- const activeBarStyleFactory = ( index , style ) =>
29- Object . assign ( { } , style , {
19+ const activeBarStyleFactory = ( index , style ) => {
20+ return Object . assign ( { } , style , {
3021 left : 'initial' ,
3122 right : '1rem' ,
3223 bottom : 'initial' ,
3324 top : `${ 2 + index * 4 } rem` ,
3425 fontSize : '12px' ,
35- padding : '8px'
26+ padding : '8px' ,
3627 } )
37-
38- function notificationMessageFactory ( notifyType , message ) {
39- let ClassName
40- let Color
41- switch ( notifyType ) {
42- case 'error' :
43- ClassName = 'fa fa-times-circle'
44- Color = 'red'
45- break
46- case 'success' :
47- ClassName = 'fa fa-check-circle'
48- Color = 'green'
49- break
50- case 'warning' :
51- ClassName = 'fa fa-exclamation-triangle'
52- Color = 'orange'
53- break
54- case 'info' :
55- ClassName = 'fa fa-info-circle'
56- Color = 'blue'
57- break
58- default :
59- }
60- return (
61- < span style = { { fontSize : 12 } } >
62- < span style = { { color : Color } } >
63- < i className = { ClassName } aria-hidden = 'true' />
64- </ span >
65- { message }
66- </ span >
67- )
6828}
6929
7030class Notification extends Component {
7131 constructor ( props ) {
7232 super ( )
7333 }
74-
7534 render ( ) {
76- const notifications = this . props . notifications . map ( ( v ) => {
77- v . action = < i className = 'fa fa-close' aria-hidden = 'true' />
78- v . message = notificationMessageFactory ( v . notifyType , v . message )
79- return v
80- } )
35+ const { notifications } = this . props
8136 return (
8237 < NotificationStack
8338 notifications = { notifications }
8439 onDismiss = { notification => actions . removeNotification ( notification . key ) }
8540 barStyleFactory = { barStyleFactory }
86- actionStyleFactory = { actionStyleFactory }
8741 activeBarStyleFactory = { activeBarStyleFactory }
8842 />
8943 )
0 commit comments