import { Fragment, ReactNode } from 'react' import { Dialog, Transition } from '@headlessui/react' import clsx from 'clsx' // From https://tailwindui.com/components/application-ui/overlays/modals export function Modal(props: { children: ReactNode open: boolean setOpen: (open: boolean) => void size?: 'sm' | 'md' | 'lg' | 'xl' position?: 'center' | 'top' | 'bottom' className?: string }) { const { children, position, open, setOpen, size = 'md', className } = props const sizeClass = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-2xl', xl: 'max-w-5xl', }[size] const positionClass = { center: 'items-center', top: 'items-start', bottom: 'items-end', }[position ?? 'bottom'] return (
{/* This element is to trick the browser into centering the modal contents. */}
{children}
) }