fix: allow for theme references (#4450)

This commit is contained in:
OpeOginni 2025-11-18 21:26:42 +01:00 committed by GitHub
parent 3068e7dcf7
commit 59f127a250
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -132,7 +132,16 @@ function resolveTheme(theme: ThemeJson, mode: "dark" | "light") {
if (c instanceof RGBA) return c
if (typeof c === "string") {
if (c === "transparent" || c === "none") return RGBA.fromInts(0, 0, 0, 0)
return c.startsWith("#") ? RGBA.fromHex(c) : resolveColor(defs[c])
if (c.startsWith("#")) return RGBA.fromHex(c)
if (defs[c]) {
return resolveColor(defs[c])
} else if (theme.theme[c as keyof Theme]) {
return resolveColor(theme.theme[c as keyof Theme])
} else {
throw new Error(`Color reference "${c}" not found in defs or theme`)
}
}
return resolveColor(c[mode])
}