-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Validate contrast color functions #24508
Comments
From the reference post and github css styles, Looks like github is using Relative Luminance to calculate the text color based on background color, where calculation of RGB is also different by definition (But I also find github just use the RGB values directly or maybe I misunderstood something). We are using color contrast for calculation now. I think the relative luminance way will make the contrast between background and text color of labels look better. |
I think our methods are similar to GitHub with the exception that GitHub also has/had the bug with the grey shade mentioned in the post. I would like to see the new functions modeled after CSS |
Actually this has been fixed using exatly the suggested solution by the article: github's current css: And the labels look good in the demo repo from the article now |
Thanks. I don't see the need for us to do this in CSS (which I think is clumsy and not unit-testable) but we should do the same they do, only in Go and JS. We can use the demo repos colors for our own unit tests. |
Yep agreed. |
For reference, demo label colors. Will be useful for our tests:
|
I am trying to modify the luminance calculation function to use the one same as github. But not sure how is this "selecting the one with the highest contrast from the list" function suppose to help? I see the current contrast calculation for scoped labels, scopeColor and itemColor are calculated based on luminance. |
To be truly universally usable, the function can not just return hardcoded black and white values. There is one case in the go codebase where it returns shades like I do think we should make all functions return |
I suggest we put the new functions in:
|
I see, do you know where this function is? I searched |
I tried to use the new luminance function with RGB channel values directly and RGB in relative luminance definiton respectively and got the following results, we might need to pick which one to use: left: use rgb directly (same as github does) right: use rgb in relative luminance definiton |
Maybe I was imagining things. Searching again, I can't find it anymore. The three instances of these functions are:
|
Those on the right look great to me. Left side has many issues with too little contrast, right has none. |
Personally I also like the right one better. Then I will go with the rgb calculation for the right one |
…e files (#24586) Close #24508 Main changes: As discussed in the issue 1. Change luminance calculation function to use [Relative Luminance](https://www.w3.org/WAI/GL/wiki/Relative_luminance) 2. Move the luminance related functions into color.go/color.js 3. Add tests for both the files (Not sure if test cases are too many now) Before (tests included by `UseLightTextOnBackground` are labels started with `##`): https://try.gitea.io/HesterG/testrepo/labels After: <img width="1307" alt="Screen Shot 2023-05-08 at 13 37 55" src="https://user-images.githubusercontent.com/17645053/236742562-fdfc3a4d-2fab-466b-9613-96f2bf96b4bc.png"> <img width="1289" alt="Screen Shot 2023-05-08 at 13 38 06" src="https://user-images.githubusercontent.com/17645053/236742570-022db68e-cec0-43bb-888a-fc54f5332cc3.png"> <img width="1299" alt="Screen Shot 2023-05-08 at 13 38 20" src="https://user-images.githubusercontent.com/17645053/236742572-9af1de45-fb7f-460b-828d-ba25fae20f51.png"> --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Backend has at least 2 implementations of a contrast color function, frontend has one.
This post has some potentially useful insights for the calculation. We should ensure the functions work the same in backend and frontend, and ideally also check if there are any existing issues where the function outputs suboptimal colors.
The text was updated successfully, but these errors were encountered: