MCPcopy Create free account
hub / github.com/anomalyco/opencode / applyTheme

Function applyTheme

packages/ui/src/theme/loader.ts:19–30  ·  view source on GitHub ↗
(theme: DesktopTheme, themeId?: string)

Source from the content-addressed store, hash-verified

17}
18
19export function applyTheme(theme: DesktopTheme, themeId?: string): void {
20 activeTheme = theme
21 const lightTokens = resolveThemeVariant(theme.light, false)
22 const darkTokens = resolveThemeVariant(theme.dark, true)
23 const lightV2Tokens = resolveThemeVariantV2(theme.light, false)
24 const darkV2Tokens = resolveThemeVariantV2(theme.dark, true)
25 const targetThemeId = themeId ?? theme.id
26 const css = buildThemeCss(lightTokens, darkTokens, lightV2Tokens, darkV2Tokens, targetThemeId)
27 const themeStyleElement = ensureLoaderStyleElement()
28 themeStyleElement.textContent = css
29 document.documentElement.setAttribute("data-theme", targetThemeId)
30}
31
32function buildThemeCss(
33 light: ResolvedTheme,

Callers

nothing calls this directly

Calls 4

resolveThemeVariantFunction · 0.90
resolveThemeVariantV2Function · 0.90
buildThemeCssFunction · 0.85
ensureLoaderStyleElementFunction · 0.85

Tested by

no test coverage detected