-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAlertIcon.tsx
More file actions
38 lines (32 loc) · 941 Bytes
/
AlertIcon.tsx
File metadata and controls
38 lines (32 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import alertSrc from '@corbado/shared-ui/assets/alert.svg';
import type { FC } from 'react';
import { useRef } from 'react';
import React from 'react';
import { useIconWithTheme } from '../../../hooks/useIconWithTheme';
import type { IconProps } from './Icon';
import { Icon } from './Icon';
export interface AlertIconProps extends IconProps {
color?: 'primary' | 'secondary' | 'error';
}
export const AlertIcon: FC<AlertIconProps> = ({ color, ...props }) => {
const svgRef = useRef<HTMLImageElement>(null);
const getColor = () => {
switch (color) {
case 'secondary':
return '--cb-text-primary-color';
case 'error':
return '--cb-error-text-color';
default:
return '--cb-button-text-primary';
}
};
const { logoSVG } = useIconWithTheme(svgRef, alertSrc, getColor());
return (
<Icon
src={logoSVG}
ref={svgRef}
alt='alert'
{...props}
/>
);
};