w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.47k stars 658 forks source link

[css-color-6] `css-color` unspecified target contrast ratios with `contrast-color()` should use the users preference #10029

Open argyleink opened 7 months ago

argyleink commented 7 months ago

https://drafts.csswg.org/css-color-6/

The general goal of contrast-color() is to provide legible color pairings for users and make it "easy" for authors. In that ethos, I think the function could use the user's contrast preference when resolving a color. This would prevent code duplication if authors were expected to repeat the contrast-color() function within media queries, passing explicit target values within the queries. This issue/proposal wants to make the user's contrast preference easier to implement for authors, and also make the default function value the most dynamic and appropriate value for users.

tldr; the default for authors would be to let the browser figure it out for each user, not a default of authors needing to know what scores match each user preference.

Quick user story:
A user prefers contrast more in their OS settings, contrast-color() defaults to using this preference and resolves a value for them to a contrast target of AAA/7.

LeaVerou commented 7 months ago

Given that the MVP of contrast-color() returns either white/black or colors very close to them, these are high contrast combinations anyway, so the user's contrast preference wouldn't change a thing.

argyleink commented 7 months ago

confirm, this is beyond the MVP, it's for when a color list is provided or the potential feature of automatic color discovery