From 10ffc1ec84067d931c30030067335afa87712bab Mon Sep 17 00:00:00 2001
From: infiniteflower <139582705+infiniteflower@users.noreply.github.com>
Date: Tue, 1 Aug 2023 09:31:53 -0400
Subject: [PATCH] Chore/refactor smart swap modal (#20239)
* Add story for smart tx popover
* Use tsx for smart tx popover story and add btn to open it
* Refactor smart tx popover component to tsx and style
* Fix modal not triggering
* Remove bold from bullet points
* Adjust margins
---
ui/pages/swaps/build-quote/build-quote.js | 16 +--
ui/pages/swaps/prepare-swap-page/index.scss | 34 -----
.../prepare-swap-page/prepare-swap-page.js | 17 +--
.../smart-transactions-popover.js | 121 ------------------
.../smart-transactions-popover.stories.tsx | 39 ++++++
.../smart-transactions-popover.tsx | 102 +++++++++++++++
6 files changed, 158 insertions(+), 171 deletions(-)
delete mode 100644 ui/pages/swaps/prepare-swap-page/smart-transactions-popover.js
create mode 100644 ui/pages/swaps/prepare-swap-page/smart-transactions-popover.stories.tsx
create mode 100644 ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx
diff --git a/ui/pages/swaps/build-quote/build-quote.js b/ui/pages/swaps/build-quote/build-quote.js
index 7c2836703..b0b9d3bbe 100644
--- a/ui/pages/swaps/build-quote/build-quote.js
+++ b/ui/pages/swaps/build-quote/build-quote.js
@@ -563,14 +563,14 @@ export default function BuildQuote({
return (
- {showSmartTransactionsOptInPopover && (
-
- )}
+
+
{t('swapSwapFrom')}
{!isSwapsDefaultTokenSymbol(fromTokenSymbol, chainId) && (
diff --git a/ui/pages/swaps/prepare-swap-page/index.scss b/ui/pages/swaps/prepare-swap-page/index.scss
index 06e617670..09c64fcf4 100644
--- a/ui/pages/swaps/prepare-swap-page/index.scss
+++ b/ui/pages/swaps/prepare-swap-page/index.scss
@@ -368,37 +368,3 @@
@keyframes slide-in {
100% { transform: translateY(0%); }
}
-
-.smart-transactions-popover {
- transform: translateY(-100%);
- animation: slide-in 0.5s forwards;
-
- &__content {
- flex-direction: column;
-
- ul {
- list-style: inside;
- }
-
- a {
- color: var(--color-primary-default);
- cursor: pointer;
- }
- }
-
- &__footer {
- flex-direction: column;
- flex: 1;
- align-items: center;
- border-top: 0;
-
- button {
- border-radius: 50px;
- }
-
- a {
- font-size: inherit;
- padding-bottom: 0;
- }
- }
-}
diff --git a/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js b/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js
index 8b59ffee7..4d8972db6 100644
--- a/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js
+++ b/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js
@@ -846,14 +846,15 @@ export default function PrepareSwapPage({
- {showSmartTransactionsOptInPopover && (
-
- )}
+
+
+
-
-
-
-
-
-
- >
- }
- footerClassName="smart-transactions-popover__footer"
- className="smart-transactions-popover"
- CustomBackground={() => {
- return (
-
- );
- }}
- >
-
-
-
-
-
- {t('smartSwapsDescription')}
-
-
- {t('stxBenefit1')}
- {t('stxBenefit2')}
- {t('stxBenefit3')}
-
- {t('stxBenefit4')}
-
- {' *'}
-
-
-
-
- {t('smartSwapsSubDescription')}
-
- {t('stxYouCanOptOut')}
-
-
-
-
- );
-}
-
-SmartTransactionsPopover.propTypes = {
- onEnableSmartTransactionsClick: PropTypes.func.isRequired,
- onCloseSmartTransactionsOptInPopover: PropTypes.func.isRequired,
-};
diff --git a/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.stories.tsx b/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.stories.tsx
new file mode 100644
index 000000000..bb2791fd7
--- /dev/null
+++ b/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.stories.tsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import { StoryFn, Meta } from '@storybook/react';
+import { useArgs } from '@storybook/client-api';
+import { BUTTON_VARIANT, Button } from '../../../components/component-library';
+import SmartTransactionPopover from './smart-transactions-popover';
+
+export default {
+ title: 'Pages/Swaps/SmartTransactionsPopover',
+ component: SmartTransactionPopover,
+ argTypes: {
+ isShowingModal: {
+ control: 'boolean',
+ },
+ },
+} as Meta;
+
+export const DefaultStory: StoryFn = () => {
+ const [{ isShowingModal }, updateArgs] = useArgs();
+ const toggleModal = () => updateArgs({ isShowingModal: !isShowingModal });
+
+ return (
+ <>
+
+ {isShowingModal && (
+ {
+ console.log('onEnableSmartTransactionsClick');
+ }}
+ onCloseSmartTransactionsOptInPopover={toggleModal}
+ />
+ )}
+ >
+ );
+};
+
+DefaultStory.storyName = 'Default';
diff --git a/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx b/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx
new file mode 100644
index 000000000..38484fab4
--- /dev/null
+++ b/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx
@@ -0,0 +1,102 @@
+import React, { useContext } from 'react';
+
+import { I18nContext } from '../../../contexts/i18n';
+import {
+ TextColor,
+ Display,
+ FlexDirection,
+ FontWeight,
+ BlockSize,
+} from '../../../helpers/constants/design-system';
+import {
+ Modal,
+ ModalContent,
+ ModalHeader,
+ ModalOverlay,
+ Text,
+ Box,
+ Button,
+ BUTTON_VARIANT,
+} from '../../../components/component-library';
+
+interface Props {
+ onEnableSmartTransactionsClick: () => void;
+ onCloseSmartTransactionsOptInPopover: () => void;
+ isOpen: boolean;
+}
+
+export default function SmartTransactionsPopover({
+ onEnableSmartTransactionsClick,
+ onCloseSmartTransactionsOptInPopover,
+ isOpen,
+}: Props) {
+ const t = useContext(I18nContext);
+ return (
+
+
+
+
+ {t('smartSwapsAreHere')}
+
+
+
+
+
+
+ {t('smartSwapsDescription')}
+
+ {t('stxBenefit1')}
+ {t('stxBenefit2')}
+ {t('stxBenefit3')}
+
+ {t('stxBenefit4')}
+
+ {' *'}
+
+
+
+
+ {t('smartSwapsSubDescription')}
+
+ {t('stxYouCanOptOut')}
+
+
+
+
+
+
+
+
+
+ );
+}