Skip to content
Permalink
Browse files
Merge pull request #2 from aa9863/master
Update Color Switcher
  • Loading branch information
csx239 committed Dec 11, 2020
2 parents 2044eed + 87b60ac commit 4e7f76d6ce9fa6bdf627900b42b258280bfbf7cb
Showing 1 changed file with 13 additions and 3 deletions.
@@ -5,6 +5,7 @@ darkDiv = document.getElementById("themeDark");

//Check in storage
lightMode = localStorage.getItem("lightMode");
console.log("Light Mode is ", lightMode)
if (lightMode == null){
localStorage.setItem("lightMode", true);
lightMode = true;
@@ -14,7 +15,8 @@ changeTheme();


function changeTheme(){
if (lightMode == true){
lightMode = localStorage.getItem("lightMode");
if (lightMode == "true"){
document.body.setAttribute("data-md-color-scheme", "default");
lightDiv.classList.remove("darkIcon");
darkDiv.classList.add("darkIcon");
@@ -27,7 +29,15 @@ function changeTheme(){
}

toggleDiv.onclick = function(){
lightMode = !lightMode;
console.log("Current Theme is", lightMode)
if (lightMode == "true"){
lightMode = false;
}
else{
lightMode = true;
}


localStorage.setItem("lightMode", lightMode);
changeTheme();
}
}

0 comments on commit 4e7f76d

Please sign in to comment.