From 6a9e9e129a46f1b6ebdc7622dcf0519b7a582d4e Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sun, 4 Oct 2020 20:43:24 +0530 Subject: [PATCH] theme-switch-button: init feature (#15) * thanks to https://feathericons.com for svgs * can be disabled in site config Params: disableThemeToggle : true --- assets/css/header.css | 16 ++++++++++++++- layouts/partials/footer.html | 20 ++++++++++++++++++- layouts/partials/header.html | 38 +++++++++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/assets/css/header.css b/assets/css/header.css index e12814d8..916e575d 100644 --- a/assets/css/header.css +++ b/assets/css/header.css @@ -16,6 +16,7 @@ .logo, .menu { + display: flex; margin: auto var(--gap); } @@ -24,8 +25,21 @@ font-weight: 700; } +.theme-toggle svg{ + height: 18px; + margin: 0 10px; +} + +body.dark #moon{ + vertical-align: middle; + display: none; +} + +body:not(.dark) #sun { + display: none; +} + .menu { - display: flex; list-style: none; word-break: keep-all; overflow-x: auto; diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index ff5cdd5a..edf86acf 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -44,4 +44,22 @@ function menu_on_scroll() { localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft); } - \ No newline at end of file + +{{- if not .Site.Params.disableThemeToggle }} + +{{- else -}} + + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html index d102a86a..fce0b612 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,14 +1,46 @@ {{- if eq .Site.Params.defaultTheme "auto" }} {{- end }}