1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Issue 17670 replace typography with text (#19433)

* Replace Typograph with Text component in numeric-input-component.js

* Replace Typography with Text component in signature-request-message.js

* Replace Typography with Text component in signature-request.component.js

* Replacing deprecating constants and fixing some signature story warnings

* Updating snapshot

* Fixing import

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
Co-authored-by: Garrett Bear <gwhisten@gmail.com>
This commit is contained in:
Ujwal Kumar 2023-06-27 04:20:08 +05:30 committed by GitHub
parent 113fdc189c
commit 04839a250d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 68 deletions

View File

@ -156,11 +156,7 @@ export default class SignatureRequestOriginal extends Component {
color={IconColor.infoDefault} color={IconColor.infoDefault}
marginRight={2} marginRight={2}
/> />
<Text <Text variant={TextVariant.bodyXs} color={TextColor.textDefault}>
variant={TextVariant.bodyXs}
color={TextColor.textDefault}
as="h7"
>
{this.context.t('mismatchAccount', [ {this.context.t('mismatchAccount', [
shortenAddress(this.props.selectedAccount.address), shortenAddress(this.props.selectedAccount.address),
shortenAddress(this.props.fromAccount.address), shortenAddress(this.props.fromAccount.address),

View File

@ -206,12 +206,13 @@ exports[`Signature Request Component render should match snapshot when we are us
</div> </div>
</div> </div>
<h3 <h3
class="box box--margin-top-4 box--margin-bottom-1 box--flex-direction-row typography signature-request__content__title typography--h3 typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text signature-request__content__title mm-text--heading-md box--margin-top-4 box--flex-direction-row box--color-text-default"
> >
Signature request Signature request
</h3> </h3>
<h6 <h6
class="box box--margin-12 box--margin-top-3 box--margin-bottom-1 box--flex-direction-row typography request-signature__content__subtitle typography--h7 typography--weight-normal typography--style-normal typography--align-center typography--color-text-alternative" align="center"
class="box mm-text request-signature__content__subtitle mm-text--body-sm box--margin-12 box--margin-top-3 box--flex-direction-row box--color-text-alternative"
> >
Only sign this message if you fully understand the content and trust the requesting site. Only sign this message if you fully understand the content and trust the requesting site.
</h6> </h6>
@ -223,7 +224,7 @@ exports[`Signature Request Component render should match snapshot when we are us
tabindex="0" tabindex="0"
> >
<h6 <h6
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-normal typography--style-normal typography--color-primary-default" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-primary-default"
> >
Verify third-party details Verify third-party details
</h6> </h6>
@ -237,7 +238,7 @@ exports[`Signature Request Component render should match snapshot when we are us
class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1" class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1"
> >
<p <p
class="box box--margin-top-1 box--margin-bottom-1 box--margin-left-4 box--flex-direction-row typography signature-request-message__title typography--p typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text mm-text--body-md mm-text--font-weight-bold box--margin-left-4 box--flex-direction-row box--color-text-default"
> >
Mail Mail
</p> </p>
@ -982,12 +983,13 @@ exports[`Signature Request Component render should match snapshot when we want t
</div> </div>
</div> </div>
<h3 <h3
class="box box--margin-top-4 box--margin-bottom-1 box--flex-direction-row typography signature-request__content__title typography--h3 typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text signature-request__content__title mm-text--heading-md box--margin-top-4 box--flex-direction-row box--color-text-default"
> >
Signature request Signature request
</h3> </h3>
<h6 <h6
class="box box--margin-12 box--margin-top-3 box--margin-bottom-1 box--flex-direction-row typography request-signature__content__subtitle typography--h7 typography--weight-normal typography--style-normal typography--align-center typography--color-text-alternative" align="center"
class="box mm-text request-signature__content__subtitle mm-text--body-sm box--margin-12 box--margin-top-3 box--flex-direction-row box--color-text-alternative"
> >
Only sign this message if you fully understand the content and trust the requesting site. Only sign this message if you fully understand the content and trust the requesting site.
</h6> </h6>
@ -999,7 +1001,7 @@ exports[`Signature Request Component render should match snapshot when we want t
tabindex="0" tabindex="0"
> >
<h6 <h6
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-normal typography--style-normal typography--color-primary-default" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-primary-default"
> >
Verify third-party details Verify third-party details
</h6> </h6>
@ -1013,7 +1015,7 @@ exports[`Signature Request Component render should match snapshot when we want t
class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1" class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1"
> >
<p <p
class="box box--margin-top-1 box--margin-bottom-1 box--margin-left-4 box--flex-direction-row typography signature-request-message__title typography--p typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text mm-text--body-md mm-text--font-weight-bold box--margin-left-4 box--flex-direction-row box--color-text-default"
> >
Mail Mail
</p> </p>

View File

@ -47,12 +47,6 @@
flex-direction: column; flex-direction: column;
min-height: min-content; min-height: min-content;
&__title {
@include H5;
font-weight: 500;
}
&__info { &__info {
@include H7; @include H7;

View File

@ -3,11 +3,10 @@ import PropTypes from 'prop-types';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { I18nContext } from '../../../../contexts/i18n'; import { I18nContext } from '../../../../contexts/i18n';
import Box from '../../../ui/box'; import Box from '../../../ui/box';
import Typography from '../../../ui/typography'; import { Text } from '../../../component-library';
import { import {
DISPLAY, Display,
FONT_WEIGHT, FlexDirection,
FLEX_DIRECTION,
AlignItems, AlignItems,
JustifyContent, JustifyContent,
Color, Color,
@ -15,6 +14,7 @@ import {
BorderColor, BorderColor,
BorderRadius, BorderRadius,
TextColor, TextColor,
FontWeight,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import SignatureRequestData from '../signature-request-data'; import SignatureRequestData from '../signature-request-data';
@ -44,14 +44,14 @@ export default function SignatureRequestMessage({
return ( return (
<Box <Box
display={DISPLAY.FLEX} display={Display.Flex}
flexDirection={FLEX_DIRECTION.COLUMN} flexDirection={FlexDirection.Column}
onScroll={debounce(setMessageIsScrolledAtBottom, 25)} onScroll={debounce(setMessageIsScrolledAtBottom, 25)}
className="signature-request-message" className="signature-request-message"
> >
{messageIsScrollable ? ( {messageIsScrollable ? (
<Box <Box
display={DISPLAY.FLEX} display={Display.Flex}
alignItems={AlignItems.center} alignItems={AlignItems.center}
justifyContent={JustifyContent.center} justifyContent={JustifyContent.center}
borderColor={BorderColor.borderDefault} borderColor={BorderColor.borderDefault}
@ -79,14 +79,13 @@ export default function SignatureRequestMessage({
className="signature-request-message__root" className="signature-request-message__root"
ref={setMessageRootRef} ref={setMessageRootRef}
> >
<Typography <Text
fontWeight={FONT_WEIGHT.BOLD} fontWeight={FontWeight.Bold}
color={TextColor.textDefault} color={TextColor.textDefault}
marginLeft={4} marginLeft={4}
className="signature-request-message__title"
> >
{primaryType} {primaryType}
</Typography> </Text>
<SignatureRequestData data={data.value} /> <SignatureRequestData data={data.value} />
</Box> </Box>
</Box> </Box>

View File

@ -4,7 +4,6 @@ import SignatureRequestMessage from './signature-request-message';
export default { export default {
title: 'Components/App/SignatureRequestMessage', title: 'Components/App/SignatureRequestMessage',
component: SignatureRequestMessage, component: SignatureRequestMessage,
argTypes: { argTypes: {
data: { control: 'object' }, data: { control: 'object' },

View File

@ -14,18 +14,15 @@ import {
import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics'; import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics';
import SiteOrigin from '../../ui/site-origin'; import SiteOrigin from '../../ui/site-origin';
import Button from '../../ui/button'; import Button from '../../ui/button';
import Typography from '../../ui/typography/typography';
import ContractDetailsModal from '../modals/contract-details-modal/contract-details-modal'; import ContractDetailsModal from '../modals/contract-details-modal/contract-details-modal';
import { import {
TypographyVariant,
FontWeight,
TextAlign, TextAlign,
TextColor, TextColor,
TextVariant,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi) ///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
IconColor, IconColor,
DISPLAY, Display,
BLOCK_SIZES, BlockSize,
TextVariant,
BackgroundColor, BackgroundColor,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
@ -37,11 +34,15 @@ import ConfirmPageContainerNavigation from '../confirm-page-container/confirm-pa
import SecurityProviderBannerMessage from '../security-provider-banner-message/security-provider-banner-message'; import SecurityProviderBannerMessage from '../security-provider-banner-message/security-provider-banner-message';
import { formatCurrency } from '../../../helpers/utils/confirm-tx.util'; import { formatCurrency } from '../../../helpers/utils/confirm-tx.util';
import { getValueFromWeiHex } from '../../../../shared/modules/conversion.utils'; import { getValueFromWeiHex } from '../../../../shared/modules/conversion.utils';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import { Icon, IconName, Text } from '../../component-library';
import Box from '../../ui/box/box';
///: END:ONLY_INCLUDE_IN
import {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
Box,
Icon,
IconName,
///: END:ONLY_INCLUDE_IN
Text,
} from '../../component-library';
import Footer from './signature-request-footer'; import Footer from './signature-request-footer';
import Message from './signature-request-message'; import Message from './signature-request-message';
@ -295,8 +296,8 @@ export default class SignatureRequest extends PureComponent {
this.props.selectedAccount.address === address ? null : ( this.props.selectedAccount.address === address ? null : (
<Box <Box
className="request-signature__mismatch-info" className="request-signature__mismatch-info"
display={DISPLAY.FLEX} display={Display.Flex}
width={BLOCK_SIZES.FULL} width={BlockSize.Full}
padding={4} padding={4}
marginBottom={4} marginBottom={4}
backgroundColor={BackgroundColor.primaryMuted} backgroundColor={BackgroundColor.primaryMuted}
@ -309,7 +310,6 @@ export default class SignatureRequest extends PureComponent {
<Text <Text
variant={TextVariant.bodyXs} variant={TextVariant.bodyXs}
color={TextColor.textDefault} color={TextColor.textDefault}
as="h7"
> >
{this.context.t('mismatchAccount', [ {this.context.t('mismatchAccount', [
shortenAddress(this.props.selectedAccount.address), shortenAddress(this.props.selectedAccount.address),
@ -330,26 +330,25 @@ export default class SignatureRequest extends PureComponent {
/> />
</div> </div>
<Typography <Text
className="signature-request__content__title" className="signature-request__content__title"
variant={TypographyVariant.H3} variant={TextVariant.headingMd}
fontWeight={FontWeight.Bold} as="h3"
boxProps={{ marginTop={4}
marginTop: 4,
}}
> >
{this.context.t('sigRequest')} {this.context.t('sigRequest')}
</Typography> </Text>
<Typography <Text
className="request-signature__content__subtitle" className="request-signature__content__subtitle"
variant={TypographyVariant.H7} variant={TextVariant.bodySm}
as="h6"
color={TextColor.textAlternative} color={TextColor.textAlternative}
align={TextAlign.Center} align={TextAlign.Center}
margin={12} margin={12}
marginTop={3} marginTop={3}
> >
{this.context.t('signatureRequestGuidance')} {this.context.t('signatureRequestGuidance')}
</Typography> </Text>
{verifyingContract ? ( {verifyingContract ? (
<div> <div>
<Button <Button
@ -358,12 +357,13 @@ export default class SignatureRequest extends PureComponent {
className="signature-request-content__verify-contract-details" className="signature-request-content__verify-contract-details"
data-testid="verify-contract-details" data-testid="verify-contract-details"
> >
<Typography <Text
variant={TypographyVariant.H7} variant={TextVariant.bodySm}
as="h6"
color={TextColor.primaryDefault} color={TextColor.primaryDefault}
> >
{this.context.t('verifyContractDetails')} {this.context.t('verifyContractDetails')}
</Typography> </Text>
</Button> </Button>
</div> </div>
) : null} ) : null}

View File

@ -9,7 +9,6 @@ const [MOCK_PRIMARY_IDENTITY, MOCK_SECONDARY_IDENTITY] = Object.values(
export default { export default {
title: 'Components/App/SignatureRequest', title: 'Components/App/SignatureRequest',
component: SignatureRequest, component: SignatureRequest,
parameters: { parameters: {
docs: { docs: {
@ -30,6 +29,10 @@ export default {
clearConfirmTransaction: { action: 'Clean Confirm' }, clearConfirmTransaction: { action: 'Clean Confirm' },
cancel: { action: 'Cancel' }, cancel: { action: 'Cancel' },
sign: { action: 'Sign' }, sign: { action: 'Sign' },
showRejectTransactionsConfirmationModal: {
action: 'showRejectTransactionsConfirmationModal',
},
cancelAll: { action: 'cancelAll' },
}, },
}; };
@ -79,6 +82,8 @@ DefaultStory.args = {
fromAccount: MOCK_PRIMARY_IDENTITY, fromAccount: MOCK_PRIMARY_IDENTITY,
providerConfig: { name: 'Goerli ETH' }, providerConfig: { name: 'Goerli ETH' },
selectedAccount: MOCK_PRIMARY_IDENTITY, selectedAccount: MOCK_PRIMARY_IDENTITY,
hardwareWalletRequiresConnection: false,
currentCurrency: 'usd',
}; };
export const AccountMismatchStory = (args) => { export const AccountMismatchStory = (args) => {

View File

@ -731,7 +731,7 @@ export const Offset: StoryFn<typeof Popover> = (args) => {
); );
}; };
export const onPressEscKey: StoryFn<typeof Popover> = (args) => { export const OnPressEscKey: StoryFn<typeof Popover> = (args) => {
const [referenceElement, setReferenceElement] = useState(); const [referenceElement, setReferenceElement] = useState();
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);

View File

@ -1,12 +1,12 @@
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Typography from '../typography/typography';
import { import {
TextColor, TextColor,
TypographyVariant, TextVariant,
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
import { DECIMAL_REGEX } from '../../../../shared/constants/tokens'; import { DECIMAL_REGEX } from '../../../../shared/constants/tokens';
import { Text } from '../../component-library';
export default function NumericInput({ export default function NumericInput({
detailText = '', detailText = '',
@ -52,13 +52,13 @@ export default function NumericInput({
ref={inputRef} ref={inputRef}
/> />
{detailText && ( {detailText && (
<Typography <Text
color={TextColor.textAlternative} color={TextColor.textAlternative}
variant={TypographyVariant.H7} variant={TextVariant.bodySm}
as="span" as="span"
> >
{detailText} {detailText}
</Typography> </Text>
)} )}
</div> </div>
); );

View File

@ -205,12 +205,13 @@ exports[`Signature Request Component render should match snapshot 1`] = `
</div> </div>
</div> </div>
<h3 <h3
class="box box--margin-top-4 box--margin-bottom-1 box--flex-direction-row typography signature-request__content__title typography--h3 typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text signature-request__content__title mm-text--heading-md box--margin-top-4 box--flex-direction-row box--color-text-default"
> >
Signature request Signature request
</h3> </h3>
<h6 <h6
class="box box--margin-12 box--margin-top-3 box--margin-bottom-1 box--flex-direction-row typography request-signature__content__subtitle typography--h7 typography--weight-normal typography--style-normal typography--align-center typography--color-text-alternative" align="center"
class="box mm-text request-signature__content__subtitle mm-text--body-sm box--margin-12 box--margin-top-3 box--flex-direction-row box--color-text-alternative"
> >
Only sign this message if you fully understand the content and trust the requesting site. Only sign this message if you fully understand the content and trust the requesting site.
</h6> </h6>
@ -222,7 +223,7 @@ exports[`Signature Request Component render should match snapshot 1`] = `
tabindex="0" tabindex="0"
> >
<h6 <h6
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-normal typography--style-normal typography--color-primary-default" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-primary-default"
> >
Verify third-party details Verify third-party details
</h6> </h6>
@ -236,7 +237,7 @@ exports[`Signature Request Component render should match snapshot 1`] = `
class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1" class="box signature-request-message__root box--margin-2 box--padding-top-3 box--padding-right-3 box--padding-bottom-3 box--flex-direction-row box--background-color-background-default box--rounded-xl box--border-color-border-muted box--border-style-solid box--border-width-1"
> >
<p <p
class="box box--margin-top-1 box--margin-bottom-1 box--margin-left-4 box--flex-direction-row typography signature-request-message__title typography--p typography--weight-bold typography--style-normal typography--color-text-default" class="box mm-text mm-text--body-md mm-text--font-weight-bold box--margin-left-4 box--flex-direction-row box--color-text-default"
> >
Mail Mail
</p> </p>