-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
2ad2827
commit 10ffc1e
Showing
6 changed files
with
158 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 0 additions & 121 deletions
121
ui/pages/swaps/prepare-swap-page/smart-transactions-popover.js
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
ui/pages/swaps/prepare-swap-page/smart-transactions-popover.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof SmartTransactionPopover>; | ||
|
||
export const DefaultStory: StoryFn<typeof SmartTransactionPopover> = () => { | ||
const [{ isShowingModal }, updateArgs] = useArgs(); | ||
const toggleModal = () => updateArgs({ isShowingModal: !isShowingModal }); | ||
|
||
return ( | ||
<> | ||
<Button variant={BUTTON_VARIANT.PRIMARY} onClick={toggleModal}> | ||
Open modal | ||
</Button> | ||
{isShowingModal && ( | ||
<SmartTransactionPopover | ||
isOpen={isShowingModal} | ||
onEnableSmartTransactionsClick={() => { | ||
console.log('onEnableSmartTransactionsClick'); | ||
}} | ||
onCloseSmartTransactionsOptInPopover={toggleModal} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
DefaultStory.storyName = 'Default'; |
102 changes: 102 additions & 0 deletions
102
ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Modal isOpen={isOpen} onClose={onCloseSmartTransactionsOptInPopover}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader onClose={onCloseSmartTransactionsOptInPopover}> | ||
{t('smartSwapsAreHere')} | ||
</ModalHeader> | ||
|
||
<Box | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Column} | ||
gap={4} | ||
marginTop={4} | ||
> | ||
<Box display={Display.Flex} flexDirection={FlexDirection.Column}> | ||
<img | ||
src="./images/logo/smart-transactions-header.png" | ||
alt={t('swapSwapSwitch')} | ||
/> | ||
</Box> | ||
<Text>{t('smartSwapsDescription')}</Text> | ||
<Text | ||
as="ul" | ||
marginTop={3} | ||
marginBottom={3} | ||
style={{ listStyle: 'inside' }} | ||
> | ||
<li>{t('stxBenefit1')}</li> | ||
<li>{t('stxBenefit2')}</li> | ||
<li>{t('stxBenefit3')}</li> | ||
<li> | ||
{t('stxBenefit4')} | ||
<Text as="span" fontWeight={FontWeight.Normal}> | ||
{' *'} | ||
</Text> | ||
</li> | ||
</Text> | ||
<Text color={TextColor.textAlternative}> | ||
{t('smartSwapsSubDescription')} | ||
<Text | ||
as="span" | ||
fontWeight={FontWeight.Bold} | ||
color={TextColor.textAlternative} | ||
> | ||
{t('stxYouCanOptOut')} | ||
</Text> | ||
</Text> | ||
|
||
<Button | ||
variant={BUTTON_VARIANT.PRIMARY} | ||
onClick={onEnableSmartTransactionsClick} | ||
width={BlockSize.Full} | ||
> | ||
{t('enableSmartSwaps')} | ||
</Button> | ||
|
||
<Button | ||
type="link" | ||
variant={BUTTON_VARIANT.LINK} | ||
onClick={onCloseSmartTransactionsOptInPopover} | ||
width={BlockSize.Full} | ||
> | ||
{t('noThanksVariant2')} | ||
</Button> | ||
</Box> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
} |