blob: 25debbabb7e12fdf35abc2697d3d348649db16e7 (
plain) (
tree)
|
|
enum Theme {
Light,
Dark,
}
function setTheme(theme: Theme) {
let is_valid_theme =
theme == Theme.Light
|| theme == Theme.Dark;
if (!is_valid_theme) {
console.log("invalid theme \"" + theme + "\"");
// Use default:
theme = Theme.Dark;
}
console.log("setting theme to `" + Theme[theme] + "`");
let body = document.getElementById("body")!;
body.setAttribute("data-theme", Theme[theme]);
localStorage.setItem("theme", JSON.stringify(theme));
}
|