WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.18k stars 4.05k forks source link

Styles editor should show color contrast failures. #48055

Open joedolson opened 1 year ago

joedolson commented 1 year ago

What problem does this address?

When modifying text and background colors in the post editor, low contrast color combinations trigger a color contrast warning. This does not occur in the style editor, though the global nature of these style changes are a much more significant accessibility issue than case-specific contrast failures.

What is your proposed solution?

The color contrast checker should be extended to the global styles editing experience, the Stylebook, etc.

@annezazu

annezazu commented 1 year ago

Calling on a crew to dive in and adding to the 6.2 board @tellthemachines @apeatling @andrewserong.

andrewserong commented 1 year ago

Oh, this is an interesting one. Currently the ContrastChecker component only appears to be rendered within the color panel used in the block editor. There are some places where it could be tricky to introduce it (such as the style book) as it might not be very easy to determine which blocks result in poor color contrast.

However, in terms of introducing color contrast checking in global styles, probably a good place for us to start would be to look at the Colors screen. Since that screen is already looking up the global background and text colors, perhaps that could be a good initial place to introduce a color contrast warning?

Next steps could then be to introduce it to the Text, Background, and Heading color screens (where each screen would then need to do a lookup for the other color property for the contrast check — e.g. Text looks up Background, Heading looks up Background, Background looks up Text, etc)

screen-colors.js screen-text-color.js screen-background-color.js
image image image

If no-one beats me to it, I'll have a go at seeing how hard it'll be to introduce the color checker in those places, as I think that might get us a good part of the way there.

andrewserong commented 1 year ago

I've had a go at adding in the ContrastChecker to the Background, Text, Links, and Colors screens in global styles, just for the root-level (not block-level) color screens. Happy for any feedback over in #48115

andrewserong commented 1 year ago

After having a go at using the existing ContrastChecker component for global styles over in #48115, the experiment revealed a few challenges that will likely require some design work before making another attempt:

In short, I think we need two steps to proceed:

  1. Design work to figure out the right messaging / display of contrast issues in global styles colors screens
  2. Extract contrast checking logic into a hook, so that custom messaging/display can be created within global styles

For more detail on the issues encountered in the first exploration, see this comment and screengrab: https://github.com/WordPress/gutenberg/pull/48115#issuecomment-1436285411

I'll add the Needs Design label.

ndiego commented 1 year ago

Given that WordPress 6.3 Beta 1 is tomorrow and there has been no action on this issue, I am going to remove it from the 6.3 Project Board.