Allow themes to define a logo (dark vs. light) when there is no custom logo defined

pull/8019/head
Henriette Dinger 5 years ago
parent 4c8a4a82f5
commit 46eeaadd8e
  1. 12
      app/controllers/custom_styles_controller.rb
  2. 4
      app/views/custom_styles/_inline_css.erb
  3. 5
      db/migrate/20200206101135_add_theme_logo_to_custom_style.rb
  4. 3
      lib/open_project/custom_styles/color_themes.rb

@ -96,8 +96,12 @@ class CustomStylesController < ApplicationController
end
def update_themes
variable_params = OpenProject::CustomStyles::ColorThemes::THEMES.find { |theme| theme[:name] == params[:theme] }[:colors]
set_colors(variable_params)
theme = OpenProject::CustomStyles::ColorThemes::THEMES.find { |t| t[:name] == params[:theme] }
color_params = theme[:colors]
logo = theme[:logo]
set_logo(logo)
set_colors(color_params)
set_theme(params)
redirect_to action: :show
@ -116,6 +120,10 @@ class CustomStylesController < ApplicationController
options
end
def set_logo(logo)
CustomStyle.current.update(theme_logo: logo)
end
def set_colors(variable_params)
variable_params.each do |param_variable, param_hexcode|
if design_color = DesignColor.find_by(variable: param_variable)

@ -32,6 +32,10 @@ See docs/COPYRIGHT.rdoc for more details.
#logo .home-link {
background-image: url("<%= custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier) %>");
}
<% elsif CustomStyle.current.theme_logo %>
#logo .home-link {
background-image: url("<%= asset_path(CustomStyle.current.theme_logo) %>");
}
<% end %>
:root {

@ -0,0 +1,5 @@
class AddThemeLogoToCustomStyle < ActiveRecord::Migration[6.0]
def change
add_column :custom_styles, :theme_logo, :string, default: nil
end
end

@ -70,7 +70,8 @@ module OpenProject::CustomStyles
'main-menu-hover-font-color' => "#000000",
'main-menu-selected-font-color' => "#000000",
'main-menu-border-color' => "#EAEAEA"
}
},
logo: 'logo_openproject.png'
},
{
name: 'OpenProject Dark',

Loading…
Cancel
Save