|
@@ -1,43 +1,61 @@
|
1
|
|
-import React, { MouseEvent } from 'react';
|
2
|
|
-import { storiesOf } from '@storybook/react';
|
3
|
|
-import { action } from '@storybook/addon-actions';
|
|
1
|
+import React, { MouseEvent } from "react";
|
|
2
|
+import { storiesOf } from "@storybook/react";
|
|
3
|
+import { action } from "@storybook/addon-actions";
|
4
|
4
|
import { withInfo } from "@storybook/addon-info";
|
5
|
|
-import { withKnobs, number, boolean, select, text, array } from "@storybook/addon-knobs";
|
6
|
|
-import { addReadme } from 'storybook-readme';
|
7
|
|
-import { Divider } from 'antd';
|
|
5
|
+import {
|
|
6
|
+ withKnobs,
|
|
7
|
+ number,
|
|
8
|
+ boolean,
|
|
9
|
+ select,
|
|
10
|
+ text,
|
|
11
|
+ array
|
|
12
|
+} from "@storybook/addon-knobs";
|
|
13
|
+import { addReadme } from "storybook-readme";
|
|
14
|
+import { Divider, Button } from "antd";
|
8
|
15
|
|
9
|
|
-import ConsumeListView from '@/components/Payment/ConsumeListView';
|
10
|
|
-import ConsumeListViewDoc from '@components/Payment/ConsumeListView/README.md';
|
11
|
|
-import PayPlatFormOptions, { PAY_CHANNEL } from '@/components/Payment/PayPlatformOptions';
|
12
|
|
-import PayPlatFormOptionsDoc from '@components/Payment/PayPlatformOptions/README.md';
|
13
|
|
-import PriceOptions from '@/components/Payment/PriceOptions';
|
14
|
|
-import PriceOptionsDoc from '@components/Payment/PriceOptions/README.md';
|
15
|
|
-import WaitPayInfoView from '@/components/Payment/WaitPayInfoView';
|
16
|
|
-import WaitPayInfoViewDoc from '@components/Payment/WaitPayInfoView/README.md';
|
17
|
|
-import { formatMoney } from '@components/Payment/Utils/utils';
|
|
16
|
+import ConsumeListView from "@/components/Payment/ConsumeListView";
|
|
17
|
+import ConsumeListViewDoc from "@components/Payment/ConsumeListView/README.md";
|
|
18
|
+import PayPlatFormOptions, {
|
|
19
|
+ PAY_CHANNEL
|
|
20
|
+} from "@/components/Payment/PayPlatformOptions";
|
|
21
|
+import PayPlatFormOptionsDoc from "@components/Payment/PayPlatformOptions/README.md";
|
|
22
|
+import PriceOptions from "@/components/Payment/PriceOptions";
|
|
23
|
+import PriceOptionsDoc from "@components/Payment/PriceOptions/README.md";
|
|
24
|
+import WaitPayInfoView from "@/components/Payment/WaitPayInfoView";
|
|
25
|
+import WaitPayInfoViewDoc from "@components/Payment/WaitPayInfoView/README.md";
|
|
26
|
+import AllocWantedModal from "@/components/Payment/AllocWantedModal";
|
|
27
|
+import WantedPublishView from "@/components/Payment/WantedPublishView";
|
|
28
|
+import WantedPublishPopover from '@/components/Payment/WantedPublishPopover';
|
|
29
|
+import { formatMoney } from "@components/Payment/Utils/utils";
|
18
|
30
|
|
19
|
|
-import { consumeList} from './data/consumeList.json';
|
|
31
|
+import { consumeList } from "./data/consumeList.json";
|
20
|
32
|
|
21
|
33
|
const consumeData: any = consumeList;
|
22
|
34
|
|
23
|
|
-const stories = storiesOf('Payment', module);
|
24
|
|
-stories.addDecorator((storyFn) => <div style={{padding: "0px 40px"}}>{storyFn()}</div>)
|
|
35
|
+const stories = storiesOf("Payment", module);
|
|
36
|
+stories.addDecorator(storyFn => (
|
|
37
|
+ <div style={{ padding: "0px 40px" }}>{storyFn()}</div>
|
|
38
|
+));
|
25
|
39
|
stories.addDecorator(withKnobs);
|
26
|
40
|
stories.addDecorator(withInfo);
|
27
|
41
|
stories.addDecorator(addReadme);
|
28
|
42
|
|
29
|
43
|
stories.add(
|
30
|
|
- 'ConsumeListView',
|
|
44
|
+ "ConsumeListView",
|
31
|
45
|
() => {
|
32
|
46
|
const [toggle, setToggle] = React.useState(false);
|
33
|
|
- return <ConsumeListView
|
34
|
|
- isToggle={toggle}
|
35
|
|
- onToggleChange={() => setToggle(!toggle)}
|
36
|
|
- onConsumeItemClick={(e: MouseEvent, clickData: any) => { console.log(clickData); }}
|
37
|
|
- dataSource={consumeData}
|
38
|
|
- listLength={consumeData.length}
|
39
|
|
- showLength={number("showLength", 5)}
|
40
|
|
- />
|
|
47
|
+ return (
|
|
48
|
+ <ConsumeListView
|
|
49
|
+ isToggle={toggle}
|
|
50
|
+ onToggleChange={() => setToggle(!toggle)}
|
|
51
|
+ onConsumeItemClick={(e: MouseEvent, clickData: any) => {
|
|
52
|
+ console.log(clickData);
|
|
53
|
+ }}
|
|
54
|
+ dataSource={consumeData}
|
|
55
|
+ listLength={consumeData.length}
|
|
56
|
+ showLength={number("showLength", 5)}
|
|
57
|
+ />
|
|
58
|
+ );
|
41
|
59
|
},
|
42
|
60
|
{
|
43
|
61
|
info: {
|
|
@@ -64,99 +82,215 @@ stories.add(
|
64
|
82
|
// })
|
65
|
83
|
// },
|
66
|
84
|
source: false,
|
67
|
|
- maxPropStringLength: 500,
|
|
85
|
+ maxPropStringLength: 500
|
68
|
86
|
},
|
69
|
|
- notes: 'A very simple example of addon notes',
|
|
87
|
+ notes: "A very simple example of addon notes",
|
70
|
88
|
readme: {
|
71
|
|
- sidebar: ConsumeListViewDoc,
|
|
89
|
+ sidebar: ConsumeListViewDoc
|
72
|
90
|
}
|
73
|
91
|
}
|
74
|
92
|
);
|
75
|
93
|
|
76
|
94
|
stories.add(
|
77
|
|
- 'PayPlatFormOptions',
|
|
95
|
+ "PayPlatFormOptions",
|
78
|
96
|
() => {
|
79
|
97
|
const [payChannel, setPayChannel] = React.useState(PAY_CHANNEL.PAYPAL);
|
80
|
98
|
return (
|
81
|
99
|
<PayPlatFormOptions
|
82
|
100
|
payChannel={payChannel}
|
83
|
|
- onPayChannelChange={(value) => {
|
|
101
|
+ onPayChannelChange={value => {
|
84
|
102
|
action(`PayItemChange: ${value}`);
|
85
|
103
|
setPayChannel(value);
|
86
|
104
|
}}
|
87
|
105
|
isMobile={boolean("isMobile", false)}
|
88
|
|
- size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
|
|
106
|
+ size={select(
|
|
107
|
+ "size",
|
|
108
|
+ { Small: "small", Normal: "normal", Large: "large" },
|
|
109
|
+ "normal"
|
|
110
|
+ )}
|
89
|
111
|
withTitle={boolean("withTitle", false)}
|
90
|
|
- locale={select("locale", { ZH: 'zh', EN: 'en' }, "zh")}
|
|
112
|
+ locale={select("locale", { ZH: "zh", EN: "en" }, "zh")}
|
91
|
113
|
/>
|
92
|
|
- )
|
|
114
|
+ );
|
93
|
115
|
},
|
94
|
116
|
{
|
95
|
117
|
info: {
|
96
|
118
|
inline: true,
|
97
|
119
|
text: ``,
|
98
|
120
|
source: false,
|
99
|
|
- maxPropStringLength: 500,
|
|
121
|
+ maxPropStringLength: 500
|
100
|
122
|
},
|
101
|
|
- notes: 'A very simple example of addon notes',
|
|
123
|
+ notes: "A very simple example of addon notes",
|
102
|
124
|
readme: {
|
103
|
|
- sidebar: PayPlatFormOptionsDoc,
|
|
125
|
+ sidebar: PayPlatFormOptionsDoc
|
104
|
126
|
}
|
105
|
127
|
}
|
106
|
128
|
);
|
107
|
129
|
|
108
|
130
|
stories.add(
|
109
|
|
- 'PriceOptions',
|
|
131
|
+ "PriceOptions",
|
110
|
132
|
() => {
|
111
|
133
|
const [price, setPrice] = React.useState(0);
|
112
|
134
|
const refInput = React.useRef(null);
|
113
|
135
|
return (
|
114
|
136
|
<>
|
115
|
|
- <PriceOptions
|
116
|
|
- price={price}
|
117
|
|
- onPriceChange={(v) => setPrice(v)}
|
118
|
|
- size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
|
119
|
|
- withTitle={boolean("withTitle", false)}
|
120
|
|
- titleText={text("titleText", "")}
|
121
|
|
- inputPlaceholderText={text("inputPlaceholderText", "其他金额")}
|
122
|
|
- focusScroll={boolean("focusScroll", false)}
|
123
|
|
- priceOptions={array("priceOptions", ["100", "600", "800"])}
|
124
|
|
- priceRender={(i: number) => `${formatMoney(i/100, 0)}¥`}
|
125
|
|
- inputRef={refInput}
|
126
|
|
- />
|
127
|
|
- <Divider />
|
128
|
|
- <div>
|
129
|
|
- price: {price}
|
130
|
|
- </div>
|
|
137
|
+ <PriceOptions
|
|
138
|
+ price={price}
|
|
139
|
+ onPriceChange={v => setPrice(v)}
|
|
140
|
+ size={select(
|
|
141
|
+ "size",
|
|
142
|
+ { Small: "small", Normal: "normal", Large: "large" },
|
|
143
|
+ "normal"
|
|
144
|
+ )}
|
|
145
|
+ withTitle={boolean("withTitle", false)}
|
|
146
|
+ titleText={text("titleText", "")}
|
|
147
|
+ inputPlaceholderText={text("inputPlaceholderText", "其他金额")}
|
|
148
|
+ focusScroll={boolean("focusScroll", false)}
|
|
149
|
+ priceOptions={array("priceOptions", ["100", "600", "800"])}
|
|
150
|
+ priceRender={(i: number) => `${formatMoney(i / 100, 0)}¥`}
|
|
151
|
+ inputRef={refInput}
|
|
152
|
+ />
|
|
153
|
+ <Divider />
|
|
154
|
+ <div>price: {price}</div>
|
131
|
155
|
</>
|
132
|
|
- )
|
|
156
|
+ );
|
133
|
157
|
},
|
134
|
158
|
{
|
135
|
159
|
info: {
|
136
|
160
|
inline: true,
|
137
|
161
|
text: ``,
|
138
|
162
|
source: false,
|
139
|
|
- maxPropStringLength: 500,
|
|
163
|
+ maxPropStringLength: 500
|
140
|
164
|
},
|
141
|
|
- notes: 'A very simple example of addon notes',
|
|
165
|
+ notes: "A very simple example of addon notes",
|
142
|
166
|
readme: {
|
143
|
|
- sidebar: PriceOptionsDoc,
|
|
167
|
+ sidebar: PriceOptionsDoc
|
144
|
168
|
}
|
145
|
169
|
}
|
146
|
|
-)
|
|
170
|
+);
|
147
|
171
|
|
148
|
172
|
stories.add(
|
149
|
|
- 'WaitPayInfoView',
|
|
173
|
+ "WaitPayInfoView",
|
150
|
174
|
() => {
|
151
|
|
- return (
|
152
|
|
- <WaitPayInfoView />
|
153
|
|
- )
|
|
175
|
+ return <WaitPayInfoView />;
|
154
|
176
|
},
|
155
|
177
|
{
|
156
|
178
|
info: { inline: true, text: ``, source: false, maxPropStringLength: 500 },
|
157
|
|
- notes: 'A very simple example of addon notes',
|
|
179
|
+ notes: "A very simple example of addon notes",
|
158
|
180
|
readme: {
|
159
|
|
- sidebar: WaitPayInfoViewDoc,
|
|
181
|
+ sidebar: WaitPayInfoViewDoc
|
160
|
182
|
}
|
161
|
183
|
}
|
|
184
|
+);
|
|
185
|
+
|
|
186
|
+stories.add(
|
|
187
|
+ "AllocWantedModal",
|
|
188
|
+ () => {
|
|
189
|
+ return (
|
|
190
|
+ <AllocWantedModal
|
|
191
|
+ allocValue={number("allocValue", 100)}
|
|
192
|
+ sendValueRange={[number("minValue", 0), number("maxValue", 100)]}
|
|
193
|
+ sendRequest={(...args: any) => {
|
|
194
|
+ console.log(args);
|
|
195
|
+ }}
|
|
196
|
+ sendGiftData={{
|
|
197
|
+ answerId: text("answerId", '1'),
|
|
198
|
+ questionId: text("questionId", '1'),
|
|
199
|
+ toUserId: text("toUserId", '1')
|
|
200
|
+ }}
|
|
201
|
+ handleVisibleChange={visiable => {
|
|
202
|
+ console.log(visiable);
|
|
203
|
+ }}
|
|
204
|
+ >
|
|
205
|
+ <Button>Click it</Button>
|
|
206
|
+ </AllocWantedModal>
|
|
207
|
+ );
|
|
208
|
+ },
|
|
209
|
+ {
|
|
210
|
+ info: { inline: true },
|
|
211
|
+ notes: "A very simple example of addon notes"
|
|
212
|
+ }
|
|
213
|
+);
|
|
214
|
+
|
|
215
|
+stories.add(
|
|
216
|
+ "WantedPushView",
|
|
217
|
+ () => {
|
|
218
|
+ const [currentWanted, setCurrentWanted] = React.useState(0);
|
|
219
|
+ return (
|
|
220
|
+ <>
|
|
221
|
+ <WantedPublishView
|
|
222
|
+ type={select("type", {
|
|
223
|
+ POP: "pop",
|
|
224
|
+ Modal: 'modal',
|
|
225
|
+ }, "pop")}
|
|
226
|
+ wrapperClass="test_wrapper"
|
|
227
|
+ current_wanted={currentWanted}
|
|
228
|
+ InputWantedValueChange={(value: any) => setCurrentWanted(value)}
|
|
229
|
+ InputWantedOnBlur={(blurValue: any) => setCurrentWanted(blurValue)}
|
|
230
|
+ InputWantedClear={() => setCurrentWanted(0)}
|
|
231
|
+ InputWantedPressEnter={(enterValue: any) => setCurrentWanted(enterValue)}
|
|
232
|
+ CloseFunction={() => { console.log("Close Button"); }}
|
|
233
|
+ />
|
|
234
|
+ <Divider />
|
|
235
|
+ <div>
|
|
236
|
+ currentWanted: {currentWanted}
|
|
237
|
+ </div>
|
|
238
|
+ </>
|
|
239
|
+ )
|
|
240
|
+ },
|
|
241
|
+ {
|
|
242
|
+ info: { inline: true },
|
|
243
|
+ notes: "A very simple example of addon notes"
|
|
244
|
+ }
|
162
|
245
|
)
|
|
246
|
+
|
|
247
|
+stories.add(
|
|
248
|
+ "WantedPublishPopover",
|
|
249
|
+ () => {
|
|
250
|
+ const [wanted, setWanted] = React.useState('');
|
|
251
|
+ return (
|
|
252
|
+ <div>
|
|
253
|
+ <WantedPublishPopover
|
|
254
|
+ popoverConfig={{
|
|
255
|
+ placement: select("popoverConfigPlacement", {
|
|
256
|
+ Undefined: undefined,
|
|
257
|
+ Left: "left",
|
|
258
|
+ Right: "right",
|
|
259
|
+ Top: "top",
|
|
260
|
+ Bottom: "bottom",
|
|
261
|
+ TopLeft: "topLeft",
|
|
262
|
+ TopRight: "topRight",
|
|
263
|
+ BottomLeft: "bottomLeft",
|
|
264
|
+ BottomRight: "bottomRight",
|
|
265
|
+ LeftTop: "leftTop",
|
|
266
|
+ LeftBottom: "leftBottom",
|
|
267
|
+ RightTop: "rightTop",
|
|
268
|
+ RightBottom: "rightBottom",
|
|
269
|
+ }, undefined),
|
|
270
|
+ trigger: select("popoverConfigTrigger", {
|
|
271
|
+ Undefined: undefined,
|
|
272
|
+ Hover: "hover",
|
|
273
|
+ Click: "click",
|
|
274
|
+ Focus: "focus",
|
|
275
|
+ ContextMenu: "contextMenu",
|
|
276
|
+ }, undefined),
|
|
277
|
+ }}
|
|
278
|
+ handleConfirm={(value: any) => {
|
|
279
|
+ setWanted(value);
|
|
280
|
+ }}
|
|
281
|
+ >
|
|
282
|
+ <Button>HoverIt{wanted}</Button>
|
|
283
|
+ </WantedPublishPopover>
|
|
284
|
+ <Divider />
|
|
285
|
+ {/* 下面用于分割wanted值的渲染,防止Error */}
|
|
286
|
+ {
|
|
287
|
+ ((wanted) => <div>wanted{wanted}</div>)(wanted)
|
|
288
|
+ }
|
|
289
|
+ </div>
|
|
290
|
+ )
|
|
291
|
+ },
|
|
292
|
+ {
|
|
293
|
+ info: { inline: true },
|
|
294
|
+ notes: "A very simple example of addon notes"
|
|
295
|
+ }
|
|
296
|
+)
|