Tentatively add a dark mode

This commit is contained in:
Danila Fedorin 2023-03-11 11:52:49 -08:00
parent 9594b699f8
commit c631be65bc
4 changed files with 61 additions and 16 deletions

View File

@ -1,9 +1,20 @@
@import "variables.scss"; @import "variables.scss";
$code-color-lineno: grey; $code-color-lineno: grey;
$code-color-keyword: black;
$code-color-type: black; :root {
$code-color-comment: grey; --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;
@ -21,7 +32,7 @@ $code-color-comment: grey;
code { code {
font-family: $font-code; font-family: $font-code;
background-color: $code-color; background-color: var(--code-color);
border: $code-border; border: $code-border;
padding: 0 0.25rem 0 0.25rem; padding: 0 0.25rem 0 0.25rem;
} }
@ -37,7 +48,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: $code-color; background-color: var(--code-color);
border-radius: 0; border-radius: 0;
border: $code-border; border: $code-border;
display: block; display: block;
@ -84,14 +95,14 @@ pre code {
.kr, .k { .kr, .k {
font-weight: bold; font-weight: bold;
color: $code-color-keyword; color: var(--code-color-keyword);
} }
.kt { .kt {
font-weight: bold; font-weight: bold;
color: $code-color-type; color: var(--code-color-type);
} }
.c, .c1 { .c, .c1 {
color: $code-color-comment; color: var(--code-color-comment);
} }

View File

@ -3,6 +3,8 @@
@import "toc.scss"; @import "toc.scss";
body { body {
background-color: var(--background-color);
color: var(--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;
@ -22,7 +24,7 @@ h1, h2, h3, h4, h5, h6 {
text-align: center; text-align: center;
&:target { &:target {
background-color: lighten(yellow, 30%); background-color: var(--target-background-color);
border-radius: 1rem; border-radius: 1rem;
} }
@ -88,7 +90,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: black; color: var(--text-color);
display: inline-block; display: inline-block;
border-bottom: none; border-bottom: none;
white-space: nowrap; white-space: nowrap;
@ -128,7 +130,7 @@ h6 {
} }
a { a {
color: black; color: var(--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;
@ -139,7 +141,8 @@ a {
} }
img { img {
max-width: 100% max-width: 100%;
background-color: white;
} }
table { table {
@ -231,6 +234,7 @@ ul.post-list {
figure { figure {
img { img {
border-radius: 0.5rem;
max-width: 70%; max-width: 70%;
display: block; display: block;
margin: auto; margin: auto;
@ -268,8 +272,8 @@ figure {
.warning { .warning {
@include bordered-block; @include bordered-block;
padding: 0.5rem; padding: 0.5rem;
background-color: #ffee99; background-color: var(--warning-background-color);
border-color: #f5c827; border-color: var(--warning-border-color);
} }
.feather { .feather {

View File

@ -2,7 +2,6 @@
@import "mixins.scss"; @import "mixins.scss";
@import "margin.scss"; @import "margin.scss";
$toc-color: $code-color;
$toc-border-color: $code-border-color; $toc-border-color: $code-border-color;
.table-of-contents { .table-of-contents {
@ -46,7 +45,7 @@ $toc-border-color: $code-border-color;
div.wrapper { div.wrapper {
@include bordered-block; @include bordered-block;
padding: 1rem; padding: 1rem;
background-color: $toc-color; background-color: var(--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%;

View File

@ -5,12 +5,43 @@ $standard-border-width: .075rem;
$primary-color: #36e281; $primary-color: #36e281;
$border-color: #bfbfbf; $border-color: #bfbfbf;
$background-color: white;
$background-color-dark: #1b1d1f;
$code-color: #f0f0f0; $code-color: #f0f0f0;
$code-color-dark: lighten($background-color-dark, 10%);
$code-border-color: darken($code-color, 10%); $code-border-color: darken($code-color, 10%);
$font-heading: "Lora", serif; $font-heading: "Lora", serif;
$font-body: "Raleway", serif; $font-body: "Raleway", serif;
$font-code: "Inconsolata", monospace; $font-code: "Inconsolata", monospace;
$warning-background-color: #ffee99;
$warning-border-color: #f5c827;
$warning-background-color-dark: #75640a;
$warning-border-color-dark: $warning-background-color;
$target-background-color: lighten(yellow, 30%);
$target-background-color-dark: #55511c;
$standard-border: $standard-border-width solid $border-color; $standard-border: $standard-border-width solid $border-color;
$code-border: $standard-border-width solid $code-border-color; $code-border: $standard-border-width solid $code-border-color;
:root {
--background-color: #{$background-color};
--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) {
:root {
--background-color: #{$background-color-dark};
--text-color: white;
--code-color: #{$code-color-dark};
--warning-background-color: #{$warning-background-color-dark};
--warning-border-color: #{$warning-border-color-dark};
--target-background-color: #{$target-background-color-dark};
}
}