2021-04-09 07:27:49 -07:00
|
|
|
import { Portal } from 'react-portal'
|
2021-04-18 06:45:11 -07:00
|
|
|
import { XIcon } from '@heroicons/react/outline'
|
2021-04-09 07:27:49 -07:00
|
|
|
|
2021-04-18 06:45:11 -07:00
|
|
|
const Modal = ({ isOpen, onClose, children, hideClose }) => {
|
2021-04-09 07:27:49 -07:00
|
|
|
return (
|
|
|
|
<Portal>
|
|
|
|
<div
|
2021-04-12 15:15:15 -07:00
|
|
|
className="fixed z-10 inset-0 overflow-y-auto"
|
2021-04-09 07:27:49 -07:00
|
|
|
aria-labelledby="modal-title"
|
|
|
|
role="dialog"
|
|
|
|
aria-modal="true"
|
|
|
|
>
|
2021-04-18 06:45:11 -07:00
|
|
|
<div className="flex items-center min-h-screen px-4 pb-20 text-center sm:block sm:p-0">
|
2021-04-09 07:27:49 -07:00
|
|
|
{isOpen ? (
|
|
|
|
<div
|
2021-04-18 03:34:37 -07:00
|
|
|
className="fixed inset-0 bg-black bg-opacity-70 transition-opacity"
|
2021-04-09 07:27:49 -07:00
|
|
|
aria-hidden="true"
|
|
|
|
onClick={onClose}
|
|
|
|
></div>
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
<span
|
2021-04-12 15:15:15 -07:00
|
|
|
className="hidden sm:inline-block sm:align-middle sm:h-screen"
|
2021-04-09 07:27:49 -07:00
|
|
|
aria-hidden="true"
|
|
|
|
>
|
|
|
|
​
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{isOpen ? (
|
|
|
|
<div
|
2021-04-18 06:45:11 -07:00
|
|
|
className="inline-block bg-th-bkg-2
|
2021-04-18 20:21:22 -07:00
|
|
|
rounded-lg text-left shadow-lg transform transition-all
|
2021-04-18 06:45:11 -07:00
|
|
|
sm:my-8 align-middle sm:max-w-md w-full"
|
2021-04-09 07:27:49 -07:00
|
|
|
>
|
2021-04-18 06:45:11 -07:00
|
|
|
{!hideClose ? (
|
|
|
|
<div className="w-full flex justify-end p-2 pb-0">
|
|
|
|
<button
|
|
|
|
onClick={onClose}
|
|
|
|
className={`text-th-fgd-1 hover:text-th-primary focus:outline-none`}
|
|
|
|
>
|
|
|
|
<XIcon className={`h-5 w-5`} />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="w-full pt-4" />
|
|
|
|
)}
|
2021-04-09 17:01:00 -07:00
|
|
|
{children}
|
2021-04-09 07:27:49 -07:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Portal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const Header = ({ children }) => {
|
|
|
|
return (
|
2021-04-18 06:45:11 -07:00
|
|
|
<div className={`flex justify-center bg-th-bkg-2 p-4 pt-0`}>{children}</div>
|
2021-04-09 07:27:49 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Modal.Header = Header
|
|
|
|
|
|
|
|
export default Modal
|