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)
110 lines
1.5 KiB
SCSS
110 lines
1.5 KiB
SCSS
// Base element style overrides
|
|
// stylelint-disable selector-no-type, selector-max-type, selector-max-specificity, selector-max-id
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html {
|
|
@include fs-4;
|
|
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
body {
|
|
font-family: $body-font-family;
|
|
font-size: inherit;
|
|
line-height: $body-line-height;
|
|
color: $body-text-color;
|
|
background-color: $body-background-color;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
ol,
|
|
ul,
|
|
dl,
|
|
pre,
|
|
address,
|
|
blockquote,
|
|
table,
|
|
div,
|
|
hr,
|
|
form,
|
|
fieldset,
|
|
noscript .table-wrapper {
|
|
margin-top: 0;
|
|
}
|
|
|
|
h1,
|
|
h2,
|
|
h3,
|
|
h4,
|
|
h5,
|
|
h6,
|
|
#toctitle {
|
|
margin-top: 0;
|
|
margin-bottom: 1em;
|
|
font-weight: 500;
|
|
line-height: $body-heading-line-height;
|
|
color: $body-heading-color;
|
|
}
|
|
|
|
p {
|
|
margin-top: 1em;
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
a {
|
|
color: $link-color;
|
|
text-decoration: none;
|
|
}
|
|
|
|
a:not([class]) {
|
|
text-decoration: underline;
|
|
text-decoration-color: $border-color;
|
|
text-underline-offset: 2px;
|
|
|
|
&:hover {
|
|
text-decoration-color: rgba($link-color, 0.45);
|
|
}
|
|
}
|
|
|
|
code {
|
|
font-family: $mono-font-family;
|
|
font-size: 0.75em;
|
|
line-height: $body-line-height;
|
|
}
|
|
|
|
figure,
|
|
pre {
|
|
margin: 0;
|
|
}
|
|
|
|
li {
|
|
margin: 0.25em 0;
|
|
}
|
|
|
|
img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
}
|
|
|
|
hr {
|
|
height: 1px;
|
|
padding: 0;
|
|
margin: $sp-6 0;
|
|
background-color: $border-color;
|
|
border: 0;
|
|
}
|
|
|
|
// adds a GitHub-style sidebar to blockquotes
|
|
blockquote {
|
|
margin: 10px 0;
|
|
|
|
// resets user-agent stylesheets for blockquotes
|
|
margin-block-start: 0;
|
|
margin-inline-start: 0;
|
|
padding-left: 1rem;
|
|
border-left: 3px solid $border-color;
|
|
}
|