1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/ui/pages/swaps/prepare-swap-page/smart-transactions-popover.tsx
infiniteflower 10ffc1ec84
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
2023-08-01 15:31:53 +02:00

103 lines
2.6 KiB
TypeScript

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')}&nbsp;
<Text
as="span"
fontWeight={FontWeight.Bold}
color={TextColor.textAlternative}
>
{t('stxYouCanOptOut')}&nbsp;
</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>
);
}