diff --git a/_config.yml b/_config.yml
index 4ee6056..3182dc3 100644
--- a/_config.yml
+++ b/_config.yml
@@ -140,7 +140,11 @@ gh_edit_branch: "main" # the branch that your docs is served from
gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
# Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define
-color_scheme: nil
+color_scheme: auto
+color_scheme_options:
+ enable_localstorage: true
+ enable_switch: true
+ switch_options: ["auto", "light", "dark"]
callouts_level: quiet # or loud
callouts:
diff --git a/_includes/components/aux_nav.html b/_includes/components/aux_nav.html
index f327da6..a6a17e2 100644
--- a/_includes/components/aux_nav.html
+++ b/_includes/components/aux_nav.html
@@ -11,5 +11,12 @@
{% endfor %}
+ {% if site.color_scheme_options and site.color_scheme_options.switch_options %}
+
+
+
+ {% endif %}
diff --git a/_includes/components/header.html b/_includes/components/header.html
index f9c3386..c754c17 100644
--- a/_includes/components/header.html
+++ b/_includes/components/header.html
@@ -5,7 +5,7 @@
{% endif %}
{% include header_custom.html %}
- {% if site.aux_links %}
+ {% if site.aux_links or site.color_scheme_options and site.color_scheme_options.switch_options %}
{% include components/aux_nav.html %}
{% endif %}
diff --git a/_includes/head.html b/_includes/head.html
index 1ef8c0a..2bd1354 100644
--- a/_includes/head.html
+++ b/_includes/head.html
@@ -5,7 +5,7 @@
Results in: HTML for the head element.
Includes:
head_nav.html, head_custom.html.
- Overwrites:
+ Overwrites:
ga_tracking_ids, ga_property, file, favicon.
Should not be cached, because included files depend on page.
{%- endcomment -%}
@@ -14,8 +14,49 @@
-
-
+ {% if site.color_scheme_options and site.color_scheme_options.enable_localstorage %}
+
+ {% else %}
+ {% case site.color_scheme %}
+ {% when "auto" %}
+
+
+ {% when nil %}
+
+ {% else %}
+
+ {% endcase %}
+ {% endif %}
+
{% include head_nav.html %}
{% if site.ga_tracking != nil %}
diff --git a/_includes/head_nav.html b/_includes/head_nav.html
index 00ad569..2534bdb 100644
--- a/_includes/head_nav.html
+++ b/_includes/head_nav.html
@@ -4,7 +4,7 @@
Results in: HTML for a page-specific style element.
Includes:
css/activation.scss.liquid.
- Overwrites:
+ Overwrites:
activation, test_scss, scss, css, index, count.
Should not be cached, because css/activation.scss.liquid depends on page.
{%- endcomment -%}
@@ -28,7 +28,7 @@
{%- assign color_scheme = "light" -%}
{%- endif %}
@import "./color_schemes/light";
- {% unless color_scheme == "light" %}
+ {% unless color_scheme == "light" or color_scheme == "auto" %}
@import "./color_schemes/{{ color_scheme }}";
{% endunless %}
{{ activation }}
diff --git a/_includes/icons/icons.html b/_includes/icons/icons.html
index 007a495..982e637 100644
--- a/_includes/icons/icons.html
+++ b/_includes/icons/icons.html
@@ -10,4 +10,7 @@
{% if site.enable_copy_code_button != false %}
{% include icons/code_copy.html %}
{% endif %}
+ {% if site.color_scheme_options and site.color_scheme_options.enable_switch %}
+ {% include icons/switch_color_scheme.html %}
+ {% endif %}
diff --git a/_includes/icons/switch_color_scheme.html b/_includes/icons/switch_color_scheme.html
new file mode 100644
index 0000000..9f1f861
--- /dev/null
+++ b/_includes/icons/switch_color_scheme.html
@@ -0,0 +1,29 @@
+
+
+ Following system colour scheme
+
+
+
+ Selected dark colour scheme
+
+
+
+ Selected light colour scheme
+
+
diff --git a/_sass/layout.scss b/_sass/layout.scss
index 027b388..b5af044 100644
--- a/_sass/layout.scss
+++ b/_sass/layout.scss
@@ -140,11 +140,32 @@
}
}
+button.site-button {
+ background: none;
+ border: none;
+}
+
.site-button {
display: flex;
height: 100%;
padding: $gutter-spacing-sm;
align-items: center;
+
+ .site-button-icon {
+ width: #{$sp-4 * 1.2};
+ height: #{$sp-4 * 1.2};
+ align-self: center;
+ color: $grey-dk-000;
+ cursor: pointer;
+ }
+
+ &:hover,
+ &:focus,
+ &:active {
+ .site-button-icon {
+ color: $link-color;
+ }
+ }
}
@include mq(md) {
diff --git a/assets/css/just-the-docs-default.scss b/assets/css/just-the-docs-default.scss
index 63fde26..e938c03 100644
--- a/assets/css/just-the-docs-default.scss
+++ b/assets/css/just-the-docs-default.scss
@@ -1,6 +1,6 @@
---
---
-{% if site.color_scheme and site.color_scheme != "nil" %}
+{% if site.color_scheme and site.color_scheme != "nil" and site.color_scheme != "auto" %}
{% assign color_scheme = site.color_scheme %}
{% else %}
{% assign color_scheme = "light" %}
diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js
index 87fa9b5..080b401 100644
--- a/assets/js/just-the-docs.js
+++ b/assets/js/just-the-docs.js
@@ -41,7 +41,7 @@ function initNav() {
const siteNav = document.getElementById('site-nav');
const mainHeader = document.getElementById('main-header');
const menuButton = document.getElementById('menu-button');
-
+
disableHeadStyleSheet();
jtd.addEvent(menuButton, 'click', function(e){
@@ -72,7 +72,7 @@ function initNav() {
}
// The page-specific