Skip to content

Commit aae1386

Browse files
authored
chore: load typography template in stories (#2253)
Storybook needs to load all assets for a component and cannot reference classes from other packages without first importing them.
1 parent e7c7382 commit aae1386

File tree

44 files changed

+339
-426
lines changed

Some content is hidden

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

44 files changed

+339
-426
lines changed

components/actionbar/stories/template.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { html } from "lit";
22
import { classMap } from "lit/directives/class-map.js";
3-
// import { ifDefined } from 'lit/directives/if-defined.js';
43

5-
import { Template as Popover } from "@spectrum-css/popover/stories/template.js";
4+
import { Template as ActionGroup } from "@spectrum-css/actiongroup/stories/template.js";
65
import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js";
76
import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js";
8-
import { Template as ActionGroup } from "@spectrum-css/actiongroup/stories/template.js";
7+
import { Template as Popover } from "@spectrum-css/popover/stories/template.js";
98

109
import "../index.css";
1110

components/actionbutton/stories/actionbutton-staticblack.stories.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { argTypes, ActionButtons } from "./index";
1+
import { ActionButtons, argTypes } from "./index";
22

33
export default {
44
title: "Components/Action button/Static Black",
@@ -13,8 +13,7 @@ export default {
1313
isQuiet: false,
1414
isEmphasized: false,
1515
hasPopup: false,
16-
backgroundColor: "rgb(181, 209, 211)",
17-
staticColor: "black",
16+
staticColor: "black",
1817
},
1918
parameters: {
2019
actions: {

components/actionbutton/stories/actionbutton-staticwhite.stories.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { argTypes, ActionButtons } from "./index";
1+
import { ActionButtons, argTypes } from "./index";
22

33
export default {
44
title: "Components/Action button/Static White",
@@ -13,8 +13,7 @@ export default {
1313
isQuiet: false,
1414
isEmphasized: false,
1515
hasPopup: false,
16-
backgroundColor: "rgb(15, 121, 125)",
17-
staticColor: "white",
16+
staticColor: "white",
1817
},
1918
parameters: {
2019
actions: {

components/actionbutton/stories/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html } from "lit";
2+
import { ifDefined } from "lit/directives/if-defined.js";
3+
import { styleMap } from "lit/directives/style-map.js";
24

3-
// Import the component markup template
45
import { Template } from "./template";
56

67
import { default as IconStories } from "@spectrum-css/icon";
@@ -96,27 +97,35 @@ export const argTypes = {
9697
},
9798
};
9899

99-
export const ActionButtons = (args) => {
100+
export const ActionButtons = ({
101+
staticColor,
102+
...args
103+
}) => {
100104
return html`
101105
<div
102-
style="padding: 1rem; ${args.staticColor && args.backgroundColor
103-
? `background-color: ${args.backgroundColor}`
104-
: ""}"
106+
style=${ifDefined(styleMap({
107+
padding: "1rem",
108+
backgroundColor: staticColor === "white" ? "rgb(15, 121, 125)" : staticColor === "black" ? "rgb(181, 209, 211)" : undefined,
109+
}))}
105110
>
106111
${Template({
107112
...args,
113+
staticColor,
108114
label: "More",
109115
iconName: undefined,
110116
})}
111117
${Template({
112118
...args,
119+
staticColor,
113120
label: "More",
114121
})}
115122
${Template({
116123
...args,
124+
staticColor,
117125
})}
118126
${Template({
119127
...args,
128+
staticColor,
120129
hasPopup: true,
121130
})}
122131
</div>

components/actionbutton/stories/template.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { html } from "lit";
22
import { classMap } from "lit/directives/class-map.js";
33
import { ifDefined } from "lit/directives/if-defined.js";
4+
import { styleMap } from "lit/directives/style-map.js";
45
import { when } from "lit/directives/when.js";
56

6-
import { lowerCase, capitalize } from "lodash-es";
7+
import { capitalize, lowerCase } from "lodash-es";
78

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

@@ -22,6 +23,7 @@ export const Template = ({
2223
hideLabel = false,
2324
staticColor,
2425
customClasses = [],
26+
customStyles = {},
2527
customIconClasses = [],
2628
onclick,
2729
id,
@@ -56,6 +58,7 @@ export const Template = ({
5658
})}
5759
id=${ifDefined(id)}
5860
role=${ifDefined(role)}
61+
style=${ifDefined(styleMap(customStyles))}
5962
?disabled=${isDisabled}
6063
@click=${onclick}
6164
>

components/alertdialog/stories/alertdialog.stories.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { html } from "lit-html";
2-
3-
// Import the component markup template
41
import { Template } from "./template";
52

63
export default {
@@ -144,4 +141,3 @@ Destructive.args = {
144141
}],
145142
content: 'Are you sure you want to delete the 3 selected documents?',
146143
};
147-

components/alertdialog/stories/template.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { html } from "lit-html";
2-
import { classMap } from "lit-html/directives/class-map.js";
3-
import { ifDefined } from "lit-html/directives/if-defined.js";
4-
import { when } from 'lit-html/directives/when.js';
51
import { useArgs } from "@storybook/client-api";
2+
import { html } from "lit";
3+
import { classMap } from "lit/directives/class-map.js";
4+
import { ifDefined } from "lit/directives/if-defined.js";
5+
import { when } from 'lit/directives/when.js';
66

7-
import { Template as Underlay } from '@spectrum-css/underlay/stories/template.js';
8-
import { Template as Modal } from '@spectrum-css/modal/stories/template.js';
9-
import { Template as Divider } from "@spectrum-css/divider/stories/template.js";
10-
import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js";
117
import { Template as Button } from '@spectrum-css/button/stories/template.js';
8+
import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js";
9+
import { Template as Divider } from "@spectrum-css/divider/stories/template.js";
1210
import { Template as Icon } from "@spectrum-css/icon/stories/template.js";
11+
import { Template as Modal } from '@spectrum-css/modal/stories/template.js';
12+
import { Template as Underlay } from '@spectrum-css/underlay/stories/template.js';
1313

1414
import '../index.css';
1515

@@ -80,7 +80,13 @@ export const Template = ({
8080
variant: "secondary",
8181
label: "Click to open Alert Dialog",
8282
treatment: "outline",
83-
customClasses: ['spectrum-CSSExample-overlayShowButton'],
83+
customClasses: [],
84+
customStyles: {
85+
position: "absolute",
86+
insetInlineStart: "50%",
87+
insetBlockStart: "50%",
88+
transform: "translate(-50%, -50%)",
89+
},
8490
onclick: () => {
8591
updateArgs({ isOpen: !isOpen });
8692
},
@@ -91,4 +97,4 @@ export const Template = ({
9197
content: Dialog,
9298
})}
9399
`
94-
}
100+
}

components/button/stories/button.stories.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html } from "lit";
2+
import { ifDefined } from "lit/directives/if-defined.js";
3+
import { styleMap } from "lit/directives/style-map.js";
24

3-
// Import the component markup template
45
import { Template } from "./template";
56

67
import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js";
@@ -69,7 +70,7 @@ export default {
6970
control: "boolean",
7071
},
7172
staticColor: {
72-
name: "StaticColor",
73+
name: "Static color",
7374
type: { name: "string" },
7475
table: {
7576
type: { summary: "string" },
@@ -99,30 +100,41 @@ export default {
99100
},
100101
};
101102

102-
const CustomButton = (args) => {
103+
const CustomButton = ({
104+
iconName,
105+
staticColor,
106+
customStyles = {},
107+
...args
108+
}) => {
103109
return html`
104110
<div
105-
style="padding: 1rem; ${args.staticColor && args.backgroundColor
106-
? `background-color: ${args.backgroundColor}`
107-
: ""}"
111+
style=${ifDefined(styleMap({
112+
padding: "1rem",
113+
backgroundColor: staticColor === "white" ? "rgb(15, 121, 125)" : staticColor === "black" ? "rgb(181, 209, 211)" : undefined,
114+
...customStyles
115+
}))}
108116
>
109117
${Template({
110118
...args,
119+
staticColor,
111120
iconName: undefined,
112121
})}
113122
${Template({
114123
...args,
124+
staticColor,
115125
iconName: undefined,
116126
treatment: "outline",
117127
})}
118128
${Template({
119129
...args,
120-
iconName: args.iconName ?? "Edit",
130+
staticColor,
131+
iconName: iconName ?? "Edit",
121132
})}
122133
${Template({
123134
...args,
135+
staticColor,
124136
hideLabel: true,
125-
iconName: args.iconName ?? "Edit",
137+
iconName: iconName ?? "Edit",
126138
})}
127139
</div>
128140
`;
@@ -151,13 +163,11 @@ Secondary.args = {
151163

152164
export const StaticColorWhite = CustomButton.bind({});
153165
StaticColorWhite.args = {
154-
backgroundColor: "rgb(15, 121, 125)",
155166
staticColor: "white",
156167
};
157168

158169
export const StaticColorBlack = CustomButton.bind({});
159170
StaticColorBlack.args = {
160-
backgroundColor: "rgb(181, 209, 211)",
161171
staticColor: "black",
162172
};
163173

components/button/stories/template.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html } from "lit";
22
import { classMap } from "lit/directives/class-map.js";
33
import { ifDefined } from "lit/directives/if-defined.js";
4+
import { styleMap } from "lit/directives/style-map.js";
45
import { when } from "lit/directives/when.js";
56

67
import { capitalize, lowerCase } from "lodash-es";
@@ -13,6 +14,7 @@ export const Template = ({
1314
rootClass = "spectrum-Button",
1415
id,
1516
customClasses = [],
17+
customStyles = {},
1618
size = "m",
1719
label,
1820
hideLabel = false,
@@ -47,6 +49,7 @@ export const Template = ({
4749
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
4850
})}
4951
id=${ifDefined(id)}
52+
style=${ifDefined(styleMap(customStyles))}
5053
?disabled=${isDisabled}
5154
@click=${onclick}
5255
aria-label=${ifDefined(hideLabel ? iconName : undefined)}

components/buttongroup/stories/template.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { html } from "lit";
22
import { classMap } from "lit/directives/class-map.js";
3-
// import { ifDefined } from 'lit/directives/if-defined.js';
43

54
import { Template as Button } from "@spectrum-css/button/stories/template.js";
65

0 commit comments

Comments
 (0)