Skip to content

Commit b8b015d

Browse files
authored
fix(storybook): updates to pass the correct content types to the dialog and popover components (#3143)
* fix(storybook): updates to pass the correct content types to the dialog and popover components * fix(storybook): pass context through button + buttongroup templates
1 parent 7d41874 commit b8b015d

File tree

4 files changed

+33
-35
lines changed

4 files changed

+33
-35
lines changed

components/button/stories/template.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const Template = ({
110110
export const ButtonsWithIconOptions = ({
111111
iconName,
112112
...args
113-
}) => Container({
113+
}, context = {}) => Container({
114114
withBorder: false,
115115
direction: "row",
116116
wrapperStyles: {
@@ -120,35 +120,35 @@ export const ButtonsWithIconOptions = ({
120120
${Template({
121121
...args,
122122
iconName: undefined,
123-
})}
123+
}, context)}
124124
${Template({
125125
...args,
126126
iconName: iconName ?? "Edit",
127-
})}
127+
}, context)}
128128
${Template({
129129
...args,
130130
hideLabel: true,
131131
iconName: iconName ?? "Edit",
132-
})}
132+
}, context)}
133133
`,
134134
});
135135

136136
/**
137137
* Display the buttons with icon options for each treatment option.
138138
*/
139-
export const TreatmentTemplate = (args) => Container({
139+
export const TreatmentTemplate = (args, context = {}) => Container({
140140
withBorder: false,
141141
direction: "column",
142142
wrapperStyles: {
143143
rowGap: "12px",
144144
},
145-
content: html`${["fill", "outline"].map((treatment) => ButtonsWithIconOptions({ ...args, treatment }))}`,
146-
});
145+
content: html`${["fill", "outline"].map((treatment) => ButtonsWithIconOptions({ ...args, treatment }, context))}`,
146+
}, context);
147147

148148
/**
149149
* Display the text overflow behavior of buttons.
150150
*/
151-
export const TextOverflowTemplate = (args) => Container({
151+
export const TextOverflowTemplate = (args, context = {}) => Container({
152152
withBorder: false,
153153
direction: "column",
154154
wrapperStyles: {
@@ -161,19 +161,19 @@ export const TextOverflowTemplate = (args) => Container({
161161
"max-inline-size": "480px",
162162
},
163163
label: "An example of text overflow behavior when there is no icon. When the button text is too long for the horizontal space available, it wraps to form another line.",
164-
})}
164+
}, context)}
165165
${Template({
166166
...args,
167167
customStyles: {
168168
"max-inline-size": "480px",
169169
},
170170
iconName: "Edit",
171171
label: "An example of text overflow behavior when the button has an icon. When the button text is too long for the horizontal space available, it wraps to form another line.",
172-
})}
172+
}, context)}
173173
`,
174-
});
174+
}, context);
175175

176-
export const TextWrapTemplate = (args) => Container({
176+
export const TextWrapTemplate = (args, context = {}) => Container({
177177
direction: "column",
178178
wrapperStyles: {
179179
rowGap: "12px",
@@ -182,20 +182,18 @@ export const TextWrapTemplate = (args) => Container({
182182
content: html`
183183
${Template({
184184
...args,
185-
customStyles: {
186-
187-
},
185+
customStyles: {},
188186
label: "Be a premium member",
189187
noWrap: true,
190-
})}
188+
}, context)}
191189
${Template({
192190
...args,
193191
customStyles: {
194192
"max-inline-size": "100%",
195193
},
196194
label: "Be a premium member",
197195
noWrap: true,
198-
})}
196+
}, context)}
199197
${Template({
200198
...args,
201199
customStyles: {
@@ -204,6 +202,6 @@ export const TextWrapTemplate = (args) => Container({
204202
iconName: "Star",
205203
label: "Be a premium member",
206204
noWrap: true,
207-
})}
205+
}, context)}
208206
`,
209-
});
207+
}, context);

components/buttongroup/stories/template.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export const Template = ({
1010
size = "m",
1111
items = [],
1212
vertical = false,
13-
}) => html`
13+
}, context = {}) => {
14+
return html`
1415
<div
1516
class=${classMap({
1617
[rootClass]: true,
@@ -25,7 +26,8 @@ export const Template = ({
2526
...item,
2627
size,
2728
customClasses: [`${rootClass}-item`],
28-
})
29+
}, context)
2930
)}
3031
</div>
3132
`;
33+
};

components/dialog/stories/dialog.stories.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default {
114114
},
115115
docs: {
116116
story: {
117-
inline: false,
117+
// TODO: restore `inline: false,`
118118
height: "500px",
119119
},
120120
},
@@ -125,13 +125,7 @@ export default {
125125
],
126126
};
127127

128-
const ExampleContent = Typography({
129-
semantics: "body",
130-
size: "m",
131-
content: [
132-
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper dignissim cras lobortis."
133-
]
134-
});
128+
const ExampleContent = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper dignissim cras lobortis.";
135129

136130
/**
137131
* The default size for dialog is medium.
@@ -143,7 +137,7 @@ Default.args = {
143137
(passthroughs, context) => Typography({
144138
semantics: "body",
145139
size: "m",
146-
content: ExampleContent,
140+
content: [ ExampleContent ],
147141
...passthroughs,
148142
}, context),
149143
],
@@ -256,7 +250,11 @@ FullscreenTakeover.parameters = {
256250
FullscreenTakeover.args = {
257251
...Default.args,
258252
layout: "fullscreenTakeover",
259-
content: [ExampleContent, ExampleContent, ExampleContent, ExampleContent],
253+
content: [ () => Typography({
254+
semantics: "body",
255+
size: "m",
256+
content: [ ExampleContent, ExampleContent, ExampleContent, ExampleContent ],
257+
})],
260258
};
261259

262260
// ********* VRT ONLY ********* //

components/popover/stories/popover.stories.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Positioning.args = {
281281
withTip: true,
282282
isOpen: true,
283283
trigger: () => null,
284-
content: [html`<span style="padding: 0 7px">Basic text content, with some added padding.</span>`],
284+
content: [() => html`<span style="padding: 0 7px">Basic text content, with some added padding.</span>`],
285285
skipAlignment: true,
286286
popoverWrapperStyles: {
287287
"display": "block",
@@ -300,12 +300,12 @@ Positioning.parameters = {
300300
* #### Default tip positioning
301301
* - The tip position is centered on the edge for top, bottom, left, right, start, and end positions.
302302
* - The tip position distance from edge is equal to the popover corner radius for all other positions.
303-
*
303+
*
304304
* #### Centering the tip with the source
305305
* In implementations, the tip position can be overridden to center it with the source by setting the
306306
* custom property `--spectrum-popover-pointer-edge-offset` equal to half the width of the source for
307-
* top and bottom popovers, or half the height of the source for side popovers. The following
308-
* example sets this custom property to `50px` for a source button that is `100px` wide.
307+
* top and bottom popovers, or half the height of the source for side popovers. The following
308+
* example sets this custom property to `50px` for a source button that is `100px` wide.
309309
*/
310310
export const TipOffset = FixedWidthSourceTemplate.bind({});
311311
TipOffset.storyName = "Tip positioning and inline offset";

0 commit comments

Comments
 (0)