Sin descripción

Wanted.stories.tsx 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import { storiesOf } from "@storybook/react";
  2. import { number, select, text, withKnobs } from "@storybook/addon-knobs";
  3. import { withInfo } from "@storybook/addon-info";
  4. import { addReadme } from "storybook-readme";
  5. import React from "react";
  6. import AllocWantedModal from "@components/Payment/AllocWantedModal";
  7. import { Button, Divider, Modal } from "antd";
  8. import WantedPublishView from "@components/Payment/WantedPublishView";
  9. import WantedPublishModal from "@components/Payment/WantedPublishModal";
  10. import WantedPublishPopover from "@components/Payment/WantedPublishPopover";
  11. const stories = storiesOf("Payment/Wanted", module);
  12. stories.addDecorator(storyFn => (
  13. <div style={{ padding: "0px 40px" }}>{storyFn()}</div>
  14. ));
  15. stories.addDecorator(withKnobs);
  16. stories.addDecorator(withInfo);
  17. stories.addDecorator(addReadme);
  18. stories.add(
  19. "AllocWantedModal",
  20. () => {
  21. return (
  22. <AllocWantedModal
  23. allocValue={number("allocValue", 100)}
  24. sendValueRange={[number("minValue", 0), number("maxValue", 100)]}
  25. sendRequest={(...args: any) => {
  26. console.log(args);
  27. }}
  28. sendGiftData={{
  29. answerId: text("answerId", "1"),
  30. questionId: text("questionId", "1"),
  31. toUserId: text("toUserId", "1")
  32. }}
  33. handleVisibleChange={visiable => {
  34. console.log(visiable);
  35. }}
  36. >
  37. <Button>Click it</Button>
  38. </AllocWantedModal>
  39. );
  40. },
  41. {
  42. info: { inline: true },
  43. notes: "A very simple example of addon notes"
  44. }
  45. );
  46. stories.add(
  47. "WantedPushView",
  48. () => {
  49. const [currentWanted, setCurrentWanted] = React.useState(0);
  50. return (
  51. <div style={{ border: "4px solid black", padding: "4px" }}>
  52. <WantedPublishView
  53. type={select(
  54. "type",
  55. {
  56. POP: "pop",
  57. Modal: "modal"
  58. },
  59. "pop"
  60. )}
  61. wrapperClass="test_wrapper"
  62. current_wanted={currentWanted}
  63. InputWantedValueChange={(value: any) => setCurrentWanted(value)}
  64. InputWantedOnBlur={(blurValue: any) => setCurrentWanted(blurValue)}
  65. InputWantedClear={() => setCurrentWanted(0)}
  66. InputWantedPressEnter={(enterValue: any) =>
  67. setCurrentWanted(enterValue)
  68. }
  69. CloseFunction={() => {
  70. console.log("Close Button");
  71. }}
  72. />
  73. <Divider />
  74. <div>currentWanted: {currentWanted}</div>
  75. </div>
  76. );
  77. },
  78. {
  79. info: { inline: true },
  80. notes: "A very simple example of addon notes"
  81. }
  82. );
  83. stories.add(
  84. "WantedPublishPopover And Modal",
  85. () => {
  86. const [wanted, setWanted] = React.useState("");
  87. const [testModal, setTestModal] = React.useState(false);
  88. return (
  89. <div>
  90. <div>
  91. <WantedPublishModal>
  92. <div>ModalClick</div>
  93. </WantedPublishModal>
  94. </div>
  95. <Divider />
  96. <div>
  97. <WantedPublishPopover
  98. popoverConfig={{
  99. placement: select(
  100. "popoverConfigPlacement",
  101. {
  102. Undefined: undefined,
  103. Left: "left",
  104. Right: "right",
  105. Top: "top",
  106. Bottom: "bottom",
  107. TopLeft: "topLeft",
  108. TopRight: "topRight",
  109. BottomLeft: "bottomLeft",
  110. BottomRight: "bottomRight",
  111. LeftTop: "leftTop",
  112. LeftBottom: "leftBottom",
  113. RightTop: "rightTop",
  114. RightBottom: "rightBottom"
  115. },
  116. undefined
  117. ),
  118. trigger: select(
  119. "popoverConfigTrigger",
  120. {
  121. Undefined: undefined,
  122. Hover: "hover",
  123. Click: "click",
  124. Focus: "focus",
  125. ContextMenu: "contextMenu"
  126. },
  127. undefined
  128. )
  129. }}
  130. handleConfirm={(value: any) => {
  131. setWanted(value);
  132. }}
  133. >
  134. <Button>HoverIt{wanted}</Button>
  135. </WantedPublishPopover>
  136. </div>
  137. <Divider />
  138. <div onClick={() => setTestModal(true)}>Show Modal</div>
  139. <Modal
  140. visible={testModal}
  141. title="Create a new collection"
  142. okText="Create"
  143. onCancel={() => setTestModal(false)}
  144. onOk={() => setTestModal(true)}
  145. >
  146. <WantedPublishModal>
  147. <div>ModalClick</div>
  148. </WantedPublishModal>
  149. </Modal>
  150. {/* 下面用于分割wanted值的渲染,防止Error */}
  151. {(wanted => (
  152. <div>wanted{wanted}</div>
  153. ))(wanted)}
  154. </div>
  155. );
  156. },
  157. {
  158. info: { inline: true },
  159. notes: "A very simple example of addon notes"
  160. }
  161. );