Skip to content

Commit 7c00749

Browse files
committed
chore(clearbutton): update storybook to include over background story
1 parent 18be98a commit 7c00749

File tree

3 files changed

+76
-24
lines changed

3 files changed

+76
-24
lines changed
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
| Modifiable Custom Properties |
2-
| ----------------------------------------- |
3-
| `--mod-clear-button-height` |
4-
| `--mod-clear-button-icon-color` |
5-
| `--mod-clear-button-icon-color-down` |
6-
| `--mod-clear-button-icon-color-hover` |
7-
| `--mod-clear-button-icon-color-key-focus` |
8-
| `--mod-clear-button-padding` |
9-
| `--mod-clear-button-width` |
1+
| Modifiable Custom Properties |
2+
| ----------------------------------------------- |
3+
| `--mod-clear-button-background-color` |
4+
| `--mod-clear-button-background-color-down` |
5+
| `--mod-clear-button-background-color-hover` |
6+
| `--mod-clear-button-background-color-key-focus` |
7+
| `--mod-clear-button-height` |
8+
| `--mod-clear-button-icon-color` |
9+
| `--mod-clear-button-icon-color-down` |
10+
| `--mod-clear-button-icon-color-hover` |
11+
| `--mod-clear-button-icon-color-key-focus` |
12+
| `--mod-clear-button-padding` |
13+
| `--mod-clear-button-width` |

components/clearbutton/stories/clearbutton.stories.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ export default {
2525
},
2626
control: "boolean",
2727
},
28-
variant: {
29-
name: "Variant",
30-
type: { name: "string" },
31-
table: {
32-
type: { summary: "string" },
33-
category: "Component",
34-
},
35-
options: ["overBackground"],
36-
control: "select",
37-
},
28+
variant: { table: { disable: true }},
3829
},
3930
args: {
4031
rootClass: "spectrum-ClearButton",
@@ -55,3 +46,13 @@ export default {
5546

5647
export const Default = Template.bind({});
5748
Default.args = {};
49+
50+
export const OverBackground = Template.bind({});
51+
OverBackground.args = {
52+
variant: "overBackground",
53+
styles: {
54+
"background-color": "rgb(15, 121, 125);",
55+
"color": "rgb(15, 121, 125);",
56+
"padding": "15px 20px;"
57+
}
58+
};

components/clearbutton/stories/template.js

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { html } from "lit";
2-
import { classMap } from "lit/directives/class-map.js";
3-
// import { ifDefined } from 'lit/directives/if-defined.js';
1+
import { html } from "lit-html";
2+
import { classMap } from "lit-html/directives/class-map.js";
3+
import { styleMap } from "lit-html/directives/style-map.js";
4+
import { ifDefined } from 'lit-html/directives/if-defined.js';
45

56
import { Template as Icon } from "@spectrum-css/icon/stories/template.js";
67

78
import "../index.css";
89

9-
export const Template = ({
10+
export const ClearButton = ({
1011
rootClass = "spectrum-ClearButton",
1112
customClasses = [],
1213
isDisabled = false,
1314
size = "m",
1415
variant,
16+
styles = {},
1517
...globals
1618
}) => {
1719
return html`
18-
<button
20+
<button
1921
type="reset"
2022
class=${classMap({
2123
[rootClass]: true,
@@ -25,6 +27,7 @@ export const Template = ({
2527
"is-disabled": isDisabled,
2628
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
2729
})}
30+
style=${ifDefined(styleMap(styles))}
2831
?disabled=${isDisabled}
2932
>
3033
<div class="${rootClass}-fill">
@@ -36,4 +39,48 @@ export const Template = ({
3639
</div>
3740
</button>
3841
`;
42+
}
43+
44+
export const Template = ({
45+
rootClass = "spectrum-ClearButton",
46+
customClasses = [],
47+
isDisabled = false,
48+
size = "m",
49+
variant,
50+
styles = {},
51+
...globals
52+
}) => {
53+
const { express } = globals;
54+
55+
try {
56+
if (!express) import(/* webpackPrefetch: true */ "../themes/spectrum.css");
57+
else import(/* webpackPrefetch: true */ "../themes/express.css");
58+
} catch (e) {
59+
console.warn(e);
60+
}
61+
62+
if (typeof variant !== "undefined") {
63+
return html`
64+
<div style=${ifDefined(styleMap(styles))}>
65+
${ClearButton({
66+
rootClass,
67+
customClasses,
68+
isDisabled,
69+
size,
70+
variant,
71+
globals
72+
})}
73+
</div>
74+
`;
75+
}
76+
77+
return ClearButton({
78+
rootClass,
79+
customClasses,
80+
isDisabled,
81+
size,
82+
variant,
83+
styles,
84+
globals
85+
})
3986
};

0 commit comments

Comments
 (0)