import clsx from 'clsx' import type { ComponentProps } from 'react' import { FaExclamationTriangle, FaInfoCircle, FaTimes } from 'react-icons/fa' import type { IconType } from 'react-icons/lib' export type AlertType = 'info' | 'warning' | 'error' | 'ghost' const ALERT_ICONS_MAP: Record = { info: FaInfoCircle, warning: FaExclamationTriangle, error: FaTimes, ghost: null, } export interface AlertProps extends ComponentProps<'div'> { type?: AlertType } export const Alert = (props: AlertProps) => { const { type = 'info', className, children, ...rest } = props const AlertIcon = ALERT_ICONS_MAP[type] return (
{AlertIcon && }
{children} {/* */}
) }