import React, { forwardRef } from 'react'; export type AlertVariant = 'info' | 'success' | 'warning' | 'danger'; export interface AlertProps extends Omit< React.HTMLAttributes, 'title' > { variant?: AlertVariant; title?: React.ReactNode; icon?: React.ReactNode; } export const Alert = forwardRef( ( { variant = 'info', title, icon, className = '', children, ...rest }, ref ) => { const classes = ['alert', `alert--${variant}`, className] .filter(Boolean) .join(' '); const structured = title !== undefined || icon !== undefined; return (
{icon !== undefined && ( )} {structured ? (
{title !== undefined &&

{title}

} {children}
) : ( children )}
); } ); Alert.displayName = 'Alert';