No Description

Payment.stories.tsx 4.2KB

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