1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 20:02:58 +01:00
metamask-extension/ui/components/app/configure-snap-popup/configure-snap-popup.tsx
Garrett Bear 66292330fe
Feat/18890/button ts update (#20492)
* button to TS migration

working demo

style props

broken mapping - need switch

working types file

working types

fix dependent imports of Button

variant mapping

working types

fix lint

fix test

fix ButtonSize issue on QuizContent

box fix

test if this works

fix button being used on QuizContent

fix button_variant import

readme fix

* fix button import

* fix primary button as anchor hover

* deprecated

* button to TS migration

fix lint

fix test

* fix rebase issue

* fix rebase issue

* lint fix
2023-08-28 14:42:00 -07:00

100 lines
2.4 KiB
TypeScript

import React from 'react';
import PropTypes from 'prop-types';
import {
ButtonVariant,
Button,
Box,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
Text,
} from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
import {
AlignItems,
Display,
FlexDirection,
JustifyContent,
TextAlign,
TextVariant,
} from '../../../helpers/constants/design-system';
export enum ConfigureSnapPopupType {
CONFIGURE = 'configure',
INSTALL = 'install',
}
export default function ConfigureSnapPopup({
type,
isOpen,
onClose,
link,
}: {
type: ConfigureSnapPopupType;
isOpen: boolean;
onClose: () => void;
link: string;
}) {
const t = useI18nContext();
return (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader onClose={onClose} margin={[4, 4, 4, 4]}>
{type === ConfigureSnapPopupType.CONFIGURE
? t('configureSnapPopupTitle')
: t('configureSnapPopupInstallTitle')}
</ModalHeader>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Column}
justifyContent={JustifyContent.flexStart}
alignItems={AlignItems.center}
>
<img
src="images/logo/metamask-fox.svg"
width="54x"
height="50px"
style={{ marginBottom: '16px' }}
/>
<Text
variant={TextVariant.bodyLgMedium}
textAlign={TextAlign.Center}
marginBottom={5}
>
{type === ConfigureSnapPopupType.CONFIGURE
? t('configureSnapPopupDescription')
: t('configureSnapPopupInstallDescription')}
</Text>
<Text variant={TextVariant.bodyLgMedium} marginBottom={4}>
{t('configureSnapPopupLink')}
</Text>
<Button
variant={ButtonVariant.Link}
marginBottom={8}
onClick={() => {
global.platform.openTab({
url: link,
});
}}
>
{link}
</Button>
</Box>
</ModalContent>
</Modal>
);
}
ConfigureSnapPopup.propTypes = {
type: PropTypes.oneOf([
ConfigureSnapPopupType.CONFIGURE,
ConfigureSnapPopupType.INSTALL,
]).isRequired,
isOpen: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
link: PropTypes.string.isRequired,
};