Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

49 linesCodeBlameRaw
1import { AlertDialog as Primitive } from "radix-ui";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5import { DIALOG_PANEL } from "./dialog";
6
7// shadcn/ui's alert dialog, for confirming what cannot be undone. It does
8// not close on a click outside; the person has to choose.
9
10export const AlertDialog = Primitive.Root;
11export const AlertDialogTrigger = Primitive.Trigger;
12
13export function AlertDialogContent({ className, ...props }: ComponentProps<typeof Primitive.Content>) {
14 return (
15 <Primitive.Portal>
16 <Primitive.Overlay className="fixed inset-0 z-50 bg-black/60 backdrop-blur-[2px] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none" />
17 <Primitive.Content className={cn(DIALOG_PANEL, "max-w-md", className)} {...props} />
18 </Primitive.Portal>
19 );
20}
21
22export function AlertDialogHeader({ className, ...props }: ComponentProps<"div">) {
23 return <div className={cn("flex flex-col gap-1.5", className)} {...props} />;
24}
25
26export function AlertDialogFooter({ className, ...props }: ComponentProps<"div">) {
27 return <div className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)} {...props} />;
28}
29
30export function AlertDialogTitle({ className, ...props }: ComponentProps<typeof Primitive.Title>) {
31 return <Primitive.Title className={cn("text-base font-semibold tracking-tight", className)} {...props} />;
32}
33
34export function AlertDialogDescription({ className, ...props }: ComponentProps<typeof Primitive.Description>) {
35 return <Primitive.Description className={cn("text-sm text-muted", className)} {...props} />;
36}
37
38const BUTTON = "inline-flex items-center justify-center gap-2 rounded-md px-3.5 py-2 text-sm font-medium transition-colors disabled:opacity-50";
39
40/** The destructive choice. Put a submit button inside with `asChild` to post a form. */
41export function AlertDialogAction({ className, ...props }: ComponentProps<typeof Primitive.Action>) {
42 return <Primitive.Action className={cn(BUTTON, "bg-danger text-bg hover:bg-danger/90", className)} {...props} />;
43}
44
45export function AlertDialogCancel({ className, ...props }: ComponentProps<typeof Primitive.Cancel>) {
46 return (
47 <Primitive.Cancel className={cn(BUTTON, "border border-line text-fg/80 hover:border-line-strong hover:bg-raised hover:text-fg", className)} {...props} />
48 );
49}