-
Notifications
You must be signed in to change notification settings - Fork 5
/
FormWrapper.story.js
111 lines (109 loc) · 2.81 KB
/
FormWrapper.story.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import Input from "@crave/farmblocks-input-text";
import { buttonTypes, buttonSizes } from "@crave/farmblocks-button";
import FormWrapper from ".";
storiesOf("Form Wrapper", module)
.add("Default", () => (
<FormWrapper onCancel={action("onCancel")} onSave={action("onSave")}>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("With title", () => (
<FormWrapper
onCancel={action("onCancel")}
onSave={action("onSave")}
title="Title"
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("loading", () => (
<FormWrapper
onCancel={action("onCancel")}
onSave={action("onSave")}
title="Title"
loading
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("extra content", () => (
<FormWrapper
onCancel={action("onCancel")}
onSave={action("onSave")}
title="Title"
extraContent={<div>Extra content renders after save button</div>}
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("in compact container", () => (
<div style={{ display: "inline-block" }}>
<FormWrapper
onCancel={action("onCancel")}
onSave={action("onSave")}
title="Long Title That Should Not Touch The Cancel Button"
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
</div>
))
.add("With id", () => (
<FormWrapper
id="an-id"
onCancel={action("onCancel")}
onSave={action("onSave")}
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("With saveButtonProps customization", () => (
<FormWrapper
onCancel={action("onCancel")}
onSave={action("onSave")}
title="Title"
saveButtonProps={{ type: buttonTypes.PRIMARY, size: buttonSizes.SMALL }}
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
))
.add("extended style", () => (
<FormWrapper
css="
background: gainsboro;
.header {
border: solid 4px maroon;
.title {
font-family: fantasy;
}
.cancel {
transform: scaleX(-1);
}
}
.body {
margin: 40px;
}
.footer {
border: solid 4px mediumslateblue;
.save {
opacity: .3;
}
}
"
title="Title"
onCancel={action("onCancel")}
onSave={action("onSave")}
>
<Input label="First Name" />
<Input label="Last Name" />
</FormWrapper>
));