import * as React from "react"; import { cva, type VariantProps } from "class-variance-authority"; import { AlertCircle, CheckCircle, Info, XCircle } from "lucide-react"; import { cn } from "@/lib/utils"; const alertVariants = cva( "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", { variants: { variant: { default: "bg-background text-foreground", destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", success: "border-success/50 text-success dark:border-success [&>svg]:text-success bg-success/10", warning: "border-warning/50 text-warning dark:border-warning [&>svg]:text-warning bg-warning/10", info: "border-info/50 text-info dark:border-info [&>svg]:text-info bg-info/10", }, }, defaultVariants: { variant: "default", }, } ); const Alert = React.forwardRef< HTMLDivElement, React.HTMLAttributes & VariantProps >(({ className, variant, ...props }, ref) => (
)); 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"; // Convenience components with icons interface AlertWithIconProps extends React.HTMLAttributes { title?: string; children: React.ReactNode; } export function AlertError({ title, children, className, ...props }: AlertWithIconProps) { return ( {title && {title}} {children} ); } export function AlertSuccess({ title, children, className, ...props }: AlertWithIconProps) { return ( {title && {title}} {children} ); } export function AlertWarning({ title, children, className, ...props }: AlertWithIconProps) { return ( {title && {title}} {children} ); } export function AlertInfo({ title, children, className, ...props }: AlertWithIconProps) { return ( {title && {title}} {children} ); } export { Alert, AlertTitle, AlertDescription };