Skip to content

Commit

Permalink
[css-color-4][css-color-5] Make color swatches open via the keyboard …
Browse files Browse the repository at this point in the history
…as well, closes #7687
  • Loading branch information
LeaVerou committed Oct 5, 2022
1 parent e41dd10 commit 85afb17
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
14 changes: 8 additions & 6 deletions css-color-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ div.example>a.self-link::before {

<script>
document.addEventListener("DOMContentLoaded", ()=>{
[...document.querySelectorAll(".swatch")].forEach(e=>{
for (let e of document.querySelectorAll(".swatch")) {
e.tabIndex = "0";
const swatchColor = getComputedStyle(e).getPropertyValue("--color");
if(!CSS.supports('color', swatchColor)) {

if (!CSS.supports('color', swatchColor)) {
e.style.background = "repeating-linear-gradient(135deg, red 0, red 4px, white 4px, white 8px)";
e.setAttribute("title", "Your browser does not recognize this color value, so we can't preview it.");
}
});
}
});
</script>

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

In the course of converting the two colors
In the course of converting the two colors
to the [=interpolation color space=],
any [=missing components=]
will be replaced with the value 0.

Thus, the first stage in interpolating two colors
is to classify any [=missing components=]
in the input colors,
and compare them to the components of the
and compare them to the components of the
[=interpolation color space=].
If any analogous [=missing components=] are found,
they will be <strong>carried forward</strong>
Expand Down
4 changes: 3 additions & 1 deletion css-color-4/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
border: 2px solid red;
}

.swatch:hover {
.swatch:hover,
.swatch:focus {
transform: scale(3);
border-radius: 2px;
transition: .4s;
z-index: 2;
}

table.gamuts tr>td {
Expand Down
30 changes: 22 additions & 8 deletions css-color-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ spec:css-color-4; type:value; text:srgb
}
</style>

<script>
document.addEventListener("DOMContentLoaded", ()=>{
for (let e of document.querySelectorAll(".swatch")) {
e.tabIndex = "0";
const swatchColor = getComputedStyle(e).getPropertyValue("--color");

if (!CSS.supports('color', swatchColor)) {
e.style.background = "repeating-linear-gradient(135deg, red 0, red 4px, white 4px, white 8px)";
e.setAttribute("title", "Your browser does not recognize this color value, so we can't preview it.");
}
}
});
</script>

Introduction {#intro}
=====================

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

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

<figure id="fig-LCH-teal-olive">
<object data="images/CH-mixing3.svg" width=500 height=500>
<p>A mixture of two colours, and the mixed output.
We are looking down the CIE L axis onto the ab plane.
There are two axes, labelled <em>a</em> and <em>b</em>
which cross at the origin,
<p>A mixture of two colours, and the mixed output.
We are looking down the CIE L axis onto the ab plane.
There are two axes, labelled <em>a</em> and <em>b</em>
which cross at the origin,
which is in the centre of the plot.
</p>
</object>
Expand Down
4 changes: 3 additions & 1 deletion css-color-5/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
font: bold .3em/1.2 sans-serif;
}

.swatch:hover {
.swatch:hover,
.swatch:focus {
transform: scale(3);
border-radius: 2px;
transition: .4s;
z-index: 2;
}

table.gamuts tr:hover {
Expand Down

0 comments on commit 85afb17

Please sign in to comment.