From 596d2f6856043e76a045987c32277c4f53887556 Mon Sep 17 00:00:00 2001 From: Marissa Huysentruyt Date: Mon, 24 Jun 2024 11:18:00 -0400 Subject: [PATCH] feat(dialog): add chromatic coverage for variants --- components/dialog/stories/dialog.stories.js | 159 +++++++++++++++++++- 1 file changed, 158 insertions(+), 1 deletion(-) diff --git a/components/dialog/stories/dialog.stories.js b/components/dialog/stories/dialog.stories.js index 0bebcb420b4..f6b8cfe4b77 100644 --- a/components/dialog/stories/dialog.stories.js +++ b/components/dialog/stories/dialog.stories.js @@ -171,7 +171,164 @@ const ExampleButtonGroup = [{ label: "Rate now", }]; -export const Default = Template.bind({}); +const Sizes = (args) => + html` ${["s", "m", "l"].map((size) => { + return html` +
+ ${Typography({ + semantics: "detail", + size: "s", + content: [ + { + s: "Small", + m: "Medium", + l: "Large", + }[size], + ], + })} + ${Template({ + ...args, + showModal: false, + isDismissable: false, + size, + })} +
+ `; + })}`; + +const DismissibleSizes = (args) => + html` ${["s", "m", "l"].map((size) => { + return html` +
+ ${Typography({ + semantics: "detail", + size: "s", + content: [ + { + s: "Small", + m: "Medium", + l: "Large", + }[size], + ], + })} + ${Template({ + ...args, + showModal: false, + isDismissable: true, + size, + })} +
+ `; + })}`; + +const Layouts = (args) => + html` + ${["fullscreen", "fullscreenTakeover"].map((variant) => { + return html` +
+ ${Typography({ + semantics: "detail", + variant: "fullscreen", + content: [ + { + fullscreen: "Fullscreen", + fullscreenTakeover: "Fullscreen Takeover", + }[variant], + ], + })} + ${Template({ + ...args, + showModal: false, + layout: variant, + isDismissable: false, + })} +
+ `; + })}`; + +const WithHero = (args) => + html` +
+ ${Typography({ + semantics: "detail", + size: "s", + content: ["Default"], + })} + ${Template({ + ...args, + size: "m", + showModal: false, + hasHeroImage: true, + isDismissable: false, + })} +
+
+ ${Typography({ + semantics: "detail", + size: "s", + content: ["Dismissible"], + })} + ${Template({ + ...args, + size: "m", + showModal: false, + hasHeroImage: true, + isDismissable: true, + })} +
+ `; + +const ChromaticVariants = (args) => { + const sectionData = [ + { + sectionName: "Sizes, Non-dismissible", + componentMarkup: Sizes({ + ...args, + }), + }, + { + sectionName: "Sizes, dismissible", + componentMarkup: DismissibleSizes({ + ...args, + }), + }, + { + sectionName: "Layouts", + componentMarkup: Layouts({ + ...args, + }), + gridColumns: 1, + }, + { + sectionName: "Hero/Cover Image", + componentMarkup: WithHero({ + ...args, + }) + }, + ]; + + return sectionData.map((data) => html` +
+ ${Typography({ + semantics: "detail", + size: "l", + content: [data.sectionName], + })} +
+ ${data.componentMarkup} +
+
+ `); +}; + +export const Default = (args) => window.isChromatic() ? ChromaticVariants(args) : Template(args); + Default.args = { heading: "Lorem ipsum dolor sit amet, consectetur adipiscing elit", header: "* Required",