Skip to content

Commit 4baad4d

Browse files
authored
remove default white background (#1489)
* remove default white background * var(--plot-background) (#1513) * dark mode for dev * dev dark mode
1 parent 7098bf3 commit 4baad4d

File tree

649 files changed

+904
-1013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

649 files changed

+904
-1013
lines changed

docs/.vitepress/theme/custom.css

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040

4141
.vp-doc .plot,
4242
.vp-doc .plot-ramp {
43-
background: none;
43+
--plot-background: var(--vp-c-bg);
4444
overflow: visible;
4545
position: relative;
4646
z-index: 1;
4747
}
4848

49+
.vp-doc .plot [aria-label="tip"] {
50+
--plot-background: var(--vp-c-bg-alt);
51+
}
52+
4953
.vp-doc .plot-figure {
5054
margin: 16px 0 0;
5155
}
@@ -71,20 +75,6 @@
7175
text-decoration: initial;
7276
}
7377

74-
:root [aria-label="tip"][fill="white"],
75-
:root [aria-label="tip"] [fill="white"] {
76-
fill: var(--vp-c-bg-alt);
77-
}
78-
79-
:root.dark marker[stroke="white"],
80-
:root.dark [aria-label^="crosshair"][stroke="white"] {
81-
stroke: var(--vp-c-bg);
82-
}
83-
84-
:root.dark marker[fill="white"] {
85-
fill: var(--vp-c-bg);
86-
}
87-
8878
.vp-doc :not(pre) > code {
8979
line-height: 1.5;
9080
}

docs/features/plots.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Plot.plot({
266266
```
267267
:::
268268

269-
The **style** option allows custom styles to override Plot’s defaults. It may be specified either as a string of inline styles (*e.g.*, `"color: red;"`, in the same fashion as assigning [*element*.style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)) or an object of properties (*e.g.*, `{color: "red"}`, in the same fashion as assigning [*element*.style properties](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration)). By default, the returned plot has a white background, a max-width of 100%, and the system-ui font. Plot’s marks and axes default to [currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword), meaning that they will inherit the surrounding content’s color.
269+
The **style** option allows custom styles to override Plot’s defaults. It may be specified either as a string of inline styles (*e.g.*, `"color: red;"`, in the same fashion as assigning [*element*.style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)) or an object of properties (*e.g.*, `{color: "red"}`, in the same fashion as assigning [*element*.style properties](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration)). By default, the returned plot has a max-width of 100%, and the system-ui font. Plot’s marks and axes default to [currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword), meaning that they will inherit the surrounding content’s color.
270270

271271
:::warning CAUTION
272272
Unitless numbers ([quirky lengths](https://www.w3.org/TR/css-values-4/#deprecated-quirky-length)) such as `{padding: 20}` are not supported by some browsers; you should instead specify a string with units such as `{padding: "20px"}`.

src/legends/ramp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export function legendRamp(color, options) {
4040
svg.append("style").text(
4141
`.${className}-ramp {
4242
display: block;
43-
background: white;
4443
height: auto;
4544
height: intrinsic;
4645
max-width: 100%;

src/marker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function markerCircleFill(color, context) {
6161
.attr("markerWidth", 6.67)
6262
.attr("markerHeight", 6.67)
6363
.attr("fill", color)
64-
.attr("stroke", "white")
64+
.attr("stroke", "var(--plot-background)")
6565
.attr("stroke-width", 1.5)
6666
.call((marker) => marker.append("circle").attr("r", 3))
6767
.node();
@@ -72,7 +72,7 @@ function markerCircleStroke(color, context) {
7272
.attr("viewBox", "-5 -5 10 10")
7373
.attr("markerWidth", 6.67)
7474
.attr("markerHeight", 6.67)
75-
.attr("fill", "white")
75+
.attr("fill", "var(--plot-background)")
7676
.attr("stroke", color)
7777
.attr("stroke-width", 1.5)
7878
.call((marker) => marker.append("circle").attr("r", 3))

src/marks/crosshair.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function textOptions(k, pointerOptions, options) {
8585
color = "currentColor",
8686
textFill: fill = color,
8787
textFillOpacity: fillOpacity,
88-
textStroke: stroke = "white",
88+
textStroke: stroke = "var(--plot-background)",
8989
textStrokeOpacity: strokeOpacity,
9090
textStrokeWidth: strokeWidth = 5
9191
} = options;

src/marks/tip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {cut, clipper, splitter, maybeTextOverflow} from "./text.js";
1414

1515
const defaults = {
1616
ariaLabel: "tip",
17-
fill: "white",
17+
fill: "var(--plot-background)",
1818
stroke: "currentColor"
1919
};
2020

src/marks/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function tree(
2424
markerEnd = marker,
2525
dot: dotDot = isNoneish(markerStart) && isNoneish(markerEnd),
2626
text: textText = "node:name",
27-
textStroke = "white",
27+
textStroke = "var(--plot-background)",
2828
title = "node:path",
2929
dx,
3030
dy,

src/plot.d.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,9 @@ export interface PlotOptions extends ScaleDefaults {
8282
* properties][2]). Note that unitless numbers ([quirky lengths][3]) such as
8383
* `{padding: 20}` may not supported by some browsers; you should instead
8484
* specify a string with units such as `{padding: "20px"}`. By default, the
85-
* returned plot has a white background, a max-width of 100%, and the
86-
* system-ui font. Plot’s marks and axes default to [currentColor][4], meaning
87-
* that they will inherit the surrounding content’s color. For example, a dark
88-
* theme:
89-
*
90-
* ```js
91-
* Plot.plot({
92-
* style: "background: black; color: white;",
93-
* marks: …
94-
* })
95-
* ```
85+
* returned plot has a max-width of 100%, and the system-ui font. Plot’s marks
86+
* and axes default to [currentColor][4], meaning that they will inherit the
87+
* surrounding content’s color.
9688
*
9789
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
9890
* [2]: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration

src/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ export function plot(options = {}) {
258258
// Warning: if you edit this, change defaultClassName.
259259
svg.append("style").text(
260260
`.${className} {
261+
--plot-background: white;
261262
display: block;
262-
background: white;
263263
height: auto;
264264
height: intrinsic;
265265
max-width: 100%;

test/output/aaplBollinger.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)