Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Adding inital typography tokens #94

Merged
merged 23 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6048d2e
Initial typography tokens and docs
georgewrmarshall May 2, 2022
109d7af
Updating folder structure
georgewrmarshall May 3, 2022
85105fb
Adding icon/alternative type
georgewrmarshall May 3, 2022
023f262
Updating jest to ignore index and updating test descriptions
georgewrmarshall May 3, 2022
90efa18
Updating colors
georgewrmarshall May 3, 2022
5c2ba2c
Adding color tests
georgewrmarshall May 3, 2022
b2d1b07
removing output folder
georgewrmarshall May 3, 2022
e78e171
removing unused fontSize
georgewrmarshall May 4, 2022
d21f0cd
Fixing docs
georgewrmarshall May 4, 2022
658ab41
Updates to docs
georgewrmarshall May 4, 2022
be4073f
Correcting some docs mistakes
georgewrmarshall May 4, 2022
5ef0454
Updating displayMD to displayMDMedium
georgewrmarshall May 4, 2022
5cfd59f
Updating headingLG to headingLGBold
georgewrmarshall May 4, 2022
50fd1e2
Updating headingMD to headingMDBold
georgewrmarshall May 4, 2022
959c1a1
Adding font weights as variants
georgewrmarshall May 4, 2022
ed14e4a
Removing line height 0
georgewrmarshall May 4, 2022
8ecb4c8
Updates to figma tokens
georgewrmarshall May 4, 2022
eb85f33
Update typography documentation
Cal-L May 5, 2022
7320e2b
Merge branch 'type-tokens' of https://github.com/MetaMask/metamask-de…
Cal-L May 5, 2022
503ab9c
empty
georgewrmarshall May 5, 2022
a6c7364
Omitting font-weights in type ramp for default styles
georgewrmarshall May 5, 2022
732312b
Fixing tests
georgewrmarshall May 5, 2022
58d6287
Fix casing for styles
Cal-L May 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/BrandColors.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Canvas, Story } from '@storybook/addon-docs/blocks';
import { Meta, Canvas, Story } from '@storybook/addon-docs';
import LinkTo from '@storybook/addon-links/react';

<Meta title="Design Tokens/Brand Colors" />
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion docs/ThemeColors.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Canvas, Story } from '@storybook/addon-docs/blocks';
import { Meta, Canvas, Story } from '@storybook/addon-docs';

import tokens from '../src/figma/tokens.json';

georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
98 changes: 98 additions & 0 deletions docs/Typography.mdx

Large diffs are not rendered by default.

318 changes: 318 additions & 0 deletions docs/Typography.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { typography } from '../src/js/typography';

import { fontSizes } from '../src/js/typography/fontSizes';
import { lineHeights } from '../src/js/typography/lineHeights';
import { fontFamilies } from '../src/js/typography/fontFamilies';
import { fontWeights } from '../src/js/typography/fontWeights';
import { letterSpacing } from '../src/js/typography/letterSpacing';

import { Text } from './components';

import README from './Typography.mdx';

export default {
title: 'Typography/Typography',
parameters: {
docs: {
page: README,
},
},
} as ComponentMeta<typeof Text>;

export const FontFamily: ComponentStory<typeof Text> = (...args) => {
const styles = {
displayMD: {
fontFamily: fontFamilies.euclidCircularB,
fontSize: fontSizes.fontSize7,
lineHeight: `${lineHeights.lineHeight6}px`,
fontWeight: fontWeights.regular,
letterSpacing: letterSpacing.letterSpacing1,
},
};
return (
<>
<Text as="h1" style={styles.displayMD} {...args}>
Euclid Circular B
</Text>
</>
);
};

