[Design Token] Added 5 new text styles for trade-app alignment#777
[Design Token] Added 5 new text styles for trade-app alignment#777georgewrmarshall merged 4 commits intomainfrom
Conversation
📖 Storybook Preview |
Added these objects: - L-PageHeading (=L-Heading-Lg) - L-SectionHeading (=L-Heading-Sm) - L-ButtonLabel-Md (=L-Body-Md-Medium) - L-ButtonLabel-Lg (=L-Body-Lg-Medium) - S-PageHeading (=S-Heading-Lg) - S-SectionHeading (=S-Heading-Sm) - S-ButtonLabel-Md (=S-Body-Md-Medium) - S-ButtonLabel-Lg (=S-Body-Lg-Medium) -
7e4eb23 to
abe12ad
Compare
| // Add optimizeDeps configuration to handle workspace packages | ||
| config.optimizeDeps = { | ||
| ...config.optimizeDeps, | ||
| exclude: [ | ||
| '@metamask/design-tokens', | ||
| '@metamask/design-system-react', | ||
| '@metamask/design-system-tailwind-preset', | ||
| ], | ||
| }; |
📖 Storybook Preview |
| - `TextVariant.ButtonLabelMd` | ||
| - `TextVariant.ButtonLabelLg` | ||
| - `TextVariant.AmountDisplayLg` | ||
|
|
| [TextVariant.ButtonLabelLg]: typography.sButtonLabelLg | ||
| .fontWeight as FontWeight, | ||
| [TextVariant.AmountDisplayLg]: typography.sAmountDisplayLg | ||
| .fontWeight as FontWeight, |
There was a problem hiding this comment.
Updating DSRN Text constants
| SectionHeading = 'section-heading', | ||
| ButtonLabelMd = 'button-label-md', | ||
| ButtonLabelLg = 'button-label-lg', | ||
| AmountDisplayLg = 'amount-display-lg', |
There was a problem hiding this comment.
Updating DSRN TextVariants
| @@ -102,6 +102,46 @@ Use the `variant` prop and the `TextVariant` enum from `@metamask/design-system- | |||
| <code>p</code> | |||
| </td> | |||
| </tr> | |||
| 'text-s-body-sm leading-s-body-sm tracking-s-body-sm md:text-l-body-sm md:leading-l-body-sm md:tracking-l-body-sm', | ||
| [TextVariant.BodyXs]: | ||
| 'text-s-body-xs leading-s-body-xs tracking-s-body-xs md:text-l-body-xs md:leading-l-body-xs md:tracking-l-body-xs', | ||
| [TextVariant.PageHeading]: |
There was a problem hiding this comment.
Updating DSR constants
| <Text variant={TextVariant.BodyMd}>BodyMd</Text> | ||
| <Text variant={TextVariant.BodySm}>BodySm</Text> | ||
| <Text variant={TextVariant.BodyXs}>BodyXs</Text> | ||
| <Text variant={TextVariant.PageHeading}>PageHeading</Text> |
| BodySm = 'body-sm', | ||
| BodyXs = 'body-xs', | ||
|
|
||
| // Special Typography Variants |
There was a problem hiding this comment.
Updating DSR TextVariant types
| @@ -10,6 +10,11 @@ export const typography = { | |||
| 's-body-md': 'var(--typography-s-body-md-font-size)', | |||
There was a problem hiding this comment.
Updating tailwind preset with new tokens
| @@ -76,6 +76,46 @@ export const typographyTailwindConfig: TypographyTailwindConfigProps = { | |||
| fontWeight: typography.sBodyXS.fontWeight, | |||
| }, | |||
| ], | |||
There was a problem hiding this comment.
Updating twrnc with new tokens
| @@ -96,6 +96,26 @@ | |||
| --typography-s-body-xs-line-height: var(--line-height-2); | |||
|
|
||
| // Helper function to convert token name to CSS variable name | ||
| const tokenNameToCSSVariable = (tokenName: string): string => { | ||
| return `--typography-${tokenName.toLowerCase().replace(/-/gu, '-')}`; |
There was a problem hiding this comment.
Fixing typography test to allow kebab case for the new type tokens
| @@ -634,6 +634,66 @@ | |||
| }, | |||
| "type": "typography" | |||
| }, | |||
| @@ -20,6 +20,11 @@ export type ThemeTypography = { | |||
| sBodySMBold: TypeStyle; | |||
| sBodyXS: TypeStyle; | |||
| sBodyXSMedium: TypeStyle; | |||
| <code>var(--typography-s-body-xs-letter-spacing)</code> | ||
| </td> | ||
| </tr> | ||
| <tr> |
There was a problem hiding this comment.
Pull Request Overview
This PR adds 10 new typography styles to the design token system to support more use-case-specific typography across the UI for trade-app alignment. The new styles are semantic aliases of existing typography tokens, providing more purposeful naming for common UI patterns.
- Adds 5 new small screen (S) and 5 new large screen (L) typography styles for specific use cases
- Updates design token definitions, CSS variables, Tailwind configurations, and React components
- Provides documentation and storybook examples for the new typography variants
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/design-tokens/src/js/typography/typography.ts |
Adds the core typography definitions for new semantic styles |
packages/design-tokens/src/js/typography/types.ts |
Updates TypeScript types to include new typography variants |
packages/design-tokens/src/figma/tokens.json |
Adds Figma design token definitions for new typography styles |
packages/design-tokens/src/css/typography.css |
Generates CSS custom properties for the new typography tokens |
packages/design-tokens/stories/Typography.stories.tsx |
Updates Storybook stories to showcase new typography variants |
packages/design-tokens/stories/Typography.mdx |
Adds documentation for the new typography styles |
packages/design-system-react/src/types/index.ts |
Adds new TextVariant enum values for React components |
packages/design-system-react/src/components/Text/Text.constants.ts |
Maps new variants to CSS classes and HTML tags |
packages/design-system-tailwind-preset/src/typography.ts |
Adds Tailwind CSS configuration for new typography tokens |
packages/design-system-twrnc-preset/src/typography.ts |
Adds React Native Tailwind configuration for new typography |
📖 Storybook Preview |
## **Description** This release adds 5 new typography variants to the MetaMask Design System and introduces new utility props for the Box component across both React and React Native platforms. ### **Typography Enhancements** - **PageHeading**: For main page titles with semantic `<h1>` HTML elements - **SectionHeading**: For section titles with semantic `<h2>` HTML elements - **ButtonLabelMd**: For medium-sized button labels with semantic `<span>` elements - **ButtonLabelLg**: For large-sized button labels with semantic `<span>` elements - **AmountDisplayLg**: For large amount/value displays with semantic `<span>` elements All new variants include: - Responsive typography (small and large screen breakpoints) - Proper font weight, letter spacing, and line height tokens - Integration with existing design token system - Full TypeScript support with updated enums ### **Box Component Improvements** - Added new utility props for margin, padding, border, border color, and background color - Enhanced developer experience with more flexible styling options ### **Package Updates** - **@metamask/design-tokens**: 8.0.0 → 8.1.0 (added new typography tokens + color updates) - **@metamask/design-system-tailwind-preset**: 0.5.0 → 0.6.0 (added CSS classes for new variants) - **@metamask/design-system-twrnc-preset**: 0.1.0 → 0.2.0 (added React Native classes + intellisense improvements) - **@metamask/design-system-react**: 0.1.0 → 0.2.0 (new Text variants + Box utility props) - **@metamask/design-system-react-native**: 0.1.0 → 0.2.0 (new Text variants + Box utility props) - **Root monorepo**: 9.0.0 → 10.0.0 (major version bump for significant feature additions) ## **Related issues** Fixes: #777 (Add new typography variants to React Text component) Fixes: #779 (Add new utility props to Box component) Fixes: #781 (Box component utility props fixes) ## **Manual testing steps** ### **Testing Typography Variants** 1. Navigate to Storybook React: `yarn storybook` 2. Go to "Components" → "Text" → "All Stories" 3. Verify all 5 new variants render correctly: - PageHeading (displays as h1) - SectionHeading (displays as h2) - ButtonLabelMd (displays as span) - ButtonLabelLg (displays as span) - AmountDisplayLg (displays as span) 4. Test responsive behavior by resizing browser window 5. Verify font weights, sizes, and spacing match design specifications ### **Testing React Native Components** 1. Navigate to React Native Storybook: `yarn storybook:ios` or `yarn storybook:android` 2. Go to "Components" → "Text" → "All Stories" 3. Verify all 5 new variants render correctly with proper styling 4. Test on both iOS and Android if possible ### **Testing Box Component** 1. Navigate to Storybook and find Box component stories 2. Verify new utility props work correctly: - Margin props (m, mx, my, mt, mr, mb, ml) - Padding props (p, px, py, pt, pr, pb, pl) - Border props and border color props - Background color props 3. Test both React and React Native implementations ### **Testing Build Process** 1. Run `yarn build` to ensure all packages build successfully 2. Run `yarn test` to verify all tests pass 3. Run `yarn lint` to ensure code quality standards are met ## **Screenshots/Recordings** ### **Before** - Text component had 9 typography variants - Box component had limited utility props - Typography system was missing key variants for page structure ### **After** - Text component now has 14 typography variants (9 existing + 5 new) - Box component includes comprehensive utility props for spacing, borders, and colors - Complete typography system supporting semantic HTML structure - Responsive design tokens for all screen sizes - Full TypeScript support with proper type definitions ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.












Description
Summary:
Added 10 new system text styles to support more use-case-specific typography across the UI.
New Styles:
•
L-PageHeading: alias ofL-Heading-Lg•
L-SectionHeading: alias ofL-Heading-Sm•
L-ButtonLabel-Lg: alias ofL-Body-Lg-Medium•
L-ButtonLabel-Md: alias ofL-Body-Md-Medium•
L-AmountDisplay-Lg: alias ofL-Display-Lg•
S-PageHeading: alias ofS-Heading-Lg•
S-SectionHeading: alias ofS-Heading-Sm•
S-ButtonLabel-Lg: alias ofS-Body-Lg-Medium•
S-ButtonLabel-Md: alias ofS-Body-Md-Medium•
S-AmountDisplay-Lg: alias ofS-Display-LgThese are not true aliases (due to JSON limitations), but intentionally mirror the values of their global counterparts. Unlike global styles (e.g., Display, Heading, Body), these system styles are scoped to common patterns from the trading app, such as page headings, button labels, and amount displays, to make them more purposeful, reusable, and consistent across future features.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist