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

feat: change breakpoint to switch black SVG img to white #1593

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

yohanboniface
Copy link
Member

@yohanboniface yohanboniface commented Feb 12, 2024

I've been a report about changed pictograms, which pointed to this map:

image

I found that with those grey, the picto should have been white, so I had a look and increased a bit the threshold.

Before:
Screenshot from 2024-02-12 12-42-02

After:
Screenshot from 2024-02-12 12-41-49

@yohanboniface yohanboniface force-pushed the icon-img-breakpoint branch 2 times, most recently from c5b6b35 to bf9b9d7 Compare February 12, 2024 11:37
@Aurelie-Jallut
Copy link

We're good !
"A minimum contrast ratio of 3:1 between interface components or graphic elements carrying information and their background."
=> White / Grey (background) => contrast = 3.94
=> White / DimGrey (background) => contrat = 5.48

@yohanboniface
Copy link
Member Author

I tried to be more accurate in the choice, so I scripted a map with (named) colors close to the threshold (in parentesis the weight computed by umap, which is just a sum of RGB values).

Before this PR:

image

With threshold = 150

image

With threshold = 140

image

With my human eyes, I feel like 140 is the best choice, but I'd like your review again on this @davidbgk @Aurelie-Jallut :)

@davidbgk
Copy link
Contributor

We need to check contrast on the green markers at the bottom but it's easier from a live version, let's do that together :)

@Aurelie-Jallut
Copy link

The number in brackets gives an indication of the weight of the color?
I don't quite understand the logic but I'm interested : )

I have the impression that there are colors above 140 that could accommodate a white picto like for example: Mediumpurple(159.33).
The color darkorange (131,67) on the other hand is at 1.37 in contrast with the white picto.

@manuhabitela
Copy link

manuhabitela commented Feb 12, 2024

👋

As Aurélie said the important thing is to have a 3:1 contrast ratio between icon and background. Usually green shades are kinda hard to match with white.

Here is a totally overwhelming grid that checks contrast of a bunch of colors of the final screenshot (note I didn't check all of them, focused on the ones with white text).

Don't worry you just have to look at the two first lines of the grid (or first two columns, as you wish). All the shown cells, which are the ones marked "DNP", do not have sufficient contrast with either black or white foreground.

Few ideas to be sure to generate OK colors:

  • use the WCAG contrast ratio formula, like the one used in color to check the background color with both black and white foreground, and chose the one that has the better contrast ratio?
  • do as what Tanaguru does and have a script return the "closest" accessible color to what you want

I've decided for a basic home made util, because:
- I'm not sure color is still maintained
- colorjs.io sounds very cool and maintained, but is 105k
- there is no custom bundle yet
- it uses proper modules, but for just the contrast util we need
  to pull all the class logic, and it's a lot
@yohanboniface
Copy link
Member Author

Mieux comme ça ? :)
Basé sur un algo de WGAG si j'ai bien tout lu Freud!

image

@yohanboniface yohanboniface merged commit e1e255f into master Feb 13, 2024
4 checks passed
@yohanboniface yohanboniface deleted the icon-img-breakpoint branch February 13, 2024 13:16
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.

None yet

4 participants