MCPcopy Create free account
hub / github.com/arctic-cli/interface / resolveColor

Function resolveColor

packages/arctic/src/settings/server.ts:22–39  ·  view source on GitHub ↗
(
  value: ColorValue,
  defs: Record<string, string>,
  theme: ThemeJson["theme"],
  mode: "dark" | "light",
)

Source from the content-addressed store, hash-verified

20type ColorValue = string | { dark: string; light: string }
21
22function resolveColor(
23 value: ColorValue,
24 defs: Record<string, string>,
25 theme: ThemeJson["theme"],
26 mode: "dark" | "light",
27): string {
28 if (typeof value === "object" && "dark" in value) {
29 value = value[mode]
30 }
31 if (typeof value === "string") {
32 if (value === "transparent" || value === "none") return "transparent"
33 if (value.startsWith("#") || value.startsWith("rgba(")) return value
34 if (defs[value]) return resolveColor(defs[value], defs, theme, mode)
35 const themeValue = theme[value as keyof typeof theme]
36 if (themeValue) return resolveColor(themeValue as ColorValue, defs, theme, mode)
37 }
38 return value as string
39}
40
41function resolveThemeColors(themeJson: ThemeJson, mode: "dark" | "light"): Record<string, string> {
42 const defs = themeJson.defs ?? {}

Callers 1

resolveThemeColorsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected