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

Merge branch 'dev' into merge-release/16.4-20250917064829

Kabiru Mwenja0df57ad06072
diff --cc frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
index 4f369074c73,a461f220d7d..40c5d125a7d
--- a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
+++ b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
@@@ -45,10 -51,22 +51,23 @@@ export default class AutoThemeSwitcher
declare readonly mobileLogoTarget:HTMLLinkElement;
declare readonly desktopLightHighContrastLogoClass:string;
declare readonly mobileWhiteLogoClass:string;
+ declare readonly hasMobileLogoTarget:boolean;
+ private colorModeContrastPreferences:Record<OpColorMode, boolean>;
+
connect() {
- if (this.modeValue !== 'sync_with_os') return;
+ if (this.themeValue === 'sync_with_os') {
+ this.syncWithOS();
+ } else {
+ this.applyTheme(this.themeValue, this.increaseContrastValue);
+ }
+ }
+
+ syncWithOS():void {
+ this.colorModeContrastPreferences = {
+ light: this.forceLightContrastValue,
+ dark: this.forceDarkContrastValue,
+ };
useMatchMedia(this, {
mediaQueries: {
@@@ -69,17 -92,18 +93,20 @@@
}
private applySystemTheme():void {
- window.OpenProject.theme.applySystemThemeImmediately();
- this.updateOpLogoContrast();
+ const colorMode = window.OpenProject.theme.detectSystemColorMode();
+ const prefersSystemHighContrast = window.OpenProject.theme.prefersSystemHighContrast();
+ const increaseContrast = prefersSystemHighContrast || this.colorModeContrastPreferences[colorMode];
+
+ this.applyTheme(colorMode, increaseContrast);
}
- private updateOpLogoContrast():void {
- const prefersSystemLightHighContrast = window.OpenProject.theme.prefersSystemLightHighContrast();
+ private updateOpLogoContrast(colorMode:OpColorMode, increaseContrast:boolean):void {
+ const isLightHighContrast = (colorMode === 'light' && increaseContrast);
- this.desktopLogoTarget.classList.toggle(this.desktopLightHighContrastLogoClass, prefersSystemLightHighContrast);
+ this.desktopLogoTarget.classList.toggle(this.desktopLightHighContrastLogoClass, isLightHighContrast);
- this.mobileLogoTarget.classList.toggle(this.mobileWhiteLogoClass, !isLightHighContrast);
+ // Custom logos are not supported on mobile
+ if (this.hasMobileLogoTarget) {
- this.mobileLogoTarget.classList.toggle(this.mobileWhiteLogoClass, !prefersSystemLightHighContrast);
++ this.mobileLogoTarget.classList.toggle(this.mobileWhiteLogoClass, !isLightHighContrast);
+ }
}
-
}