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

Deprecating Typography component (#17672)

* Deprecating Typography component

* Fixing lint issue
This commit is contained in:
George Marshall 2023-02-09 12:17:25 -08:00 committed by GitHub
parent 7aad1c9650
commit a5b908ccf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 154 additions and 24 deletions

View File

@ -1,6 +1,19 @@
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import ActionableMessage from '../actionable-message'; import ActionableMessage from '../actionable-message';
import Typography from '.'; import Typography from '.';
import { SEVERITIES } from '../../../helpers/constants/design-system';
import { BannerAlert } from '../../component-library/banner-alert';
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
# Typography # Typography

View File

@ -53,6 +53,14 @@ export const ValidTags = [
'label', 'label',
]; ];
/**
* @deprecated `<Typography />` has been deprecated in favour of the `<Text />` component in ./ui/components/component-library/text/text.js
*
* See storybook documentation for Text here https://metamask.github.io/metamask-storybook/?path=/docs/components-componentlibrary-text--default-story#text
*
* Help to replace `Typography` with `Text` by submitting PRs against https://github.com/MetaMask/metamask-extension/issues/17670
*/
export default function Typography({ export default function Typography({
variant = TypographyVariant.paragraph, variant = TypographyVariant.paragraph,
color = Color.textDefault, color = Color.textDefault,

View File

@ -1,3 +1,11 @@
/**
* @deprecated `<Typography />` has been deprecated in favour of the `<Text />` component in ./ui/components/component-library/text/text.js
*
* See storybook documentation for Text here https://metamask.github.io/metamask-storybook/?path=/docs/components-componentlibrary-text--default-story#text
*
* Help to replace `Typography` with `Text` by submitting PRs against https://github.com/MetaMask/metamask-extension/issues/17670
*/
@use "design-system"; @use "design-system";
@use "sass:map"; @use "sass:map";

View File

@ -10,9 +10,12 @@ import {
Color as ColorEnum, Color as ColorEnum,
TextColor, TextColor,
BorderColor, BorderColor,
SEVERITIES,
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
import Box from '../box'; import Box from '../box';
import { BannerAlert } from '../../component-library/banner-alert';
import { ValidColors, ValidTags } from './typography'; import { ValidColors, ValidTags } from './typography';
import README from './README.mdx'; import README from './README.mdx';
@ -104,12 +107,23 @@ function renderBackgroundColor(color) {
} }
export const DefaultStory = (args) => ( export const DefaultStory = (args) => (
<>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
<Typography <Typography
boxProps={{ backgroundColor: renderBackgroundColor(args.color) }} boxProps={{ backgroundColor: renderBackgroundColor(args.color) }}
{...args} {...args}
> >
{args.children} {args.children}
</Typography> </Typography>
</>
); );
DefaultStory.storyName = 'Default'; DefaultStory.storyName = 'Default';
@ -120,6 +134,15 @@ DefaultStory.args = {
export const Variant = (args) => ( export const Variant = (args) => (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
{Object.values(TypographyVariant).map((variant) => ( {Object.values(TypographyVariant).map((variant) => (
<Typography <Typography
boxProps={{ backgroundColor: renderBackgroundColor(args.color) }} boxProps={{ backgroundColor: renderBackgroundColor(args.color) }}
@ -138,6 +161,15 @@ export const Color = (args) => {
const LAST_VALID_COLORS_ARRAY_INDEX = 16; const LAST_VALID_COLORS_ARRAY_INDEX = 16;
return ( return (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
{Object.values(ValidColors).map((color, index) => { {Object.values(ValidColors).map((color, index) => {
if (index === LAST_VALID_COLORS_ARRAY_INDEX) { if (index === LAST_VALID_COLORS_ARRAY_INDEX) {
return ( return (
@ -191,6 +223,15 @@ export const Color = (args) => {
export const FontWeight = (args) => ( export const FontWeight = (args) => (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
{Object.values(FONT_WEIGHT).map((weight) => ( {Object.values(FONT_WEIGHT).map((weight) => (
<Typography <Typography
boxProps={{ backgroundColor: renderBackgroundColor(args.color) }} boxProps={{ backgroundColor: renderBackgroundColor(args.color) }}
@ -206,6 +247,15 @@ export const FontWeight = (args) => (
export const FontStyle = (args) => ( export const FontStyle = (args) => (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
{Object.values(FONT_STYLE).map((style) => ( {Object.values(FONT_STYLE).map((style) => (
<Typography <Typography
boxProps={{ backgroundColor: renderBackgroundColor(args.color) }} boxProps={{ backgroundColor: renderBackgroundColor(args.color) }}
@ -221,6 +271,15 @@ export const FontStyle = (args) => (
export const Align = (args) => ( export const Align = (args) => (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
{Object.values(TEXT_ALIGN).map((align) => ( {Object.values(TEXT_ALIGN).map((align) => (
<Typography <Typography
boxProps={{ backgroundColor: renderBackgroundColor(args.color) }} boxProps={{ backgroundColor: renderBackgroundColor(args.color) }}
@ -235,6 +294,16 @@ export const Align = (args) => (
); );
export const OverflowWrap = (args) => ( export const OverflowWrap = (args) => (
<>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
<div <div
style={{ style={{
width: 250, width: 250,
@ -249,10 +318,20 @@ export const OverflowWrap = (args) => (
{OVERFLOW_WRAP.BREAK_WORD}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d {OVERFLOW_WRAP.BREAK_WORD}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d
</Typography> </Typography>
</div> </div>
</>
); );
export const As = (args) => ( export const As = (args) => (
<> <>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
<Typography boxProps={{ display: DISPLAY.BLOCK }} marginBottom={4}> <Typography boxProps={{ display: DISPLAY.BLOCK }} marginBottom={4}>
You can change the root element of the Typography component using the as You can change the root element of the Typography component using the as
prop. Inspect the below elements to see the underlying HTML elements prop. Inspect the below elements to see the underlying HTML elements
@ -276,9 +355,20 @@ export const As = (args) => (
); );
export const Margin = (args) => ( export const Margin = (args) => (
<>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
<Typography {...args}> <Typography {...args}>
This Typography component has a margin of {args.margin * 4}px This Typography component has a margin of {args.margin * 4}px
</Typography> </Typography>
</>
); );
Margin.args = { Margin.args = {
@ -286,7 +376,18 @@ Margin.args = {
}; };
export const BoxProps = (args) => ( export const BoxProps = (args) => (
<>
<BannerAlert
severity={SEVERITIES.WARNING}
title="Deprecated"
description="<Typography/> has been deprecated in favour of the <Text /> component"
actionButtonLabel="See details"
actionButtonProps={{
href: 'https://github.com/MetaMask/metamask-extension/issues/17670',
}}
/>
<Typography {...args}>This uses the boxProps prop</Typography> <Typography {...args}>This uses the boxProps prop</Typography>
</>
); );
BoxProps.args = { BoxProps.args = {