summaryrefslogtreecommitdiffhomepage
path: root/packages/app/public/oc-theme-preload.js
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-09 11:57:27 -0600
committeradamelmore <[email protected]>2026-01-09 11:57:31 -0600
commit0f2124db32606020766d237ce774a3c2e7783ee3 (patch)
tree9ebe345ecdb5cf4be8f8dcc88fac042c4980f1a3 /packages/app/public/oc-theme-preload.js
parente30a159264713b045faf784f4799d2626ac9b78c (diff)
downloadopencode-0f2124db32606020766d237ce774a3c2e7783ee3.tar.gz
opencode-0f2124db32606020766d237ce774a3c2e7783ee3.zip
fix(app): no inline js
Diffstat (limited to 'packages/app/public/oc-theme-preload.js')
-rw-r--r--packages/app/public/oc-theme-preload.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/app/public/oc-theme-preload.js b/packages/app/public/oc-theme-preload.js
new file mode 100644
index 000000000..f8c710496
--- /dev/null
+++ b/packages/app/public/oc-theme-preload.js
@@ -0,0 +1,28 @@
+;(function () {
+ var themeId = localStorage.getItem("opencode-theme-id")
+ if (!themeId) return
+
+ var scheme = localStorage.getItem("opencode-color-scheme") || "system"
+ var isDark = scheme === "dark" || (scheme === "system" && matchMedia("(prefers-color-scheme: dark)").matches)
+ var mode = isDark ? "dark" : "light"
+
+ document.documentElement.dataset.theme = themeId
+ document.documentElement.dataset.colorScheme = mode
+
+ if (themeId === "oc-1") return
+
+ var css = localStorage.getItem("opencode-theme-css-" + themeId + "-" + mode)
+ if (css) {
+ var style = document.createElement("style")
+ style.id = "oc-theme-preload"
+ style.textContent =
+ ":root{color-scheme:" +
+ mode +
+ ";--text-mix-blend-mode:" +
+ (isDark ? "plus-lighter" : "multiply") +
+ ";" +
+ css +
+ "}"
+ document.head.appendChild(style)
+ }
+})()