-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add new typography tokens to variables and utilities #2245
Conversation
|
src/base/base.scss
Outdated
@@ -15,7 +15,7 @@ button { | |||
body { | |||
font-family: $body-font; | |||
font-size: $body-font-size; | |||
line-height: $body-line-height; | |||
line-height: var(--primer-text-body-lineHeight-medium, $body-line-height); |
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.
@vdepizzol I'm a bit concerned about this one. It seems like most typography settings actually just fallback to this line-height on the body. I did set explicit line-height values on all the headings in PCSS, but there might be more in dotcom that we don't see reflected here. Any thoughts?
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.
@langermank I think it makes sense to keep the body
line-height
at 1.5
, and then apply the body-lineHeight-medium
token to any component that requires the body-medium typography style. Wdyt?
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.
Sounds good to me! I wonder if we should add font-size
and line-height
to the p
tag in typography-base
🤔
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.
Confirm that the mixins I deleted aren't being used
Generally I haven't seen mixins being used much outside of PCSS. That said, if we remove them, should we mark this PR as a major
change so that it won't break anything?
I have an open question that I’m struggling a bit with… do y'all have any thoughts on performance and overhead, and how it relates to this work? Because in a lot of cases we’re essentially going from shipping .text-light: 300; to shipping :root {
--base-text-weight-light: 300;
}
.text-light {
font-weight: var(--base-text-weight-light, 300) !important;
} In this example about 17 characters to define one style rule, to about 117 characters in total. I feel like we’re at risk of ballooning the size of the bundle(s) by applying this approach broadly, and in many instances (including this one) I'm not sure if we're adding value with the new abstraction layer. We obviously want the source of truth to be the design tokens but… could we do that in some other way? Do we need these values to stay CSS vars as we distribute |
@simurai excellent point. I think for this PR, I'm actually going to put them back in so we can get away with a patch here for testing. Then, once we're ready to roll out without fallbacks we can cut a major release where we remove unused code etc etc. |
Let's not forget we use gzip; so character count is less important as repetition is deduplicated. So while characters go from 45 to 123 (173% increase), the byte gz byte count goes from 62 to 100 (105% size increase): $ echo '.text-light { font-weight: 300 !important; }' | wc -c
45
$ echo '.text-light { font-weight: 300 !important; }' | gzip -c9 | wc -c
62
$ echo ':root {
--base-text-weight-light: 300;
}
.text-light {
font-weight: var(--base-text-weight-light, 300) !important;
}' | wc -c
123
$ echo ':root {
--base-text-weight-light: 300;
}
.text-light {
font-weight: var(--base-text-weight-light, 300) !important;
}' | gzip -c9 | wc -c
100 Brotli is even better due to the shared dictionary: $ echo '.text-light { font-weight: 300 !important; }' | gzip -c9 | wc -c
40
$ echo ':root {
--base-text-weight-light: 300;
}
.text-light {
font-weight: var(--base-text-weight-light, 300) !important;
}' | brotli | wc -c
93 |
@tobiasahlin thanks for raising this! I started a discussion so we can gather some insight on how to proceed. Regardless of where this discussion goes, we'll need to use CSS variables for this initial test so we can provide a fallback to support everything outside of our feature flag. I'd love to move forward with this PR, and once we're satisfied with the test we'll use whatever method we agree on for utility classes later 🙌 |
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
Closing in favor of #2302 |
What are you trying to accomplish?
This swaps in the new typography design tokens to our existing variables and utilities. Since this is all behind a feature flag in dotcom, it seems like the easiest way to test is by replacing the values of existing vars/utils.
What approach did you choose and why?
Since the new tokens are behind a feature flag, we rely on fallbacks for general support. In this PR, I chose to use the fallback slot for the original value rather than a 1-1 map to the new design token. That way, there should be no visual changes in dotcom while we still have the feature flag in place.
For any variable that does not have a fallback, that's because the original CSS didn't specify a value in the first place. The browser will just ignore it if it can't find the variable.
What should reviewers focus on?
Can these changes ship as is?