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

color-contrast support for basic gradient backgrounds #4628

Open
dbjorge opened this issue Oct 28, 2024 · 0 comments
Open

color-contrast support for basic gradient backgrounds #4628

dbjorge opened this issue Oct 28, 2024 · 0 comments
Labels
feat New feature or enhancement ungroomed Ticket needs a maintainer to prioritize and label

Comments

@dbjorge
Copy link
Contributor

dbjorge commented Oct 28, 2024

Product

axe-core

Feature Description

Today, color-contrast gives an incomplete result anytime it detects text with a background-image that involves any sort of gradient.

However, it's relatively common for gradient backgrounds to be "simple" cases like this:

<span
  style="background-image: linear-gradient(rgb(240, 240, 240), rgb(255, 255, 255))"
>
  Text
</span>

...where color contrast would pass if tested at any point along the interpolation between the 2 color stops.

It would be a nice feature for axe-core to be able to handle "simple" gradient cases like this by testing a foreground color against multiple background colors and only giving a bgGradient incomplete if the different tests give different results.

In color spaces where relative luminance changes monotonically during a gradient interpolation (eg, sRGB), this would just require testing against each color stop (and confirming that "which of fg and bg is lighter" doesn't swap between the stops). In other color spaces (probably including the default gradient interpolation color space (oklab)), it might be simplest to just pick some arbitrary number of points in the color space along the interpolation and test each.

@dbjorge dbjorge added feat New feature or enhancement ungroomed Ticket needs a maintainer to prioritize and label labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or enhancement ungroomed Ticket needs a maintainer to prioritize and label
Projects
None yet
Development

No branches or pull requests

1 participant