import * as React from 'react'; import { cva, type VariantProps } from 'class-variance-authority'; import { X } from 'lucide-react'; const alertVariants = cva( 'relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg+div]:translate-y-[-3px] [&:has(svg)]:pl-11', { variants: { variant: { default: 'bg-background text-foreground border-border', success: 'bg-green-50 text-green-900 border-green-200 dark:bg-green-950/20 dark:text-green-100 dark:border-green-800', error: 'bg-red-50 text-red-900 border-red-200 dark:bg-red-950/20 dark:text-red-100 dark:border-red-800', warning: 'bg-yellow-50 text-yellow-900 border-yellow-200 dark:bg-yellow-950/20 dark:text-yellow-100 dark:border-yellow-800', info: 'bg-blue-50 text-blue-900 border-blue-200 dark:bg-blue-950/20 dark:text-blue-100 dark:border-blue-800', }, }, defaultVariants: { variant: 'default', }, } ); export interface AlertProps extends React.HTMLAttributes, VariantProps { onClose?: () => void; } const Alert = React.forwardRef( ({ className, variant, onClose, children, ...props }, ref) => (
{children} {onClose && ( )}
) ); Alert.displayName = 'Alert'; const AlertTitle = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); AlertTitle.displayName = 'AlertTitle'; const AlertDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); AlertDescription.displayName = 'AlertDescription'; export { Alert, AlertTitle, AlertDescription };