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

Function buildThemeCss

packages/ui/src/theme/loader.ts:32–76  ·  view source on GitHub ↗
(
  light: ResolvedTheme,
  dark: ResolvedTheme,
  lightV2: ResolvedV2Theme,
  darkV2: ResolvedV2Theme,
  themeId: string,
)

Source from the content-addressed store, hash-verified

30}
31
32function buildThemeCss(
33 light: ResolvedTheme,
34 dark: ResolvedTheme,
35 lightV2: ResolvedV2Theme,
36 darkV2: ResolvedV2Theme,
37 themeId: string,
38): string {
39 const isDefaultTheme = themeId === "oc-2"
40 const lightCss = `${themeToCss(light)}\n ${themeV2ToCss(lightV2)}`
41 const darkCss = `${themeToCss(dark)}\n ${themeV2ToCss(darkV2)}`
42
43 if (isDefaultTheme) {
44 return `
45:root {
46 color-scheme: light;
47 --text-mix-blend-mode: multiply;
48
49 ${lightCss}
50
51 @media (prefers-color-scheme: dark) {
52 color-scheme: dark;
53 --text-mix-blend-mode: plus-lighter;
54
55 ${darkCss}
56 }
57}
58`
59 }
60
61 return `
62html[data-theme="${themeId}"] {
63 color-scheme: light;
64 --text-mix-blend-mode: multiply;
65
66 ${lightCss}
67
68 @media (prefers-color-scheme: dark) {
69 color-scheme: dark;
70 --text-mix-blend-mode: plus-lighter;
71
72 ${darkCss}
73 }
74}
75`
76}
77
78export async function loadThemeFromUrl(url: string): Promise<DesktopTheme> {
79 const response = await fetch(url)

Callers 1

applyThemeFunction · 0.85

Calls 2

themeToCssFunction · 0.90
themeV2ToCssFunction · 0.90

Tested by

no test coverage detected