-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathuseStartTyping.story.tsx
39 lines (34 loc) · 939 Bytes
/
useStartTyping.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
35
36
37
38
39
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { useStartTyping } from '../src';
import ShowDocs from './util/ShowDocs';
const Demo = () => {
const input = React.useRef(null);
useStartTyping(() => {
if (input.current) {
input.current.focus();
}
});
return (
<div>
<p>Start typing, and below field will get focused.</p>
<input ref={input} />
<br />
<hr />
<p>Try focusing below elements and see what happens.</p>
<button>When button is focused, it will lose it.</button>
<br />
<br />
<input />
<br />
<br />
<textarea>Editable textarea</textarea>
<br />
<br />
<div contentEditable={true}>Editable DIV</div>
</div>
);
};
storiesOf('Sensors/useStartTyping', module)
.add('Docs', () => <ShowDocs md={require('../docs/useStartTyping.md')} />)
.add('Demo', () => <Demo />);