From f37d24b23738b9fd03bb77a86bacf98cf354f72c Mon Sep 17 00:00:00 2001 From: Shrill Shrestha Date: Fri, 5 Feb 2021 11:10:50 -0600 Subject: [PATCH 1/2] Add darkmode to subpages --- _sass/page.scss | 4 ++-- assets/js/darkmode.js | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/_sass/page.scss b/_sass/page.scss index 5d0f887..97fdffc 100644 --- a/_sass/page.scss +++ b/_sass/page.scss @@ -51,7 +51,7 @@ body { .page h2 { text-align: left !important; font-weight: 800 !important; - color: $text_color; + color: inherit; font-size: $fontsize_h2; margin-bottom: 0.5em; } @@ -70,7 +70,7 @@ body { } .page p { - color: $text_color; + color: inherit; font-weight: 500; } diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js index 4e5fb57..84f983c 100644 --- a/assets/js/darkmode.js +++ b/assets/js/darkmode.js @@ -4,25 +4,37 @@ let toogleStatus = document.getElementById('check-mode'); let bodyElement = document.getElementsByTagName('body')[0]; let navLogo = document.getElementsByClassName('nav-logo')[0]; let cards = document.getElementsByClassName('card'); +let container = document.getElementsByClassName('page'); +console.log(imode); if(imode == "true"){ toogleStatus.checked = true; - darkmode() + darkmode(); } function darkmode(){ if(toogleStatus.checked){ bodyElement.className += " " + "darkmode"; navLogo.className += " " + "darkmode"; - for(let i = 0; i < cards.length; i++){ - cards[i].className += " " + "alt-background"; + if(cards){ + for(let i = 0; i < cards.length; i++){ + cards[i].className += " " + "alt-background"; + } + } + if(container[0]){ + container[0].className += " " + "darkmode"; } localStorage.setItem("isDark", true); }else{ bodyElement.classList.remove('darkmode'); navLogo.classList.remove('darkmode'); - for(let i = 0; i < cards.length; i++){ - cards[i].classList.remove('alt-background'); + if(cards){ + for(let i = 0; i < cards.length; i++){ + cards[i].classList.remove('alt-background'); + } + } + if(container[0]){ + container[0].classList.remove("darkmode"); } localStorage.setItem("isDark", false); } From 5ade2d3bfd3ee82dfcf4ff0a38220ce671a28b9c Mon Sep 17 00:00:00 2001 From: Shrill Shrestha Date: Fri, 5 Feb 2021 11:17:21 -0600 Subject: [PATCH 2/2] fix footer dark mode --- assets/js/darkmode.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js index 84f983c..3de45f3 100644 --- a/assets/js/darkmode.js +++ b/assets/js/darkmode.js @@ -5,6 +5,7 @@ let bodyElement = document.getElementsByTagName('body')[0]; let navLogo = document.getElementsByClassName('nav-logo')[0]; let cards = document.getElementsByClassName('card'); let container = document.getElementsByClassName('page'); +let footer = document.getElementsByClassName('footer'); console.log(imode); if(imode == "true"){ @@ -24,6 +25,9 @@ function darkmode(){ if(container[0]){ container[0].className += " " + "darkmode"; } + if(footer[0]){ + footer[0].className += " " + "darkmode"; + } localStorage.setItem("isDark", true); }else{ bodyElement.classList.remove('darkmode'); @@ -36,6 +40,9 @@ function darkmode(){ if(container[0]){ container[0].classList.remove("darkmode"); } + if(footer[0]){ + footer[0].classList.remove("darkmode"); + } localStorage.setItem("isDark", false); } }