Skip to content

Commit

Permalink
Update changeTheme.js
Browse files Browse the repository at this point in the history
  • Loading branch information
DogukanUrker committed Dec 15, 2023
1 parent 6996c04 commit 9849612
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion static/js/changeTheme.js
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
// πŸš€
var root = document.querySelector(":root");
var changeTheme = document.querySelector(".changeTheme");

var theme;

if (localStorage.getItem(theme) === "dark") {
toDark();
} else if (localStorage.getItem(theme) === "light") {
toLight();
}

function toLight() {
localStorage.setItem(theme, "light");
root.style.setProperty("--themePrimary", "#000");
root.style.setProperty("--themeSecondary", "#fff");
root.style.setProperty("--themeHelper", "#303030");
changeTheme.innerHTML = "🌞";
changeTheme.setAttribute("onclick", "javascript: toDark();");
}

function toDark() {
localStorage.setItem(theme, "dark");
root.style.setProperty("--themePrimary", "#fff");
root.style.setProperty("--themeSecondary", "#000");
root.style.setProperty("--themeHelper", "#C6C6C6");
changeTheme.innerHTML = "🌚";
changeTheme.setAttribute("onclick", "javascript: toLight();");
}

0 comments on commit 9849612

Please sign in to comment.