Skip to content

[Design Token] Added 5 new text styles for trade-app alignment#777

Merged
georgewrmarshall merged 4 commits intomainfrom
ta-type-token-alignment
Jul 16, 2025
Merged

[Design Token] Added 5 new text styles for trade-app alignment#777
georgewrmarshall merged 4 commits intomainfrom
ta-type-token-alignment

Conversation

@Akatori-Design
Copy link
Contributor

@Akatori-Design Akatori-Design commented Jul 14, 2025

Description

Summary:
Added 10 new system text styles to support more use-case-specific typography across the UI.

New Styles:
L-PageHeading : alias of L-Heading-Lg
L-SectionHeading : alias of L-Heading-Sm
L-ButtonLabel-Lg : alias of L-Body-Lg-Medium
L-ButtonLabel-Md : alias of L-Body-Md-Medium
L-AmountDisplay-Lg : alias of L-Display-Lg
S-PageHeading : alias of S-Heading-Lg
S-SectionHeading : alias of S-Heading-Sm
S-ButtonLabel-Lg : alias of S-Body-Lg-Medium
S-ButtonLabel-Md : alias of S-Body-Md-Medium
S-AmountDisplay-Lg : alias of S-Display-Lg

These 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.

image image

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

@Akatori-Design Akatori-Design requested a review from a team as a code owner July 14, 2025 23:04
@Akatori-Design Akatori-Design changed the title [Design Token] Added 5 new text styles (total of 10 new objects) [Design Token] Added 5 new text styles for trade-app alignment Jul 14, 2025
@github-actions
Copy link
Contributor

📖 Storybook Preview

@amandaye0h
Copy link
Contributor

Are we planning to support semibold as a weight option? Noticing that the headers use semibold (600), not bold (700):
Screenshot 2025-07-16 at 4 02 23 AM

Akatori-Design and others added 3 commits July 16, 2025 16:17
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)

-
@georgewrmarshall georgewrmarshall force-pushed the ta-type-token-alignment branch from 7e4eb23 to abe12ad Compare July 16, 2025 23:20
Comment on lines +54 to +62
// Add optimizeDeps configuration to handle workspace packages
config.optimizeDeps = {
...config.optimizeDeps,
exclude: [
'@metamask/design-tokens',
'@metamask/design-system-react',
'@metamask/design-system-tailwind-preset',
],
};
Copy link
Contributor

@georgewrmarshall georgewrmarshall Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes an issue with storybook. Not exactly sure why it has started now.

Screenshot 2025-07-16 at 4 21 37 PM Screenshot 2025-07-16 at 4 21 39 PM

@github-actions
Copy link
Contributor

📖 Storybook Preview

- `TextVariant.ButtonLabelMd`
- `TextVariant.ButtonLabelLg`
- `TextVariant.AmountDisplayLg`

Copy link
Contributor

@georgewrmarshall georgewrmarshall Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSRN docs

Screenshot 2025-07-16 at 4 28 04 PM

Storybook

Screenshot 2025-07-16 at 4 27 36 PM

[TextVariant.ButtonLabelLg]: typography.sButtonLabelLg
.fontWeight as FontWeight,
[TextVariant.AmountDisplayLg]: typography.sAmountDisplayLg
.fontWeight as FontWeight,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSRN Text constants

SectionHeading = 'section-heading',
ButtonLabelMd = 'button-label-md',
ButtonLabelLg = 'button-label-lg',
AmountDisplayLg = 'amount-display-lg',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSRN TextVariants

@@ -102,6 +102,46 @@ Use the `variant` prop and the `TextVariant` enum from `@metamask/design-system-
<code>p</code>
</td>
</tr>
Copy link
Contributor

@georgewrmarshall georgewrmarshall Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSR Text docs

Screenshot 2025-07-16 at 4 25 24 PM

'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]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Contributor

@georgewrmarshall georgewrmarshall Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSRN Text variant stories

Screenshot 2025-07-16 at 4 24 43 PM

BodySm = 'body-sm',
BodyXs = 'body-xs',

// Special Typography Variants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating DSR TextVariant types

@@ -10,6 +10,11 @@ export const typography = {
's-body-md': 'var(--typography-s-body-md-font-size)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating tailwind preset with new tokens

@@ -76,6 +76,46 @@ export const typographyTailwindConfig: TypographyTailwindConfigProps = {
fontWeight: typography.sBodyXS.fontWeight,
},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating twrnc with new tokens

@@ -96,6 +96,26 @@
--typography-s-body-xs-line-height: var(--line-height-2);
Copy link
Contributor

@georgewrmarshall georgewrmarshall Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating CSS file

Screenshot 2025-07-16 at 4 32 09 PM Screenshot 2025-07-16 at 4 32 13 PM


// Helper function to convert token name to CSS variable name
const tokenNameToCSSVariable = (tokenName: string): string => {
return `--typography-${tokenName.toLowerCase().replace(/-/gu, '-')}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing typography test to allow kebab case for the new type tokens

@@ -634,6 +634,66 @@
},
"type": "typography"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figma json updates from @Akatori-Design

@@ -20,6 +20,11 @@ export type ThemeTypography = {
sBodySMBold: TypeStyle;
sBodyXS: TypeStyle;
sBodyXSMedium: TypeStyle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating JS

Screenshot 2025-07-16 at 4 30 47 PM Screenshot 2025-07-16 at 4 31 03 PM

<code>var(--typography-s-body-xs-letter-spacing)</code>
</td>
</tr>
<tr>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating docs

Screenshot 2025-07-16 at 4 31 36 PM

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@georgewrmarshall georgewrmarshall requested a review from Copilot July 16, 2025 23:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@brianacnguyen brianacnguyen added this pull request to the merge queue Jul 16, 2025
@georgewrmarshall georgewrmarshall removed this pull request from the merge queue due to the queue being cleared Jul 16, 2025
@github-actions
Copy link
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall merged commit aab0bab into main Jul 16, 2025
38 checks passed
@georgewrmarshall georgewrmarshall deleted the ta-type-token-alignment branch July 16, 2025 23:58
@georgewrmarshall georgewrmarshall changed the title [Design Token] Added 5 new text styles for trade-app alignment feat: added 5 new text styles for trade-app alignment Jul 17, 2025
@georgewrmarshall georgewrmarshall changed the title feat: added 5 new text styles for trade-app alignment [Design Token] Added 5 new text styles for trade-app alignment Jul 17, 2025
@georgewrmarshall georgewrmarshall mentioned this pull request Jul 17, 2025
7 tasks
georgewrmarshall added a commit that referenced this pull request Jul 17, 2025
## **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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants