@@ -4,40 +4,87 @@ import { NotificationStack } from 'react-notification'
44import * as actions from './actions'
55import state from './state'
66
7- const barStyleFactory = ( index , style ) => {
8- return Object . assign ( { } , style , {
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 , {
919 left : 'initial' ,
1020 right : '-100%' ,
1121 bottom : 'initial' ,
1222 top : `${ 2 + index * 4 } rem` ,
1323 zIndex : 20 ,
1424 fontSize : '12px' ,
15- padding : '8px' ,
25+ padding : '8px'
1626 } )
17- }
1827
19- const activeBarStyleFactory = ( index , style ) => {
20- return Object . assign ( { } , style , {
28+ const activeBarStyleFactory = ( index , style ) =>
29+ Object . assign ( { } , style , {
2130 left : 'initial' ,
2231 right : '1rem' ,
2332 bottom : 'initial' ,
2433 top : `${ 2 + index * 4 } rem` ,
2534 fontSize : '12px' ,
26- padding : '8px' ,
35+ padding : '8px'
2736 } )
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+ )
2868}
2969
3070class Notification extends Component {
3171 constructor ( props ) {
3272 super ( )
3373 }
74+
3475 render ( ) {
35- const { notifications } = this . props
76+ const notifications = this . props . notifications . map ( ( v ) => {
77+ v . action = < i className = 'fa fa-close' aria-hidden = 'true' />
78+ v . dismissAfter = false
79+ v . message = notificationMessageFactory ( v . notifyType , v . message )
80+ return v
81+ } )
3682 return (
3783 < NotificationStack
3884 notifications = { notifications }
3985 onDismiss = { notification => actions . removeNotification ( notification . key ) }
4086 barStyleFactory = { barStyleFactory }
87+ actionStyleFactory = { actionStyleFactory }
4188 activeBarStyleFactory = { activeBarStyleFactory }
4289 />
4390 )
0 commit comments