73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
|
|
import { cn } from "cn"
|
|
|
|
function Dialog(props: DialogPrimitive.Root.Props) {
|
|
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
}
|
|
|
|
function DialogContent({
|
|
className,
|
|
children,
|
|
...props
|
|
}: DialogPrimitive.Popup.Props) {
|
|
return (
|
|
<DialogPrimitive.Portal>
|
|
<DialogPrimitive.Backdrop
|
|
data-slot="dialog-backdrop"
|
|
className="fixed inset-0 z-50 bg-black/40 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs"
|
|
/>
|
|
<DialogPrimitive.Popup
|
|
data-slot="dialog-content"
|
|
className={cn(
|
|
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-sm text-popover-foreground ring-1 ring-foreground/10 outline-none transition-all duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 sm:max-w-md",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</DialogPrimitive.Popup>
|
|
</DialogPrimitive.Portal>
|
|
)
|
|
}
|
|
|
|
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
return <div data-slot="dialog-header" className={cn("flex flex-col gap-1.5", className)} {...props} />
|
|
}
|
|
|
|
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="dialog-footer"
|
|
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
|
return (
|
|
<DialogPrimitive.Title
|
|
data-slot="dialog-title"
|
|
className={cn("text-base leading-none font-medium", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {
|
|
return (
|
|
<DialogPrimitive.Description
|
|
data-slot="dialog-description"
|
|
className={cn("text-sm text-muted-foreground", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
const DialogClose = DialogPrimitive.Close
|
|
|
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle }
|