Skip to content

Commit bec4b1c

Browse files
chore(dialog): use getRandomId and renderContent functions
1 parent 56396f0 commit bec4b1c

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

components/dialog/stories/template.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Template as CloseButton } from "@spectrum-css/closebutton/stories/templ
44
import { Template as Modal } from "@spectrum-css/modal/stories/template.js";
55
import { Template as Typography } from "@spectrum-css/typography/stories/template.js";
66
import { Template as Underlay } from "@spectrum-css/underlay/stories/template.js";
7-
// import { getRandomId, renderContent } from "@spectrum-css/preview/decorators";
7+
import { getRandomId, renderContent } from "@spectrum-css/preview/decorators";
88
import { html } from "lit";
99
import { classMap } from "lit/directives/class-map.js";
1010
import { ifDefined } from "lit/directives/if-defined.js";
@@ -25,7 +25,7 @@ export const Template = ({
2525
hasCheckbox = false,
2626
content = [],
2727
customClasses = [],
28-
id,
28+
id= getRandomId("dialog"),
2929
size = "m",
3030
layout,
3131
hasHeroImage = false,
@@ -41,19 +41,19 @@ export const Template = ({
4141
[rootClass]: true,
4242
[`${rootClass}--dismissible`]: isDismissible && ["fullscreen", "fullscreenTakeover"].every(l => layout !== l),
4343
[`${rootClass}--${layout}`]: typeof layout !== "undefined",
44-
[`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined",
44+
[`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined",
4545
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
4646
})}
4747
id=${ifDefined(id)}
4848
role="dialog"
4949
tabindex="-1"
5050
aria-modal="true"
5151
style=${ifDefined(styleMap(customStyles))}
52-
>
52+
>
5353
<div class="${rootClass}-grid">
5454
${when(hasHeroImage, () =>
5555
html`
56-
<div
56+
<div
5757
class="spectrum-Dialog-hero"
5858
style="background-image:url(${heroImageUrl ? heroImageUrl : "example-card-portrait.png"})">
5959
</div>
@@ -65,17 +65,18 @@ export const Template = ({
6565
`)}
6666
${when(header, () => html`
6767
<span class="${rootClass}-header-content">
68-
${Typography({
68+
${renderContent(header)}
69+
<!-- ${Typography({
6970
semantics: "body",
7071
size: "m",
7172
// @todo: takeover dialogs can accept other components in their headers. could the renderContent function work here?
7273
content: [ header ]
73-
})}
74+
})} -->
7475
</span>
7576
`,
7677
)}
7778
</div>
78-
<section class="${rootClass}-content">${content.map((c) => (typeof c === "function" ? c({}) : c))}</section>
79+
<section class="${rootClass}-content">${renderContent(content)}</section>
7980
${when(isDismissible, () =>
8081
CloseButton({
8182
customClasses: [`${rootClass}-closeButton`],
@@ -114,12 +115,13 @@ export const Template = ({
114115
label: footer,
115116
})}
116117
`,
117-
() =>
118-
Typography({
119-
semantics: "body",
120-
size: "m",
121-
content: [ footer ]
122-
})
118+
() =>
119+
// Typography({
120+
// semantics: "body",
121+
// size: "m",
122+
// content: [ footer ]
123+
// })
124+
renderContent(footer)
123125
)}
124126
</div>
125127
<div class="${rootClass}-buttonGroup">
@@ -141,7 +143,7 @@ export const Template = ({
141143
},
142144
}, context)}
143145
</div>
144-
`,
146+
`,
145147
() => html`
146148
<div class="${rootClass}-noFooter"></div>
147149
<div class="${rootClass}-buttonGroup">

0 commit comments

Comments
 (0)