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)
117 lines
3.5 KiB
SCSS
117 lines
3.5 KiB
SCSS
// Typography
|
|
|
|
$body-font-family: system-ui, -apple-system, blinkmacsystemfont, "Segoe UI",
|
|
roboto, "Helvetica Neue", arial, sans-serif !default;
|
|
$mono-font-family: "SFMono-Regular", menlo, consolas, monospace !default;
|
|
$root-font-size: 16px !default; // DEPRECATED: previously base font-size for rems
|
|
$body-line-height: 1.4 !default;
|
|
$content-line-height: 1.6 !default;
|
|
$body-heading-line-height: 1.25 !default;
|
|
|
|
// Font size
|
|
// `-sm` suffix is the size at the small (and above) media query
|
|
|
|
$font-size-1: 0.5625rem !default;
|
|
$font-size-1-sm: 0.625rem !default;
|
|
$font-size-2: 0.6875rem !default; // h4 - uppercased!, h6 not uppercased, text-small
|
|
$font-size-3: 0.75rem !default; // h5
|
|
$font-size-4: 0.875rem !default;
|
|
$font-size-5: 1rem !default; // h3
|
|
$font-size-6: 1.125rem !default; // h2
|
|
$font-size-7: 1.5rem !default;
|
|
$font-size-8: 2rem !default; // h1
|
|
$font-size-9: 2.25rem !default;
|
|
$font-size-10: 2.625rem !default;
|
|
$font-size-10-sm: 3rem !default;
|
|
|
|
// Colors
|
|
|
|
$white: #fff !default;
|
|
$grey-dk-000: #959396 !default;
|
|
$grey-dk-100: #5c5962 !default;
|
|
$grey-dk-200: #44434d !default;
|
|
$grey-dk-250: #302d36 !default;
|
|
$grey-dk-300: #27262b !default;
|
|
$grey-lt-000: #f5f6fa !default;
|
|
$grey-lt-100: #eeebee !default;
|
|
$grey-lt-200: #ecebed !default;
|
|
$grey-lt-300: #e6e1e8 !default;
|
|
$purple-000: #7253ed !default;
|
|
$purple-100: #5e41d0 !default;
|
|
$purple-200: #4e26af !default;
|
|
$purple-300: #381885 !default;
|
|
$blue-000: #2c84fa !default;
|
|
$blue-100: #2869e6 !default;
|
|
$blue-200: #264caf !default;
|
|
$blue-300: #183385 !default;
|
|
$green-000: #41d693 !default;
|
|
$green-100: #11b584 !default;
|
|
$green-200: #009c7b !default;
|
|
$green-300: #026e57 !default;
|
|
$yellow-000: #ffeb82 !default;
|
|
$yellow-100: #fadf50 !default;
|
|
$yellow-200: #f7d12e !default;
|
|
$yellow-300: #e7af06 !default;
|
|
$red-000: #f77e7e !default;
|
|
$red-100: #f96e65 !default;
|
|
$red-200: #e94c4c !default;
|
|
$red-300: #dd2e2e !default;
|
|
|
|
// Spacing
|
|
|
|
$spacing-unit: 1rem; // 1rem == 16px
|
|
|
|
$spacers: (
|
|
sp-0: 0,
|
|
sp-1: $spacing-unit * 0.25,
|
|
sp-2: $spacing-unit * 0.5,
|
|
sp-3: $spacing-unit * 0.75,
|
|
sp-4: $spacing-unit,
|
|
sp-5: $spacing-unit * 1.5,
|
|
sp-6: $spacing-unit * 2,
|
|
sp-7: $spacing-unit * 2.5,
|
|
sp-8: $spacing-unit * 3,
|
|
sp-9: $spacing-unit * 3.5,
|
|
sp-10: $spacing-unit * 4,
|
|
) !default;
|
|
$sp-1: map-get($spacers, sp-1) !default; // 0.25 rem == 4px
|
|
$sp-2: map-get($spacers, sp-2) !default; // 0.5 rem == 8px
|
|
$sp-3: map-get($spacers, sp-3) !default; // 0.75 rem == 12px
|
|
$sp-4: map-get($spacers, sp-4) !default; // 1 rem == 16px
|
|
$sp-5: map-get($spacers, sp-5) !default; // 1.5 rem == 24px
|
|
$sp-6: map-get($spacers, sp-6) !default; // 2 rem == 32px
|
|
$sp-7: map-get($spacers, sp-7) !default; // 2.5 rem == 40px
|
|
$sp-8: map-get($spacers, sp-8) !default; // 3 rem == 48px
|
|
$sp-9: map-get($spacers, sp-9) !default; // 3.5 rem == 56px
|
|
$sp-10: map-get($spacers, sp-10) !default; // 4 rem == 64px
|
|
|
|
// Borders
|
|
|
|
$border: 1px solid !default;
|
|
$border-radius: 4px !default;
|
|
$border-color: $grey-lt-100 !default;
|
|
|
|
// Grid system
|
|
|
|
$gutter-spacing: $sp-6 !default;
|
|
$gutter-spacing-sm: $sp-4 !default;
|
|
$nav-width: 16.5rem !default;
|
|
$nav-width-md: 15.5rem !default;
|
|
$nav-list-item-height: $sp-6 !default;
|
|
$nav-list-item-height-sm: $sp-8 !default;
|
|
$nav-list-expander-right: true;
|
|
$content-width: 50rem !default;
|
|
$header-height: 3.75rem !default;
|
|
$search-results-width: $content-width - $nav-width !default;
|
|
$transition-duration: 400ms;
|
|
|
|
// Media queries in pixels
|
|
|
|
$media-queries: (
|
|
xs: 20rem,
|
|
sm: 31.25rem,
|
|
md: $content-width,
|
|
lg: $content-width + $nav-width,
|
|
xl: 87.5rem,
|
|
) !default;
|