Moving to new theme

This commit is contained in:
Fabian
2019-06-18 22:55:04 +02:00
parent 560828f4a2
commit 0b56f9b1a8
21 changed files with 268 additions and 462 deletions

27
src/theme.ts Normal file
View File

@ -0,0 +1,27 @@
const light = require("!!raw-loader!@hibas123/theme/out/light.css").default;
const dark = require("!!raw-loader!@hibas123/theme/out/dark.css").default;
let isDark = localStorage.getItem("theme") === "dark";
let styleElm: HTMLStyleElement;
function apply() {
if (styleElm) styleElm.remove();
styleElm = document.createElement("style");
document.head.appendChild(styleElm);
styleElm.innerHTML = isDark ? dark : light;
}
apply();
function toggle() {
isDark = !isDark;
localStorage.setItem("theme", isDark ? "dark" : "light");
apply();
}
export default {
active: () => isDark,
toggle: () => toggle()
}