[csswg-drafts] [css-color-5] add target contrast ratio to color-contrast? (#4749)

svgeesus has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-5] add target contrast ratio to color-contrast? ==

@mirisuzanne [wrote](https://gist.github.com/una/edcfa0d3600e0b89b2ebf266bf549721#gistcomment-2936297)

> I like the basic thrust, but working on design systems, I often need more control than max-contrast from a list. I’d like to see these uses considered as well:
> 
>     * min contrast to meet a particular ratio (from list)
>     * adjust given color to meet a particular ratio
> 
> I imagine the latter may open up too much complexity - but I’d consider the former a primary use-case.

Currently, [the color-contrast() function](https://drafts.csswg.org/css-color-5/#colorcontrast) takes two arguments: a color, and a list of colors.

This requirement could be addressed by adding a third parameter, which is a target contrast ratio. Instead of comparing the whole list, comparisons stop once the target contrast ratio has been reached or exceeded.

This assumes that the list is in order of desirability, but the resolution of #4732 already implies this (if two colors in the list have the same contrast, the earlier in the list wins; this implies the stylesheet author put them in order of desirability).

```
color-contrast() = color-contrast( <color>  <color>#  number?)
```

The number is optional and if omitted, the whole list is searched to find the highest contrast ratio.

So for example

```
color-contrast(tan var(--blue1), var(--blue2), var(--blue3), var(--blue4) 4.5)
```

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4749 using your GitHub account

Received on Wednesday, 5 February 2020 19:35:48 UTC