( themeName: ThemeIdentifier, customColorsOverride?: CustomThemeColors, isPreview = false, )
| 52 | } |
| 53 | |
| 54 | async function apply( |
| 55 | themeName: ThemeIdentifier, |
| 56 | customColorsOverride?: CustomThemeColors, |
| 57 | isPreview = false, |
| 58 | ): Promise<void> { |
| 59 | console.debug(`Theme controller applying theme ${themeName}`, { |
| 60 | customColorsOverride, |
| 61 | isPreview, |
| 62 | }); |
| 63 | |
| 64 | const isCustom = themeName === "custom"; |
| 65 | |
| 66 | const themeColors = isCustom |
| 67 | ? convertCustomColorsToTheme( |
| 68 | customColorsOverride ?? Config.customThemeColors, |
| 69 | ) |
| 70 | : themes[themeName]; |
| 71 | |
| 72 | setTheme({ ...themeColors, name: themeName }); |
| 73 | |
| 74 | updateThemeIndicator(isPreview ? themeName : undefined); |
| 75 | |
| 76 | if (isColorDark(themeColors.bg)) { |
| 77 | qs("body")?.addClass("darkMode"); |
| 78 | } else { |
| 79 | qs("body")?.removeClass("darkMode"); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | function updateThemeIndicator(nameOverride?: string): void { |
| 84 | //text |
no test coverage detected