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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import React from 'react';
import { Button } from '@meetfranz/forms';
import { storiesOf } from '../stores/stories';
const defaultProps = {
label: 'Button',
id: 'test1',
name: 'test1',
type: 'button',
onClick: (e: React.MouseEvent<HTMLButtonElement>) => console.log('click event', e),
disabled: false,
};
const createStore = (args?: any) => {
return observable(Object.assign({}, defaultProps, args));
};
const WithStoreButton = observer(({ store }: { store: any }) => (
<>
<Button
{...Object.assign({}, defaultProps, store)}
onClick={() => {
store.busy = !store.busy;
window.setTimeout(() => {
store.busy = !store.busy;
}, 1000);
}}
/>
</>
));
storiesOf('Button')
.add('Basic', () => (
<WithStoreButton store={createStore()} />
))
.add('Secondary', () => (
<WithStoreButton store={createStore({
buttonType: 'secondary',
})} />
))
.add('Warning', () => (
<WithStoreButton store={createStore({
buttonType: 'warning',
})} />
))
.add('Danger', () => (
<WithStoreButton store={createStore({
buttonType: 'danger',
})} />
))
.add('Inverted', () => (
<WithStoreButton store={createStore({
buttonType: 'inverted',
})} />
))
.add('Full width', () => (
<WithStoreButton store={createStore({
stretch: true,
})} />
))
.add('Disabled', () => (
<WithStoreButton store={createStore({
disabled: true,
})} />
))
.add('With loader', () => (
<WithStoreButton store={createStore({
busy: true,
})} />
));
|