Aucune description

Wanted.stories.tsx 5.1KB

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