|
1 | | -import { withKnobs } from '@storybook/addon-knobs'; |
| 1 | +import { withKnobs, text, select, number } from '@storybook/addon-knobs'; |
2 | 2 | import { storiesOf } from '@storybook/web-components'; |
3 | 3 | import { html } from 'lit-html'; |
4 | 4 | import './lcd1602-element'; |
5 | 5 |
|
6 | | -const helloWorld = new Uint8Array('Hello, World!'.split('').map(c => c.charCodeAt(0))); |
| 6 | +const encode = (s: string) => new Uint8Array(s.split('').map(c => c.charCodeAt(0))); |
| 7 | +const helloWorld = 'Hello, World!'; |
7 | 8 |
|
8 | 9 | storiesOf('LCD1602', module) |
9 | 10 | .addDecorator(withKnobs) |
10 | 11 | .add( |
11 | 12 | 'Hello, World!', |
12 | 13 | () => html` |
13 | | - <wokwi-lcd1602 .characters="${helloWorld}"></wokwi-7segment> |
| 14 | + <wokwi-lcd1602 |
| 15 | + .characters="${encode(text('value', helloWorld))}" |
| 16 | + cursor=${select('cursor', ['off', 'blink', 'underline'], 'off')} |
| 17 | + cursorX=${number('cursorX', 0, { min: 0, max: 15 })} |
| 18 | + cursorY=${number('cursorY', 0, { min: 0, max: 1 })} |
| 19 | + ></wokwi-lcd1602> |
14 | 20 | ` |
15 | 21 | ) |
16 | 22 | .add( |
17 | 23 | 'White on blue', |
18 | 24 | () => html` |
19 | | - <wokwi-lcd1602 color="white" background="blue" .characters="${helloWorld}"></wokwi-7segment> |
| 25 | + <wokwi-lcd1602 |
| 26 | + color="white" |
| 27 | + background="blue" |
| 28 | + .characters="${encode(helloWorld)}" |
| 29 | + cursor="blink" |
| 30 | + ></wokwi-lcd1602> |
20 | 31 | ` |
21 | 32 | ) |
22 | 33 | .add( |
23 | 34 | 'Blinking cursor', |
24 | 35 | () => html` |
25 | | - <wokwi-lcd1602 |
26 | | - .characters="${helloWorld}" |
| 36 | + <wokwi-lcd1602 |
| 37 | + .characters="${encode(helloWorld)}" |
27 | 38 | cursor="blink" |
28 | | - cursorX="7" |
| 39 | + cursorX="7" |
29 | 40 | cursorY="1" |
30 | | - ></wokwi-7segment> |
| 41 | + ></wokwi-lcd1602> |
31 | 42 | ` |
32 | 43 | ) |
33 | 44 | .add( |
34 | 45 | 'Underline cursor', |
35 | 46 | () => html` |
36 | | - <wokwi-lcd1602 |
37 | | - .characters="${helloWorld}" |
| 47 | + <wokwi-lcd1602 |
| 48 | + .characters="${encode(helloWorld)}" |
38 | 49 | cursor="underline" |
39 | | - cursorX="7" |
| 50 | + cursorX="7" |
40 | 51 | cursorY="1" |
41 | | - ></wokwi-7segment> |
| 52 | + ></wokwi-lcd1602> |
42 | 53 | ` |
43 | 54 | ); |
0 commit comments