1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

replacing deprecated components and consts (#19563)

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
This commit is contained in:
Dhruv 2023-07-26 01:52:26 +05:30 committed by GitHub
parent bab1670432
commit a10fb75f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 121 additions and 70 deletions

View File

@ -31,7 +31,6 @@
@import 'flask/experimental-area/index'; @import 'flask/experimental-area/index';
@import 'snaps/snap-content-footer/index'; @import 'snaps/snap-content-footer/index';
@import 'snaps/snap-install-warning/index'; @import 'snaps/snap-install-warning/index';
@import 'snaps/snap-remove-warning/index';
@import 'snaps/snap-ui-renderer/index'; @import 'snaps/snap-ui-renderer/index';
@import 'snaps/snap-ui-markdown/index'; @import 'snaps/snap-ui-markdown/index';
@import 'snaps/snap-delineator/index'; @import 'snaps/snap-delineator/index';

View File

@ -1,12 +0,0 @@
.snap-remove-warning {
color: var(--color-text-default);
&__footer-button {
height: 40px;
margin-inline-end: 24px;
&:last-of-type {
margin-inline-end: 0;
}
}
}

View File

@ -1,51 +1,64 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useI18nContext } from '../../../../hooks/useI18nContext';
import Typography from '../../../ui/typography/typography'; import {
import { TypographyVariant } from '../../../../helpers/constants/design-system'; Text,
import Box from '../../../ui/box/box'; Box,
import Popover from '../../../ui/popover'; Button,
import Button from '../../../ui/button'; Modal,
ModalContent,
ModalHeader,
ModalOverlay,
BUTTON_VARIANT,
BUTTON_SIZES,
} from '../../../component-library';
export default function SnapRemoveWarning({ onCancel, onSubmit, snapName }) { import {
BlockSize,
Display,
FlexDirection,
} from '../../../../helpers/constants/design-system';
export default function SnapRemoveWarning({
isOpen,
onCancel,
onSubmit,
snapName,
}) {
const t = useI18nContext(); const t = useI18nContext();
const SnapRemoveWarningFooter = () => {
return ( return (
<> <Modal isOpen={isOpen} onClose={onCancel}>
<ModalOverlay />
<ModalContent
modalDialogProps={{
display: Display.Flex,
flexDirection: FlexDirection.Column,
gap: 4,
}}
>
<ModalHeader onClose={onCancel}>{t('pleaseConfirm')}</ModalHeader>
<Text>{t('removeSnapConfirmation', [snapName])}</Text>
<Box width={BlockSize.Full} display={Display.Flex} gap={4}>
<Button <Button
className="snap-remove-warning__footer-button" block
type="default" variant={BUTTON_VARIANT.SECONDARY}
size={BUTTON_SIZES.LG}
onClick={onCancel} onClick={onCancel}
> >
{t('nevermind')} {t('nevermind')}
</Button> </Button>
<Button <Button
block
size={BUTTON_SIZES.LG}
id="popoverRemoveSnapButton" id="popoverRemoveSnapButton"
className="snap-remove-warning__footer-button" danger
type="danger-primary"
onClick={onSubmit} onClick={onSubmit}
> >
{t('removeSnap')} {t('removeSnap')}
</Button> </Button>
</>
);
};
return (
<Popover
className="snap-remove-warning"
title={t('pleaseConfirm')}
footer={<SnapRemoveWarningFooter />}
onClose={onCancel}
headerProps={{ padding: [6, 4, 0, 6] }}
>
<Box paddingRight={4} paddingBottom={4} paddingLeft={6}>
<Typography variant={TypographyVariant.H4}>
{t('removeSnapConfirmation', [snapName])}
</Typography>
</Box> </Box>
</Popover> </ModalContent>
</Modal>
); );
} }
@ -62,4 +75,8 @@ SnapRemoveWarning.propTypes = {
* Name of snap * Name of snap
*/ */
snapName: PropTypes.string, snapName: PropTypes.string,
/**
* Whether the modal is open
*/
isOpen: PropTypes.bool,
}; };

View File

@ -0,0 +1,29 @@
import React from 'react';
import SnapRemoveWarning from './snap-remove-warning';
export default {
title: 'Components/App/Snaps/SnapRemoveWarning',
component: SnapRemoveWarning,
argTypes: {
onCancel: {
action: 'onCancel',
},
onSubmit: {
action: 'onSubmit',
},
snapName: {
control: 'text',
},
isOpen: {
control: 'boolean',
},
},
args: {
snapName: 'Snap Name',
isOpen: true,
},
};
export const DefaultStory = (args) => <SnapRemoveWarning {...args} />;
DefaultStory.storyName = 'Default';

View File

@ -2,17 +2,17 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import { import {
TypographyVariant, TextVariant,
OVERFLOW_WRAP, OverflowWrap,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import Typography from '../../../ui/typography/typography'; import { Text } from '../../../component-library';
const Paragraph = (props) => ( const Paragraph = (props) => (
<Typography <Text
{...props} {...props}
variant={TypographyVariant.H6} variant={TextVariant.bodyMd}
className="snap-ui-markdown__text" className="snap-ui-markdown__text"
overflowWrap={OVERFLOW_WRAP.BREAK_WORD} overflowWrap={OverflowWrap.BreakWord}
/> />
); );

View File

@ -0,0 +1,19 @@
import React from 'react';
import { SnapUIMarkdown } from './snap-ui-markdown';
export default {
title: 'Components/App/Snaps/SnapUIMarkdown',
component: SnapUIMarkdown,
argTypes: {
children: {
control: 'text',
},
},
args: {
children: 'A Test String',
},
};
export const DefaultStory = (args) => <SnapUIMarkdown {...args} />;
DefaultStory.storyName = 'Default';

View File

@ -189,15 +189,14 @@ function ViewSnap() {
{`${t('remove')} ${snapName}`} {`${t('remove')} ${snapName}`}
</Text> </Text>
</Button> </Button>
{isShowingRemoveWarning && (
<SnapRemoveWarning <SnapRemoveWarning
isOpen={isShowingRemoveWarning}
onCancel={() => setIsShowingRemoveWarning(false)} onCancel={() => setIsShowingRemoveWarning(false)}
onSubmit={async () => { onSubmit={async () => {
await dispatch(removeSnap(snap.id)); await dispatch(removeSnap(snap.id));
}} }}
snapName={snapName} snapName={snapName}
/> />
)}
</Box> </Box>
</Box> </Box>
</Box> </Box>