76 行
2.4 KiB
TypeScript
76 行
2.4 KiB
TypeScript
import * as React from "react";
|
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
import { cn } from "../../lib/utils";
|
|
|
|
export const Dialog = DialogPrimitive.Root;
|
|
export const DialogTrigger = DialogPrimitive.Trigger;
|
|
export const DialogClose = DialogPrimitive.Close;
|
|
|
|
export const DialogPortal = DialogPrimitive.Portal;
|
|
|
|
export const DialogOverlay = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Overlay
|
|
ref={ref}
|
|
className={cn("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
DialogOverlay.displayName = "DialogOverlay";
|
|
|
|
export const DialogContent = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPortal>
|
|
<DialogOverlay />
|
|
<DialogPrimitive.Content
|
|
ref={ref}
|
|
className={cn(
|
|
"fixed left-1/2 top-1/2 z-50 w-[92vw] max-w-lg -translate-x-1/2 -translate-y-1/2 rounded-xl border border-zinc-200 bg-white p-6 shadow-lg focus-visible:outline-none",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
</DialogPortal>
|
|
));
|
|
|
|
DialogContent.displayName = "DialogContent";
|
|
|
|
export const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn("flex flex-col gap-1.5 text-center sm:text-left", className)} {...props} />
|
|
);
|
|
|
|
export const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn("mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)} {...props} />
|
|
);
|
|
|
|
export const DialogTitle = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Title
|
|
ref={ref}
|
|
className={cn("text-lg font-semibold text-zinc-900", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
DialogTitle.displayName = "DialogTitle";
|
|
|
|
export const DialogDescription = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Description
|
|
ref={ref}
|
|
className={cn("text-sm text-zinc-600", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
DialogDescription.displayName = "DialogDescription";
|