mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
29 lines
865 B
JavaScript
29 lines
865 B
JavaScript
;(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)
|
|
}
|
|
})()
|