BillTracker/client/components/ui/alert-dialog.jsx

78 lines
2.7 KiB
React
Raw Normal View History

2026-05-03 19:51:57 -05:00
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
import { cn } from '@/lib/utils';
import { buttonVariants } from '@/components/ui/button';
const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
const AlertDialogPortal = AlertDialogPrimitive.Portal;
const AlertDialogCancel = AlertDialogPrimitive.Cancel;
const AlertDialogAction = AlertDialogPrimitive.Action;
function AlertDialogOverlay({ className, ...props }) {
return (
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-foreground/25 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className
)}
{...props}
/>
);
}
function AlertDialogContent({ className, children, ...props }) {
2026-05-03 19:51:57 -05:00
return (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
{...props}
2026-05-03 19:51:57 -05:00
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-1rem)] max-w-md max-h-[calc(100svh-1rem)] gap-4 overflow-y-auto rounded-2xl border border-border/70 bg-card p-4 text-card-foreground shadow-xl',
'-translate-x-1/2 -translate-y-1/2',
'duration-200 ease-[0.22,1,0.36,1]',
'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-[0.98] data-[state=open]:slide-in-from-top-[1%]',
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-[0.98] data-[state=closed]:slide-out-to-top-[1%]',
'sm:w-full sm:max-h-[calc(100svh-2rem)] sm:p-6',
2026-05-03 19:51:57 -05:00
className
)}
>
{children}
</AlertDialogPrimitive.Content>
2026-05-03 19:51:57 -05:00
</AlertDialogPortal>
);
}
function AlertDialogHeader({ className, ...props }) {
return <div className={cn('flex flex-col gap-2', className)} {...props} />;
}
function AlertDialogFooter({ className, ...props }) {
return (
<div className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)} {...props} />
);
}
function AlertDialogTitle({ className, ...props }) {
return (
<AlertDialogPrimitive.Title
className={cn('text-base font-semibold text-foreground', className)}
{...props}
/>
);
}
function AlertDialogDescription({ className, ...props }) {
return (
<AlertDialogPrimitive.Description
className={cn('text-sm text-muted-foreground leading-relaxed', className)}
{...props}
/>
);
}
export {
AlertDialog, AlertDialogTrigger, AlertDialogPortal, AlertDialogOverlay,
AlertDialogContent, AlertDialogHeader, AlertDialogFooter,
AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel,
};