From 6dd0bafa45ce22f0acac7d6e097e3f1790cdb5d7 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Fri, 22 Sep 2023 16:58:30 +0800
Subject: ...

---
 FrontEnd/src/components/dialog/Dialog.tsx | 50 +++++++------------------------
 1 file changed, 11 insertions(+), 39 deletions(-)

(limited to 'FrontEnd/src/components/dialog/Dialog.tsx')

diff --git a/FrontEnd/src/components/dialog/Dialog.tsx b/FrontEnd/src/components/dialog/Dialog.tsx
index 2d0b34db..b5524a11 100644
--- a/FrontEnd/src/components/dialog/Dialog.tsx
+++ b/FrontEnd/src/components/dialog/Dialog.tsx
@@ -1,10 +1,8 @@
-import { ReactNode, useRef } from "react";
-import classNames from "classnames";
-import { CSSTransition } from "react-transition-group";
+import { ReactNode } from "react";
 
 import { ThemeColor } from "../common";
 
-import InPortal from "../InPortal";
+import DialogOverlay from "./DialogOverlay";
 
 import "./Dialog.css";
 
@@ -23,41 +21,15 @@ export default function Dialog({
   children,
   disableCloseOnClickOnOverlay,
 }: DialogProps) {
-  const nodeRef = useRef(null);
-  const lastPointerDownIdRef = useRef<number | null>(null);
-
   return (
-    <InPortal>
-      <CSSTransition
-        nodeRef={nodeRef}
-        mountOnEnter
-        unmountOnExit
-        in={open}
-        timeout={300}
-        classNames="cru-dialog"
-      >
-        <div
-          ref={nodeRef}
-          className={classNames(
-            `cru-theme-${color ?? "primary"}`,
-            "cru-dialog-overlay",
-          )}
-        >
-          <div
-            className="cru-dialog-background"
-            onPointerDown={(e) => {
-              lastPointerDownIdRef.current = e.pointerId;
-            }}
-            onPointerUp={(e) => {
-              if (lastPointerDownIdRef.current === e.pointerId) {
-                if (!disableCloseOnClickOnOverlay) onClose();
-              }
-              lastPointerDownIdRef.current = null;
-            }}
-          />
-          <div className="cru-dialog-container">{children}</div>
-        </div>
-      </CSSTransition>
-    </InPortal>
+    <DialogOverlay
+      open={open}
+      onClose={onClose}
+      transitionClassNames="cru-dialog-normal"
+      overlayClassName={`cru-dialog-normal cru-theme-${color ?? "primary"}`}
+      disableCloseOnClickOnOverlay={disableCloseOnClickOnOverlay}
+    >
+      {children}
+    </DialogOverlay>
   );
 }
-- 
cgit v1.2.3

