Skip to content

Commit

Permalink
alert-dialog destructive variant added
Browse files Browse the repository at this point in the history
  • Loading branch information
modamaan committed Feb 6, 2025
1 parent 58e252c commit b10ce7d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/components/ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";

import { cn } from "@/lib/utils";
Expand Down Expand Up @@ -97,13 +98,27 @@ const AlertDialogDescription = React.forwardRef<
AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName;

const alertVariants = cva("mt-2 sm:mt-0", {
variants: {
variant: {
default: "bg-white text-gray-950 dark:bg-gray-950 dark:text-gray-50",
destructive:
"bg-red-500 text-gray-50 shadow-sm hover:bg-red-500/90 dark:bg-red-900 dark:text-gray-50 dark:hover:bg-red-900/90",
},
},
defaultVariants: {
variant: "default",
},
});

const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => (
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> &
VariantProps<typeof alertVariants>
>(({ className, variant, ...props }, ref) => (
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
className={cn(buttonVariants(), alertVariants({ variant }), className)}
{...props}
/>
));
Expand Down

0 comments on commit b10ce7d

Please sign in to comment.