Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag text unreadable #18659

Closed
MGChecker opened this issue Feb 7, 2022 · 12 comments
Closed

Tag text unreadable #18659

MGChecker opened this issue Feb 7, 2022 · 12 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself topic/ui Change the appearance of the Gitea UI

Comments

@MGChecker
Copy link

Gitea Version

1.16.1

Operating System

Linux

Browser Version

Firefox

Can you reproduce the bug on the Gitea demo site?

Yes

Description

After the tag design change done in 1.16.x, many tag texts are rendered in black which were rendered in white before. For some colors, for example #207de5, this leads to text which is barely readable at best, especially if the tag is seen on white background.

In my opinion, an (at least) partial rollback of this text color change would be helpful.

Screenshots

Screenshot from 2022-02-07 18-42-29
Screenshot from 2022-02-07 18-42-07

@lafriks lafriks added issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself topic/ui Change the appearance of the Gitea UI labels Feb 8, 2022
@wxiaoguang
Copy link
Contributor

It should have been fixed in 1.19/1.20

@MGChecker
Copy link
Author

In 1.19.1, there is no improvement of the situation.

@wxiaoguang wxiaoguang reopened this Apr 27, 2023
@wxiaoguang
Copy link
Contributor

The improved code is here, do you have ideas about your case?

if r, g, b, err := label.ColorRGB(); err == nil {
// Make scope and item background colors slightly darker and lighter respectively.
// More contrast needed with higher luminance, empirically tweaked.
luminance := (0.299*r + 0.587*g + 0.114*b) / 255
contrast := 0.01 + luminance*0.03
// Ensure we add the same amount of contrast also near 0 and 1.
darken := contrast + math.Max(luminance+contrast-1.0, 0.0)
lighten := contrast + math.Max(contrast-luminance, 0.0)
// Compute factor to keep RGB values proportional.
darkenFactor := math.Max(luminance-darken, 0.0) / math.Max(luminance, 1.0/255.0)
lightenFactor := math.Min(luminance+lighten, 1.0) / math.Max(luminance, 1.0/255.0)
scopeBytes := []byte{
uint8(math.Min(math.Round(r*darkenFactor), 255)),
uint8(math.Min(math.Round(g*darkenFactor), 255)),
uint8(math.Min(math.Round(b*darkenFactor), 255)),
}
itemBytes := []byte{
uint8(math.Min(math.Round(r*lightenFactor), 255)),
uint8(math.Min(math.Round(g*lightenFactor), 255)),
uint8(math.Min(math.Round(b*lightenFactor), 255)),
}
itemColor = "#" + hex.EncodeToString(itemBytes)
scopeColor = "#" + hex.EncodeToString(scopeBytes)
}

@MGChecker
Copy link
Author

To me, this is not really related to scoped labels. It's just about using white text on dark labels more aggresively.
Screenshot from 2023-04-27 10-12-43
Screenshot from 2023-04-27 10-13-02

@MGChecker
Copy link
Author

I would expect an improvement from a change in

return brightness < 0.35

increasing this number slightly to 0.4 or something.

@wxiaoguang
Copy link
Contributor

To me, this is not really related to scoped labels. It's just about using white text on dark labels more aggresively.

Yup, it's not really related "scoped label", I mentioned that because the algorithm was changed (improved) again in that PR

@wxiaoguang
Copy link
Contributor

I would expect an improvement from a change in

return brightness < 0.35

increasing this number slightly to 0.4 or something.

Since it was contributed by #22585 .... @brechtvl do you have some ideas about this issue? I am not color expert 😁

@wxiaoguang
Copy link
Contributor

After #24586 , #207de5 looks good now

https://try.gitea.io/wxiaoguang/test/labels

image

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label May 11, 2023
@brechtvl
Copy link
Contributor

brechtvl commented May 11, 2023

On that same page, this one is still not readable:
enhancement

But I think this issue can't be fully solved by tweaking the logic to decide between black and white text. For some label color neither of those will be have good contrast. This can be seen playing around with:
https://www.myndex.com/APCA/

Another thing is that the theme background color matters quite a bit for readability, something that's readable with a dark background may not be on a light background. GitHub uses a completely different rendering style in dark themes. To fully solve the problem I think either that is needed, or the label color should be automatically darkened or lightened and not be exactly what the user chose.

@MGChecker
Copy link
Author

For me, this seems to be due to the fact that the color of the text is not white, but grey for some reason (only really noticable with white background). The greyness reduces the contrast significantly. Still, generally it is an improvement over the status quo ante.

On dark background, the label is fine.

@wxiaoguang
Copy link
Contributor

The latest code in #24586 is GetLuminance(r, g, b) < 0.453 (quote: " increasing this number slightly to 0.4 or something.")

So I guess this issue as a regression bug report it could be closed? It could have new issues to make detailed plans for the further improvements, to make the discussion more focused.

@wxiaoguang
Copy link
Contributor

I think this issue could be closed. Thank you all.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

No branches or pull requests

4 participants