Skip to content
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

Switch for line-height to values calculated in relative magnitude, instead of pixels #1978

Open
burashka opened this issue Dec 4, 2024 · 0 comments

Comments

@burashka
Copy link

burashka commented Dec 4, 2024

Switch for line-height to values calculated in relative magnitude, instead of pixels, as the variable itself is set. It is necessary because the line-height must be in a dimensionless value, since this is a font parameter and should depend on the font size. This is an inherited value, so it affects not only the element to which it is assigned, but also any nested ones, which gives an incorrect result when using a dimensional value, even if it is not pixels but a different dimension. In addition, this is an accessibility error, since the font will not necessarily be the size that the site author sets.

This is briefly discussed on the MDN page for line-height (accessibility is also mentioned above on the page):
https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#prefer_unitless_numbers_for_line-height_values

Example:

    --g-text-body-1-line-height-rel: #{calc(math.div(18, 13))};
    --g-text-body-2-line-height-rel: #{calc(math.div(20, 15))};
    --g-text-body-3-line-height-rel: #{calc(math.div(24, 17))};
    --g-text-body-short-line-height-rel: #{calc(math.div(16, 13))};
    --g-text-caption-1-line-height-rel: #{calc(math.div(12, 9))};
    --g-text-caption-2-line-height-rel: #{calc(math.div(16, 11))};
    --g-text-header-1-line-height-rel: #{calc(math.div(24, 20))};
    --g-text-header-2-line-height-rel: #{calc(math.div(28, 24))};
    --g-text-subheader-1-line-height-rel: #{calc(math.div(18, 13))};
    --g-text-subheader-2-line-height-rel: #{calc(math.div(20, 15))};
    --g-text-subheader-3-line-height-rel: #{calc(math.div(24, 17))};
    --g-text-display-1-line-height-rel: #{calc(math.div(36, 28))};
    --g-text-display-2-line-height-rel: #{calc(math.div(40, 32))};
    --g-text-display-3-line-height-rel: #{calc(math.div(48, 40))};
    --g-text-display-4-line-height-rel: #{calc(math.div(52, 48))};
    --g-text-code-1-line-height-rel: #{calc(math.div(18, 12))};
    --g-text-code-2-line-height-rel: #{calc(math.div(20, 14))};
    --g-text-code-3-line-height-rel: #{calc(math.div(24, 16))};
    --g-text-code-inline-1-line-height-rel: #{calc(math.div(14, 12))};
    --g-text-code-inline-2-line-height-rel: #{calc(math.div(16, 14))};
    --g-text-code-inline-3-line-height-rel: #{calc(math.div(20, 16))};
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

No branches or pull requests

1 participant