2021-08-03 17:36:55 +00:00
|
|
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
2021-10-12 09:35:44 +00:00
|
|
|
import React, { ReactNode } from "react";
|
2021-08-03 17:36:55 +00:00
|
|
|
|
2021-10-12 09:35:44 +00:00
|
|
|
export type DialogProps = React.ComponentProps<typeof DialogPrimitive["Root"]>;
|
2021-08-23 12:45:25 +00:00
|
|
|
export function Dialog(props: DialogProps) {
|
|
|
|
const { children, ...other } = props;
|
2021-08-03 17:36:55 +00:00
|
|
|
return (
|
2021-08-23 12:45:25 +00:00
|
|
|
<DialogPrimitive.Root {...other}>
|
2021-08-03 17:36:55 +00:00
|
|
|
<DialogPrimitive.Overlay className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
|
|
|
|
{children}
|
|
|
|
</DialogPrimitive.Root>
|
|
|
|
);
|
|
|
|
}
|
2021-08-23 12:45:25 +00:00
|
|
|
type DialogContentProps = React.ComponentProps<typeof DialogPrimitive["Content"]>;
|
2021-08-03 17:36:55 +00:00
|
|
|
|
2021-08-23 12:45:25 +00:00
|
|
|
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
|
({ children, ...props }, forwardedRef) => (
|
|
|
|
<DialogPrimitive.Content
|
|
|
|
{...props}
|
|
|
|
className="min-w-[360px] fixed left-1/2 top-1/2 p-6 text-left bg-white rounded shadow-xl overflow-hidden -translate-x-1/2 -translate-y-1/2 sm:align-middle sm:w-full sm:max-w-lg"
|
2021-09-15 02:58:29 +00:00
|
|
|
ref={forwardedRef}>
|
2021-08-23 12:45:25 +00:00
|
|
|
{children}
|
|
|
|
</DialogPrimitive.Content>
|
|
|
|
)
|
|
|
|
);
|
2021-08-03 17:36:55 +00:00
|
|
|
|
2021-09-14 13:21:18 +00:00
|
|
|
type DialogHeaderProps = {
|
2021-10-18 07:02:25 +00:00
|
|
|
title: React.ReactNode;
|
|
|
|
subtitle?: React.ReactNode;
|
2021-09-14 13:21:18 +00:00
|
|
|
};
|
|
|
|
|
2021-10-18 07:02:25 +00:00
|
|
|
export function DialogHeader(props: DialogHeaderProps) {
|
2021-08-06 12:32:08 +00:00
|
|
|
return (
|
|
|
|
<div className="mb-8">
|
2021-09-22 21:23:19 +00:00
|
|
|
<h3 className="font-cal text-gray-900 text-lg font-bold leading-6" id="modal-title">
|
2021-10-18 07:02:25 +00:00
|
|
|
{props.title}
|
2021-08-06 12:32:08 +00:00
|
|
|
</h3>
|
2021-10-18 07:02:25 +00:00
|
|
|
{props.subtitle && <div className="text-gray-400 text-sm">{props.subtitle}</div>}
|
2021-10-12 09:35:44 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function DialogFooter(props: { children: ReactNode }) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className="mt-5 flex space-x-2 justify-end">{props.children}</div>
|
2021-08-06 12:32:08 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-03 17:36:55 +00:00
|
|
|
DialogContent.displayName = "DialogContent";
|
|
|
|
|
|
|
|
export const DialogTrigger = DialogPrimitive.Trigger;
|
|
|
|
export const DialogClose = DialogPrimitive.Close;
|