-
Notifications
You must be signed in to change notification settings - Fork 1k
USWDS - Icon list: Allow $theme-body-font-size to accept all size tokens #5363
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
Conversation

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.
Intuitive and effective!
- Updating
$theme-body-font-size
with2xs
and3xs
correctly updated icon list - No compilation errors with listed values
- Compilation errors correctly when using an unaccepted value
- No noted visual regression

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.
Nice fix, all type scale settings are now supported!
Warning
Added note about increased size in compiled CSS file at the end.
Items tested
- No compile errors
- Icon list generates sizes based on all size tokens 1
Alternate testing
You can visit the variant Icon List Custom Size and change icon size via StorybookJS controls.
Storybook adds a textarea you can use to test the generated values.
Values tested
uswds/packages/uswds-core/src/styles/tokens/font/type-scale.scss
Lines 1 to 23 in 0395273
$system-type-scale: ( | |
"micro": 10px, | |
1: 12px, | |
2: 13px, | |
3: 14px, | |
4: 15px, | |
5: 16px, | |
6: 17px, | |
7: 18px, | |
8: 20px, | |
9: 22px, | |
10: 24px, | |
11: 28px, | |
12: 32px, | |
13: 36px, | |
14: 40px, | |
15: 48px, | |
16: 56px, | |
17: 64px, | |
18: 80px, | |
19: 120px, | |
20: 140px, | |
); |
uswds/packages/uswds-core/src/styles/variables/type-scale.scss
Lines 1 to 18 in d5a7fb0
@use "../functions/general"; | |
@use "../functions/font/system-type-scale" as *; | |
@use "../settings"; | |
@use "../tokens/font/type-scale" as *; | |
$project-type-scale: ( | |
"3xs": system-type-scale(settings.$theme-type-scale-3xs), | |
"2xs": system-type-scale(settings.$theme-type-scale-2xs), | |
"xs": system-type-scale(settings.$theme-type-scale-xs), | |
"sm": system-type-scale(settings.$theme-type-scale-sm), | |
"md": system-type-scale(settings.$theme-type-scale-md), | |
"lg": system-type-scale(settings.$theme-type-scale-lg), | |
"xl": system-type-scale(settings.$theme-type-scale-xl), | |
"2xl": system-type-scale(settings.$theme-type-scale-2xl), | |
"3xl": system-type-scale(settings.$theme-type-scale-3xl), | |
); | |
$all-type-scale: general.map-collect($system-type-scale, $project-type-scale); |
Footnotes
-
⚠️ Warning: Compiled CSS file size increases.620KB on develop
vs659KB on al-icon-list-scale
↩
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.
Good callout on the compiled CSS size increase, though I think this fix is good to go as-is and the impact on minified CSS should be minimal
Summary
Updated icon list styles to allow
$theme-body-font-size
to accept2xs
and3xs
size tokens.Breaking change
This is not a breaking change.
Related issue
Issue #5357
Related PR
Changelog and documentation update PR
Preview link
Preview link: Icon list component
Problem statement
Icon list styles are preventing users from setting
$theme-body-font-size
to2xs
or3xs
size tokens.Solution
Currently, the icon list styles rely on a component-specific map ($theme-body-font-sizes) to translate acceptable token values. This map does not include
2xs
or3xs
sizes.Because icon list styles rely on $theme-body-font-size as a fallback when it can't find a value in
$theme-body-font-sizes
, it doesn't know what to do when$theme-body-font-size
is set to2xs
or3xs
. It cannot translate the value.To allow these missing size tokens, as well as remove the need for maintaining a component-specific map, this PR uses the system
$all-type-scale
in place of$theme-body-font-sizes
. The $all-type-scale variable inuswds-core
combines $project-type-scale and $system-type-scale maps.Considerations
2xs
and3xs
from the icon list sizes. If so, we should build an alternate solution.Testing and review
$theme-body-font-size
, including "2xs" and "3xs"