| 1 | import { cva, type VariantProps } from "class-variance-authority"; |
| 2 | import type * as React |
| 3 | import { cn } |
| 4 | |
| 5 | const alertVariants = cva |
| 6 | "relative grid w-full items-start gap-x-2 gap-y-0.5 rounded-xl border px-3.5 py-3 text-card-foreground text-sm has-[>svg]:has-data-[slot=alert-action]:grid-cols-[calc(var(--spacing)*4)_1fr_auto] has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-data-[slot=alert-action]:grid-cols-[1fr_auto] has-[>svg]:gap-x-2 [&>svg]:h-lh [&>svg]:w-4", |
| 7 | { |
| 8 | defaultVariants: { |
| 9 | variant: "default", |
| 10 | }, |
| 11 | variants: { |
| 12 | variant: { |
| 13 | default: "bg-transparent dark:bg-input/32 [&>svg]:text-muted-foreground", |
| 14 | error: "border-destructive/32 bg-destructive/4 [&>svg]:text-destructive", |
| 15 | info: "border-info/32 bg-info/4 [&>svg]:text-info", |
| 16 | success: "border-success/32 bg-success/4 [&>svg]:text-success", |
| 17 | warning: "border-warning/32 bg-warning/4 [&>svg]:text-warning", |
| 18 | }, |
| 19 | }, |
| 20 | }, |
| 21 | ); |
| 22 | |
| 23 | export function Alert({ |
| 24 | className, |
| 25 | variant, |
| 26 | ...props |
| 27 | }: React. |
| 28 | return ( |
| 29 | <div |
| 30 | className={cn(alertVariants |
| 31 | data-slot="alert" |
| 32 | role="alert" |
| 33 | {...props} |
| 34 | /> |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | export function AlertTitle({ |
| 39 | className, |
| 40 | ...props |
| 41 | }: React. |
| 42 | return ( |
| 43 | <div |
| 44 | className={cn(" |
| 45 | data-slot="alert-title" |
| 46 | {...props} |
| 47 | /> |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | export function AlertDescription({ |
| 52 | className, |
| 53 | ...props |
| 54 | }: React. |
| 55 | return ( |
| 56 | <div |
| 57 | className={cn(" |
| 58 | data-slot="alert-description" |
| 59 | {...props} |
| 60 | /> |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | export function AlertAction({ |
| 65 | className, |
| 66 | ...props |
| 67 | }: React. |
| 68 | return ( |
| 69 | <div |
| 70 | className={cn( |
| 71 | "flex gap-1 max-sm:col-start-2 max-sm:mt-2 sm:row-start-1 sm:row-end-3 sm:self-center sm:[[data-slot=alert-description]~&]:col-start-2 sm:[[data-slot=alert-title]~&]:col-start-2 sm:[svg~&]:col-start-2 sm:[svg~[data-slot=alert-description]~&]:col-start-3 sm:[svg~[data-slot=alert-title]~&]:col-start-3", |
| 72 | className, |
| 73 | )} |
| 74 | data-slot="alert-action" |
| 75 | {...props} |
| 76 | /> |
| 77 | ); |
| 78 | } |