Skip to content

Commit

Permalink
feat(lcd1602): add knobs to stories
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Feb 4, 2020
1 parent 84ddc91 commit c556686
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/lcd1602-element.stories.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,54 @@
import { withKnobs } from '@storybook/addon-knobs';
import { withKnobs, text, select, number } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/web-components';
import { html } from 'lit-html';
import './lcd1602-element';

const helloWorld = new Uint8Array('Hello, World!'.split('').map(c => c.charCodeAt(0)));
const encode = (s: string) => new Uint8Array(s.split('').map(c => c.charCodeAt(0)));
const helloWorld = 'Hello, World!';

storiesOf('LCD1602', module)
.addDecorator(withKnobs)
.add(
'Hello, World!',
() => html`
<wokwi-lcd1602 .characters="${helloWorld}"></wokwi-7segment>
<wokwi-lcd1602
.characters="${encode(text('value', helloWorld))}"
cursor=${select('cursor', ['off', 'blink', 'underline'], 'off')}
cursorX=${number('cursorX', 0, { min: 0, max: 15 })}
cursorY=${number('cursorY', 0, { min: 0, max: 1 })}
></wokwi-lcd1602>
`
)
.add(
'White on blue',
() => html`
<wokwi-lcd1602 color="white" background="blue" .characters="${helloWorld}"></wokwi-7segment>
<wokwi-lcd1602
color="white"
background="blue"
.characters="${encode(helloWorld)}"
cursor="blink"
></wokwi-lcd1602>
`
)
.add(
'Blinking cursor',
() => html`
<wokwi-lcd1602
.characters="${helloWorld}"
<wokwi-lcd1602
.characters="${encode(helloWorld)}"
cursor="blink"
cursorX="7"
cursorX="7"
cursorY="1"
></wokwi-7segment>
></wokwi-lcd1602>
`
)
.add(
'Underline cursor',
() => html`
<wokwi-lcd1602
.characters="${helloWorld}"
<wokwi-lcd1602
.characters="${encode(helloWorld)}"
cursor="underline"
cursorX="7"
cursorX="7"
cursorY="1"
></wokwi-7segment>
></wokwi-lcd1602>
`
);

0 comments on commit c556686

Please sign in to comment.