Skip to content

Commit 85afb17

Browse files
committed
[css-color-4][css-color-5] Make color swatches open via the keyboard as well, closes #7687
1 parent e41dd10 commit 85afb17

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

css-color-4/Overview.bs

+8-6
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ div.example>a.self-link::before {
133133

134134
<script>
135135
document.addEventListener("DOMContentLoaded", ()=>{
136-
[...document.querySelectorAll(".swatch")].forEach(e=>{
136+
for (let e of document.querySelectorAll(".swatch")) {
137+
e.tabIndex = "0";
137138
const swatchColor = getComputedStyle(e).getPropertyValue("--color");
138-
if(!CSS.supports('color', swatchColor)) {
139+
140+
if (!CSS.supports('color', swatchColor)) {
139141
e.style.background = "repeating-linear-gradient(135deg, red 0, red 4px, white 4px, white 8px)";
140142
e.setAttribute("title", "Your browser does not recognize this color value, so we can't preview it.");
141143
}
142-
});
144+
}
143145
});
144146
</script>
145147

@@ -3458,7 +3460,7 @@ Specifying Predefined Colors: the ''color()'' function</h3>
34583460
These are not invalid and are retained for intermediate computations;
34593461
instead, for display, they are
34603462
<a>css gamut mapped</a> using a relative colorimetric intent
3461-
which brings the values
3463+
which brings the values
34623464
(in the display color space)
34633465
within the range 0/0% to 1/100%
34643466
at actual-value time.
@@ -4390,15 +4392,15 @@ Color Space for Interpolation</h3>
43904392
<h3 id="interpolation-missing">
43914393
Interpolating with Missing Components</h3>
43924394

4393-
In the course of converting the two colors
4395+
In the course of converting the two colors
43944396
to the [=interpolation color space=],
43954397
any [=missing components=]
43964398
will be replaced with the value 0.
43974399

43984400
Thus, the first stage in interpolating two colors
43994401
is to classify any [=missing components=]
44004402
in the input colors,
4401-
and compare them to the components of the
4403+
and compare them to the components of the
44024404
[=interpolation color space=].
44034405
If any analogous [=missing components=] are found,
44044406
they will be <strong>carried forward</strong>

css-color-4/style.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
border: 2px solid red;
1515
}
1616

17-
.swatch:hover {
17+
.swatch:hover,
18+
.swatch:focus {
1819
transform: scale(3);
1920
border-radius: 2px;
2021
transition: .4s;
22+
z-index: 2;
2123
}
2224

2325
table.gamuts tr>td {

css-color-5/Overview.bs

+22-8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ spec:css-color-4; type:value; text:srgb
5151
}
5252
</style>
5353

54+
<script>
55+
document.addEventListener("DOMContentLoaded", ()=>{
56+
for (let e of document.querySelectorAll(".swatch")) {
57+
e.tabIndex = "0";
58+
const swatchColor = getComputedStyle(e).getPropertyValue("--color");
59+
60+
if (!CSS.supports('color', swatchColor)) {
61+
e.style.background = "repeating-linear-gradient(135deg, red 0, red 4px, white 4px, white 8px)";
62+
e.setAttribute("title", "Your browser does not recognize this color value, so we can't preview it.");
63+
}
64+
}
65+
});
66+
</script>
67+
5468
Introduction {#intro}
5569
=====================
5670

@@ -238,10 +252,10 @@ and a percentage of 100% returns the same color converted to the specified color
238252

239253
<figure id="fig-LCH-peru-goldenrod">
240254
<object data="images/CH-mixing.svg" width=480 height=480>
241-
<p>A mixture of two colours, and the mixed output.
242-
We are looking down the CIE L axis onto the ab plane.
243-
There are two axes, labelled <em>a</em> and <em>b</em>
244-
which cross at the origin,
255+
<p>A mixture of two colours, and the mixed output.
256+
We are looking down the CIE L axis onto the ab plane.
257+
There are two axes, labelled <em>a</em> and <em>b</em>
258+
which cross at the origin,
245259
which is in the centre of the plot.</p>
246260
</object>
247261
<figcaption>Mixtures of peru and palegoldenrod in CIE LCH.
@@ -280,10 +294,10 @@ and a percentage of 100% returns the same color converted to the specified color
280294

281295
<figure id="fig-LCH-teal-olive">
282296
<object data="images/CH-mixing3.svg" width=500 height=500>
283-
<p>A mixture of two colours, and the mixed output.
284-
We are looking down the CIE L axis onto the ab plane.
285-
There are two axes, labelled <em>a</em> and <em>b</em>
286-
which cross at the origin,
297+
<p>A mixture of two colours, and the mixed output.
298+
We are looking down the CIE L axis onto the ab plane.
299+
There are two axes, labelled <em>a</em> and <em>b</em>
300+
which cross at the origin,
287301
which is in the centre of the plot.
288302
</p>
289303
</object>

css-color-5/style.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
font: bold .3em/1.2 sans-serif;
2828
}
2929

30-
.swatch:hover {
30+
.swatch:hover,
31+
.swatch:focus {
3132
transform: scale(3);
3233
border-radius: 2px;
3334
transition: .4s;
35+
z-index: 2;
3436
}
3537

3638
table.gamuts tr:hover {

0 commit comments

Comments
 (0)