import { ReactNode, useRef } from "react"; import ReactDOM from "react-dom"; import { CSSTransition } from "react-transition-group"; import classNames from "classnames"; import { ThemeColor } from "../common"; import { useCloseDialog } from "./DialogProvider"; import "./Dialog.css"; const optionalPortalElement = document.getElementById("portal"); if (optionalPortalElement == null) { throw new Error("Portal element not found"); } const portalElement = optionalPortalElement; interface DialogProps { color?: ThemeColor; children?: ReactNode; disableCloseOnClickOnOverlay?: boolean; } export default function Dialog({ color, children, disableCloseOnClickOnOverlay, }: DialogProps) { color = color ?? "primary"; const closeDialog = useCloseDialog(); const nodeRef = useRef(null); return ReactDOM.createPortal(
{children}
, portalElement, ); }