summaryrefslogtreecommitdiff
path: root/public/theme.js
diff options
context:
space:
mode:
authorKyren223 <contact@kyren.codes>2026-10-07 03:14:47 +0300
committerKyren223 <contact@kyren.codes>2026-10-07 03:14:47 +0300
commit6e70fe447ec9504757fbdc152b5b3697c9af8def (patch)
tree4da46c4f479e87e17ac5f786baafff4e285b37c1 /public/theme.js
parentba1be9573ef20d6424ae987257a1c727c47d4b53 (diff)
Initial iteration
Diffstat (limited to 'public/theme.js')
-rw-r--r--public/theme.js12
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);