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

a11y does not support opacity #93

Open
dasveloper opened this issue Jun 11, 2022 · 2 comments
Open

a11y does not support opacity #93

dasveloper opened this issue Jun 11, 2022 · 2 comments

Comments

@dasveloper
Copy link

The a11y plugin doesn't support opacity. It would be great if it did.

Black on white = 21
colord('#000000').contrast('#FFFFFF')

Transparent black on white = 21, even though the text is invisible.
colord('#00000000').contrast('#FFFFFF')

Black on white is readable
colord('#000000').isReadable('#FFFFFF')

Transparent black on white is readable, even though the text is invisible.
colord('#00000000').isReadable('#FFFFFF')

@ciampo
Copy link

ciampo commented Jan 25, 2023

I think an important consideration to make when implementing such a feature (and the reason why colord may not support it yet) is that the computation of contrast/readability should take into account also the underlying "background" color.

For example:

colord("#ffffff").isReadable("#ff000080"); // true (white on 50% transparent red)

should return very different results if the color "underlying" the transparent red is black or white.

In short, the contrast calculation should be done against the equivalent "compound" solid color

@ciampo
Copy link

ciampo commented Jan 26, 2023

Update: as @t-hamano pointed out in WordPress/gutenberg#47373 (comment) , the mix plugin could be used to calculate the compound color, which can then be fed to the relevant a11y util

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

No branches or pull requests

2 participants