-
Notifications
You must be signed in to change notification settings - Fork 138
Audit Color Combinations and Automatically Correct Color Contrast at User-Customizable Colors #284
Comments
There's a lot that can be done for accessibility with colors... For example there shouldn't be ANY text-color controls in the customizer. |
The hue-only approach works very well because all of the logic can live directly in the CSS by using HSL colors (and swapping out the selected hue). However, this theme lends itself better to full color pickers based on the differences between the default colors (less monochromatic). My leaning is essentially for color pickers for the background colors and the (opinionated-default) accent color, with everything else being generated. The generation logic should result in the current default color patters when the default colors are applied. |
My leaning is to supply default colors that meet the a11y goal, and let the user change the colors to whatever they prefer. |
After talking this through, we've decided that we will implement the following color options/changes:
@aristath has offered to lead the implementation of these options, and @celloexpressions will assist with feedback. |
* Get the color properties we'll need * Add isBackgroundLight & isBackgroundDark methods * cleanup * hslToRGB function * More WIP * Rebuilt it * missed this * add customizer.js file * Changed accent-color control to hue. * disable previous implementation for now * Enqueue files * notes * Add twentytwenty_get_color_for_area function * Change body & accent colors on the frontend * Add script for live-update background-color * Let there be light. * Rename files & add some more inline docs * use real functions instead of closures * Use wp_localize_script * Improve color calculations * Rename file to color-calculations * Revert "Rename file to color-calculations" This reverts commit c3a8054. * inline docs fix * minor bugfix in case there was an error * Add calcs for header colors * Add styles for header * typo * bugfix for header colors on preview Problem occured when when changing content bg-color * Tweak the fallback calc * pushed this one by mistake * Improve color script consistency & performance * Simplify colors script * The TwentyTwenty_Color class is no longer required * more color script tweaks - prefer AAA-compliant * Create proper sanitization callback * Remove old colorpicker, no longer used * Add accent color to editor palette * fix accent_accessible_colors setting default value * Added header/footer background-color * Rename file to color-calculations * Remove priorities from controls because 10. * Return false on twentytwenty_get_color_for_area * create elements array * shorten the array definitions * Save the background-color value in the option * auto-calculate secondary color * rename key to "borders" * added PHP implementation for css-output * Save secondary color. * better calculations for secondary color * Add elements for secondary * bugfix for secondary value (return string) * fix sanitization method for new structure * coding-standards fixes * Add more colors to the palette * Add body color styles to the editor * tweak for editor title color * Add support for dark-mode depending on background * remove extra blank line - fails travis test * coding-standards fixes * fill missing default values * fix lint issues
Thank you Joy! 👍 Lines 661 to 699 in 049e8fe
These will have to be reviewed and tweaked to fix any issues like the one you mentioned. That array is used in the customizer for the live previews, as well as in custom-css.php for the frontend.Please note that besides the accent , background , text and secondary there's also borders that can be used, I just didn't manage to do a complete clone of all the elements as that one was added last.
|
I made a small update here #440, but this can still be improved on, we might not want this level of specificity. |
The accent color is not restricted to the same saturation.
If yellow accent on gray doesn't return pure yellow but instead is mustard-y on most background-colors, that's because that is the most accessible color with that hue on that background. |
I know it's complicated, but perhaps too complicated. The colors that need to be WCAG compliant should refer to text contrast with background, not just any two colors. But I can see that the Accent color is used as text color in some places and not in others, and on multiple backgrounds. |
I'm afraid not. The colors are selected based on their luminance contrast with the background. So it's not linear, it depends on the hue. Yellow in particular is the most problematic hue when it comes to luminance... it is the closest to white and poses a lot of challenges, it is the edge case. There is no perfect solution. |
The accent colors are used primarily for links, buttons etc. Not just any text... That's why it's necessary to check the contrast against both the background and surrounding text. |
If we want to further tweak the color-selection, we can remove the surrounding-text check from these lines: twentytwenty/assets/js/color-calculations.js Lines 58 to 61 in 049e8fe
|
I don't have any major objections to the implementation that has been merged here. It looks like some of the minor fixes and adjustments have already been worked out. With yellow in particular, I would note that the background color needs to be dark to achieve contrast without getting a darker color than may be desired. This seems like expected behavior and encourages users to select combinations that work well together for contrast. A few more things to consider before we close this out:
If anyone has time to create an actual child theme to test the exstensibility of this feature, that's the best way to find problems with the technical implementation. |
I believe these 2 are already being taken care of in the main stylesheet and elements have already been added to the array.
It's a single filter,
Yes, they can change all elements using the
On the PHP side it should be fairly simple. |
Congrats for this amazing work on the color settings! 👏 |
Adding elements and styles for the colors that already get calculated is easy using the existing filters. Developers can define elements that will be controlled by the existing colors. They can define new "areas" that will have their colors calculated by changing the I'm not sure if we should do something to fix that. |
@aristath and @celloexpressions where are we at with this issue? Has it been fixed? Is there more work that needs to be done? Please let me know. Thanks |
Hey, someone mentioned this on Slack today: https://stripe.com/es-mx/blog/accessible-color-systems Could be good to get less muddy colors. |
I feel like we currently have a fairly good system in place with the theme that makes color selections accessible with the options that are provided for color selections. I am closing this issue here as I think this is pretty much done but if other things need adjusted we should open new tickets for the changes on trac. |
I think this is reducing accessibility to some color contrast rules set up by a function. What about red/green color blindness? This color slider gimmick is totally overrated if you ask me. |
@maxcady the function works using relative luminance which also takes into account the different ways people may perceive colors - including red and and green color blindness. It is what WCAG recommends, and in fact the algorithms used are the exact same ones from the WCAG recommendations. |
There have been several issues and PRs related to color options. Now that the initial implementation is mostly complete, let's evaluate whether Twenty Twenty provides an appropriate amount of customization without over-complicating the user experience, in accordance with the WordPress Philosophy.
We also need to review all combinations of text and background colors for:
Ideally, the result will be that users can change all of the colors in the theme and that a minimum color contrast threshold will be maintained regardless of the user's combination of selected colors. The current default color palate is:
#fff - header/footer background
#f5efe0 - body background
#dcd7ca - borders
#cd2653 - accent
#6d6d6d - secondary text
#000 - text
Initial Proposal
Based on my audit of color usage, I would propose the following adjustments:
With these adjustments, users can customize these colors:
And the theme would "calculate" selections for these colors when the defaults don't provide adequate contrast (via an extension of #249):
All of the calculated colors can be either a specific preset color or a color generated based on the user's selected colors.
Next Steps
style.css
for the default and user-customizable colors.The text was updated successfully, but these errors were encountered: