Skip to content

Commit 5a84c28

Browse files
mbostockFil
andauthored
allow light-dark() (#2412)
* allow light-dark() * set color-scheme in root * light-dark() for box, tree * pranier * test the defaults for treeLink and treeNode * prandier --------- Co-authored-by: Philippe Rivière <fil@rezo.net>
1 parent 7c15682 commit 5a84c28

17 files changed

+254
-44
lines changed

src/marks/box.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function boxX(
1616
x = identity,
1717
y = null,
1818
r,
19-
fill = "color-mix(in srgb, currentColor 20%, var(--plot-background))",
19+
fill = "light-dark(#ccc, #555)",
2020
fillOpacity,
2121
stroke = "currentColor",
2222
strokeOpacity,
@@ -42,7 +42,7 @@ export function boxY(
4242
y = identity,
4343
x = null,
4444
r,
45-
fill = "color-mix(in srgb, currentColor 20%, var(--plot-background))",
45+
fill = "light-dark(#ccc, #555)",
4646
fillOpacity,
4747
stroke = "currentColor",
4848
strokeOpacity,

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
}

src/transforms/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function treeLink({
6565
path = identity, // the delimited path
6666
delimiter, // how the path is separated
6767
curve = "bump-x",
68-
stroke = "color-mix(in srgb, currentColor 33%, var(--plot-background))",
68+
stroke = "light-dark(#777, #aaa)",
6969
strokeWidth = 1.5,
7070
strokeOpacity = 0.5,
7171
treeLayout = tree,

test/output/boxplot.svg

Lines changed: 1 addition & 1 deletion
Loading

test/output/boxplotFacetInterval.svg

Lines changed: 11 additions & 11 deletions
Loading

test/output/boxplotFacetNegativeInterval.svg

Lines changed: 11 additions & 11 deletions
Loading

test/output/diamondsBoxplot.svg

Lines changed: 1 addition & 1 deletion
Loading

test/output/greekGodsDefaults.svg

Lines changed: 43 additions & 0 deletions
Loading

test/output/greekGodsExplicit.svg

Lines changed: 1 addition & 1 deletion
Loading

test/output/internFacetNaN.svg

Lines changed: 12 additions & 12 deletions
Loading

0 commit comments

Comments
 (0)