Skip to content

Commit

Permalink
feat(css): refine dark mode support with auto_dark_mode option (def…
Browse files Browse the repository at this point in the history
…ault on)
  • Loading branch information
sparanoid committed Aug 24, 2019
1 parent 980c16d commit 4c936d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 3 additions & 0 deletions _app/_data/curtana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ clean_homepage: false
# Style post link color (if defined) for article list
# Default: false
colorful_list: false

# Enable dark mode automatically via `prefers-color-scheme: dark`
auto_dark_mode: false
12 changes: 12 additions & 0 deletions _app/_includes/themes/curtana/includes/css-variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
{% endif %}
}

{%- comment -%} Dark mode overrides, that's all we need for dark mode {%- endcomment -%}
{% if site.data.curtana.auto_dark_mode %}
@media (prefers-color-scheme: dark) {
:root {
--text-color-l: 95%;
--bg-color-l: 14%;
--bg-color-s: 2%;
--code-color-l: calc(var(--link-color-l) * 1.3);
}
}
{% endif %}

body {
{% if page.scheme-bg-img %}
{% assign first = true %}
Expand Down
7 changes: 1 addition & 6 deletions _app/assets/_scss/_user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@

// EXAMPLE: amsf.github.io custom appearance
:root {
--code-color-h: calc(var(--link-color-h) + 30);
--code-color-h: calc(var(--link-color-h) + 10);
--code-color-s: calc(var(--link-color-s) * .2 + 40%);

@media (prefers-color-scheme: dark) {
// Code should be lighter in dark mode
--code-color-l: calc(var(--link-color-l) * 1.3);
}
}

.content .sub-title {
Expand Down
1 change: 1 addition & 0 deletions _app/assets/themes/curtana/_scss/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ body:hover .latest {
margin: 0 0 1.8rem;
border: none;
border-bottom: 1px solid var(--text-color);
background: inherit;

// Remove border-radius for iOS devices
border-radius: 0;
Expand Down
6 changes: 0 additions & 6 deletions _app/assets/themes/curtana/_scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,4 @@ $breakpoint-xs: 400px !default;
--code-color-90: hsla(var(--code-color-hsl), .9);
--code-color-light: hsl(var(--code-color-h), var(--code-color-s), calc(var(--code-color-l) / .9));
--code-color-dark: hsl(var(--code-color-h), var(--code-color-s), calc(var(--code-color-l) * .9));

// Dark mode overrides, that's all we need for dark mode
@media (prefers-color-scheme: dark) {
--text-color-l: 95%;
--bg-color-l: 5%;
}
}

0 comments on commit 4c936d0

Please sign in to comment.