diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/issues/label.go | 27 | ||||
-rw-r--r-- | models/issues/label_test.go | 9 |
2 files changed, 0 insertions, 36 deletions
diff --git a/models/issues/label.go b/models/issues/label.go index 35c649e8f2..9c22dcdd2d 100644 --- a/models/issues/label.go +++ b/models/issues/label.go @@ -159,33 +159,6 @@ func (l *Label) BelongsToRepo() bool { return l.RepoID > 0 } -// Get color as RGB values in 0..255 range -func (l *Label) ColorRGB() (float64, float64, float64, error) { - color, err := strconv.ParseUint(l.Color[1:], 16, 64) - if err != nil { - return 0, 0, 0, err - } - - r := float64(uint8(0xFF & (uint32(color) >> 16))) - g := float64(uint8(0xFF & (uint32(color) >> 8))) - b := float64(uint8(0xFF & uint32(color))) - return r, g, b, nil -} - -// Determine if label text should be light or dark to be readable on background color -func (l *Label) UseLightTextColor() bool { - if strings.HasPrefix(l.Color, "#") { - if r, g, b, err := l.ColorRGB(); err == nil { - // Perceived brightness from: https://www.w3.org/TR/AERT/#color-contrast - // In the future WCAG 3 APCA may be a better solution - brightness := (0.299*r + 0.587*g + 0.114*b) / 255 - return brightness < 0.35 - } - } - - return false -} - // Return scope substring of label name, or empty string if none exists func (l *Label) ExclusiveScope() string { if !l.Exclusive { diff --git a/models/issues/label_test.go b/models/issues/label_test.go index 1f6ce4f42e..1bc5a1a935 100644 --- a/models/issues/label_test.go +++ b/models/issues/label_test.go @@ -22,15 +22,6 @@ func TestLabel_CalOpenIssues(t *testing.T) { assert.EqualValues(t, 2, label.NumOpenIssues) } -func TestLabel_TextColor(t *testing.T) { - assert.NoError(t, unittest.PrepareTestDatabase()) - label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1}) - assert.False(t, label.UseLightTextColor()) - - label = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 2}) - assert.True(t, label.UseLightTextColor()) -} - func TestLabel_ExclusiveScope(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 7}) |