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

Make text of light tags legible #558

Merged
merged 4 commits into from
Jan 8, 2022

Conversation

Roy-Orbison
Copy link
Contributor

I found that many tags are difficult to read due to lack of contrast between the white text specified in the CSS and the random background colours, e.g.:

Screenshot_20220105_174112

These could be improved by dynamically assessing the brightness of the tag colour, and applying a different text colour, e.g.:

Screenshot_20220105_174407

Here's an untested draft of my idea to fix it. Feedback would be appreciated as I don't know TypeScript.

@Roy-Orbison Roy-Orbison force-pushed the tag-legibility branch 6 times, most recently from 2953940 to 7f5e2f6 Compare January 7, 2022 00:57
@acelaya
Copy link
Member

acelaya commented Jan 7, 2022

Thanks for the contribution!

I'll do a proper review in a couple of days/weeks, as soon as I finish a few other things and also release v3.5.1 of this project.

@Roy-Orbison
Copy link
Contributor Author

No worries. I'm sure you can easily fix my mistake that's preventing compilation, the rgb parsing works in JS, just not TS. 🙃

@Roy-Orbison Roy-Orbison force-pushed the tag-legibility branch 2 times, most recently from 7ba7f19 to 9191b0e Compare January 7, 2022 05:57
@github-actions
Copy link

github-actions bot commented Jan 7, 2022

@Roy-Orbison Roy-Orbison marked this pull request as ready for review January 7, 2022 06:00
@Roy-Orbison
Copy link
Contributor Author

Thanks for doing that CI task, it made debugging much easier. I just had a gander at our server in that preview environment, it worked. The contrast looks maybe a little too heavy on some colours around the threshold. You could probably reduce this effect with per-theme text colours in the CSS.

Screenshot_20220107_170118
Screenshot_20220107_170445

@acelaya
Copy link
Member

acelaya commented Jan 8, 2022

I really like how it looks. It's something so ovbious now that I see it done 🙂
image
image

@acelaya
Copy link
Member

acelaya commented Jan 8, 2022

There are some edge cases though. Shlink's brand color looks better with white text, but I guess that's a matter of tweaking the logic afterwards.
image

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2022

Codecov Report

Merging #558 (12f61d0) into develop (5b7f1ef) will increase coverage by 0.05%.
The diff coverage is 81.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #558      +/-   ##
===========================================
+ Coverage    78.53%   78.58%   +0.05%     
===========================================
  Files          174      174              
  Lines         2082     2092      +10     
  Branches       321      324       +3     
===========================================
+ Hits          1635     1644       +9     
+ Misses         187      186       -1     
- Partials       260      262       +2     
Impacted Files Coverage Δ
src/tags/helpers/Tag.tsx 50.00% <ø> (+50.00%) ⬆️
src/utils/services/ColorGenerator.ts 85.18% <81.81%> (-3.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b7f1ef...12f61d0. Read the comment docs.

@acelaya
Copy link
Member

acelaya commented Jan 8, 2022

I have pushed a couple of fixes for the linting issues, and added the missing tests.

I have also changed the CSS classes to use BEM, as that's the approach used in this project.

Thanks again for the contribution 🙂

@acelaya acelaya added this to the 3.6.0 milestone Jan 8, 2022
@acelaya acelaya merged commit 34a59db into shlinkio:develop Jan 8, 2022
@Roy-Orbison
Copy link
Contributor Author

Thanks for cleaning it up, I never expected it to go in as-is.

Another option for reducing excessive contrast could be to add up to two classes, one for tags lighter than, say 160, and one for those lighter than 96, instead of only one for the 128 midpoint. The first would only get dark text in the light theme, and the second would get dark text in the dark theme.

@acelaya
Copy link
Member

acelaya commented Jan 8, 2022

The theme doesn't really affect this. It's more like deciding where to put the "switch". Currently it's 50-50, but maybe it would look better with 60-40, or whatever.

I don't know. I'll probably do some checks with middle colors at some point, but for now, it works.

@Roy-Orbison
Copy link
Contributor Author

The theme doesn't really affect this.

No, it really does. The perception of how dark or light something is is relative to its surroundings. See this classic example for proof. The two-class option would mean only switching to the other text colour when absolutely necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants