import type { VariantProps } from 'class-variance-authority' import { toastVariants } from './variants' import { MaterialIcon, MaterialIconSetIconProps } from '../Icons/MaterialIcon' import styles from './toasts.module.css' import { Typography } from '../Typography' import { useIntl } from 'react-intl' import { IconButton } from '../IconButton' export type ToastsProps = VariantProps & { variant: NonNullable['variant']> onClose?: () => void } & ( | { children: React.ReactNode message?: never } | { children?: never message: React.ReactNode } ) export function Toast({ children, message, onClose, variant }: ToastsProps) { const className = toastVariants({ variant }) const intl = useIntl() const Icon = return (
{Icon && Icon}
{message ? (

{message}

) : (
{children}
)} {onClose ? ( ) : null}
) } interface AlertIconProps { variant: ToastsProps['variant'] } function AlertIcon({ variant, ...props }: AlertIconProps & MaterialIconSetIconProps) { switch (variant) { case 'error': return case 'info': return case 'success': return case 'warning': return } } function getRole(variant: ToastsProps['variant']) { switch (variant) { case 'error': case 'warning': return 'alert' case 'info': case 'success': default: return 'status' } }