import { XIcon } from '@heroicons/react/outline' import React, { ReactNode } from 'react' import { useRecoilState } from 'recoil' import * as DialogPrimitive from '@radix-ui/react-dialog' import Button from './Button' import { appState } from '../../store/Atoms' export interface ModalProps { show: boolean children?: ReactNode onClose?: () => void title: string showCloseIcon?: boolean className?: string } const Modal = React.forwardRef< React.ElementRef, ModalProps >((props, forwardedRef) => { const { show, children, onClose, className, title, showCloseIcon } = props const [_, setAppState] = useRecoilState(appState) const onOpenChange = (open: boolean) => { if (!open) { onClose?.() setAppState(old => { return { ...old, disableShortCuts: false } }) } } return (
{title} {showCloseIcon ? (
{children}
) }) Modal.defaultProps = { showCloseIcon: true, } export default Modal