Re: [csswg-drafts] [css-color-6] `contrast-color()` syntax proposal (#7954)

> This allows an algo to have more than 1 argument. The (unfinished) [wcag3](https://www.w3.org/TR/wcag-3.0/) for example also takes font weight and size into account, which could then be expressed as wcag3(75, font-size, weight)

engineering made it sound like they could derive that as they needed and wouldnt require authors to pass it explicitly to fulfill the algo. hopefully authors wont have to know that much about the api surface area of a contrast algorithm to use it right.

### something to consider..
The longer this function sits, the more that folks will use cielab to estimate L* differences for contrast. [See this post here where the author suggests we don't need `color-contrast()`](https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl#:~:text=body%20%7B%0A%20%20background%3A%20var(%2D%2Daccent)%3B%0A%20%20/*%20We%20do%20not%20need%20to%20detect%20text%20color%20with%20color%2Dcontrast()%0A%20%20%20%20%20because%20OKLCH%20has%20predicted%20contrast.%0A%20%20%20%20%20All%20backgrounds%20with%20L%E2%89%A575%25%20have%20good%20contrast%20with%20black%20text.%20*/%0A%20%20color%3A%20black%3B%0A%7D). I've considered this before as well, as relative color syntax allows me to ask for a calculated L* difference easily, completely bypassing all these conversations about which contrast algorithm is the best. there's a number of problems with this doing this:
1. delta 60 is an estimate for roughly wcag ~4.5, so it may be more or less than needed
2. it doesnt take into account the users contrast preference
3. it doesnt know foreground from background

All things that `contrast-color()` should do for authors, like in this proposal.

BUT, this L* calc() ability is about to be in hands before `contrast-color()`. Even without relative color syntax the math can be done on a per channel basis with custom properties in a cielab space: `background: oklch(calc(var(--bg-l) + 50) c h)`. The sooner we can resolve on this function, the more folks we can save from attempting to bake accessibility into their colors themselves. 

-- 
GitHub Notification of comment by argyleink
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7954#issuecomment-1292730083 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 26 October 2022 22:25:39 UTC