MCPcopy
hub / github.com/monkeytypegame/monkeytype / apply

Function apply

frontend/src/ts/controllers/theme-controller.ts:54–81  ·  view source on GitHub ↗
(
  themeName: ThemeIdentifier,
  customColorsOverride?: CustomThemeColors,
  isPreview = false,
)

Source from the content-addressed store, hash-verified

52}
53
54async 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
83function updateThemeIndicator(nameOverride?: string): void {
84 //text

Callers 6

applyPresetFunction · 0.70
setFunction · 0.70
clearPreviewFunction · 0.70
randomizeThemeFunction · 0.70
clearRandomFunction · 0.70

Calls 6

isColorDarkFunction · 0.90
qsFunction · 0.90
updateThemeIndicatorFunction · 0.85
addClassMethod · 0.45
removeClassMethod · 0.45

Tested by

no test coverage detected