Closed Davidster closed 1 month ago
Ended up reverting this because the solution here is just trading some bad cases for others.
The fallback.inverse()
case still does not guarantee readability and it is affecting the Light
and Dark
theme variants, which are the most common.
We need to find a smarter way to generate a readable color.
Darn, well surely if swapping to the complete other end of the luminance spectrum doesn't fix the contrast then there is no possible way to pass the WCAG test for that particular background color, right? Maybe if neither white nor black passes the test then we could take the one that's closest to passing?
.. and log a warning if no good option was found?
we could also use the AA contrast ratio (4.5:1) instead of AAA (7:1) as a minimum
Maybe if neither white nor black passes the test then we could take the one that's closest to passing?
@Davidster Good idea. Did that in https://github.com/iced-rs/iced/commit/72b975ec82660b39f27b6cb015b763caf20e6483 and seems to work well.
If we run the todo example with the SolarizedDark theme, we can see that the text color selected for display on top of a cyan background is white ('All' button):
which brutally fails the WCAG contrast guidelines.
This change guarantees that the text color passes the test, and passes the guidelines by selecting black text for the example in question.