No Description

index.stories.tsx 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. import React from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { action } from '@storybook/addon-actions';
  4. import { withInfo } from "@storybook/addon-info";
  5. import { withKnobs, number, boolean, select } from "@storybook/addon-knobs";
  6. import { addReadme } from 'storybook-readme';
  7. import ConsumeListView from '@components/Payment/Common/ConsumeListView';
  8. import ConsumeListViewDoc from '@components/Payment/Common/ConsumeListView/README.md';
  9. import PayPlatFormOptions, { PAY_CHANNEL } from '@components/Payment/Common/PayPlatformOptions';
  10. import PayPlatFormOptionsDoc from '@components/Payment/Common/PayPlatformOptions/README.md';
  11. import PriceOptions from '@components/Payment/Common/PriceOptions';
  12. import PriceOptionsDoc from '@components/Payment/Common/PriceOptions/README.md';
  13. import WaitPayInfoView from '@components/Payment/Common/WaitPayInfoView';
  14. import WaitPayInfoViewDoc from '@components/Payment/Common/WaitPayInfoView/README.md';
  15. const stories = storiesOf('Payment', module);
  16. stories.addDecorator((storyFn) => <div style={{padding: "0px 40px"}}>{storyFn()}</div>)
  17. stories.addDecorator(withKnobs);
  18. stories.addDecorator(withInfo);
  19. stories.addDecorator(addReadme);
  20. const consumeData = [
  21. {
  22. "id": 69,
  23. "consume_id": "20190919120838283305719",
  24. "goods_id": 0,
  25. "goods_type": 4,
  26. "num": 9,
  27. "user_id": 71082,
  28. "user_nickname": "lydia",
  29. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2018/8/26/10adf03c70fb128d546e0d40fea77047.jpg",
  30. "to_user_id": 1,
  31. "to_user_nickname": "",
  32. "to_user_avatar": "",
  33. "bill_price": 900,
  34. "ref_id": 0,
  35. "business_type": 3,
  36. "created_at": 1568894918,
  37. "updated_at": 1568894918
  38. },
  39. {
  40. "id": 32,
  41. "consume_id": "20190802095658644217897",
  42. "goods_id": 2,
  43. "goods_type": 1,
  44. "num": 8,
  45. "user_id": 2,
  46. "user_nickname": "jim",
  47. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2018/4/6/7d4948f6e9a66789f776b0c69c8d51d9.png",
  48. "to_user_id": 1,
  49. "to_user_nickname": "",
  50. "to_user_avatar": "",
  51. "bill_price": 800,
  52. "ref_id": 0,
  53. "business_type": 3,
  54. "created_at": 1564739818,
  55. "updated_at": 1564739818
  56. },
  57. {
  58. "id": 46,
  59. "consume_id": "20190819131433734083448",
  60. "goods_id": 2,
  61. "goods_type": 1,
  62. "num": 7,
  63. "user_id": 5,
  64. "user_nickname": "Chris",
  65. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/6/12/a1aec180fbb727cc693c7a2f14812dac.jpg",
  66. "to_user_id": 1,
  67. "to_user_nickname": "",
  68. "to_user_avatar": "",
  69. "bill_price": 700,
  70. "ref_id": 0,
  71. "business_type": 3,
  72. "created_at": 1566220473,
  73. "updated_at": 1566220473
  74. },
  75. {
  76. "id": 20,
  77. "consume_id": "20190729154830503859957",
  78. "goods_id": 2,
  79. "goods_type": 1,
  80. "num": 5,
  81. "user_id": 217,
  82. "user_nickname": "Paul",
  83. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/12/4/b9221e3176d92c349affc3633a0ec7bf.jpg",
  84. "to_user_id": 1,
  85. "to_user_nickname": "",
  86. "to_user_avatar": "",
  87. "bill_price": 500,
  88. "ref_id": 0,
  89. "business_type": 3,
  90. "created_at": 1564415310,
  91. "updated_at": 1564415310
  92. },
  93. {
  94. "id": 127,
  95. "consume_id": "20191204115927765695546",
  96. "goods_id": 2,
  97. "goods_type": 1,
  98. "num": 1,
  99. "user_id": 45,
  100. "user_nickname": "Adam",
  101. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/6/12/cbc5208e3a8aba6fcfc2cef2a4d5151d.jpg",
  102. "to_user_id": 1,
  103. "to_user_nickname": "",
  104. "to_user_avatar": "",
  105. "bill_price": 100,
  106. "ref_id": 0,
  107. "business_type": 3,
  108. "created_at": 1575460767,
  109. "updated_at": 1575460767
  110. },
  111. {
  112. "id": 71,
  113. "consume_id": "20190922010906704921621",
  114. "goods_id": 0,
  115. "goods_type": 4,
  116. "num": 1,
  117. "user_id": 22428,
  118. "user_nickname": "简单生活",
  119. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/9/22/27886bb4305ab56adc0b20018b975dc5.jpg",
  120. "to_user_id": 1,
  121. "to_user_nickname": "",
  122. "to_user_avatar": "",
  123. "bill_price": 100,
  124. "ref_id": 0,
  125. "business_type": 3,
  126. "created_at": 1569114546,
  127. "updated_at": 1569114546
  128. },
  129. {
  130. "id": 70,
  131. "consume_id": "20190920014118872836942",
  132. "goods_id": 0,
  133. "goods_type": 4,
  134. "num": 1,
  135. "user_id": 70406,
  136. "user_nickname": "vicky",
  137. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/5/5/8a0db661919f926501192eccf13740f1jpg",
  138. "to_user_id": 1,
  139. "to_user_nickname": "",
  140. "to_user_avatar": "",
  141. "bill_price": 100,
  142. "ref_id": 0,
  143. "business_type": 3,
  144. "created_at": 1568943678,
  145. "updated_at": 1568943678
  146. },
  147. {
  148. "id": 68,
  149. "consume_id": "20190917224355248346157",
  150. "goods_id": 0,
  151. "goods_type": 4,
  152. "num": 1,
  153. "user_id": 71603,
  154. "user_nickname": "Slate",
  155. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/10/19/1cb9f491e90258ba91a189027ef774b7.jpg",
  156. "to_user_id": 1,
  157. "to_user_nickname": "",
  158. "to_user_avatar": "",
  159. "bill_price": 100,
  160. "ref_id": 0,
  161. "business_type": 3,
  162. "created_at": 1568760235,
  163. "updated_at": 1568760235
  164. }
  165. ];
  166. stories.add(
  167. 'ConsumeListView',
  168. () => {
  169. const [toggle, setToggle] = React.useState(false);
  170. return <ConsumeListView
  171. isToggle={toggle}
  172. onToggleChange={() => setToggle(!toggle)}
  173. dataSource={consumeData}
  174. listLength={consumeData.length}
  175. showLength={number("showLength", 5)}
  176. />
  177. },
  178. {
  179. info: {
  180. inline: true,
  181. text: `
  182. ~~~typescript
  183. <ConsumeListView
  184. isToggle={toggle}
  185. onToggleChange={() => setToggle(!toggle)}
  186. dataSource={consumeData}
  187. listLength={consumeData.length}
  188. showLength={number("showLength", 5)}
  189. />
  190. ~~~
  191. `,
  192. // TableComponent: (props: TableComponentOptionProps) => {
  193. // const { propDefinitions } = props;
  194. // return propDefinitions.map(i => {
  195. // return (
  196. // <div>
  197. // {i.defaultValue}
  198. // </div>
  199. // )
  200. // })
  201. // },
  202. source: false,
  203. maxPropStringLength: 500,
  204. },
  205. notes: 'A very simple example of addon notes',
  206. readme: {
  207. sidebar: ConsumeListViewDoc,
  208. }
  209. }
  210. );
  211. stories.add(
  212. 'PayPlatFormOptions',
  213. () => {
  214. const [payitem, setPayitem] = React.useState(PAY_CHANNEL.PAYPAL);
  215. return (
  216. <PayPlatFormOptions
  217. payitem={payitem}
  218. onPayItemChange={(value) => {
  219. action(`PayItemChange: ${value}`);
  220. setPayitem(value);
  221. }}
  222. isMobile={boolean("isMobile", false)}
  223. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  224. withTitle={boolean("withTitle", false)}
  225. locale={select("locale", { ZH: 'zh', EN: 'en' }, "zh")}
  226. />
  227. )
  228. },
  229. {
  230. info: {
  231. inline: true,
  232. text: ``,
  233. source: false,
  234. maxPropStringLength: 500,
  235. },
  236. notes: 'A very simple example of addon notes',
  237. readme: {
  238. sidebar: PayPlatFormOptionsDoc,
  239. }
  240. }
  241. );
  242. stories.add(
  243. 'PriceOptions',
  244. () => {
  245. const [price, setPrice] = React.useState(0);
  246. const refInput = React.useRef(null);
  247. return (
  248. <PriceOptions
  249. price={price}
  250. onPriceChange={(v) => setPrice(v)}
  251. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  252. withTitle={boolean("withTitle", false)}
  253. focusScroll={boolean("focusScroll", false)}
  254. inputRef={refInput}
  255. />
  256. )
  257. },
  258. {
  259. info: {
  260. inline: true,
  261. text: ``,
  262. source: false,
  263. maxPropStringLength: 500,
  264. },
  265. notes: 'A very simple example of addon notes',
  266. readme: {
  267. sidebar: PriceOptionsDoc,
  268. }
  269. }
  270. )
  271. stories.add(
  272. 'WaitPayInfoView',
  273. () => {
  274. return (
  275. <WaitPayInfoView />
  276. )
  277. },
  278. {
  279. info: { inline: true, text: ``, source: false, maxPropStringLength: 500 },
  280. notes: 'A very simple example of addon notes',
  281. readme: {
  282. sidebar: WaitPayInfoViewDoc,
  283. }
  284. }
  285. )