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 darkened, transparent border color in color square

Oliver Güntherf8600251a849
diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rb
index a049b8a5abc..2b6f36f65c0 100644
--- a/app/helpers/colors_helper.rb
+++ b/app/helpers/colors_helper.rb
@@ -27,6 +27,8 @@
#++
module ColorsHelper
+ include Primer::JoinStyleArgumentsHelper
+
def options_for_colors(colored_thing)
colors = []
Color.find_each do |c|
@@ -86,10 +88,17 @@ module ColorsHelper
def icon_for_color(color, options = {})
return unless color
+ return unless color.hexcode.present?
+
+ style = join_style_arguments(
+ "background-color: #{color.hexcode}",
+ "border-color: #{color.darken(0.5)}50",
+ options[:style]
+ )
- options.merge! class: "color--preview " + options[:class].to_s,
+ options.merge!(class: "color--preview #{options[:class]}",
title: color.name,
- style: "background-color: #{color.hexcode};" + options[:style].to_s
+ style:)
content_tag(:span, " ", options)
end
diff --git a/app/models/color.rb b/app/models/color.rb
index 9a47108bb0c..89f5f6c8a2f 100644
--- a/app/models/color.rb
+++ b/app/models/color.rb
@@ -35,6 +35,7 @@ class Color < ApplicationRecord
class_name: "Type",
dependent: :nullify
+ after_initialize :normalize_hexcode
before_validation :normalize_hexcode
validates :name, :hexcode, presence: true
diff --git a/app/views/custom_styles/_interface.html.erb b/app/views/custom_styles/_interface.html.erb
index 17a4746519e..eecd07d39c4 100644
--- a/app/views/custom_styles/_interface.html.erb
+++ b/app/views/custom_styles/_interface.html.erb
@@ -9,8 +9,7 @@
<span class="form--field-container">
<div class="form--field-affix">
<%= icon_for_color(
- OpenStruct.new(
- variable: design_color.variable,
+ Color.new(
hexcode: design_color.hexcode
),
data: { target: "#design_colors_" + design_color.variable }
diff --git a/app/views/custom_styles/_pdf_export_styles.html.erb b/app/views/custom_styles/_pdf_export_styles.html.erb
index a36589219e7..7d3fdc168a5 100644
--- a/app/views/custom_styles/_pdf_export_styles.html.erb
+++ b/app/views/custom_styles/_pdf_export_styles.html.erb
@@ -99,8 +99,7 @@ See COPYRIGHT and LICENSE files for more details.
<% design_color_name = "export_cover_text_color" %>
<% design_color_hex = @custom_style.export_cover_text_color.presence || "" %>
<%= icon_for_color(
- OpenStruct.new(
- variable: design_color_name,
+ Color.new(
hexcode: design_color_hex
),
data: { target: "#" + design_color_name }