2022-04-02 06:17:50 -07:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
|
|
|
|
import { Dialog, Transition } from '@headlessui/react';
|
|
|
|
|
|
|
|
export interface ModalProps {
|
|
|
|
open: boolean;
|
|
|
|
onClose: () => void;
|
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Modal = ({ open, onClose, children }: ModalProps): JSX.Element => {
|
|
|
|
return (
|
|
|
|
<Transition appear show={open} as={Fragment}>
|
|
|
|
<Dialog
|
|
|
|
as="div"
|
|
|
|
className="fixed inset-0 z-10 overflow-y-auto"
|
|
|
|
onClose={onClose}
|
|
|
|
>
|
|
|
|
<div className="min-h-screen px-4 text-center">
|
|
|
|
<Transition.Child
|
|
|
|
as={Fragment}
|
2022-04-02 06:57:31 -07:00
|
|
|
enter="ease-out duration-100"
|
2022-04-02 06:17:50 -07:00
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
2022-04-02 06:57:31 -07:00
|
|
|
leave="ease-in duration-100"
|
2022-04-02 06:17:50 -07:00
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
|
|
|
<Dialog.Overlay className="fixed inset-0 backdrop-blur-md" />
|
|
|
|
</Transition.Child>
|
|
|
|
|
|
|
|
{/* This element is to trick the browser into centering the modal contents. */}
|
|
|
|
<span
|
|
|
|
className="inline-block h-screen align-middle"
|
|
|
|
aria-hidden="true"
|
|
|
|
>
|
|
|
|
​
|
|
|
|
</span>
|
|
|
|
<Transition.Child
|
|
|
|
as={Fragment}
|
2022-04-02 06:57:31 -07:00
|
|
|
enter="ease-out duration-100"
|
2022-04-02 06:17:50 -07:00
|
|
|
enterFrom="opacity-0 scale-95"
|
|
|
|
enterTo="opacity-100 scale-100"
|
|
|
|
leave="ease-in duration-200"
|
|
|
|
leaveFrom="opacity-100 scale-100"
|
|
|
|
leaveTo="opacity-0 scale-95"
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Transition.Child>
|
|
|
|
</div>
|
|
|
|
</Dialog>
|
|
|
|
</Transition>
|
|
|
|
);
|
|
|
|
};
|