File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Toast } from '../core/types';
5
5
import { ErrorIcon , ErrorTheme } from './error' ;
6
6
import { LoaderIcon , LoaderTheme } from './loader' ;
7
7
import { CheckmarkIcon , CheckmarkTheme } from './checkmark' ;
8
+ import { WarnIcon , WarnTheme } from './warn' ;
8
9
9
10
const StatusWrapper = styled ( 'div' ) `
10
11
position: absolute;
@@ -42,6 +43,7 @@ export type IconThemes = Partial<{
42
43
success : CheckmarkTheme ;
43
44
error : ErrorTheme ;
44
45
loading : LoaderTheme ;
46
+ warn : WarnTheme ;
45
47
} > ;
46
48
47
49
export const ToastIcon : React . FC < {
@@ -60,18 +62,21 @@ export const ToastIcon: React.FC<{
60
62
return null ;
61
63
}
62
64
65
+ const renderIcon = ( type : Toast [ 'type' ] ) => {
66
+ switch ( type ) {
67
+ case 'error' :
68
+ return < ErrorIcon { ...iconTheme } /> ;
69
+ case 'warn' :
70
+ return < WarnIcon { ...iconTheme } /> ;
71
+ default :
72
+ return < CheckmarkIcon { ...iconTheme } /> ;
73
+ }
74
+ } ;
75
+
63
76
return (
64
77
< IndicatorWrapper >
65
78
< LoaderIcon { ...iconTheme } />
66
- { type !== 'loading' && (
67
- < StatusWrapper >
68
- { type === 'error' ? (
69
- < ErrorIcon { ...iconTheme } />
70
- ) : (
71
- < CheckmarkIcon { ...iconTheme } />
72
- ) }
73
- </ StatusWrapper >
74
- ) }
79
+ { type !== 'loading' && < StatusWrapper > { renderIcon ( type ) } </ StatusWrapper > }
75
80
</ IndicatorWrapper >
76
81
) ;
77
82
} ;
You can’t perform that action at this time.
0 commit comments