forked from zapkub/react-thailand-address-typeahead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (43 loc) · 1.42 KB
/
index.js
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
40
41
42
43
44
45
import React from 'react';
import { storiesOf, action } from '@kadira/storybook';
import { withState } from 'recompose';
import AddressForm from '../src/index';
import '../src/styles.css';
storiesOf('Component', module)
.add('montage', () => (
<div style={{ width: 350 }}>
<AddressForm onAddressSelected={action('onSelectedAdress')} />
<code>{'<AddressForm onAddressSelected={action(\'onSelectedAdress\')} />'}</code>
</div>
))
.add('handle result', () => {
const WithStateComponent = withState('result', 'setResult', null)(({ result, setResult }) => (
<div style={{ width: 350 }}>
<div>
selected : {result ? `${result.p} ${result.a} ${result.d} ${result.z}` : null}
</div>
<AddressForm onAddressSelected={address => setResult(address)} />
</div>
));
return (<div>
<WithStateComponent />
<code>
{`
<div style={{ width: 350 }}>
<div>
selected : {result ? \`\${result.p} \${result.a} \${result.d} \${result.z}\` : null}
</div>
<AddressForm onAddressSelected={address => setResult(address)} />
</div>
`}
</code>
</div>);
})
.add('custom render result', () => (
<div style={{ width: 400 }}>
<AddressForm
renderResult={data => <b>{`Hi ${data.p}:${data.d} ${data.a}`}</b>}
onAddressSelected={action('onSelectedAdress')}
/>
</div>
));