|
1 |
| -import { storiesOf } from '@storybook/web-components'; |
2 |
| -import { withKnobs, boolean, text, number } from '@storybook/addon-knobs'; |
3 | 1 | import { html } from 'lit';
|
4 | 2 | import './led-element';
|
5 | 3 |
|
6 |
| -const brightnessOptions = { |
7 |
| - range: true, |
8 |
| - min: 0, |
9 |
| - max: 1.0, |
10 |
| - step: 0.05, |
| 4 | +export default { |
| 5 | + title: 'LED', |
| 6 | + component: 'wokwi-led', |
| 7 | + argTypes: { |
| 8 | + value: { control: 'boolean' }, |
| 9 | + brightness: { control: { type: 'range', min: 0, max: 1.0, step: 0.05 } }, |
| 10 | + color: { control: { type: 'color' } }, |
| 11 | + lightColor: { control: { type: 'color' } }, |
| 12 | + label: 'string', |
| 13 | + flip: { control: 'boolean' }, |
| 14 | + }, |
| 15 | + args: { |
| 16 | + brightness: 1.0, |
| 17 | + flip: false, |
| 18 | + value: false, |
| 19 | + }, |
11 | 20 | };
|
12 | 21 |
|
13 |
| -storiesOf('LED', module) |
14 |
| - .addParameters({ component: 'wokwi-led' }) |
15 |
| - .addDecorator(withKnobs) |
16 |
| - .add( |
17 |
| - 'Red', |
18 |
| - () => |
19 |
| - html` |
20 |
| - <wokwi-led |
21 |
| - color="red" |
22 |
| - .value=${boolean('value', false)} |
23 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
24 |
| - ></wokwi-led> |
25 |
| - ` |
26 |
| - ) |
27 |
| - .add( |
28 |
| - 'Red with label', |
29 |
| - () => |
30 |
| - html` |
31 |
| - <wokwi-led |
32 |
| - color="red" |
33 |
| - .value=${boolean('value', false)} |
34 |
| - label="${text('label', '12')}" |
35 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
36 |
| - ></wokwi-led> |
37 |
| - ` |
38 |
| - ) |
39 |
| - .add( |
40 |
| - 'Flipped', |
41 |
| - () => |
42 |
| - html` |
43 |
| - <wokwi-led |
44 |
| - color="red" |
45 |
| - .value=${boolean('value', false)} |
46 |
| - .flip=${boolean('flip', true)} |
47 |
| - ></wokwi-led> |
48 |
| - ` |
49 |
| - ) |
50 |
| - .add( |
51 |
| - 'Green', |
52 |
| - () => |
53 |
| - html` |
54 |
| - <wokwi-led |
55 |
| - color="green" |
56 |
| - .value=${boolean('value', false)} |
57 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
58 |
| - ></wokwi-led> |
59 |
| - ` |
60 |
| - ) |
61 |
| - .add( |
62 |
| - 'Yellow', |
63 |
| - () => |
64 |
| - html` |
65 |
| - <wokwi-led |
66 |
| - color="yellow" |
67 |
| - .value=${boolean('value', false)} |
68 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
69 |
| - ></wokwi-led> |
70 |
| - ` |
71 |
| - ) |
72 |
| - .add( |
73 |
| - 'Blue', |
74 |
| - () => |
75 |
| - html` |
76 |
| - <wokwi-led |
77 |
| - color="blue" |
78 |
| - .value=${boolean('value', false)} |
79 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
80 |
| - ></wokwi-led> |
81 |
| - ` |
82 |
| - ) |
83 |
| - .add( |
84 |
| - 'Orange', |
85 |
| - () => |
86 |
| - html` |
87 |
| - <wokwi-led |
88 |
| - color="orange" |
89 |
| - .value=${boolean('value', false)} |
90 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
91 |
| - ></wokwi-led> |
92 |
| - ` |
93 |
| - ) |
94 |
| - .add( |
95 |
| - 'White', |
96 |
| - () => |
97 |
| - html` |
98 |
| - <wokwi-led |
99 |
| - color="white" |
100 |
| - .value=${boolean('value', false)} |
101 |
| - .brightness=${number('brightness', 1.0, brightnessOptions)} |
102 |
| - ></wokwi-led> |
103 |
| - ` |
104 |
| - ) |
105 |
| - .add( |
106 |
| - 'Brightness Levels', |
107 |
| - () => |
108 |
| - html` |
109 |
| - <wokwi-led color="red" label="0" .value=${true} brightness="0"></wokwi-led> |
110 |
| - <wokwi-led color="red" label="1%" .value=${true} brightness="0.01"></wokwi-led> |
111 |
| - <wokwi-led color="red" label="10%" .value=${true} brightness="0.1"></wokwi-led> |
112 |
| - <wokwi-led color="red" label="25%" .value=${true} brightness="0.25"></wokwi-led> |
113 |
| - <wokwi-led color="red" label="50%" .value=${true} brightness="0.5"></wokwi-led> |
114 |
| - <wokwi-led color="red" label="75%" .value=${true} brightness="0.75"></wokwi-led> |
115 |
| - <wokwi-led color="red" label="100%" .value=${true}></wokwi-led> |
116 |
| - ` |
117 |
| - ); |
| 22 | +const Template = ({ color, flip, label, lightColor, value }) => |
| 23 | + html`<wokwi-led |
| 24 | + color=${color} |
| 25 | + .flip=${flip} |
| 26 | + label=${label} |
| 27 | + lightColor=${lightColor} |
| 28 | + .value=${value} |
| 29 | + ></wokwi-led>`; |
| 30 | + |
| 31 | +export const Red = Template.bind({}); |
| 32 | +Red.args = { color: 'red' }; |
| 33 | + |
| 34 | +export const RedWithLabel = Template.bind({}); |
| 35 | +RedWithLabel.args = { color: 'red', label: '12' }; |
| 36 | + |
| 37 | +export const Flipped = Template.bind({}); |
| 38 | +Flipped.args = { color: 'red', flip: true }; |
| 39 | + |
| 40 | +export const Green = Template.bind({}); |
| 41 | +Green.args = { color: 'green' }; |
| 42 | + |
| 43 | +export const Yellow = Template.bind({}); |
| 44 | +Yellow.args = { color: 'yellow' }; |
| 45 | + |
| 46 | +export const Blue = Template.bind({}); |
| 47 | +Blue.args = { color: 'blue' }; |
| 48 | + |
| 49 | +export const Orange = Template.bind({}); |
| 50 | +Orange.args = { color: 'orange' }; |
| 51 | + |
| 52 | +export const White = Template.bind({}); |
| 53 | +White.args = { color: 'white' }; |
| 54 | + |
| 55 | +export const BrightnessLevels = () => |
| 56 | + html` |
| 57 | + <wokwi-led color="red" label="0" .value=${true} brightness="0"></wokwi-led> |
| 58 | + <wokwi-led color="red" label="1%" .value=${true} brightness="0.01"></wokwi-led> |
| 59 | + <wokwi-led color="red" label="10%" .value=${true} brightness="0.1"></wokwi-led> |
| 60 | + <wokwi-led color="red" label="25%" .value=${true} brightness="0.25"></wokwi-led> |
| 61 | + <wokwi-led color="red" label="50%" .value=${true} brightness="0.5"></wokwi-led> |
| 62 | + <wokwi-led color="red" label="75%" .value=${true} brightness="0.75"></wokwi-led> |
| 63 | + <wokwi-led color="red" label="100%" .value=${true}></wokwi-led> |
| 64 | + `; |
0 commit comments