( light: ResolvedTheme, dark: ResolvedTheme, lightV2: ResolvedV2Theme, darkV2: ResolvedV2Theme, themeId: string, )
| 30 | } |
| 31 | |
| 32 | function 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 ` |
| 62 | html[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 | |
| 78 | export async function loadThemeFromUrl(url: string): Promise<DesktopTheme> { |
| 79 | const response = await fetch(url) |
no test coverage detected