Skip to content

Commit 407e3c4

Browse files
committed
allow light-dark()
1 parent 1634d77 commit 407e3c4

4 files changed

Lines changed: 136 additions & 1 deletion

File tree

src/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ export function isColor(value) {
547547
value = value.toLowerCase().trim();
548548
return (
549549
/^#[0-9a-f]{3,8}$/.test(value) || // hex rgb, rgba, rrggbb, rrggbbaa
550-
/^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(value) || // <funciri>, CSS variable, color, etc.
550+
/^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\(.*\)$/.test(value) || // <funciri>, CSS variable, color, etc.
551551
namedColors.has(value) // currentColor, red, etc.
552552
);
553553
}

test/output/lightDark.svg

Lines changed: 124 additions & 0 deletions
Loading

test/plots/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ import "./letter-frequency-dot.js";
155155
import "./letter-frequency-lollipop.js";
156156
import "./letter-frequency-wheel.js";
157157
import "./libor-projections.js";
158+
import "./light-dark.js";
158159
import "./likert-survey.js";
159160
import "./linear-regression-cars.js";
160161
import "./linear-regression-mtcars.js";

test/plots/light-dark.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Plot from "@observablehq/plot";
2+
import * as d3 from "d3";
3+
import {test} from "test/plot";
4+
5+
test(async function lightDark() {
6+
const alphabet = await d3.csv<any>("data/alphabet.csv", d3.autoType);
7+
return Plot.plot({
8+
marks: [Plot.barX(alphabet, {x: "frequency", y: "letter", fill: "light-dark(steelblue, orange)", sort: {y: "-x"}})]
9+
});
10+
});

0 commit comments

Comments
 (0)