-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathuseKeyboardJs.story.tsx
34 lines (31 loc) Β· 1007 Bytes
/
useKeyboardJs.story.tsx
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
import { text, withKnobs } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import useKeyboardJs from '../src/useKeyboardJs';
import { CenterStory } from './util/CenterStory';
import ShowDocs from './util/ShowDocs';
const Demo = ({ combo }) => {
const [pressed] = useKeyboardJs(combo);
return (
<CenterStory>
<div style={{ textAlign: 'center' }}>
Press{' '}
<code
style={{ color: 'red', background: '#f6f6f6', padding: '3px 6px', borderRadius: '3px' }}>
{combo}
</code>{' '}
combo
<br />
<br />
<div style={{ fontSize: '4em' }}>{pressed ? 'π' : ''}</div>
</div>
</CenterStory>
);
};
storiesOf('Sensors/useKeyboardJs', module)
.addDecorator(withKnobs)
.add('Docs', () => <ShowDocs md={require('../docs/useKeyboardJs.md')} />)
.add('Demo', () => {
const combo = text('Combo', 'i + l + u');
return <Demo combo={combo} />;
});