Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Reuse `window.OpenProject.theme` instance

Kabiru Mwenja63c32e562c6b
diff --git a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
index 4614ee39072..c7131236a19 100644
--- a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
+++ b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
@@ -30,7 +30,6 @@
import { Controller } from '@hotwired/stimulus';
import { useMatchMedia } from 'stimulus-use';
-import { ThemeUtils } from 'core-app/core/setup/globals/theme-utils';
export default class AutoThemeSwitcher extends Controller {
static values = {
@@ -38,13 +37,10 @@ export default class AutoThemeSwitcher extends Controller {
};
declare readonly modeValue:string;
- private themeUtils:ThemeUtils;
connect() {
if (this.modeValue !== 'sync_with_os') return;
- this.themeUtils = new ThemeUtils();
-
useMatchMedia(this, {
mediaQueries: {
lightMode: '(prefers-color-scheme: light)',
@@ -53,10 +49,10 @@ export default class AutoThemeSwitcher extends Controller {
}
isLightMode():void {
- this.themeUtils.applyThemeToBody('light');
+ window.OpenProject.theme.applyThemeToBody('light');
}
notLightMode():void {
- this.themeUtils.applyThemeToBody('dark');
+ window.OpenProject.theme.applyThemeToBody('dark');
}
}