Skip to content

Commit

Permalink
💄 localStorage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matyo91 committed Oct 3, 2021
1 parent 57afd68 commit 8e38f1f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
33 changes: 0 additions & 33 deletions docs/assets/js/darkmode-init.js

This file was deleted.

15 changes: 1 addition & 14 deletions docs/assets/js/darkmode.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down

0 comments on commit 8e38f1f

Please sign in to comment.