import type { PropsWithChildren } from 'react'; import { VscFlame, VscInfo, VscWarning } from 'react-icons/vsc'; export interface IAlert { title?: string | undefined; type: 'danger' | 'info' | 'success'; } function resolveType(type: IAlert['type']) { switch (type) { case 'danger': { return { text: 'text-red-500', border: 'border-red-500', icon: , }; } case 'info': { return { text: 'text-blue-500', border: 'border-blue-500', icon: , }; } case 'success': { return { text: 'text-green-500', border: 'border-green-500', icon: , }; } } } export function Alert({ title, type, children }: PropsWithChildren) { const { text, border, icon } = resolveType(type); return (
{children}
{icon} {title}
); }