diff options
Diffstat (limited to 'public/theme.js')
| -rw-r--r-- | public/theme.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/public/theme.js b/public/theme.js new file mode 100644 index 0000000..90bd1de --- /dev/null +++ b/public/theme.js @@ -0,0 +1,12 @@ +async function applyStyle(path, name) { + const res = await fetch(`${path}/${encodeURIComponent(name)}`); + if (!res.ok) return false; + for (const [key, value] of Object.entries(await res.json())) { + document.documentElement.style.setProperty(`--${key}`, value); + } + return true; +} + +window.setStyle = (path, name) => applyStyle(path, name); +window.setTheme = (name) => applyStyle("/theme", name); +window.setFontPack = (name) => applyStyle("/font-pack", name); |
