summaryrefslogtreecommitdiffstats
path: root/uidev/src/stories/button.stories.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'uidev/src/stories/button.stories.tsx')
-rw-r--r--uidev/src/stories/button.stories.tsx74
1 files changed, 74 insertions, 0 deletions
diff --git a/uidev/src/stories/button.stories.tsx b/uidev/src/stories/button.stories.tsx
new file mode 100644
index 000000000..1a54eb6bf
--- /dev/null
+++ b/uidev/src/stories/button.stories.tsx
@@ -0,0 +1,74 @@
1import { observable } from 'mobx';
2import { observer } from 'mobx-react';
3import React from 'react';
4
5import { Button } from '@meetfranz/forms';
6import { storiesOf } from '../stores/stories';
7
8const defaultProps = {
9 label: 'Button',
10 id: 'test1',
11 name: 'test1',
12 type: 'button',
13 onClick: (e: React.MouseEvent<HTMLButtonElement>) => console.log('click event', e),
14 disabled: false,
15};
16
17const createStore = (args?: any) => {
18 return observable(Object.assign({}, defaultProps, args));
19};
20
21const WithStoreButton = observer(({ store }: { store: any }) => (
22 <>
23 <Button
24 {...Object.assign({}, defaultProps, store)}
25 onClick={() => {
26 store.busy = !store.busy;
27
28 window.setTimeout(() => {
29 store.busy = !store.busy;
30 }, 1000);
31 }}
32 />
33 </>
34));
35
36storiesOf('Button')
37 .add('Basic', () => (
38 <WithStoreButton store={createStore()} />
39 ))
40 .add('Secondary', () => (
41 <WithStoreButton store={createStore({
42 buttonType: 'secondary',
43 })} />
44 ))
45 .add('Warning', () => (
46 <WithStoreButton store={createStore({
47 buttonType: 'warning',
48 })} />
49 ))
50 .add('Danger', () => (
51 <WithStoreButton store={createStore({
52 buttonType: 'danger',
53 })} />
54 ))
55 .add('Inverted', () => (
56 <WithStoreButton store={createStore({
57 buttonType: 'inverted',
58 })} />
59 ))
60 .add('Full width', () => (
61 <WithStoreButton store={createStore({
62 stretch: true,
63 })} />
64 ))
65 .add('Disabled', () => (
66 <WithStoreButton store={createStore({
67 disabled: true,
68 })} />
69 ))
70 .add('With loader', () => (
71 <WithStoreButton store={createStore({
72 busy: true,
73 })} />
74 ));