import React, { PropsWithChildren, useMemo } from 'react'; import _ from 'lodash'; import { AlertProps } from './types'; const Alert = ({ dismissible, important, mode = 'info', children, className, style, customIcon, ...props }: AlertProps) => { const classes = [ 'alert', mode && `alert-${mode}`, dismissible && `alert-dismissible`, important && `alert-important`, className ].filter(Boolean).join(' '); const Icon = useMemo(() => { if (customIcon) return customIcon; let icon; switch (mode) { case 'danger': icon = 'ti ti-alert-circle'; break; case 'success': icon = 'ti ti-check'; break; case 'warning': icon = 'ti ti-alert-triangle'; break; case 'info': icon = 'ti ti-info-circle'; } return (
) }, [mode, customIcon]); return (
{Icon} {children}
{dismissible && }
) } export const AlertTitle = ({ className, children }: { className?: string } & PropsWithChildren) => (

{children}

) export const AlertText = ({ className, children }: { className?: string; children: any }) => (
{children}
) export const AlertLink = ({ className, children, href }: { className?: string; href?: string } & PropsWithChildren) => ( {children} ) export default Alert;