Skip to content

Commit 10da76b

Browse files
author
Jostein Kringlen
committed
feat: render warn icon when type is "warn"
1 parent ff7c91b commit 10da76b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/components/toast-icon.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Toast } from '../core/types';
55
import { ErrorIcon, ErrorTheme } from './error';
66
import { LoaderIcon, LoaderTheme } from './loader';
77
import { CheckmarkIcon, CheckmarkTheme } from './checkmark';
8+
import { WarnIcon, WarnTheme } from './warn';
89

910
const StatusWrapper = styled('div')`
1011
position: absolute;
@@ -42,6 +43,7 @@ export type IconThemes = Partial<{
4243
success: CheckmarkTheme;
4344
error: ErrorTheme;
4445
loading: LoaderTheme;
46+
warn: WarnTheme;
4547
}>;
4648

4749
export const ToastIcon: React.FC<{
@@ -60,18 +62,21 @@ export const ToastIcon: React.FC<{
6062
return null;
6163
}
6264

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+
6376
return (
6477
<IndicatorWrapper>
6578
<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>}
7580
</IndicatorWrapper>
7681
);
7782
};

0 commit comments

Comments
 (0)