gristlabs / grist-core

Grist is the evolution of spreadsheets.
https://www.getgrist.com
Apache License 2.0
7.27k stars 322 forks source link

Fix color contrast issues #1243

Open manuhabitela opened 1 month ago

manuhabitela commented 1 month ago

Describe the problem to be solved

:wave:

The goal of this issue is to track all color contrasts issues according to WCAG, the international accessibility guidelines, so that everyone can correctly distinguish text, UI elements, etc.

Context is:

Sources:

There are lots of tools to test color contrast ratio issues:

Describe the solution you would like

Here are the issues I noticed for now:

Screenshots:

Choosing more visible gray variants would fix lots of the issues as, besides the green Grist color, most color issues are tied to the white/gray combined usage.

Will add examples to this issue when I encounter more.

manuhabitela commented 1 month ago

To help better understand, here is a big picture view of potential contrast issues thanks a tool that allows to cross reference all colors of a complete color palette:

You can filter out the grid on the left side with the AAA, AA, AA18 and DNP buttons.

What do the buttons mean you ask?

:information_source: Note that for actually disabled elements on a page (like a disabled button that we can't click on), or for purely decorative things on a page, color contrast ratio requirements can be ignored. Basically the rule is: if I could remove the element from the page and still completely understand everything I need, we don't care about color issues.


This contrast grid tool is not the best one to quickly test new color combinations on the fly, so you can try lots of other ones online. This one for example.

Here is a really quick test with an OK-green (with white), just lowered luminance of the theme color enough to match 4.5:1 ratio.

image

@dsagal

lusebille commented 1 month ago

I've made some mocks applied those rules https://www.figma.com/design/wcpetFt6aOKzTszcvPPWLQ/%5B05%2F24%5D-Grist-Design?node-id=2202-97849&t=qyem49MNdu9SdpUT-1

tayflo commented 4 weeks ago

I agree with this issue, thanks for pointing it out! I also feel like better contrast would be more comfortable even for users without colorblindness or such.

I've made some mocks applied those rules: figma link

If I may share my personal opinion on those, I would say among the two I prefer the left one, more greeny and less bluish – it's quite personal, but to me it feels more "living" and less "cold".

PS: Thanks @manuhabitela for the contrast-grid.eightshapes.com tool! It's great, I did not know about it.

I was going to also mention the coolors.co tool but just saw you did it already :-) One advantage it has over the eightshapes tool is it has a built-in color selector which allows for quick tweaking, and one advantage over the siegemedia tool is it display both <AA, >AA and >AAA levels for both small and large text in a clear way (tho, it allows for comparison between only two colors (no grid), and is not open-source).

dsagal commented 3 weeks ago

That article mentioned in https://github.com/gristlabs/grist-core/issues/1244#issuecomment-2435505433 (this article) is interesting. In particular, according to this new APCA effort, the Grist "green" is very close to being accessible. With a small adjustment (from #16B378 to #16a16b) it passes their "60%, minimum for normal-sized text" threshold, both for white-on-green and for green-on-white: https://www.myndex.com/APCA/?BG=16a16b&TXT=ffffff&DEV=G4g&BUF=A22

manuhabitela commented 2 weeks ago

Yep! Beware though :)

So it's a good tool but I don't think we should take it as "no need to target WCAG 2 requirements".

dsagal commented 2 weeks ago

Got it @manuhabitela. So looking through the mockups, I see as most visible difference to users the following changes:

White-on-green would satisfy 4.5:1 ratio, but green foreground would satisfy it on white background and light-grey (#F7F7F7), but not on "salad green" (#DCF4EB) from some other proposed designs.

What do you think of this adjustment:

Separately, we should be considering a project of opt-in themes to support a high-contrast theme. Another nice-to-have opt-in theme would be "Grist classic" theme with today's colors. Having such an option would make it much easier to switch the default colors, since any users who miss today's colors could keep them. @manuhabitela , am I right that this would be entirely OK, as long as the default is accessible?

Related question to @manuhabitela : does the dark-mode theme need to be adjusted for a11y? It is the default when the OS/browser is set to a dark mode preference.

For any themes, I know @georgegevoian had some thoughts about drastically reducing the number of CSS variables that we have today, which should make multiple themes easier to maintain (e.g. as new components are added). @manuhabitela , let me know if you are interested in looking into that -- that sounds like more work upfront, but may save work later.

manuhabitela commented 2 weeks ago

What do you think of this adjustment:

  • Green color for white-on-green elements (like buttons): #16B378 -> #12875C (slightly closer to today's, just meeting 4.5:1 contrast)
  • Green color as foreground: #16B378 -> #0F7B51 (slightly darker than proposed, meeting 4.5:1 contrast even on light grey and on salad green)

Sounds great for me! @lusebille?

Note that the "salad green" ratio, for currently suggested mockups, does not need the 4.5:1 contrast ratio as its used for non-text UIs (icon buttons). So only 3:1 is needed for now. But it's a good idea on paper to target 4.5:1, this will allow us to use this combination for text UIs later.

Separately, we should be considering a project of opt-in themes to support a high-contrast theme. Another nice-to-have opt-in theme would be "Grist classic" theme with today's colors. Having such an option would make it much easier to switch the default colors, since any users who miss today's colors could keep them. @manuhabitela , am I right that this would be entirely OK, as long as the default is accessible?

It's entirely OK as long as one theme is accessible. If the default is not accessible, on paper, it's OK as long as we give the option to enable an accessible theme.

My main advice would be, make the default theme the most WCAG-compliant as we can. And for the few cases we conclude it's not ideal by default, because the UI shows a lot of stuff at once, and having sharp contrasts might make things harder, "heavier" to read here and there; we leave them as not WCAG-compliant on the default theme, but handle them correctly in a specific high contrast mode.

From my personal point of view I wouldn't make any exception and have the default theme follow all WCAG rules, but I can understand this can feel too much sometimes haha, especially in a UI like Grist.

Related question to @manuhabitela : does the dark-mode theme need to be adjusted for a11y? It is the default when the OS/browser is set to a dark mode preference.

It would be obviously better if adjustments were made to the dark mode so that it fixes all contrast issues too, but again, it doesnt need to be WCAG-compliant if we have one alternative theme that fixes all issues.

For any themes, I know @georgegevoian had some thoughts about drastically reducing the number of CSS variables that we have today, which should make multiple themes easier to maintain (e.g. as new components are added). @manuhabitela , let me know if you are interested in looking into that -- that sounds like more work upfront, but may save work later.

Yeah that seems like a good idea to tackle that first, I can check that up.

lusebille commented 1 week ago

Maybe my figma is clear only in my head (anyway github is so unclear for me 😅 ) :

  • Grey borders around inputs, widgets, panels changing #D9D9D9 -> #B1B1B1 (mostly) or #8C8C8C (around widgets), though only the latter satisfies the 3:1 contrast ratio

**>>The rule is more :

White-on-green would satisfy 4.5:1 ratio, but green foreground would satisfy it on white background and light-grey (#F7F7F7), but not on "salad green" (#DCF4EB) from some other proposed designs.

What do you think of this adjustment:

  • Green color for white-on-green elements (like buttons): #16B378 -> #12875C (slightly closer to today's, just meeting 4.5:1 contrast)
  • Green color as foreground: #16B378 -> #0F7B51 (slightly darker than proposed, meeting 4.5:1 contrast even on light grey and on salad green)

>> Ok for me ( I've made those changed in the mocks) @manuhabitela with the Blue DSFR no need the have 2 colors , notice that I've added also a new 'dark- green' on figma file, and dark green will replace both dark and darker green , so #009058 and #007548 >> #196C47