From 4abcda6820f0d824d110ee3ddd6d457433dfbf26 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Wed, 25 May 2022 16:42:18 +0800 Subject: [PATCH] feat(ui): add mobile terms of use iframe modal (#947) add mobile terms of use iframe modal --- packages/phrases/src/locales/en.ts | 1 + packages/phrases/src/locales/zh-cn.ts | 1 + .../IframeConfirmModal.module.scss | 42 ++++++++++++++ .../ConfirmModal/IframeConfirmModal.tsx | 55 +++++++++++++++++++ .../ui/src/components/ConfirmModal/index.tsx | 1 + .../ui/src/components/TermsOfUse/index.tsx | 6 +- .../src/components/TextLink/index.module.scss | 1 + .../TermsOfUseConfirmModal/index.tsx | 16 ++++-- .../TermsOfUseIframeModal/index.test.tsx | 30 ++++++++++ .../TermsOfUseIframeModal/index.tsx | 27 +++++++++ .../TermsOfUsePromiseModal/index.tsx | 7 ++- .../ui/src/containers/TermsOfUse/index.tsx | 5 +- packages/ui/src/hooks/use-terms.ts | 17 ++++-- 13 files changed, 194 insertions(+), 15 deletions(-) create mode 100644 packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss create mode 100644 packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx create mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseIframeModal/index.test.tsx create mode 100644 packages/ui/src/containers/TermsOfUse/TermsOfUseIframeModal/index.tsx diff --git a/packages/phrases/src/locales/en.ts b/packages/phrases/src/locales/en.ts index 1a6c3718b..69e60762a 100644 --- a/packages/phrases/src/locales/en.ts +++ b/packages/phrases/src/locales/en.ts @@ -42,6 +42,7 @@ const translation = { bind: 'Binding with {{address}}', back: 'Go Back', nav_back: 'Back', + agree: 'Agree', }, description: { email: 'email', diff --git a/packages/phrases/src/locales/zh-cn.ts b/packages/phrases/src/locales/zh-cn.ts index bee7ca915..a8bab92b4 100644 --- a/packages/phrases/src/locales/zh-cn.ts +++ b/packages/phrases/src/locales/zh-cn.ts @@ -44,6 +44,7 @@ const translation = { bind: '绑定到 {{address}}', back: '返回', nav_back: '返回', + agree: '同意', }, description: { email: '邮箱', diff --git a/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss b/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss new file mode 100644 index 000000000..be0a94649 --- /dev/null +++ b/packages/ui/src/components/ConfirmModal/IframeConfirmModal.module.scss @@ -0,0 +1,42 @@ +@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; +} + + +.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 new file mode 100644 index 000000000..5cca07eb6 --- /dev/null +++ b/packages/ui/src/components/ConfirmModal/IframeConfirmModal.tsx @@ -0,0 +1,55 @@ +import classNames from 'classnames'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import ReactModal from 'react-modal'; + +import Button from '@/components/Button'; + +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 { t } = useTranslation(undefined, { keyPrefix: 'main_flow' }); + + return ( + +
+
+