summaryrefslogtreecommitdiff
path: root/app/helpers/labels_helper.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-30 17:17:29 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-30 17:17:29 +0300
commitd9d8d3b7995c351cb4a7d91718f3f48324bd099a (patch)
tree9a58e84761207777f08d5c33ee1d9a69da74170e /app/helpers/labels_helper.rb
parent70f868b737af99c8a8697a3cb5e19b8da3d9c3d9 (diff)
downloadgitlab-ce-d9d8d3b7995c351cb4a7d91718f3f48324bd099a.tar.gz
Fix old api compatibility and tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/helpers/labels_helper.rb')
-rw-r--r--app/helpers/labels_helper.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index 17c87f5c762..37f3832e54f 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -5,13 +5,7 @@ module LabelsHelper
def render_colored_label(label)
label_color = label.color || "#428bca"
- r, g, b = label_color.slice(1,7).scan(/.{2}/).map(&:hex)
-
- if (r + g + b) > 500
- text_color = "#333"
- else
- text_color = "#FFF"
- end
+ text_color = text_color_for_bg(label_color)
content_tag :span, class: 'label color-label', style: "background:#{label_color};color:#{text_color}" do
label.name
@@ -30,4 +24,14 @@ module LabelsHelper
'#FFECDB'
]
end
+
+ def text_color_for_bg(bg_color)
+ r, g, b = bg_color.slice(1,7).scan(/.{2}/).map(&:hex)
+
+ if (r + g + b) > 500
+ "#333"
+ else
+ "#FFF"
+ end
+ end
end