diff options
| author | Kyren223 <contact@kyren.codes> | 2026-10-07 03:14:47 +0300 |
|---|---|---|
| committer | Kyren223 <contact@kyren.codes> | 2026-10-07 03:14:47 +0300 |
| commit | 6e70fe447ec9504757fbdc152b5b3697c9af8def (patch) | |
| tree | 4da46c4f479e87e17ac5f786baafff4e285b37c1 /public/theme.js | |
| parent | ba1be9573ef20d6424ae987257a1c727c47d4b53 (diff) | |
Initial iteration
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); |
