Skip to content

Commit 596d2f6

Browse files
feat(dialog): add chromatic coverage for variants
1 parent 77eb419 commit 596d2f6

File tree

1 file changed

+158
-1
lines changed

1 file changed

+158
-1
lines changed

components/dialog/stories/dialog.stories.js

Lines changed: 158 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,164 @@ const ExampleButtonGroup = [{
171171
label: "Rate now",
172172
}];
173173

174-
export const Default = Template.bind({});
174+
const Sizes = (args) =>
175+
html` ${["s", "m", "l"].map((size) => {
176+
return html`
177+
<div>
178+
${Typography({
179+
semantics: "detail",
180+
size: "s",
181+
content: [
182+
{
183+
s: "Small",
184+
m: "Medium",
185+
l: "Large",
186+
}[size],
187+
],
188+
})}
189+
${Template({
190+
...args,
191+
showModal: false,
192+
isDismissable: false,
193+
size,
194+
})}
195+
</div>
196+
`;
197+
})}`;
198+
199+
const DismissibleSizes = (args) =>
200+
html` ${["s", "m", "l"].map((size) => {
201+
return html`
202+
<div>
203+
${Typography({
204+
semantics: "detail",
205+
size: "s",
206+
content: [
207+
{
208+
s: "Small",
209+
m: "Medium",
210+
l: "Large",
211+
}[size],
212+
],
213+
})}
214+
${Template({
215+
...args,
216+
showModal: false,
217+
isDismissable: true,
218+
size,
219+
})}
220+
</div>
221+
`;
222+
})}`;
223+
224+
const Layouts = (args) =>
225+
html`
226+
${["fullscreen", "fullscreenTakeover"].map((variant) => {
227+
return html`
228+
<div style="padding-block-end: 2rem">
229+
${Typography({
230+
semantics: "detail",
231+
variant: "fullscreen",
232+
content: [
233+
{
234+
fullscreen: "Fullscreen",
235+
fullscreenTakeover: "Fullscreen Takeover",
236+
}[variant],
237+
],
238+
})}
239+
${Template({
240+
...args,
241+
showModal: false,
242+
layout: variant,
243+
isDismissable: false,
244+
})}
245+
</div>
246+
`;
247+
})}`;
248+
249+
const WithHero = (args) =>
250+
html`
251+
<div>
252+
${Typography({
253+
semantics: "detail",
254+
size: "s",
255+
content: ["Default"],
256+
})}
257+
${Template({
258+
...args,
259+
size: "m",
260+
showModal: false,
261+
hasHeroImage: true,
262+
isDismissable: false,
263+
})}
264+
</div>
265+
<div>
266+
${Typography({
267+
semantics: "detail",
268+
size: "s",
269+
content: ["Dismissible"],
270+
})}
271+
${Template({
272+
...args,
273+
size: "m",
274+
showModal: false,
275+
hasHeroImage: true,
276+
isDismissable: true,
277+
})}
278+
</div>
279+
`;
280+
281+
const ChromaticVariants = (args) => {
282+
const sectionData = [
283+
{
284+
sectionName: "Sizes, Non-dismissible",
285+
componentMarkup: Sizes({
286+
...args,
287+
}),
288+
},
289+
{
290+
sectionName: "Sizes, dismissible",
291+
componentMarkup: DismissibleSizes({
292+
...args,
293+
}),
294+
},
295+
{
296+
sectionName: "Layouts",
297+
componentMarkup: Layouts({
298+
...args,
299+
}),
300+
gridColumns: 1,
301+
},
302+
{
303+
sectionName: "Hero/Cover Image",
304+
componentMarkup: WithHero({
305+
...args,
306+
})
307+
},
308+
];
309+
310+
return sectionData.map((data) => html`
311+
<div class="spectrum-Typography">
312+
${Typography({
313+
semantics: "detail",
314+
size: "l",
315+
content: [data.sectionName],
316+
})}
317+
<div
318+
style=${styleMap({
319+
display: "grid",
320+
gap: "1.5rem",
321+
gridTemplateColumns: `repeat(${data?.gridColumns?.toString() ?? "4"}, 1fr)`,
322+
})}
323+
>
324+
${data.componentMarkup}
325+
</div>
326+
</div>
327+
`);
328+
};
329+
330+
export const Default = (args) => window.isChromatic() ? ChromaticVariants(args) : Template(args);
331+
175332
Default.args = {
176333
heading: "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
177334
header: "* Required",

0 commit comments

Comments
 (0)