From 65d15e2c3f03c4fec60991c3beb2c2a7a31aead8 Mon Sep 17 00:00:00 2001 From: Marissa Huysentruyt Date: Thu, 5 Dec 2024 22:48:06 -0500 Subject: [PATCH] chore(dialog): use getRandomId and renderContent functions --- components/dialog/stories/template.js | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/components/dialog/stories/template.js b/components/dialog/stories/template.js index 84b4874bfd5..3cf761f9a44 100644 --- a/components/dialog/stories/template.js +++ b/components/dialog/stories/template.js @@ -4,7 +4,7 @@ import { Template as CloseButton } from "@spectrum-css/closebutton/stories/templ import { Template as Modal } from "@spectrum-css/modal/stories/template.js"; import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { Template as Underlay } from "@spectrum-css/underlay/stories/template.js"; -// import { getRandomId, renderContent } from "@spectrum-css/preview/decorators"; +import { getRandomId, renderContent } from "@spectrum-css/preview/decorators"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -25,7 +25,7 @@ export const Template = ({ hasCheckbox = false, content = [], customClasses = [], - id, + id= getRandomId("dialog"), size = "m", layout, hasHeroImage = false, @@ -41,7 +41,7 @@ export const Template = ({ [rootClass]: true, [`${rootClass}--dismissible`]: isDismissible && ["fullscreen", "fullscreenTakeover"].every(l => layout !== l), [`${rootClass}--${layout}`]: typeof layout !== "undefined", - [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", + [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -49,11 +49,11 @@ export const Template = ({ tabindex="-1" aria-modal="true" style=${ifDefined(styleMap(customStyles))} - > + >
${when(hasHeroImage, () => html` -
@@ -65,17 +65,18 @@ export const Template = ({ `)} ${when(header, () => html` - ${Typography({ + ${renderContent(header)} + `, )}
-
${content.map((c) => (typeof c === "function" ? c({}) : c))}
+
${renderContent(content)}
${when(isDismissible, () => CloseButton({ customClasses: [`${rootClass}-closeButton`], @@ -114,12 +115,13 @@ export const Template = ({ label: footer, })} `, - () => - Typography({ - semantics: "body", - size: "m", - content: [ footer ] - }) + () => + // Typography({ + // semantics: "body", + // size: "m", + // content: [ footer ] + // }) + renderContent(footer) )}
@@ -141,7 +143,7 @@ export const Template = ({ }, }, context)}
- `, + `, () => html`