From 8e38f1fa591f6c0718f0f93f2aac4adffe9030cf Mon Sep 17 00:00:00 2001 From: Mathieu Ledru Date: Sun, 3 Oct 2021 02:20:44 +0200 Subject: [PATCH] :lipstick: localStorage fix --- docs/assets/js/darkmode-init.js | 33 --------------------------------- docs/assets/js/darkmode.js | 15 +-------------- 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 docs/assets/js/darkmode-init.js diff --git a/docs/assets/js/darkmode-init.js b/docs/assets/js/darkmode-init.js deleted file mode 100644 index fd96c862..00000000 --- a/docs/assets/js/darkmode-init.js +++ /dev/null @@ -1,33 +0,0 @@ -const globalDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; -const localMode = localStorage.getItem('theme'); - -if (globalDark && (localMode === null)) { - - localStorage.setItem('theme', 'light'); - document.documentElement.classList.add('data-light-mode'); - -} - -if (globalDark && (localMode === 'dark')) { - - document.documentElement.classList.add('data-dark-mode'); - -} - -if (globalDark && (localMode === 'sepia')) { - - document.documentElement.classList.add('data-sepia-mode'); - -} - -if (localMode === 'dark') { - - document.documentElement.classList.add('data-dark-mode'); - -} - -if (localMode === 'sepia') { - - document.documentElement.classList.add('data-sepia-mode'); - -} diff --git a/docs/assets/js/darkmode.js b/docs/assets/js/darkmode.js index 2119e597..1bceefc7 100644 --- a/docs/assets/js/darkmode.js +++ b/docs/assets/js/darkmode.js @@ -1,25 +1,12 @@ -const globalDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; const localMode = localStorage.getItem('theme'); -if (globalDark && (localMode === null)) { +if (localMode === null) { localStorage.setItem('theme', 'light'); document.documentElement.classList.add('data-light-mode'); } -if (globalDark && (localMode === 'dark')) { - - document.documentElement.classList.add('data-dark-mode'); - -} - -if (globalDark && (localMode === 'sepia')) { - - document.documentElement.classList.add('data-sepia-mode'); - -} - if (localMode === 'dark') { document.documentElement.classList.add('data-dark-mode');