diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-27 15:09:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-27 15:09:12 +0300 |
commit | 3ab4feda4dce9c9f0672375ae27c2f7c2ba6f4ad (patch) | |
tree | be5a771e0427ed98cdb58acfd5c631b4b2eb4bf9 /app/helpers | |
parent | c72e5ebe9938d315ec598197873e71a80168d40a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/labels_helper.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 97232def91c..3142d7d7782 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -115,13 +115,7 @@ module LabelsHelper end def text_color_class_for_bg(bg_color) - if bg_color.length == 4 - r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex } - else - r, g, b = bg_color[1, 7].scan(/.{2}/).map(&:hex) - end - - if (r + g + b) > 500 + if light_color?(bg_color) 'gl-label-text-dark' else 'gl-label-text-light' @@ -129,17 +123,21 @@ module LabelsHelper end def text_color_for_bg(bg_color) - if bg_color.length == 4 - r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex } + if light_color?(bg_color) + '#333333' else - r, g, b = bg_color[1, 7].scan(/.{2}/).map(&:hex) + '#FFFFFF' end + end - if (r + g + b) > 500 - '#333333' + def light_color?(color) + if color.length == 4 + r, g, b = color[1, 4].scan(/./).map { |v| (v * 2).hex } else - '#FFFFFF' + r, g, b = color[1, 7].scan(/.{2}/).map(&:hex) end + + (r + g + b) > 500 end def labels_filter_path_with_defaults(only_group_labels: false, include_ancestor_groups: true, include_descendant_groups: false) |