설명 없음

Payment.stories.tsx 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import React, { MouseEvent } 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, text, array } from "@storybook/addon-knobs";
  6. import { addReadme } from 'storybook-readme';
  7. import { Divider } from 'antd';
  8. import ConsumeListView from '@/components/Payment/ConsumeListView';
  9. import ConsumeListViewDoc from '@components/Payment/ConsumeListView/README.md';
  10. import PayPlatFormOptions, { PAY_CHANNEL } from '@/components/Payment/PayPlatformOptions';
  11. import PayPlatFormOptionsDoc from '@components/Payment/PayPlatformOptions/README.md';
  12. import PriceOptions from '@/components/Payment/PriceOptions';
  13. import PriceOptionsDoc from '@components/Payment/PriceOptions/README.md';
  14. import WaitPayInfoView from '@/components/Payment/WaitPayInfoView';
  15. import WaitPayInfoViewDoc from '@components/Payment/WaitPayInfoView/README.md';
  16. import { formatMoney } from '@components/Payment/Utils/utils';
  17. import { consumeList} from './data/consumeList.json';
  18. const consumeData: any = consumeList;
  19. const stories = storiesOf('Payment', module);
  20. stories.addDecorator((storyFn) => <div style={{padding: "0px 40px"}}>{storyFn()}</div>)
  21. stories.addDecorator(withKnobs);
  22. stories.addDecorator(withInfo);
  23. stories.addDecorator(addReadme);
  24. stories.add(
  25. 'ConsumeListView',
  26. () => {
  27. const [toggle, setToggle] = React.useState(false);
  28. return <ConsumeListView
  29. isToggle={toggle}
  30. onToggleChange={() => setToggle(!toggle)}
  31. onConsumeItemClick={(e: MouseEvent, clickData: any) => { console.log(clickData); }}
  32. dataSource={consumeData}
  33. listLength={consumeData.length}
  34. showLength={number("showLength", 5)}
  35. />
  36. },
  37. {
  38. info: {
  39. inline: true,
  40. text: `
  41. ~~~typescript
  42. <ConsumeListView
  43. isToggle={toggle}
  44. onToggleChange={() => setToggle(!toggle)}
  45. dataSource={consumeData}
  46. listLength={consumeData.length}
  47. showLength={number("showLength", 5)}
  48. />
  49. ~~~
  50. `,
  51. // TableComponent: (props: TableComponentOptionProps) => {
  52. // const { propDefinitions } = props;
  53. // return propDefinitions.map(i => {
  54. // return (
  55. // <div>
  56. // {i.defaultValue}
  57. // </div>
  58. // )
  59. // })
  60. // },
  61. source: false,
  62. maxPropStringLength: 500,
  63. },
  64. notes: 'A very simple example of addon notes',
  65. readme: {
  66. sidebar: ConsumeListViewDoc,
  67. }
  68. }
  69. );
  70. stories.add(
  71. 'PayPlatFormOptions',
  72. () => {
  73. const [payChannel, setPayChannel] = React.useState(PAY_CHANNEL.PAYPAL);
  74. return (
  75. <PayPlatFormOptions
  76. payChannel={payChannel}
  77. onPayChannelChange={(value) => {
  78. action(`PayItemChange: ${value}`);
  79. setPayChannel(value);
  80. }}
  81. isMobile={boolean("isMobile", false)}
  82. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  83. withTitle={boolean("withTitle", false)}
  84. locale={select("locale", { ZH: 'zh', EN: 'en' }, "zh")}
  85. />
  86. )
  87. },
  88. {
  89. info: {
  90. inline: true,
  91. text: ``,
  92. source: false,
  93. maxPropStringLength: 500,
  94. },
  95. notes: 'A very simple example of addon notes',
  96. readme: {
  97. sidebar: PayPlatFormOptionsDoc,
  98. }
  99. }
  100. );
  101. stories.add(
  102. 'PriceOptions',
  103. () => {
  104. const [price, setPrice] = React.useState(0);
  105. const refInput = React.useRef(null);
  106. return (
  107. <>
  108. <PriceOptions
  109. price={price}
  110. onPriceChange={(v) => setPrice(v)}
  111. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  112. withTitle={boolean("withTitle", false)}
  113. titleText={text("titleText", "")}
  114. inputPlaceholderText={text("inputPlaceholderText", "其他金额")}
  115. focusScroll={boolean("focusScroll", false)}
  116. priceOptions={array("priceOptions", ["100", "600", "800"])}
  117. priceRender={(i: number) => `${formatMoney(i/100, 0)}¥`}
  118. inputRef={refInput}
  119. />
  120. <Divider />
  121. <div>
  122. price: {price}
  123. </div>
  124. </>
  125. )
  126. },
  127. {
  128. info: {
  129. inline: true,
  130. text: ``,
  131. source: false,
  132. maxPropStringLength: 500,
  133. },
  134. notes: 'A very simple example of addon notes',
  135. readme: {
  136. sidebar: PriceOptionsDoc,
  137. }
  138. }
  139. )
  140. stories.add(
  141. 'WaitPayInfoView',
  142. () => {
  143. return (
  144. <WaitPayInfoView />
  145. )
  146. },
  147. {
  148. info: { inline: true, text: ``, source: false, maxPropStringLength: 500 },
  149. notes: 'A very simple example of addon notes',
  150. readme: {
  151. sidebar: WaitPayInfoViewDoc,
  152. }
  153. }
  154. )