export const SmallScreen: ComponentStory<typeof Text> = (...args) => {
const smallScreenFontSizeBase = 16;
const styles = {
displayMD: {
fontFamily: typography.sDisplayMD.fontFamily,
fontSize: typography.sDisplayMD.fontSize,
lineHeight: `${typography.sDisplayMD.lineHeight}px`,
fontWeight: typography.sDisplayMD.fontWeight,
},
headingLG: {
fontFamily: typography.sHeadingLG.fontFamily,
fontSize: typography.sHeadingLG.fontSize,
lineHeight: `${typography.sHeadingLG.lineHeight}px`,
fontWeight: typography.sHeadingLG.fontWeight,
},
headingMD: {
fontFamily: typography.sHeadingMD.fontFamily,
fontSize: typography.sHeadingMD.fontSize,
lineHeight: `${typography.sHeadingMD.lineHeight}px`,
fontWeight: typography.sHeadingMD.fontWeight,
},
headingSM: {
fontFamily: typography.sHeadingSM.fontFamily,
fontSize: typography.sHeadingSM.fontSize,
lineHeight: `${typography.sHeadingSM.lineHeight}px`,
fontWeight: typography.sHeadingSM.fontWeight,
},
headingSMRegular: {
fontFamily: typography.sHeadingSMRegular.fontFamily,
fontSize: typography.sHeadingSMRegular.fontSize,
lineHeight: `${typography.sHeadingSMRegular.lineHeight}px`,
fontWeight: typography.sHeadingSMRegular.fontWeight,
},
bodyMD: {
fontFamily: typography.sBodyMD.fontFamily,
fontSize: typography.sBodyMD.fontSize,
lineHeight: `${typography.sBodyMD.lineHeight}px`,
fontWeight: typography.sBodyMD.fontWeight,
},
bodyMDBold: {
fontFamily: typography.sBodyMDBold.fontFamily,
fontSize: typography.sBodyMDBold.fontSize,
lineHeight: `${typography.sBodyMDBold.lineHeight}px`,
fontWeight: typography.sBodyMDBold.fontWeight,
},
bodySM: {
fontFamily: typography.sBodySM.fontFamily,
fontSize: typography.sBodySM.fontSize,
lineHeight: `${typography.sBodySM.lineHeight}px`,
fontWeight: typography.sBodySM.fontWeight,
},
bodySMBold: {
fontFamily: typography.sBodySMBold.fontFamily,
fontSize: typography.sBodySMBold.fontSize,
lineHeight: `${typography.sBodySMBold.lineHeight}px`,
fontWeight: typography.sBodySMBold.fontWeight,
},
bodyXS: {
fontFamily: typography.sBodyXS.fontFamily,
fontSize: typography.sBodyXS.fontSize,
lineHeight: `${typography.sBodyXS.lineHeight}px`,
fontWeight: typography.sBodyXS.fontWeight,
letterSpacing: typography.sBodyXS.letterSpacing,
},
};
return (
<>
<Text as="h1" style={styles.displayMD} {...args}>
{`S DisplayMD ${styles.displayMD.fontSize}px/${
styles.displayMD.lineHeight
} ${styles.displayMD.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="h2" style={styles.headingLG} {...args}>
{`S HeadingLG ${styles.headingLG.fontSize}px/${
styles.headingLG.lineHeight
} ${styles.headingLG.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="h3" style={styles.headingMD} {...args}>
{`S HeadingMD ${styles.headingMD.fontSize}px/${
styles.headingMD.lineHeight
} ${styles.headingMD.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="h4" style={styles.headingSM} {...args}>
{`S HeadingSM ${styles.headingSM.fontSize}px/${
styles.headingSM.lineHeight
} ${styles.headingSM.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="h4" style={styles.headingSMRegular} {...args}>
{`S HeadingSM Regular ${styles.headingSMRegular.fontSize}px/${
styles.headingSMRegular.lineHeight
} ${styles.headingSMRegular.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodyMDBold} {...args}>
{`S BodyMD Bold ${styles.bodyMDBold.fontSize}px/${
styles.bodyMDBold.lineHeight
} ${styles.bodyMDBold.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodyMD} {...args}>
{`S BodyMD ${styles.bodyMD.fontSize}px/${styles.bodyMD.lineHeight} ${
styles.bodyMD.fontSize / smallScreenFontSizeBase
}rem`}
</Text>
<Text as="p" style={styles.bodySMBold} {...args}>
{`S BodySM Bold ${styles.bodySMBold.fontSize}px/${
styles.bodySMBold.lineHeight
} ${styles.bodySMBold.fontSize / smallScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodySM} {...args}>
{`S BodySM ${styles.bodySM.fontSize}px/${styles.bodySM.lineHeight} ${
styles.bodySM.fontSize / smallScreenFontSizeBase
}rem`}
</Text>
<Text as="p" style={styles.bodyXS} {...args}>
{`S BodyXS ${styles.bodyXS.fontSize}px/${styles.bodyXS.lineHeight} ${
styles.bodyXS.fontSize / smallScreenFontSizeBase
}rem`}
</Text>
</>
);
};

export const LargeScreen: ComponentStory<typeof Text> = (...args) => {
const largeScreenFontSizeBase = 16;
const styles = {
displayMD: {
fontFamily: typography.lDisplayMD.fontFamily,
fontSize: typography.lDisplayMD.fontSize,
lineHeight: `${typography.lDisplayMD.lineHeight}px`,
fontWeight: typography.lDisplayMD.fontWeight,
},
headingLG: {
fontFamily: typography.lHeadingLG.fontFamily,
fontSize: typography.lHeadingLG.fontSize,
lineHeight: `${typography.lHeadingLG.lineHeight}px`,
fontWeight: typography.lHeadingLG.fontWeight,
},
headingMD: {
fontFamily: typography.lHeadingMD.fontFamily,
fontSize: typography.lHeadingMD.fontSize,
lineHeight: `${typography.lHeadingMD.lineHeight}px`,
fontWeight: typography.lHeadingMD.fontWeight,
},
headingSM: {
fontFamily: typography.lHeadingSM.fontFamily,
fontSize: typography.lHeadingSM.fontSize,
lineHeight: `${typography.lHeadingSM.lineHeight}px`,
fontWeight: typography.lHeadingSM.fontWeight,
},
headingSMRegular: {
fontFamily: typography.lHeadingSMRegular.fontFamily,
fontSize: typography.lHeadingSMRegular.fontSize,
lineHeight: `${typography.lHeadingSMRegular.lineHeight}px`,
fontWeight: typography.lHeadingSMRegular.fontWeight,
},
bodyMDBold: {
fontFamily: typography.lBodyMDBold.fontFamily,
fontSize: typography.lBodyMDBold.fontSize,
lineHeight: `${typography.lBodyMDBold.lineHeight}px`,
fontWeight: typography.lBodyMDBold.fontWeight,
},
bodyMD: {
fontFamily: typography.lBodyMD.fontFamily,
fontSize: typography.lBodyMD.fontSize,
lineHeight: `${typography.lBodyMD.lineHeight}px`,
fontWeight: typography.lBodyMD.fontWeight,
},
bodySMBold: {
fontFamily: typography.lBodySMBold.fontFamily,
fontSize: typography.lBodySMBold.fontSize,
lineHeight: `${typography.lBodySMBold.lineHeight}px`,
fontWeight: typography.lBodySMBold.fontWeight,
},
bodySM: {
fontFamily: typography.lBodySM.fontFamily,
fontSize: typography.lBodySM.fontSize,
lineHeight: `${typography.lBodySM.lineHeight}px`,
fontWeight: typography.lBodySM.fontWeight,
},
bodyXS: {
fontFamily: typography.lBodyXS.fontFamily,
fontSize: typography.lBodyXS.fontSize,
lineHeight: `${typography.lBodyXS.lineHeight}px`,
fontWeight: typography.lBodyXS.fontWeight,
letterSpacing: typography.lBodyXS.letterSpacing,
},
};
return (
<>
<Text as="h1" style={styles.displayMD} {...args}>
{`L DisplayMD ${styles.displayMD.fontSize}px/${
styles.displayMD.lineHeight
} ${styles.displayMD.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="h2" style={styles.headingLG} {...args}>
{`L HeadingLG ${styles.headingLG.fontSize}px/${
styles.headingLG.lineHeight
} ${styles.headingLG.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="h3" style={styles.headingMD} {...args}>
{`L HeadingMD ${styles.headingMD.fontSize}px/${
styles.headingMD.lineHeight
} ${styles.headingMD.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="h4" style={styles.headingSM} {...args}>
{`L HeadingSM ${styles.headingSM.fontSize}px/${
styles.headingSM.lineHeight
} ${styles.headingSM.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="h4" style={styles.headingSMRegular} {...args}>
{`L HeadingSM Regular ${styles.headingSMRegular.fontSize}px/${
styles.headingSMRegular.lineHeight
} ${styles.headingSMRegular.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodyMDBold} {...args}>
{`L BodyMD Bold ${styles.bodyMDBold.fontSize}px/${
styles.bodyMDBold.lineHeight
} ${styles.bodyMDBold.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodyMD} {...args}>
{`L BodyMD ${styles.bodyMD.fontSize}px/${styles.bodyMD.lineHeight} ${
styles.bodyMD.fontSize / largeScreenFontSizeBase
}rem`}
</Text>
<Text as="p" style={styles.bodySMBold} {...args}>
{`L BodySM Bold ${styles.bodySMBold.fontSize}px/${
styles.bodySMBold.lineHeight
} ${styles.bodySMBold.fontSize / largeScreenFontSizeBase}rem`}
</Text>
<Text as="p" style={styles.bodySM} {...args}>
{`L BodySM ${styles.bodySM.fontSize}px/${styles.bodySM.lineHeight} ${
styles.bodySM.fontSize / largeScreenFontSizeBase
}rem`}
</Text>
<Text as="p" style={styles.bodyXS} {...args}>
{`L BodyXS ${styles.bodyXS.fontSize}px/${styles.bodyXS.lineHeight} ${
styles.bodyXS.fontSize / largeScreenFontSizeBase
}rem`}
</Text>
</>
);
};

export const FontWeight: ComponentStory<typeof Text> = (...args) => {
const styles = {
regular: {
fontFamily: fontFamilies.euclidCircularB,
fontSize: fontSizes.fontSize4,
lineHeight: `${lineHeights.lineHeight5}px`,
fontWeight: fontWeights.regular,
},
medium: {
fontFamily: fontFamilies.euclidCircularB,
fontSize: fontSizes.fontSize4,
lineHeight: `${lineHeights.lineHeight5}px`,
fontWeight: fontWeights.medium,
},
bold: {
fontFamily: fontFamilies.euclidCircularB,
fontSize: fontSizes.fontSize4,
lineHeight: `${lineHeights.lineHeight5}px`,
fontWeight: fontWeights.bold,
},
};
return (
<>
<Text as="h3" style={styles.regular} {...args}>
Regular 400
</Text>
<Text as="h3" style={styles.medium} {...args}>
Medium 500
</Text>
<Text as="h3" style={styles.bold} {...args}>
Bold 700
</Text>
</>
);
};
29 changes: 29 additions & 0 deletions docs/components/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { Text } from '.';

export default {
title: 'Doc components/Text',
argTypes: {
children: {
control: 'text',
},
as: {
control: 'select',
options: ['h1', 'h2', 'p', 'a', 'li'],
},
style: {
control: 'object',
},
},
} as ComponentMeta<typeof Text>;

const Template: ComponentStory<typeof Text> = (args) => <Text {...args} />;

export const DefaultStory = Template.bind({});

DefaultStory.args = {
children: 'Text',
};

DefaultStory.storyName = 'Default';
28 changes: 28 additions & 0 deletions docs/components/Text/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

interface Props<C extends React.ElementType> {
/**
* The children or content of the Text component
*/
children?: React.ReactChild;
/**
* Polymorphic prop to change the html root element of the component
*/
as?: string;
/**
* The style prop of the Text component
*/
style?: object;
}

type TextProps<C extends React.ElementType> = Props<C> &
Omit<React.ComponentPropsWithoutRef<C>, keyof Props<C>>;

export const Text = <C extends React.ElementType = 'span'>({
style,
children,
as,
}: TextProps<C>) => {
const Component = as || 'span';
return <Component style={style}>{children}</Component>;
};
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions docs/components/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Text } from './Text';
1 change: 1 addition & 0 deletions docs/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { ColorSwatch } from './ColorSwatch';
export { ColorSwatchGroup } from './ColorSwatchGroup';
export { Text } from './Text';
Loading