Skip to content

Commit

Permalink
Fixed main theme color switch
Browse files Browse the repository at this point in the history
  • Loading branch information
bigois committed Jul 4, 2023
1 parent 00891f6 commit e11b326
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions assets/js/theme-switch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
window.addEventListener("DOMContentLoaded", function() {
const toggleDarkMode = document.getElementById("theme-toggle");

if (localStorage.getItem('theme') === 'light') {
setTheme('light');
if (localStorage.getItem('theme') === null) {
document.documentElement.classList.add('dark-mode');
document.documentElement.classList.remove('light-mode');
localStorage.setItem('theme', 'dark');
} else {
setTheme('dark');
if (localStorage.getItem('theme') === 'light') {
setTheme('light');
} else {
setTheme('dark');
}
}

jtd.addEvent(toggleDarkMode, 'click', function(){
Expand Down

0 comments on commit e11b326

Please sign in to comment.