From 09f9cbc0192f129dd15163048acfe18414aa303d Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Mon, 14 Nov 2022 16:13:25 -0600 Subject: [PATCH 1/4] Init fix --- .../discourse/initializers/dark-light-toggle-hamburger.js | 8 +++++++- settings.yml | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js index d1e72cc..a4f4592 100644 --- a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js +++ b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js @@ -70,6 +70,7 @@ Have you selected two different themes for your dark/light schemes in user prefe lightTheme.media = "none"; Session.currentProp("defaultColorSchemeIsDark", true); + Session.currentProp("darkModeAvailable", true) }; let switchToLight = function () { @@ -81,6 +82,7 @@ Have you selected two different themes for your dark/light schemes in user prefe darkTheme.media = "none"; Session.currentProp("defaultColorSchemeIsDark", false); + Session.currentProp("darkModeAvailable", false) }; let switchToAuto = function () { @@ -93,8 +95,10 @@ Have you selected two different themes for your dark/light schemes in user prefe if (window?.matchMedia("(prefers-color-scheme: dark)").matches) { Session.currentProp("defaultColorSchemeIsDark", true); + Session.currentProp("darkModeAvailable", true) } else { Session.currentProp("defaultColorSchemeIsDark", false); + Session.currentProp("darkModeAvailable", false) } }; @@ -198,7 +202,9 @@ Have you selected two different themes for your dark/light schemes in user prefe }, }); - if (settings.add_color_scheme_toggle_to_header) { + // with new sidebar rolling out, this will be the main option of showing + // allow those who dont use sidebar to remove from header + if (!settings.remove_color_scheme_toggle_from_header) { api.addToHeaderIcons("dark-light-toggle"); } diff --git a/settings.yml b/settings.yml index cafc938..da7cdad 100644 --- a/settings.yml +++ b/settings.yml @@ -2,7 +2,7 @@ svg_icons: default: "moon|sun" type: "list" list_type: "compact" -add_color_scheme_toggle_to_header: +remove_color_scheme_toggle_from_header: default: false type: bool - description: "Add color scheme toggle button to site header" + description: "Do not show color scheme toggle button in site header" From a09455c8ce68ea78b0af78657619873437b37758 Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Mon, 14 Nov 2022 16:17:57 -0600 Subject: [PATCH 2/4] prettier --- .../discourse/initializers/dark-light-toggle-hamburger.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js index a4f4592..f90d54d 100644 --- a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js +++ b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js @@ -70,7 +70,7 @@ Have you selected two different themes for your dark/light schemes in user prefe lightTheme.media = "none"; Session.currentProp("defaultColorSchemeIsDark", true); - Session.currentProp("darkModeAvailable", true) + Session.currentProp("darkModeAvailable", true); }; let switchToLight = function () { @@ -82,7 +82,7 @@ Have you selected two different themes for your dark/light schemes in user prefe darkTheme.media = "none"; Session.currentProp("defaultColorSchemeIsDark", false); - Session.currentProp("darkModeAvailable", false) + Session.currentProp("darkModeAvailable", false); }; let switchToAuto = function () { @@ -95,10 +95,10 @@ Have you selected two different themes for your dark/light schemes in user prefe if (window?.matchMedia("(prefers-color-scheme: dark)").matches) { Session.currentProp("defaultColorSchemeIsDark", true); - Session.currentProp("darkModeAvailable", true) + Session.currentProp("darkModeAvailable", true); } else { Session.currentProp("defaultColorSchemeIsDark", false); - Session.currentProp("darkModeAvailable", false) + Session.currentProp("darkModeAvailable", false); } }; From 7adde92121dddb4754b55418efa0ae344a3bd92e Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Mon, 14 Nov 2022 17:42:07 -0600 Subject: [PATCH 3/4] more --- .../discourse/initializers/dark-light-toggle-hamburger.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js index f90d54d..1e6ee6c 100644 --- a/javascripts/discourse/initializers/dark-light-toggle-hamburger.js +++ b/javascripts/discourse/initializers/dark-light-toggle-hamburger.js @@ -213,6 +213,7 @@ Have you selected two different themes for your dark/light schemes in user prefe click() { toggleDarkLight(); + this.scheduleRerender(); }, html() { @@ -251,6 +252,7 @@ Have you selected two different themes for your dark/light schemes in user prefe } else { switchToAuto(); } + this.scheduleRerender(); }, html() { From 44273d5a7a591ebe6370d8961c695beb3f42d174 Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Mon, 14 Nov 2022 17:46:33 -0600 Subject: [PATCH 4/4] more --- settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.yml b/settings.yml index da7cdad..763da41 100644 --- a/settings.yml +++ b/settings.yml @@ -3,6 +3,6 @@ svg_icons: type: "list" list_type: "compact" remove_color_scheme_toggle_from_header: - default: false + default: true type: bool description: "Do not show color scheme toggle button in site header"