From c4ce9f5bd350e1f00acaf7be0230044b7c422839 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sun, 20 Sep 2020 14:26:29 +0100 Subject: [PATCH] feat(menu): change palette icon to moon + add option to hide search - a static moon icon is currently commonly used by popular sites such as Facebook and Reddit to represent a light/dark chooser - fix automatic light/dark theming when the chooser is hidden with `show_day_night` set to `false` - add boolean `show_search` option to `main_menu` in `params.toml` to hide search button from main (still accessible from the standard / keyboard shortcut) --- wowchemy/assets/js/academic.js | 5 +++-- wowchemy/assets/js/load-theme.js | 2 +- wowchemy/layouts/_default/baseof.html | 2 +- wowchemy/layouts/partials/navbar.html | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wowchemy/assets/js/academic.js b/wowchemy/assets/js/academic.js index 0ed7574d..181abe22 100644 --- a/wowchemy/assets/js/academic.js +++ b/wowchemy/assets/js/academic.js @@ -336,9 +336,10 @@ * Change Theme Mode (0: Day, 1: Night, 2: Auto). * --------------------------------------------------------------------------- */ + // TODO: import theme functions from load-theme.js to avoid duplication. function canChangeTheme() { - // If the theme changer component is present, then user is allowed to change the theme variation. - return $('.js-theme-selector').length; + // If var is set, then user is allowed to change the theme variation. + return Boolean(window.wcDarkLightEnabled); } function getThemeMode() { diff --git a/wowchemy/assets/js/load-theme.js b/wowchemy/assets/js/load-theme.js index 748214e2..f7bb6f31 100644 --- a/wowchemy/assets/js/load-theme.js +++ b/wowchemy/assets/js/load-theme.js @@ -5,7 +5,7 @@ function canChangeTheme() { // If var is set, then user is allowed to change the theme variation. - return Boolean(window.staDarkLightChooser); + return Boolean(window.wcDarkLightEnabled); } function initThemeVariation() { diff --git a/wowchemy/layouts/_default/baseof.html b/wowchemy/layouts/_default/baseof.html index 80366aa0..2e974d76 100644 --- a/wowchemy/layouts/_default/baseof.html +++ b/wowchemy/layouts/_default/baseof.html @@ -11,7 +11,7 @@ {{/* Load day/night theme. */}} {{/* Initialise default theme. */}} {{ if site.Params.day_night }} - + {{ end }} {{ if eq (.Scratch.Get "light") true }} diff --git a/wowchemy/layouts/partials/navbar.html b/wowchemy/layouts/partials/navbar.html index c39a203d..258d8e6b 100644 --- a/wowchemy/layouts/partials/navbar.html +++ b/wowchemy/layouts/partials/navbar.html @@ -139,7 +139,8 @@