blob: 31cf807b221e5709bd81159bc76adb55d56cb351 (
plain) (
tree)
|
|
function setTheme(theme) {
localStorage.setItem("theme",theme);
var root = document.querySelector(":root");
var rootstyle = getComputedStyle(root);
const black = rootstyle.getPropertyValue("--black");
const white = rootstyle.getPropertyValue("--white");
var bgcol;
var fgcol;
if (theme === "dark") {
bgcol = black;
fgcol = white;
}
else if (theme === "light") {
bgcol = white;
fgcol = black;
}
else {
setTheme("dark");
return;
}
root.style.setProperty("--backgroundColour",bgcol);
root.style.setProperty("--foregroundColour",fgcol);
}
|