-
Notifications
You must be signed in to change notification settings - Fork 705
Expand file tree
/
Copy pathindicator.stories.ts
More file actions
101 lines (90 loc) · 2.37 KB
/
Copy pathindicator.stories.ts
File metadata and controls
101 lines (90 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type {Meta, StoryObj} from '@storybook/web-components-vite';
import {html, nothing} from 'lit';
import './indicator.js';
import type CraftIndicator from './indicator.js';
import {Variant} from '@src/constants/variants';
const appearances = ['filled-outlined', 'filled', 'outlined'];
/**
* Renders the indicator in each appearance, with a label, so every story shares
* the same markup.
*/
const renderIndicators = (
label: string,
attrs: {fill?: string; size?: CraftIndicator['size']} = {}
) => html`
<tr>
<td>${label}</td>
${appearances.map(
(appearance) => html`
<td>
<craft-indicator
fill="${attrs.fill ?? nothing}"
size="${attrs.size ?? nothing}"
appearance="${appearance}"
></craft-indicator>
</td>
`
)}
</tr>
`;
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta = {
title: 'Components/Indicator',
component: 'craft-indicator',
args: {},
render: () => html`
<table>
<thead>
<th></th>
${appearances.map((appearance) => html`<th>${appearance}</th>`)}
</thead>
<tbody>
${Object.values(Variant).map((variant) =>
renderIndicators(variant, {fill: variant})
)}
</tbody>
</table>
`,
} satisfies Meta<CraftIndicator>;
export default meta;
type Story = StoryObj<CraftIndicator>;
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Default: Story = {
args: {},
};
const arbitraryValues = [
'#2c61de',
'rgba(30, 40, 40, 0.2)',
'linear-gradient(red, blue)',
];
export const ArbitraryColor: Story = {
render: () => html`
<table>
<thead>
<th></th>
${appearances.map((appearance) => html`<th>${appearance}</th>`)}
</thead>
<tbody>
${arbitraryValues.map((value) =>
renderIndicators(value, {fill: value})
)}
</tbody>
</table>
`,
};
const sizes: Array<CraftIndicator['size']> = ['md', 'lg'];
export const ArbitrarySize: Story = {
render: () => html`
<table>
<thead>
<th></th>
${appearances.map((appearance) => html`<th>${appearance}</th>`)}
</thead>
<tbody>
${sizes.map((size) =>
renderIndicators(size === 'md' ? 'md (default)' : size, {size})
)}
</tbody>
</table>
`,
};