aboutsummaryrefslogtreecommitdiffstats
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.tsx97
1 files changed, 97 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..d81808530
--- /dev/null
+++ b/uidev/src/stories/button.stories.tsx
@@ -0,0 +1,97 @@
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 disabled: false,
14};
15
16const createStore = (args?: any) => {
17 return observable(Object.assign({}, defaultProps, args));
18};
19
20const WithStoreButton = observer(({ store }: { store: any }) => (
21 <>
22 <Button
23 {...Object.assign({}, defaultProps, store)}
24 onClick={!store.onClick ? () => {
25 store.busy = !store.busy;
26
27 window.setTimeout(() => {
28 store.busy = !store.busy;
29 }, 1000);
30 } : store.onClick}
31 />
32 </>
33));
34
35storiesOf('Button')
36 .add('Basic', () => (
37 <WithStoreButton store={createStore()} />
38 ))
39 .add('Secondary', () => (
40 <WithStoreButton store={createStore({
41 buttonType: 'secondary',
42 })} />
43 ))
44 .add('Success', () => (
45 <WithStoreButton store={createStore({
46 buttonType: 'success',
47 })} />
48 ))
49 .add('Warning', () => (
50 <WithStoreButton store={createStore({
51 buttonType: 'warning',
52 })} />
53 ))
54 .add('Danger', () => (
55 <WithStoreButton store={createStore({
56 buttonType: 'danger',
57 })} />
58 ))
59 .add('Inverted', () => (
60 <WithStoreButton store={createStore({
61 buttonType: 'inverted',
62 })} />
63 ))
64 .add('Full width', () => (
65 <WithStoreButton store={createStore({
66 stretch: true,
67 })} />
68 ))
69 .add('Disabled', () => (
70 <WithStoreButton store={createStore({
71 disabled: true,
72 })} />
73 ))
74 .add('With loader', () => (
75 <WithStoreButton store={createStore({
76 busy: true,
77 })} />
78 ))
79 .add('As link', () => (
80 <WithStoreButton store={createStore({
81 href: 'https://meetfranz.com',
82 })} />
83 ))
84 .add('As link (target=_blank)', () => (
85 <WithStoreButton store={createStore({
86 href: 'https://meetfranz.com',
87 target: '_blank',
88 })} />
89 ))
90 .add('As link (with onClick)', () => (
91 <WithStoreButton store={createStore({
92 href: 'https://meetfranz.com',
93 onClick: (e: React.MouseEvent<HTMLAnchorElement>) => {
94 e.preventDefault();
95 alert('Click event');
96 },
97 })} />));