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

Use 'force' terminology for theme contrast preferences

Kabiru Mwenjab1375a299260
diff --git a/app/forms/my/look_and_feel_form.rb b/app/forms/my/look_and_feel_form.rb
index 5ce73ac1b41..d9f9d30e12b 100644
--- a/app/forms/my/look_and_feel_form.rb
+++ b/app/forms/my/look_and_feel_form.rb
@@ -48,14 +48,14 @@ class My::LookAndFeelForm < ApplicationForm
end
f.check_box_group(data: { my__look_and_feel_target: "autoThemeContrast" }) do |group|
- group.check_box name: :enable_auto_light_theme_contrast,
- label: attribute_name(:enable_auto_light_theme_contrast),
- checked: user_preference.enable_auto_light_theme_contrast?,
- caption: attribute_name(:enable_auto_light_theme_contrast_caption)
- group.check_box name: :enable_auto_dark_theme_contrast,
- label: attribute_name(:enable_auto_dark_theme_contrast),
- checked: user_preference.enable_auto_dark_theme_contrast?,
- caption: attribute_name(:enable_auto_dark_theme_contrast_caption)
+ group.check_box name: :force_light_theme_contrast,
+ label: attribute_name(:force_light_theme_contrast),
+ checked: user_preference.force_light_theme_contrast?,
+ caption: attribute_name(:force_light_theme_contrast_caption)
+ group.check_box name: :force_dark_theme_contrast,
+ label: attribute_name(:force_dark_theme_contrast),
+ checked: user_preference.force_dark_theme_contrast?,
+ caption: attribute_name(:force_dark_theme_contrast_caption)
end
f.check_box_group(data: { my__look_and_feel_target: "singleThemeContrast" }) do |group|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index db17dcaf153..4a7043a6735 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -323,10 +323,8 @@ module ApplicationHelper
}
if pref.sync_with_os_theme?
- theme_options[:auto_theme_switcher_enable_auto_light_theme_contrast_value] =
- pref.enable_auto_light_theme_contrast?
- theme_options[:auto_theme_switcher_enable_auto_dark_theme_contrast_value] =
- pref.enable_auto_dark_theme_contrast?
+ theme_options[:auto_theme_switcher_force_light_contrast_value] = pref.force_light_theme_contrast?
+ theme_options[:auto_theme_switcher_force_dark_contrast_value] = pref.force_dark_theme_contrast?
else
theme_options[:color_mode] = theme
theme_options[:"#{theme}_theme"] = theme
diff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rb
index 2235758f342..d69ee751969 100644
--- a/app/models/permitted_params.rb
+++ b/app/models/permitted_params.rb
@@ -267,8 +267,8 @@ class PermittedParams
params.fetch(:pref, {}).permit(:time_zone,
:theme,
:increase_theme_contrast,
- :enable_auto_light_theme_contrast,
- :enable_auto_dark_theme_contrast,
+ :force_light_theme_contrast,
+ :force_dark_theme_contrast,
:comments_sorting,
:disable_keyboard_shortcuts,
:warn_on_leaving_unsaved,
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 82f25a4e87b..e8b08827707 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -137,12 +137,12 @@ class UserPreference < ApplicationRecord
settings[:increase_theme_contrast] = to_boolean(value)
end
- def enable_auto_light_theme_contrast=(value)
- settings[:enable_auto_light_theme_contrast] = to_boolean(value)
+ def force_light_theme_contrast=(value)
+ settings[:force_light_theme_contrast] = to_boolean(value)
end
- def enable_auto_dark_theme_contrast=(value)
- settings[:enable_auto_dark_theme_contrast] = to_boolean(value)
+ def force_dark_theme_contrast=(value)
+ settings[:force_dark_theme_contrast] = to_boolean(value)
end
COLOR_MODES.each do |base_theme_name|
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 40110c7d4b4..b8d7bc444f2 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1286,10 +1286,10 @@ en:
increase_theme_contrast: "Increase theme contrast"
increase_contrast: "Increase contrast"
increase_contrast_caption: "Enables high-contrast mode for the chosen colour mode."
- enable_auto_light_theme_contrast: "Force high-contrast when in Light mode"
- enable_auto_dark_theme_contrast: "Force high-contrast when in Dark mode"
- enable_auto_light_theme_contrast_caption: "Uses the high-contrast version of Light mode when automatic color mode is selected."
- enable_auto_dark_theme_contrast_caption: "Uses the high-contrast version of Dark mode when automatic color mode is selected."
+ force_light_theme_contrast: "Force high-contrast when in Light mode"
+ force_dark_theme_contrast: "Force high-contrast when in Dark mode"
+ force_light_theme_contrast_caption: "Uses the high-contrast version of Light mode when automatic color mode is selected."
+ force_dark_theme_contrast_caption: "Uses the high-contrast version of Dark mode when automatic color mode is selected."
theme: "Color mode"
time_zone: "Time zone"
mode_guideline: "Some modes will overwrite custom theme colors for accessibility and legibility. Please select Light mode for full custom theme support."
diff --git a/config/schemas/user_preferences.schema.json b/config/schemas/user_preferences.schema.json
index 56189b7e7b9..60e67646fe8 100644
--- a/config/schemas/user_preferences.schema.json
+++ b/config/schemas/user_preferences.schema.json
@@ -16,10 +16,10 @@
"increase_theme_contrast": {
"type": "boolean"
},
- "enable_auto_light_theme_contrast": {
+ "force_light_theme_contrast": {
"type": "boolean"
},
- "enable_auto_dark_theme_contrast": {
+ "force_dark_theme_contrast": {
"type": "boolean"
},
"disable_keyboard_shortcuts": {
diff --git a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
index 50b459a824c..a461f220d7d 100644
--- a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
+++ b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
@@ -36,8 +36,8 @@ export default class AutoThemeSwitcher extends Controller {
static values = {
theme: String,
increaseContrast: Boolean,
- enableAutoLightThemeContrast: Boolean,
- enableAutoDarkThemeContrast: Boolean,
+ forceLightContrast: Boolean,
+ forceDarkContrast: Boolean,
};
static targets = ['desktopLogo', 'mobileLogo'];
@@ -45,8 +45,8 @@ export default class AutoThemeSwitcher extends Controller {
declare readonly themeValue:OpTheme;
declare readonly increaseContrastValue:boolean;
- declare readonly enableAutoLightThemeContrastValue:boolean;
- declare readonly enableAutoDarkThemeContrastValue:boolean;
+ declare readonly forceLightContrastValue:boolean;
+ declare readonly forceDarkContrastValue:boolean;
declare readonly desktopLogoTarget:HTMLLinkElement;
declare readonly mobileLogoTarget:HTMLLinkElement;
declare readonly desktopLightHighContrastLogoClass:string;
@@ -64,8 +64,8 @@ export default class AutoThemeSwitcher extends Controller {
syncWithOS():void {
this.colorModeContrastPreferences = {
- light: this.enableAutoLightThemeContrastValue,
- dark: this.enableAutoDarkThemeContrastValue,
+ light: this.forceLightContrastValue,
+ dark: this.forceDarkContrastValue,
};
useMatchMedia(this, {
diff --git a/spec/features/my/interface_spec.rb b/spec/features/my/interface_spec.rb
index 04483dd5536..afd8a74ef0e 100644
--- a/spec/features/my/interface_spec.rb
+++ b/spec/features/my/interface_spec.rb
@@ -101,8 +101,8 @@ RSpec.describe "My account Interface settings",
configure_auto_contrast(light: true, dark: true)
expect(page).to have_auto_theme_config(
- enable_auto_light_contrast: true,
- enable_auto_dark_contrast: true
+ force_light_contrast: true,
+ force_dark_contrast: true
)
end
diff --git a/spec/migrations/migrate_theme_preferences_spec.rb b/spec/migrations/migrate_theme_preferences_spec.rb
index 04458feef49..7e38cde361f 100644
--- a/spec/migrations/migrate_theme_preferences_spec.rb
+++ b/spec/migrations/migrate_theme_preferences_spec.rb
@@ -53,8 +53,8 @@ RSpec.describe MigrateThemePreferences, type: :model do
expect(user.pref.settings["time_zone"]).to eq("UTC")
# Verify model methods work correctly for unset auto-contrast settings
- expect(user.pref).not_to be_enable_auto_light_theme_contrast
- expect(user.pref).not_to be_enable_auto_dark_theme_contrast
+ expect(user.pref).not_to be_force_light_theme_contrast
+ expect(user.pref).not_to be_force_dark_theme_contrast
end
it "converts dark_high_contrast to new structure" do
diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb
index ac9af652f27..8de7a36e957 100644
--- a/spec/models/user_preference_spec.rb
+++ b/spec/models/user_preference_spec.rb
@@ -329,8 +329,8 @@ RSpec.describe UserPreference do
it "defaults contrast settings to false" do
expect(subject).not_to be_increase_theme_contrast
- expect(subject).not_to be_enable_auto_light_theme_contrast
- expect(subject).not_to be_enable_auto_dark_theme_contrast
+ expect(subject).not_to be_force_light_theme_contrast
+ expect(subject).not_to be_force_dark_theme_contrast
expect(subject).not_to be_a_light_high_contrast_theme
expect(subject).not_to be_a_dark_high_contrast_theme
end
@@ -343,11 +343,11 @@ RSpec.describe UserPreference do
:increase_theme_contrast?
it_behaves_like "accepts real and false booleans",
- :enable_auto_light_theme_contrast=,
- :enable_auto_light_theme_contrast?
+ :force_light_theme_contrast=,
+ :force_light_theme_contrast?
it_behaves_like "accepts real and false booleans",
- :enable_auto_dark_theme_contrast=,
- :enable_auto_dark_theme_contrast?
+ :force_dark_theme_contrast=,
+ :force_dark_theme_contrast?
end
end
diff --git a/spec/support/capybara/theme_selectors.rb b/spec/support/capybara/theme_selectors.rb
index 015b5ecc46e..38baf83fa0b 100644
--- a/spec/support/capybara/theme_selectors.rb
+++ b/spec/support/capybara/theme_selectors.rb
@@ -67,26 +67,26 @@ Capybara.add_selector :auto_theme_config do
xpath
end
- expression_filter(:enable_auto_light_contrast) do |expr, enabled|
+ expression_filter(:force_light_contrast) do |expr, enabled|
if enabled
- builder(expr).add_attribute_conditions("data-auto-theme-switcher-enable-auto-light-theme-contrast-value": "true")
+ builder(expr).add_attribute_conditions("data-auto-theme-switcher-force-light-contrast-value": "true")
else
expr
end
end
- expression_filter(:enable_auto_dark_contrast) do |expr, enabled|
+ expression_filter(:force_dark_contrast) do |expr, enabled|
if enabled
- builder(expr).add_attribute_conditions("data-auto-theme-switcher-enable-auto-dark-theme-contrast-value": "true")
+ builder(expr).add_attribute_conditions("data-auto-theme-switcher-force-dark-contrast-value": "true")
else
expr
end
end
- describe_expression_filters do |enable_auto_light_contrast: nil, enable_auto_dark_contrast: nil, **|
+ describe_expression_filters do |force_light_contrast: nil, force_dark_contrast: nil, **|
desc = +""
- desc << " with auto light contrast" if enable_auto_light_contrast
- desc << " with auto dark contrast" if enable_auto_dark_contrast
+ desc << " with forced light contrast" if force_light_contrast
+ desc << " with forced dark contrast" if force_dark_contrast
desc
end
end
@@ -101,10 +101,10 @@ module Capybara
Matchers::NegatedMatcher.new(have_theme(locator, **, &))
end
- def have_auto_theme_config(enable_auto_light_contrast: false, enable_auto_dark_contrast: false, **, &)
+ def have_auto_theme_config(force_light_contrast: false, force_dark_contrast: false, **, &)
Matchers::HaveSelector.new(:auto_theme_config, nil,
- enable_auto_light_contrast:,
- enable_auto_dark_contrast:,
+ force_light_contrast:,
+ force_dark_contrast:,
**, &)
end
end