You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
import * as React from 'react'
|
|
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
const Dialog = DialogPrimitive.Root
|
|
const DialogTrigger = DialogPrimitive.Trigger
|
|
const DialogClose = DialogPrimitive.Close
|
|
const DialogPortal = DialogPrimitive.Portal
|
|
|
|
function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
return (
|
|
<DialogPrimitive.Overlay
|
|
className={cn('fixed inset-0 z-50 bg-black/55 backdrop-blur-[3px]', className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function DialogContent({
|
|
className,
|
|
children,
|
|
onPointerDownOutside,
|
|
onInteractOutside,
|
|
...props
|
|
}: React.ComponentProps<typeof DialogPrimitive.Content>) {
|
|
return (
|
|
<DialogPortal>
|
|
<DialogOverlay />
|
|
<DialogPrimitive.Content
|
|
className={cn(
|
|
'fixed left-1/2 top-1/2 z-50 w-full max-w-[640px] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border-soft bg-card text-card-foreground shadow-[0_30px_80px_rgba(0,0,0,.35)] anim-pop outline-none',
|
|
className,
|
|
)}
|
|
onPointerDownOutside={(e) => {
|
|
// Prevent closing modal when clicking outside (backdrop)
|
|
e.preventDefault()
|
|
onPointerDownOutside?.(e)
|
|
}}
|
|
onInteractOutside={(e) => {
|
|
e.preventDefault()
|
|
onInteractOutside?.(e)
|
|
}}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</DialogPrimitive.Content>
|
|
</DialogPortal>
|
|
)
|
|
}
|
|
|
|
const DialogTitle = DialogPrimitive.Title
|
|
const DialogDescription = DialogPrimitive.Description
|
|
|
|
function DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
return (
|
|
<div
|
|
className={cn('flex flex-col space-y-1.5 text-start pb-3 border-b border-border-soft', className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
return (
|
|
<div
|
|
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-4 border-t border-border-soft', className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {
|
|
Dialog,
|
|
DialogTrigger,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogFooter,
|
|
DialogTitle,
|
|
DialogDescription,
|
|
}
|
|
|