import { VscFlame } from '@react-icons/all-files/vsc/VscFlame'; import { VscInfo } from '@react-icons/all-files/vsc/VscInfo'; import { VscWarning } from '@react-icons/all-files/vsc/VscWarning'; import type { PropsWithChildren } from 'react'; export interface IAlert { title?: string | undefined; type: 'danger' | 'info' | 'success' | 'warning'; } 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: , }; } case 'warning': { return { text: 'text-yellow-500', border: 'border-yellow-500', icon: , }; } } } export function Alert({ title, type, children }: PropsWithChildren) { const { text, border, icon } = resolveType(type); return (
{children}
{icon} {title ? {title} : null}
); }