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

Enable dark mode in personal settings

Henriette Dargeafb7a98c4958
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5a1610f8a35..c03499add44 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -280,7 +280,8 @@ module ApplicationHelper
def theme_options_for_select
[
[t("themes.light"), "light"],
- [t("themes.light_high_contrast"), "light_high_contrast"]
+ [t("themes.light_high_contrast"), "light_high_contrast"],
+ [t("themes.dark"), "dark"]
]
end
diff --git a/app/views/custom_styles/_primer_color_mapping.erb b/app/views/custom_styles/_primer_color_mapping.erb
index 424b9edb419..d14e6838868 100644
--- a/app/views/custom_styles/_primer_color_mapping.erb
+++ b/app/views/custom_styles/_primer_color_mapping.erb
@@ -13,7 +13,8 @@
--button-primary-bgColor-rest: var(--button--primary-background-color) !important;
--button-primary-bgColor-hover: var(--button--primary-background-hover-color) !important;
}
- [data-light-theme=light_high_contrast]{
+ [data-light-theme=light_high_contrast],
+ [data-dark-theme=dark] {
--avatar-border-color: var(--color-avatar-border);
--list-item-hover--border-color: var(--color-action-list-item-default-active-border);
--list-item-hover--color: var(--color-fg-default);
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 98df69b847d..3969dc8751b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -432,6 +432,7 @@ en:
no_results_content_text: Add a new status
themes:
+ dark: "Dark"
light: "Light"
light_high_contrast: "Light high contrast"
diff --git a/config/schemas/user_preferences.schema.json b/config/schemas/user_preferences.schema.json
index 8953b4ef48c..b6dfb34596a 100644
--- a/config/schemas/user_preferences.schema.json
+++ b/config/schemas/user_preferences.schema.json
@@ -14,7 +14,7 @@
},
"theme": {
"type": "string",
- "enum": ["light", "light_high_contrast"]
+ "enum": ["light", "light_high_contrast", "dark"]
},
"warn_on_leaving_unsaved": {
"type": "boolean"
diff --git a/frontend/src/app/shared/components/colors/colors.service.ts b/frontend/src/app/shared/components/colors/colors.service.ts
index 065462cdb89..d8739273be5 100644
--- a/frontend/src/app/shared/components/colors/colors.service.ts
+++ b/frontend/src/app/shared/components/colors/colors.service.ts
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
export const colorModes = {
lightHighContrast: 'lightHighContrast',
light: 'light',
+ dark: 'dark',
};
@Injectable({ providedIn: 'root' })
@@ -25,6 +26,16 @@ export class ColorsService {
}
public colorMode():string {
- return document.body.getAttribute('data-light-theme') === 'light_high_contrast' ? colorModes.lightHighContrast : colorModes.light;
+ switch (document.body.getAttribute('data-light-theme')) {
+ case 'light_high_contrast':
+ return colorModes.lightHighContrast;
+ case 'dark':
+ return colorModes.dark;
+ case 'light':
+ return colorModes.light;
+ default: {
+ return colorModes.light;
+ }
+ }
}
}