summaryrefslogtreecommitdiff
path: root/app/helpers/labels_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/labels_helper.rb')
-rw-r--r--app/helpers/labels_helper.rb26
1 files changed, 2 insertions, 24 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index 2150729cb2a..877785c9eaf 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -61,7 +61,7 @@ module LabelsHelper
render_label_text(
label.name,
suffix: suffix,
- css_class: "gl-label-text #{text_color_class_for_bg(label.color)}",
+ css_class: "gl-label-text #{label.text_color_class}",
bg_color: label.color
)
end
@@ -114,30 +114,8 @@ module LabelsHelper
end
end
- def text_color_class_for_bg(bg_color)
- if light_color?(bg_color)
- 'gl-label-text-dark'
- else
- 'gl-label-text-light'
- end
- end
-
def text_color_for_bg(bg_color)
- if light_color?(bg_color)
- '#333333'
- else
- '#FFFFFF'
- end
- end
-
- def light_color?(color)
- if color.length == 4
- r, g, b = color[1, 4].scan(/./).map { |v| (v * 2).hex }
- else
- r, g, b = color[1, 7].scan(/.{2}/).map(&:hex)
- end
-
- (r + g + b) > 500
+ ::Gitlab::Color.of(bg_color).contrast
end
def labels_filter_path_with_defaults(only_group_labels: false, include_ancestor_groups: true, include_descendant_groups: false)