BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9ae820ad
Commit
9ae820ad
authored
Jan 26, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-issue-12677' into 'master'
Update text_color_for_bg helper to support RGB triplet color codes Closes #12677 See merge request !2587
parents
28e2d214
2e911721
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
labels_helper.rb
app/helpers/labels_helper.rb
+5
-1
labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+5
-0
No files found.
app/helpers/labels_helper.rb
View file @
9ae820ad
...
...
@@ -83,7 +83,11 @@ module LabelsHelper
end
def
text_color_for_bg
(
bg_color
)
r
,
g
,
b
=
bg_color
.
slice
(
1
,
7
).
scan
(
/.{2}/
).
map
(
&
:hex
)
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
'#333333'
...
...
spec/helpers/labels_helper_spec.rb
View file @
9ae820ad
...
...
@@ -66,5 +66,10 @@ describe LabelsHelper do
it
'uses dark text on light backgrounds'
do
expect
(
text_color_for_bg
(
'#EEEEEE'
)).
to
eq
(
'#333333'
)
end
it
'supports RGB triplets'
do
expect
(
text_color_for_bg
(
'#FFF'
)).
to
eq
'#333333'
expect
(
text_color_for_bg
(
'#000'
)).
to
eq
'#FFFFFF'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment