Няма описание

Payment.stories.tsx 4.1KB

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