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

Offer three colour themes which change the design variables

Henriette Dinger02444a2a9216
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index e364f2b164b..f2dddb87f1e 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/app/controllers/custom_styles_controller.rb
@@ -87,7 +87,25 @@ class CustomStylesController < ApplicationController
def update_colors
variable_params = params[:design_colors].first
+ set_colors(variable_params)
+ redirect_to action: :show
+ end
+
+ def update_themes
+ variable_params = OpenProject::CustomStyles::ColorThemes::THEMES.find { |theme| theme[:name] == params[:theme] }[:colors]
+ set_colors(variable_params)
+
+ redirect_to action: :show
+ end
+
+ def show_local_breadcrumb
+ true
+ end
+
+ private
+
+ def set_colors(variable_params)
variable_params.each do |param_variable, param_hexcode|
if design_color = DesignColor.find_by(variable: param_variable)
if param_hexcode.blank?
@@ -102,16 +120,8 @@ class CustomStylesController < ApplicationController
design_color.save
end
end
-
- redirect_to action: :show
- end
-
- def show_local_breadcrumb
- true
end
- private
-
def require_ee_token
unless EnterpriseToken.allows_to?(:define_custom_style)
redirect_to custom_style_upsale_path
diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erb
index 422b66ed29a..947a932f269 100644
--- a/app/views/custom_styles/show.html.erb
+++ b/app/views/custom_styles/show.html.erb
@@ -137,10 +137,27 @@ See docs/COPYRIGHT.rdoc for more details.
</section>
<% end %>
-<%= form_tag update_design_colors_path, method: :post, class: "form" do %>
+<%= form_tag update_design_themes_path, method: :post, class: "form" do %>
<section class="form--section">
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.custom_colors') %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.color_themes') %></legend>
+ <div class="form--field">
+ <div class="form--field-container">
+ <%= styled_select_tag 'theme',
+ options_for_select(OpenProject::CustomStyles::ColorThemes::THEMES.map { |val| val[:name] }),
+ container_class: '-slim' %>
+ </div>
+ </div>
+
+ <button type="submit" class="button"><%= I18n.t(:button_save) %></button>
+ </fieldset>
+ </section>
+<% end %>
+
+<%= form_tag update_design_colors_path, method: :post, class: "form" do %>
+ <section class="form--section">
+ <fieldset class="form--fieldset -collapsible collapsed">
+ <legend class="form--fieldset-legend"><%= I18n.t(:label_advanced_settings) %></legend>
<% DesignColor.setables.each do |design_color| %>
<div class="form--field -required">
diff --git a/config/routes.rb b/config/routes.rb
index 4571d2068da..17ffd9523b9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -347,6 +347,7 @@ OpenProject::Application.routes.draw do
delete 'design/touch_icon' => 'custom_styles#touch_icon_delete', as: 'custom_style_touch_icon_delete'
get 'design/upsale' => 'custom_styles#upsale', as: 'custom_style_upsale'
post 'design/colors' => 'custom_styles#update_colors', as: 'update_design_colors'
+ post 'design/themes' => 'custom_styles#update_themes', as: 'update_design_themes'
resource :custom_style, only: %i[update show create], path: 'design'
resources :attribute_help_texts, only: %i(index new create edit update destroy)
diff --git a/lib/open_project/custom_styles/color_themes.rb b/lib/open_project/custom_styles/color_themes.rb
new file mode 100644
index 00000000000..14611c71157
--- /dev/null
+++ b/lib/open_project/custom_styles/color_themes.rb
@@ -0,0 +1,98 @@
+#-- encoding: UTF-8
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+module OpenProject::CustomStyles
+ class ColorThemes
+ THEMES = [
+ {
+ name: 'OpenProject',
+ colors: {
+ 'primary-color' => "#1A67A3",
+ 'primary-color-dark' => "#175A8E",
+ 'alternative-color' => "#35C53F",
+ 'content-link-color' => "#175A8E",
+ 'header-bg-color' => "#1A67A3",
+ 'header-item-bg-hover-color' => "#175A8E",
+ 'header-item-font-color' => "#FFFFFF",
+ 'header-item-font-hover-color' => "#FFFFFF",
+ 'header-border-bottom-color' => "",
+ 'main-menu-bg-color' => "#333739",
+ 'main-menu-bg-selected-background' => "#175A8E",
+ 'main-menu-bg-hover-background' => "#124E7C",
+ 'main-menu-font-color' => "#FFFFFF",
+ 'main-menu-hover-font-color' => "#FFFFFF",
+ 'main-menu-selected-font-color' => "#FFFFFF",
+ 'main-menu-border-color' => "#EAEAEA",
+ }
+ },
+ {
+ name: 'OpenProject Light',
+ colors: {
+ 'primary-color' => "#1A67A3",
+ 'primary-color-dark' => "#175A8E",
+ 'alternative-color' => "#138E1B",
+ 'content-link-color' => "#175A8E",
+ 'header-bg-color' => "#FAFAFA",
+ 'header-item-bg-hover-color' => "#E1E1E1",
+ 'header-item-font-color' => "#313131",
+ 'header-item-font-hover-color' => "#313131",
+ 'header-border-bottom-color' => "#E1E1E1",
+ 'main-menu-bg-color' => "#ECECEC",
+ 'main-menu-bg-selected-background' => "#A9A9A9",
+ 'main-menu-bg-hover-background' => "#FFFFFF",
+ 'main-menu-font-color' => "#000000",
+ 'main-menu-hover-font-color' => "#000000",
+ 'main-menu-selected-font-color' => "#000000",
+ 'main-menu-border-color' => "#EAEAEA",
+ }
+ },
+ {
+ name: 'OpenProject Dark',
+ colors: {
+ 'primary-color' => "#1A67A3",
+ 'primary-color-dark' => "#175A8E",
+ 'alternative-color' => "#138E1B",
+ 'content-link-color' => "#175A8E",
+ 'header-bg-color' => "#031D2F",
+ 'header-item-bg-hover-color' => "#0F3A5A",
+ 'header-item-font-color' => "#DFDFDF",
+ 'header-item-font-hover-color' => "#DFDFDF",
+ 'header-border-bottom-color' => "",
+ 'main-menu-bg-color' => "#2F3131",
+ 'main-menu-bg-selected-background' => "#143E5F",
+ 'main-menu-bg-hover-background' => "#0D2B42",
+ 'main-menu-font-color' => "#DFDFDF",
+ 'main-menu-hover-font-color' => "#DFDFDF",
+ 'main-menu-selected-font-color' => "#DFDFDF",
+ 'main-menu-border-color' => "#000000",
+ }
+ }
+ ].freeze
+ end
+end