Skip to content

Commit 50372e0

Browse files
authored
docs(meter): let meter use its rootclass in storybook (#3231)
Meter's Storybook template was using the rootClass for progress bar, rather than its own rootClass. It was set up this way because of the way the two components are housed together, and meter primarily just uses ProgressBar, with some added classes. This value not being unique made it difficult to compare and match up the value of rootClass in the packageJson spectrum data to the actual rootClass defined in the story files default args.
1 parent e4003a4 commit 50372e0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

components/progressbar/stories/meter.stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default {
3636
},
3737
args: {
3838
...ProgressBar.args,
39+
rootClass: "spectrum-Meter",
3940
size: "l",
4041
label: "Storage space",
4142
},

components/progressbar/stories/meter.template.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
import { Container } from "@spectrum-css/preview/decorators";
2-
import { Template as ProgressBar } from "./template.js";
32
import { html } from "lit";
3+
import { capitalize } from "lodash-es";
4+
import { Template as ProgressBar } from "./template.js";
45

56
import "../index.css";
67

78
export const Template = ({
89
customClasses = [],
910
fill,
1011
size = "s",
12+
rootClass = "spectrum-Meter",
13+
staticColor,
1114
...item
1215
} = {}, context = {}) => ProgressBar({
1316
customClasses: [
14-
...customClasses,
15-
"spectrum-Meter",
16-
typeof size !== "undefined" ? `spectrum-Meter--size${size.toUpperCase()}` : null,
17+
rootClass,
18+
typeof size !== "undefined" ? `${rootClass}--size${size.toUpperCase()}` : null,
1719
typeof fill !== "undefined" ? `is-${fill}` : null,
20+
/*
21+
* The `spectrum-Meter--staticWhite` class is not present in the Meter CSS, as it makes use of
22+
* `spectrum-ProgressBar--staticWhite`, but having this allows for simpler detection of static
23+
* colors when looking at the element using its `rootClass` in our decorators.
24+
*/
25+
typeof staticColor !== "undefined" ? `${rootClass}--static${capitalize(staticColor)}` : null,
26+
...customClasses,
1827
].filter(Boolean),
1928
size,
29+
staticColor,
2030
...item,
2131
}, context);
2232

0 commit comments

Comments
 (0)