Skip to content

Commit fc6f018

Browse files
committed
feat(storybook): add story to explain item indentation using custom css prop
1 parent a6d5ffe commit fc6f018

File tree

1 file changed

+93
-65
lines changed

1 file changed

+93
-65
lines changed

packages/uui-menu-item/lib/uui-menu-item.story.ts

+93-65
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default {
1212
title: 'Buttons/Menu Item',
1313
component: 'uui-menu-item',
1414
decorators: [
15-
(story: any) => html`
16-
<div style="max-width: 500px;">${story()}</div>
17-
`,
15+
(story: any) => html` <div style="max-width: 500px;">${story()}</div> `,
1816
],
1917
id: 'uui-menu-item',
2018
args: {
@@ -130,12 +128,12 @@ AAAOverview.parameters = {
130128

131129
export const Nested = () =>
132130
html`
133-
${labelNames.map(
134-
(name: string) =>
135-
html` <uui-menu-item label="${name}" has-children>
136-
${renderItems()}
137-
</uui-menu-item>`
138-
)}
131+
${labelNames.map(
132+
(name: string) =>
133+
html` <uui-menu-item label="${name}" has-children>
134+
${renderItems()}
135+
</uui-menu-item>`
136+
)}
139137
`;
140138
Nested.parameters = {
141139
docs: {
@@ -163,12 +161,12 @@ function activeStoryOnClick(e: UUIMenuItemEvent) {
163161

164162
export const Active = () =>
165163
html`
166-
${MenuItems.map(
167-
menuItem =>
168-
html`<uui-menu-item
164+
${MenuItems.map(
165+
menuItem =>
166+
html`<uui-menu-item
169167
label="${menuItem.title}"
170168
@click-label=${activeStoryOnClick}></uui-menu-item>`
171-
)}
169+
)}
172170
`;
173171
Active.parameters = {
174172
docs: {
@@ -181,10 +179,12 @@ Active.parameters = {
181179

182180
export const Loading = () =>
183181
html`
184-
${MenuItems.map(
185-
menuItem =>
186-
html`<uui-menu-item label="${menuItem.title}" ?loading=${menuItem.loading}></uui-menu-item>`
187-
)}
182+
${MenuItems.map(
183+
menuItem =>
184+
html`<uui-menu-item
185+
label="${menuItem.title}"
186+
?loading=${menuItem.loading}></uui-menu-item>`
187+
)}
188188
`;
189189
Loading.parameters = {
190190
docs: {
@@ -208,12 +208,14 @@ function disabledStoryOnClick(e: UUIMenuItemEvent) {
208208

209209
export const Disabled = () =>
210210
html`
211-
${MenuItems.map(menuItem =>
212-
html`
213-
<uui-menu-item
214-
@click-label=${disabledStoryOnClick}
215-
label="${menuItem.title}"></uui-menu-item>
216-
`)}
211+
${MenuItems.map(
212+
menuItem =>
213+
html`
214+
<uui-menu-item
215+
@click-label=${disabledStoryOnClick}
216+
label="${menuItem.title}"></uui-menu-item>
217+
`
218+
)}
217219
`;
218220
Disabled.parameters = {
219221
docs: {
@@ -226,16 +228,18 @@ Disabled.parameters = {
226228

227229
export const WithActions = () =>
228230
html`
229-
${MenuItems.map(menuItem =>
230-
html`
231-
<uui-menu-item label="${menuItem.title}">
232-
<uui-action-bar slot="actions">
233-
<uui-button label="Open actions menu"
234-
><uui-symbol-more></uui-symbol-more
235-
></uui-button>
236-
</uui-action-bar>
237-
</uui-menu-item>
238-
`)}
231+
${MenuItems.map(
232+
menuItem =>
233+
html`
234+
<uui-menu-item label="${menuItem.title}">
235+
<uui-action-bar slot="actions">
236+
<uui-button label="Open actions menu"
237+
><uui-symbol-more></uui-symbol-more
238+
></uui-button>
239+
</uui-action-bar>
240+
</uui-menu-item>
241+
`
242+
)}
239243
`;
240244
WithActions.parameters = {
241245
docs: {
@@ -255,7 +259,10 @@ WithActions.parameters = {
255259

256260
export const Selectable = () =>
257261
html`
258-
${MenuItems.map(menuItem => html`<uui-menu-item label="${menuItem.title}"></uui-menu-item>`)}
262+
${MenuItems.map(
263+
menuItem =>
264+
html`<uui-menu-item label="${menuItem.title}"></uui-menu-item>`
265+
)}
259266
`;
260267
Selectable.args = {
261268
selectable: true,
@@ -273,24 +280,24 @@ Selectable.parameters = {
273280
export const WithIcon = (props: any) =>
274281
html`
275282
<uui-icon-registry-essential>
276-
${MenuItems.map(
277-
menuItem =>
278-
html`
279-
<uui-menu-item
280-
label=${menuItem.title}
281-
?loading=${props.loading}
282-
?disabled=${props.disabled}
283-
?has-children=${props.hasChildren}
284-
?show-children=${props.showChildren}
285-
?selected=${props.selected}
286-
?active=${props.active}
287-
?selectable=${props.selectable}
288-
href=${props.href}
289-
target=${props.target}>
290-
<uui-icon slot="icon" name=${menuItem.icon}></uui-icon>
291-
</uui-menu-item>
292-
`
293-
)}
283+
${MenuItems.map(
284+
menuItem =>
285+
html`
286+
<uui-menu-item
287+
label=${menuItem.title}
288+
?loading=${props.loading}
289+
?disabled=${props.disabled}
290+
?has-children=${props.hasChildren}
291+
?show-children=${props.showChildren}
292+
?selected=${props.selected}
293+
?active=${props.active}
294+
?selectable=${props.selectable}
295+
href=${props.href}
296+
target=${props.target}>
297+
<uui-icon slot="icon" name=${menuItem.icon}></uui-icon>
298+
</uui-menu-item>
299+
`
300+
)}
294301
</uui-icon-registry-essential>
295302
`;
296303
WithIcon.parameters = {
@@ -308,19 +315,19 @@ WithIcon.parameters = {
308315
export const AnchorTag = (props: any) =>
309316
html`
310317
<uui-icon-registry-essential>
311-
<uui-menu-item
312-
label=${props.label}
313-
?loading=${props.loading}
314-
?disabled=${props.disabled}
315-
?has-children=${props.hasChildren}
316-
?show-children=${props.showChildren}
317-
?selected=${props.selected}
318-
?active=${props.active}
319-
?selectable=${props.selectable}
320-
href=${props.href}
321-
target=${props.target}>
322-
<uui-icon slot="icon" name="document"></uui-icon>
323-
</uui-menu-item>
318+
<uui-menu-item
319+
label=${props.label}
320+
?loading=${props.loading}
321+
?disabled=${props.disabled}
322+
?has-children=${props.hasChildren}
323+
?show-children=${props.showChildren}
324+
?selected=${props.selected}
325+
?active=${props.active}
326+
?selectable=${props.selectable}
327+
href=${props.href}
328+
target=${props.target}>
329+
<uui-icon slot="icon" name="document"></uui-icon>
330+
</uui-menu-item>
324331
</uui-icon-registry-essential>
325332
`;
326333
AnchorTag.args = {
@@ -340,3 +347,24 @@ AnchorTag.parameters = {
340347
},
341348
},
342349
};
350+
351+
export const ItemIndentation: Story = () =>
352+
html`
353+
${MenuItems.map(
354+
(menuItem, i) =>
355+
html`
356+
<uui-menu-item
357+
label="${menuItem.title}"
358+
style="${ifDefined(i === 1 ? '--uui-menu-item-indent: 1' : '')}">
359+
</uui-menu-item>
360+
`
361+
)}
362+
`;
363+
364+
ItemIndentation.parameters = {
365+
docs: {
366+
source: {
367+
code: `<uui-menu-item label="Menu Item 1" style="--uui-menu-item-indent: 1"></uui-menu-item>`,
368+
},
369+
},
370+
};

0 commit comments

Comments
 (0)