-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: removing unneeded typography classnames from the tailwind preset #117
Conversation
@@ -20,6 +20,61 @@ describe('Typography', () => { | |||
'--typography-l-heading-sm-regular-line-height', | |||
'--typography-l-heading-sm-regular-font-weight', | |||
'--typography-l-heading-sm-regular-letter-spacing', | |||
'--typography-s-body-lg-regular-font-family', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added all the removed variables to the ignore list. We have a test in place to ensure all typography variables are used. In a future design-tokens version, these variables will be removed as they are now deprecated.
bd562d1
to
852f0e0
Compare
@@ -33,7 +33,7 @@ const typographyClassMap: Record<TextVariant, string> = { | |||
[TextVariant.HeadingSm]: | |||
'text-s-heading-sm font-s-heading-sm leading-s-heading-sm tracking-s-heading-sm lg:text-l-heading-sm lg:font-l-heading-sm lg:leading-l-heading-sm lg:tracking-l-heading-sm', | |||
[TextVariant.BodyLg]: | |||
'text-s-body-lg-medium font-s-body-lg-medium leading-s-body-lg-medium tracking-s-body-lg-medium lg:text-l-body-lg-medium lg:font-l-body-lg-medium lg:leading-l-body-lg-medium lg:tracking-l-body-lg-medium', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing font weight prefix from Text
component
852f0e0
to
debbd12
Compare
@@ -5,29 +5,18 @@ export const typography = { | |||
's-heading-lg': 'var(--typography-s-heading-lg-font-size)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
's-body-lg-regular': 'var(--typography-s-body-lg-regular-font-size)', | ||
's-body-md-bold': 'var(--typography-s-body-md-bold-font-size)', | ||
's-body-md-medium': 'var(--typography-s-body-md-medium-font-size)', | ||
's-body-lg': 'var(--typography-s-body-lg-regular-font-size)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately our Token Studio had to generate CSS variables that mirrored the Figma styles so we don't have any css variables without the font weight prefix
'l-body-lg-medium': 'var(--typography-l-body-lg-medium-font-weight)', | ||
'l-body-md-bold': 'var(--typography-l-body-md-bold-font-weight)', | ||
'l-body-md-medium': 'var(--typography-l-body-md-medium-font-weight)', | ||
'l-body-lg': 'var(--font-weight-regular)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we forgot to create the CSS variables for large screen so falling back to the font weight token here
debbd12
to
56ffadf
Compare
's-body-lg-regular': 'var(--typography-s-body-lg-regular-font-weight)', | ||
's-body-md-bold': 'var(--typography-s-body-md-bold-font-weight)', | ||
's-body-md-medium': 'var(--typography-s-body-md-medium-font-weight)', | ||
's-body-lg': 'var(--font-weight-regular)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--typography-l-body-lg-regular-letter-spacing
CSS token incorrectly points to medium? so falling back to root font weight token here too
https://github.com/MetaMask/design-tokens/blob/main/src/css/typography.css#L73
Description
This PR removes unused font weight variants from the Tailwind preset classname generation. Previously, font weights such as
body-md-medium
andbody-md-bold
were included, wheremedium
andbold
specified font weights. With this update, we no longer use these variants. Instead, font weight is now managed through thefontWeight
prop, aligning with recent deprecations aimed at simplifying the styling logic. This change reduces confusion and improves maintainability by eliminating redundant classnames.Related issues
Fixes: N/A (Part of Text component)
Manual testing steps
packages/design-system-tailwind-preset/src/typography.ts
fileScreenshots/ Screen Recordings
Before
Recording showing incorrect medium weight
BodyLg
variantbefore720.mov
Recording showing many suffixed classnames with font weights
before72.mov
After
Recording showing fixed
BodyLg
variantafter720.mov
Recording showing only suffixes that remain are CSS variables and tests
after720.mov
Pre-merge author checklist
Pre-merge reviewer checklist