From 803fb742b1dfeff55dcf1d4727f8bd484d76372a Mon Sep 17 00:00:00 2001 From: simeng-li Date: Wed, 12 Oct 2022 15:47:14 +0800 Subject: [PATCH] refactor(ui): refactor terms of use modals - refacrtor the terms of use modals using global confirm modal provider - remove react-modal-promise dependency - remove iframeConfirmModal Component --- packages/ui/package.json | 1 - .../IframeConfirmModal.module.scss | 51 ---------- .../ConfirmModal/IframeConfirmModal.tsx | 63 ------------ .../ConfirmModal/MobileModal.module.scss | 26 +++++ .../ui/src/components/ConfirmModal/index.tsx | 2 - .../modalPromisify/index.test.tsx | 37 -------- .../ConfirmModal/modalPromisify/index.tsx | 29 ------ .../containers/ConfirmModalProvider/index.tsx | 4 +- .../index.module.scss | 7 ++ .../IframeConfirmModalContent/index.tsx | 39 ++++++++ .../TermsOfUseConfirmModal/index.test.tsx | 16 ---- .../TermsOfUseConfirmModal/index.tsx | 67 ------------- .../TermsOfUseConfirmModalContent/index.tsx | 45 +++++++++ .../TermsOfUseIframeModal/index.test.tsx | 36 ------- .../TermsOfUseIframeModal/index.tsx | 36 ------- .../ui/src/containers/TermsOfUse/index.tsx | 25 ++--- .../containers/UsernameSignIn/index.test.tsx | 95 ++++++++++--------- packages/ui/src/hooks/use-confirm-modal.ts | 2 + packages/ui/src/hooks/use-terms.ts | 52 ++++++---- packages/ui/src/utils/promisify.test.ts | 18 ---- packages/ui/src/utils/promisify.ts | 9 -- 21 files changed, 215 insertions(+), 445 deletions(-) delete mode 100644 packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss delete mode 100644 packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx delete mode 100644 packages/ui/src/components/ConfirmModal/modalPromisify/index.test.tsx delete mode 100644 packages/ui/src/components/ConfirmModal/modalPromisify/index.tsx create mode 100644 packages/ui/src/containers/TermsOfUse/IframeConfirmModalContent/index.module.scss create mode 100644 packages/ui/src/containers/TermsOfUse/IframeConfirmModalContent/index.tsx delete mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseConfirmModal/index.test.tsx delete mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseConfirmModal/index.tsx create mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseConfirmModalContent/index.tsx delete mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseIframeModal/index.test.tsx delete mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseIframeModal/index.tsx delete mode 100644 packages/ui/src/utils/promisify.test.ts delete mode 100644 packages/ui/src/utils/promisify.ts diff --git a/packages/ui/package.json b/packages/ui/package.json index f7c50b219..21565fde9 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -59,7 +59,6 @@ "react-dom": "^18.0.0", "react-i18next": "^11.18.3", "react-modal": "^3.15.1", - "react-modal-promise": "^1.0.2", "react-router-dom": "^6.2.2", "react-string-replace": "^1.0.0", "react-timer-hook": "^3.0.5", diff --git a/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss b/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss deleted file mode 100644 index 8a1072fa0..000000000 --- a/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss +++ /dev/null @@ -1,51 +0,0 @@ -@use '@/scss/underscore' as _; - -.overlay { - z-index: 100; -} - -.modal { - position: absolute; - left: 20px; - right: 20px; - top: 40px; - bottom: 40px; - outline: none; -} - -.container { - background: var(--color-dialogue); - border-radius: 12px; - width: 100%; - height: 100%; - @include _.flex_column(stretch, center); -} - -.content { - padding: _.unit(5); - flex: 1; - @include _.flex_column; -} - -iframe { - display: block; - - &.hidden { - display: none; - } -} - - -.footer { - border-top: 1px solid var(--color-divider); - @include _.flex_row; - padding: _.unit(5); - - > * { - flex: 1; - } - - > button:first-child { - margin-right: _.unit(2); - } -} diff --git a/packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx b/packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx deleted file mode 100644 index 22ad550cc..000000000 --- a/packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import classNames from 'classnames'; -import { useState } from 'react'; -import ReactModal from 'react-modal'; - -import Button from '@/components/Button'; -import { LoadingIcon } from '@/components/LoadingLayer'; - -import * as modalStyles from '../../scss/modal.module.scss'; -import * as styles from './IframeConfirmModal.module.scss'; -import { ModalProps } from './type'; - -type Props = { url: string } & Omit; - -const IframeConfirmModal = ({ - className, - isOpen = false, - url, - cancelText = 'action.cancel', - confirmText = 'action.confirm', - onConfirm, - onClose, -}: Props) => { - const [isLoading, setIsLoading] = useState(true); - - return ( - -
-
- {isLoading && } -