Skip to content

Commit c556686

Browse files
committed
feat(lcd1602): add knobs to stories
1 parent 84ddc91 commit c556686

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/lcd1602-element.stories.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,54 @@
1-
import { withKnobs } from '@storybook/addon-knobs';
1+
import { withKnobs, text, select, number } from '@storybook/addon-knobs';
22
import { storiesOf } from '@storybook/web-components';
33
import { html } from 'lit-html';
44
import './lcd1602-element';
55

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!';
78

89
storiesOf('LCD1602', module)
910
.addDecorator(withKnobs)
1011
.add(
1112
'Hello, World!',
1213
() => 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>
1420
`
1521
)
1622
.add(
1723
'White on blue',
1824
() => 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>
2031
`
2132
)
2233
.add(
2334
'Blinking cursor',
2435
() => html`
25-
<wokwi-lcd1602
26-
.characters="${helloWorld}"
36+
<wokwi-lcd1602
37+
.characters="${encode(helloWorld)}"
2738
cursor="blink"
28-
cursorX="7"
39+
cursorX="7"
2940
cursorY="1"
30-
></wokwi-7segment>
41+
></wokwi-lcd1602>
3142
`
3243
)
3344
.add(
3445
'Underline cursor',
3546
() => html`
36-
<wokwi-lcd1602
37-
.characters="${helloWorld}"
47+
<wokwi-lcd1602
48+
.characters="${encode(helloWorld)}"
3849
cursor="underline"
39-
cursorX="7"
50+
cursorX="7"
4051
cursorY="1"
41-
></wokwi-7segment>
52+
></wokwi-lcd1602>
4253
`
4354
);

0 commit comments

Comments
 (0)