Skip to content

Commit 57fe500

Browse files
LeaVeroufantasai
andcommitted
[css-color-6] Change syntax per NYC F2F resolutions #7359
- Dropped `to` and `vs` keywords - Moved algorithm to prelude - Added tbd keywords to distinguish foreground and background Co-Authored-By: fantasai <725717+fantasai@users.noreply.github.com>
1 parent f28babd commit 57fe500

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

css-color-6/Overview.bs

+23-12
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,28 @@ Computing a Contrasting Color: the ''contrast-color()'' function {#colorcontrast
6363
Its syntax is:
6464

6565
<pre class='prod'>
66-
<<contrast-color()>> = contrast-color( <<color>> [[ vs <<color>># ]? to <<target-contrast>>]? )
66+
<<contrast-color()>> = contrast-color(
67+
[ [ <<color>> && [ tbd-fg | tbd-bg ] && <<target-contrast>>? ] |
68+
[ <<color>> && [ tbd-fg | tbd-bg ] && <<target-contrast>>, <<color>># ] )
6769
<<target-contrast>> = <<wcag2>>
6870
</pre>
6971

7072
The only mandatory argument is the <dfn lt="contrast base color" local-lt="base color">base color</dfn>
7173
against which the contrast is computed.
7274
This is typically (but not necessarily) a background color.
7375

74-
An optional list of <dfn local-lt="color candidates">contrast color candidates</dfn> may be provided after a ''vs'' keyword.
76+
The optional list of <<color>> values represents
77+
the <dfn lt="contrast color candidates" local-lt="color candidates">color candidates</dfn>.
7578
If no candidates are provided, the default candidates are used: ''white, black''.
7679

80+
The ''tbd-fg'' and ''tbd-bg'' keywords
81+
indicate the role of the [=base color=] in calculating the contrast:
82+
as text against a list of [=color candidate|candidate=] background colors (<dfn for="contrast-color()" value>text</dfn>)
83+
or as a background against a list of [=color candidate|candidate=] text colors.
84+
(The effective contrast of a pair of colors depends on their usage.)
85+
86+
ISSUE (#7359): The keywords to specify whether the [=base color=] is a foreground or background are <abbr title="to be decided">TBD</abbr>.
87+
7788
The <dfn><<target-contrast>></dfn> argument specifies the contrast algorithm to use.
7889
If no [=color candidates=] have been provided,
7990
<<target-contrast>> may be omitted,
@@ -113,7 +124,7 @@ If there is a target contrast</h4>
113124
https://colorjs.io/notebook/?storage=https%3A%2F%2Fgist.github.com%2Fsvgeesus%2Fec249f376fcecbaa8794f75dbfc1dacf
114125
-->
115126
<div class="example">
116-
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to wcag2(aa))</pre>
127+
<pre class="lang-css">contrast-color(wheat tbd-bg wcag2(aa), bisque, darkgoldenrod, olive, sienna, darkgreen, maroon)</pre>
117128

118129
The calculation is as follows:
119130
* <span class="swatch" style="--color: wheat"></span> wheat (#f5deb3), the background, has relative luminance 0.749
@@ -128,7 +139,7 @@ If there is a target contrast</h4>
128139
</div>
129140

130141
<div class="example">
131-
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to wcag2(5.8))</pre>
142+
<pre class="lang-css">contrast-color(wheat tbd-bg wcag2(5.8), bisque, darkgoldenrod, olive, sienna, darkgreen, maroon)</pre>
132143

133144
The calculation is as follows:
134145
* the relative luminances and contrast ratios are the same as the previous example.
@@ -137,7 +148,7 @@ If there is a target contrast</h4>
137148
</div>
138149

139150
<div class="example">
140-
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive to wcag2(AA))</pre>
151+
<pre class="lang-css">contrast-color(wheat tbd-bg wcag2(AA), bisque, darkgoldenrod, olive)</pre>
141152

142153
The calculation is as follows:
143154
* the relative luminances and contrast ratios are the same as the previous example.
@@ -164,7 +175,7 @@ If no target contrast is specified</h4>
164175
<div class="example">
165176
<pre class="lang-css">
166177
--myAccent: #b22222;
167-
color: contrast-color(wheat vs tan, sienna, var(--myAccent), #d2691e to wcag2)
178+
color: contrast-color(wheat tbd-bg wcag2, tan, sienna, var(--myAccent), #d2691e)
168179
</pre>
169180

170181
The calculation is as follows:
@@ -182,7 +193,7 @@ If no target contrast is specified</h4>
182193
foo {
183194
--bg: hsl(200 50% 80%);
184195
--purple-in-hsl: hsl(300 100% 25%);
185-
color: contrast-color(var(--bg) vs hsl(200 83% 23%), purple, var(--purple-in-hsl) to wcag2);
196+
color: contrast-color(var(--bg) tbd-fg wcag2, hsl(200 83% 23%), purple, var(--purple-in-hsl));
186197
}
187198
</pre>
188199

@@ -290,7 +301,7 @@ If no target contrast is specified</h4>
290301
For example, given the value
291302

292303
<pre class="lang-css">
293-
contrast-color(rgb(179 213 230) vs cadetblue, hsl(200 83% 23%) to wcag2(AA))
304+
contrast-color(rgb(179 213 230) tbd-bg wcag2(AA), cadetblue, hsl(200 83% 23%))
294305
</pre>
295306

296307
the contrast with cadetblue is <strong>1.97</strong>
@@ -311,13 +322,13 @@ If no target contrast is specified</h4>
311322
the value
312323

313324
<pre class="lang-css">
314-
contrast-color(currentColor vs hsl(200 83% 23%), purple to wcag2(AA))
325+
contrast-color(currentColor tbd-bg wcag2(AA), hsl(200 83% 23%), purple)
315326
</pre>
316327

317328
has the computed value
318329

319330
<pre class="lang-css">
320-
contrast-color(currentColor vs rgb(10 75 107), rgb(128 0 128) to wcag2(4.5))
331+
contrast-color(currentColor tbd-bg wcag2(4.5), rgb(10 75 107), rgb(128 0 128))
321332
</pre>
322333

323334
</div>
@@ -401,14 +412,14 @@ is the same as that specified in
401412

402413
<div class="example">
403414
The winner of this contrast choice
404-
<pre>contrast-color(wheat vs olive, sienna, maroon)</pre>
415+
<pre>contrast-color(wheat tbd-bg wcag2, olive, sienna, maroon)</pre>
405416
is maroon,
406417
so the result is serialized as
407418
<span class="swatch" style="--color: maroon"></span>
408419
"rgb(128 0 0)".
409420

410421
While the winner of
411-
<pre>contrast-color(wheat vs color(prophoto-rgb 0.4 0.4 0.2), color(display-p3 0.45 0.08 0.05))</pre>
422+
<pre>contrast-color(wheat tbd-bg wcag2, color(prophoto-rgb 0.4 0.4 0.2), color(display-p3 0.45 0.08 0.05))</pre>
412423
is color(display-p3 0.45 0.08 0.05),
413424
so the result is serialized as
414425
<span class="swatch" style="--color: rgb(49.277% 0.414% 0.524%)"></span>

0 commit comments

Comments
 (0)