Skip to content

Commit 019161d

Browse files
committed
only test current color scheme
1 parent 2b1c1e7 commit 019161d

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

test/plots/legend-opacity.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,30 @@
11
import * as Plot from "@observablehq/plot";
2-
import type {LegendScales} from "@observablehq/plot";
3-
import {select} from "d3";
42
import {test} from "test/plot";
53

6-
function opacityLegends(options: LegendScales) {
7-
const doc = (typeof document !== "undefined" ? document : undefined) || Plot.legend(options).ownerDocument;
8-
const div = doc.createElement("div");
9-
div.style.cssText = "display: flex; gap: 20px;";
10-
for (const [bg, color] of [
11-
["white", "black"],
12-
["black", "white"]
13-
]) {
14-
const box = doc.createElement("div");
15-
box.style.cssText = `background-color: ${bg}; color: ${color}; color-scheme: ${
16-
color === "white" ? "dark" : "light"
17-
}; padding: 20px;`;
18-
const svg = Plot.legend(options);
19-
select(svg).attr("style", `--plot-background: ${bg}`);
20-
box.appendChild(svg);
21-
div.appendChild(box);
22-
}
23-
return div;
24-
}
25-
264
test(function opacityLegend() {
27-
return opacityLegends({opacity: {domain: [0, 10], label: "Quantitative"}});
5+
return Plot.legend({opacity: {domain: [0, 10], label: "Quantitative"}});
286
});
297

308
test(function opacityLegendRange() {
31-
return opacityLegends({opacity: {domain: [0, 1], range: [0.5, 1], label: "Range"}});
9+
return Plot.legend({opacity: {domain: [0, 1], range: [0.5, 1], label: "Range"}});
3210
});
3311

3412
test(function opacityLegendLinear() {
35-
return opacityLegends({opacity: {type: "linear", domain: [0, 10], label: "Linear"}});
13+
return Plot.legend({opacity: {type: "linear", domain: [0, 10], label: "Linear"}});
3614
});
3715

3816
test(function opacityLegendColor() {
39-
return opacityLegends({opacity: {type: "linear", domain: [0, 10], label: "Linear"}, color: "steelblue"});
17+
return Plot.legend({opacity: {type: "linear", domain: [0, 10], label: "Linear"}, color: "steelblue"});
4018
});
4119

4220
test(function opacityLegendLog() {
43-
return opacityLegends({opacity: {type: "log", domain: [1, 10], label: "Log"}});
21+
return Plot.legend({opacity: {type: "log", domain: [1, 10], label: "Log"}});
4422
});
4523

4624
test(function opacityLegendSqrt() {
47-
return opacityLegends({opacity: {type: "sqrt", domain: [0, 1], label: "Sqrt"}});
25+
return Plot.legend({opacity: {type: "sqrt", domain: [0, 1], label: "Sqrt"}});
4826
});
4927

5028
test(function opacityLegendCSS4() {
51-
return opacityLegends({opacity: {type: "linear", domain: [0, 1], label: "p3"}, color: "color(display-p3 0 1 0)"});
29+
return Plot.legend({opacity: {type: "linear", domain: [0, 1], label: "p3"}, color: "color(display-p3 0 1 0)"});
5230
});

0 commit comments

Comments
 (0)