mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-10 14:01:22 -06:00
This PR replaces all uses of `px` in relation to font size (opposed to borders, spacing, etc.) with the equivalent `rem` value when the body font size is `16px`. 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 the `rem` function, the `_functions.scss` file (that was the only function there), and removed the import from `support.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: - border-related properties - shadow-related properties - sizing for "non-text" elements (ex `hr`, `blockquote` decorative spacing) - `$root-font-size` (see below) The only pixel value change in this PR is the `padding-left` for `blockquote`, which I've changed from `15px` to `1rem` (which is `16px` in the "stock" theme). ## deprecating `$root-font-size` There's a SCSS variable called `$root-font-size`. It is used in two places: 1. the `rem()` function 2. the `.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: 1. If they do not change `$root-font-size`, they need to do nothing; this PR is a no-op. 2. if they do change `$root-font-size` - they should instead set the `font-size` of `body` with the appropriate `px` value - optionally, they can replace all custom code that uses `$root-font-size` with `1rem` (find-and-replace works here)
34 lines
707 B
SCSS
34 lines
707 B
SCSS
// Media query
|
|
|
|
// Media query mixin
|
|
// Usage:
|
|
// @include mq(md) {
|
|
// ..medium and up styles
|
|
// }
|
|
@mixin mq($name) {
|
|
// Retrieves the value from the key
|
|
$value: map-get($media-queries, $name);
|
|
|
|
// If the key exists in the map
|
|
@if $value {
|
|
// Prints a media query based on the value
|
|
@media (min-width: $value) {
|
|
@content;
|
|
}
|
|
} @else {
|
|
@warn "No value could be retrieved from `#{$media-query}`. Please make sure it is defined in `$media-queries` map.";
|
|
}
|
|
}
|
|
|
|
// Responsive container
|
|
|
|
@mixin container {
|
|
padding-right: $gutter-spacing-sm;
|
|
padding-left: $gutter-spacing-sm;
|
|
|
|
@include mq(md) {
|
|
padding-right: $gutter-spacing;
|
|
padding-left: $gutter-spacing;
|
|
}
|
|
}
|