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
Fix font-size scaling for text-related CSS properties by using rem
instead of fixed px
values; deprecate $root-font-size
#1169
Conversation
rem
instead of px
in certain SASS unitsrem
instead of px
for all text related CSS properties
A quick light ping for @just-the-docs/reviewers; if anybody has capacity to take a look at this change, that would be great! It will finally resolve all warnings on build, and I'll move on to some other requested work - e.g. automatic theme switching. |
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.
This looks great. I double-checked the math on all the new REM values. Removing the functions.scss file cleans things up nicely. The site builds perfectly (no more depreciation warning about division). Just two comments:
- It's worth mentioning that you decided to go with the non-breaking option to leave the $root-font-size variable. So I think this PR is no longer a breaking change.
- The left padding for blockquotes was changed from 15px to 1rem. This is the only conversion that wasn't exactly equivalent at 16px=1rem. But I don't think it matters— they still look like blockquotes.
Thanks for the quick review @cking0987, and sorry to leave you hanging! Great opportunity to cut a new release and address one of our recent headaches. |
rem
instead of px
for all text related CSS propertiesrem
; deprecate $root-font-size
rem
; deprecate $root-font-size
rem
instead of fixed px
values; deprecate $root-font-size
This PR replaces all uses of
px
in relation to font size (opposed to borders, spacing, etc.) with the equivalentrem
value when the body font size is16px
. The intention is to better scale the website when the user changes the font size for<body>
(often done for accessibility reasons).This PR is technically a breaking change, though it's a minor one (see subheading below). I'm putting this up so that we can discuss it as a community.
(technically closes #1088 and fixes #1073, but let's see if we end up merging this)
mechanics
To do this, I systematically went through every
px
value for all.scss
files. Then, I deleted therem
function, the_functions.scss
file (that was the only function there), and removed the import fromsupport.scss
. A nice side effect of this is that we no longer perform any SASS division.The only remaining uses of
px
are for either:hr
,blockquote
decorative spacing)$root-font-size
(see below)The only pixel value change in this PR is the
padding-left
forblockquote
, which I've changed from15px
to1rem
(which is16px
in the "stock" theme).deprecating
$root-font-size
There's a SCSS variable called
$root-font-size
. It is used in two places:rem()
function.site-title
when printing (i.e. a@print
style)The changes I listed above let us ignore the first case. The second case seems like it has the intention of matching the body font size, so I replaced it with
1rem
.We can choose to leave the variable in (in case others use it in custom code - which I'm sure that some do) and leave a deprecation notice, or just remove it now. I'm leaning towards the former, which is less disruptive.
how users would upgrade
This is a breaking change of some sorts, but the change is very straightforward for users:
$root-font-size
, they need to do nothing; this PR is a no-op.$root-font-size
font-size
ofbody
with the appropriatepx
value$root-font-size
with1rem
(find-and-replace works here)