Skip to content

Commit 5f7da8e

Browse files
bjarnefiOvergaard
andauthored
docs: Update story for color swatches (#488)
* Update story for color swatches with example where label is different than value * lint --------- Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 209bb02 commit 5f7da8e

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

packages/uui-color-swatches/lib/uui-color-swatches.story.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ import { Story } from '@storybook/web-components';
44
import { html } from 'lit-html';
55

66
const swatches = [
7-
'#d0021b',
8-
'#f5a623',
9-
'#f8e71c',
10-
'#8b572a',
11-
'#7ed321',
12-
'#417505',
13-
'#bd10e0',
14-
'#9013fe',
15-
'#4a90e2',
16-
'#50e3c2',
17-
'#b8e986',
18-
'#000000',
19-
'#444',
20-
'#888',
21-
'#ccc',
22-
'#fff',
7+
{ label: 'Blood Orange', value: '#d0021b' },
8+
{ label: 'Marigold', value: '#f5a623' },
9+
{ label: 'Yellow Sun', value: '#f8e71c' },
10+
{ label: 'Milk Chocolate', value: '#8b572a' },
11+
{ label: 'Lemon Lime', value: '#7ed321' },
12+
{ label: 'Avocado', value: '#417505' },
13+
{ label: 'Vivid Mulberry', value: '#bd10e0' },
14+
{ label: 'Electric Violet', value: '#9013fe' },
15+
{ label: 'Tufts Blue', value: '#4a90e2' },
16+
{ label: 'Crayola', value: '#b8e986' },
17+
{ label: 'Black', value: '#000000' },
18+
{ label: 'Grey', value: '#888' },
19+
{ label: 'Outer Space', value: '#444' },
20+
{ label: 'Chinese Silver', value: '#ccc' },
21+
{ label: 'White', value: '#fff' },
2322
];
2423

2524
const swatchesTransparent = [
@@ -56,12 +55,16 @@ export default {
5655

5756
const Template: Story = props => html`
5857
<uui-color-swatches .value=${props.value ?? ''} label="my color pallette">
59-
${props.swatches.map(
60-
(swatch: string) =>
61-
html`<uui-color-swatch label="${swatch}" .showLabel=${props.showLabel}
62-
>${swatch}</uui-color-swatch
63-
>`
64-
)}
58+
${props.swatches.map((swatch: any) => {
59+
const label = typeof swatch === 'string' ? swatch : swatch.label;
60+
const value = typeof swatch === 'string' ? swatch : swatch.value;
61+
62+
return html`<uui-color-swatch
63+
label="${label}"
64+
.showLabel=${props.showLabel}
65+
>${value}</uui-color-swatch
66+
>`;
67+
})}
6568
</uui-color-swatches>
6669
`;
6770

0 commit comments

Comments
 (0)