Add fallbacks to CSS variables for older browsers
This commit is contained in:
parent
c631be65bc
commit
0bd55bc58a
|
@ -1,21 +1,5 @@
|
||||||
@import "variables.scss";
|
@import "variables.scss";
|
||||||
|
|
||||||
$code-color-lineno: grey;
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--code-color-keyword: black;
|
|
||||||
--code-color-type: black;
|
|
||||||
--code-color-comment: grey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
:root {
|
|
||||||
--code-color-keyword: #{darken(white, 40%)};
|
|
||||||
--code-color-type: #{darken(white, 40%)};
|
|
||||||
--code-color-comment: grey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-label {
|
.highlight-label {
|
||||||
padding: 0.25rem 0.5rem 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem 0.25rem 0.5rem;
|
||||||
border: $code-border;
|
border: $code-border;
|
||||||
|
@ -32,7 +16,7 @@ $code-color-lineno: grey;
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-family: $font-code;
|
font-family: $font-code;
|
||||||
background-color: var(--code-color);
|
@include var(background-color, code-color);
|
||||||
border: $code-border;
|
border: $code-border;
|
||||||
padding: 0 0.25rem 0 0.25rem;
|
padding: 0 0.25rem 0 0.25rem;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +32,7 @@ pre code {
|
||||||
.lntable {
|
.lntable {
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
padding: 0.5rem 0 0.5rem 0;
|
padding: 0.5rem 0 0.5rem 0;
|
||||||
background-color: var(--code-color);
|
@include var(background-color, code-color);
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
border: $code-border;
|
border: $code-border;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -80,7 +64,7 @@ pre code {
|
||||||
.lnt {
|
.lnt {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 0 1rem 0 1rem;
|
padding: 0 1rem 0 1rem;
|
||||||
color: $code-color-lineno;
|
color: $code-lineno-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hl {
|
.hl {
|
||||||
|
@ -95,14 +79,14 @@ pre code {
|
||||||
|
|
||||||
.kr, .k {
|
.kr, .k {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: var(--code-color-keyword);
|
@include var(color, code-keyword-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kt {
|
.kt {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: var(--code-color-type);
|
@include var(color, code-type-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.c, .c1 {
|
.c, .c1 {
|
||||||
color: var(--code-color-comment);
|
color: $code-comment-color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
@import "variables.scss";
|
@import "variables.scss";
|
||||||
@import "mixins.scss";
|
@import "mixins.scss";
|
||||||
|
|
||||||
$margin-width: 30rem;
|
|
||||||
$margin-inner-offset: 0.5rem;
|
|
||||||
$margin-outer-offset: 1rem;
|
|
||||||
|
|
||||||
@mixin below-two-margins {
|
@mixin below-two-margins {
|
||||||
@media screen and
|
@media screen and
|
||||||
(max-width: $container-width-threshold +
|
(max-width: $container-width-threshold +
|
||||||
|
|
21
assets/scss/modes.scss
Normal file
21
assets/scss/modes.scss
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
:root {
|
||||||
|
@each $varName, $varDefault in $css-vars {
|
||||||
|
--#{$varName}: #{$varDefault};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--background-color: #{$background-color-dark};
|
||||||
|
--text-color: white;
|
||||||
|
|
||||||
|
--warning-background-color: #{$warning-background-color-dark};
|
||||||
|
--warning-border-color: #{$warning-border-color-dark};
|
||||||
|
|
||||||
|
--target-background-color: #{$target-background-color-dark};
|
||||||
|
|
||||||
|
--code-color: #{$code-color-dark};
|
||||||
|
--code-keyword-color: #{$code-token-color-dark};
|
||||||
|
--code-type-color: #{$code-token-color-dark};
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,9 +2,6 @@
|
||||||
@import "mixins.scss";
|
@import "mixins.scss";
|
||||||
@import "margin.scss";
|
@import "margin.scss";
|
||||||
|
|
||||||
$sidenote-padding: 1rem;
|
|
||||||
$sidenote-highlight-border-width: .2rem;
|
|
||||||
|
|
||||||
.sidenote {
|
.sidenote {
|
||||||
&:hover {
|
&:hover {
|
||||||
.sidenote-label {
|
.sidenote-label {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
@import "variables.scss";
|
@import "variables.scss";
|
||||||
@import "mixins.scss";
|
@import "mixins.scss";
|
||||||
@import "toc.scss";
|
@import "toc.scss";
|
||||||
|
@import "modes.scss";
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: var(--background-color);
|
@include var(background-color, background-color);
|
||||||
color: var(--text-color);
|
@include var(color, text-color);
|
||||||
font-family: $font-body;
|
font-family: $font-body;
|
||||||
font-size: 1.0rem;
|
font-size: 1.0rem;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
@ -24,7 +25,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
&:target {
|
&:target {
|
||||||
background-color: var(--target-background-color);
|
@include var(background-color, target-background-color);
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ nav {
|
||||||
a {
|
a {
|
||||||
padding: 0.25rem 0.75rem 0.25rem .75rem;
|
padding: 0.25rem 0.75rem 0.25rem .75rem;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--text-color);
|
@include var(color, text-color);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@ -130,7 +131,7 @@ h6 {
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--text-color);
|
@include var(color, text-color);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-bottom: .2rem solid $primary-color;
|
border-bottom: .2rem solid $primary-color;
|
||||||
transition: color 0.25s;
|
transition: color 0.25s;
|
||||||
|
@ -272,8 +273,8 @@ figure {
|
||||||
.warning {
|
.warning {
|
||||||
@include bordered-block;
|
@include bordered-block;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
background-color: var(--warning-background-color);
|
@include var(background-color, warning-background-color);
|
||||||
border-color: var(--warning-border-color);
|
@include var(border-color, warning-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.feather {
|
.feather {
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
@import "mixins.scss";
|
@import "mixins.scss";
|
||||||
@import "margin.scss";
|
@import "margin.scss";
|
||||||
|
|
||||||
$toc-border-color: $code-border-color;
|
|
||||||
|
|
||||||
.table-of-contents {
|
.table-of-contents {
|
||||||
@include margin-content;
|
@include margin-content;
|
||||||
@include margin-content-left;
|
@include margin-content-left;
|
||||||
|
@ -45,7 +43,7 @@ $toc-border-color: $code-border-color;
|
||||||
div.wrapper {
|
div.wrapper {
|
||||||
@include bordered-block;
|
@include bordered-block;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
background-color: var(--code-color);
|
@include var(background-color, code-color);
|
||||||
border-color: $toc-border-color;
|
border-color: $toc-border-color;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
$container-width: 45rem;
|
$container-width: 45rem;
|
||||||
$container-min-padding: 1rem;
|
$container-min-padding: 1rem;
|
||||||
$container-width-threshold: $container-width + 2 * $container-min-padding;
|
$container-width-threshold: $container-width + 2 * $container-min-padding;
|
||||||
$standard-border-width: .075rem;
|
|
||||||
|
|
||||||
$primary-color: #36e281;
|
$primary-color: #36e281;
|
||||||
$border-color: #bfbfbf;
|
$border-color: #bfbfbf;
|
||||||
$background-color: white;
|
$background-color: white;
|
||||||
$background-color-dark: #1b1d1f;
|
$background-color-dark: #1b1d1f;
|
||||||
$code-color: #f0f0f0;
|
$standard-border-width: .075rem;
|
||||||
$code-color-dark: lighten($background-color-dark, 10%);
|
$standard-border: $standard-border-width solid $border-color;
|
||||||
$code-border-color: darken($code-color, 10%);
|
|
||||||
|
|
||||||
$font-heading: "Lora", serif;
|
$font-heading: "Lora", serif;
|
||||||
$font-body: "Raleway", serif;
|
$font-body: "Raleway", serif;
|
||||||
|
@ -23,25 +21,40 @@ $warning-border-color-dark: $warning-background-color;
|
||||||
$target-background-color: lighten(yellow, 30%);
|
$target-background-color: lighten(yellow, 30%);
|
||||||
$target-background-color-dark: #55511c;
|
$target-background-color-dark: #55511c;
|
||||||
|
|
||||||
$standard-border: $standard-border-width solid $border-color;
|
$code-color: #f0f0f0;
|
||||||
|
$code-color-dark: lighten($background-color-dark, 10%);
|
||||||
|
$code-token-color: black;
|
||||||
|
$code-token-color-dark: darken(white, 40%);
|
||||||
|
$code-border-color: darken($code-color, 10%);
|
||||||
|
$code-lineno-color: grey;
|
||||||
|
$code-comment-color: grey;
|
||||||
$code-border: $standard-border-width solid $code-border-color;
|
$code-border: $standard-border-width solid $code-border-color;
|
||||||
|
|
||||||
:root {
|
$sidenote-padding: 1rem;
|
||||||
--background-color: #{$background-color};
|
$sidenote-highlight-border-width: .2rem;
|
||||||
--text-color: black;
|
|
||||||
--code-color: #{$code-color};
|
|
||||||
--warning-background-color: #{$warning-background-color};
|
|
||||||
--warning-border-color: #{$warning-border-color};
|
|
||||||
--target-background-color: #{$target-background-color};
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
$margin-width: 30rem;
|
||||||
:root {
|
$margin-inner-offset: 0.5rem;
|
||||||
--background-color: #{$background-color-dark};
|
$margin-outer-offset: 1rem;
|
||||||
--text-color: white;
|
|
||||||
--code-color: #{$code-color-dark};
|
$toc-border-color: $code-border-color;
|
||||||
--warning-background-color: #{$warning-background-color-dark};
|
|
||||||
--warning-border-color: #{$warning-border-color-dark};
|
// Default values for CSS variables for fallback.
|
||||||
--target-background-color: #{$target-background-color-dark};
|
$css-vars: (
|
||||||
}
|
background-color: $background-color,
|
||||||
|
text-color: black,
|
||||||
|
|
||||||
|
warning-background-color: $warning-background-color,
|
||||||
|
warning-border-color: $warning-border-color,
|
||||||
|
|
||||||
|
target-background-color: $target-background-color,
|
||||||
|
|
||||||
|
code-color: $code-color,
|
||||||
|
code-keyword-color: $code-token-color,
|
||||||
|
code-type-color: $code-token-color,
|
||||||
|
);
|
||||||
|
|
||||||
|
@mixin var($property, $varName) {
|
||||||
|
#{$property}: map-get($css-vars, $varName);
|
||||||
|
#{$property}: var(--#{$varName});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user