설명 없음

Wanted.stories.tsx 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 } 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. return (
  88. <div>
  89. <div>
  90. <WantedPublishModal>
  91. <div>ModalClick</div>
  92. </WantedPublishModal>
  93. </div>
  94. <Divider />
  95. <div>
  96. <WantedPublishPopover
  97. popoverConfig={{
  98. placement: select(
  99. "popoverConfigPlacement",
  100. {
  101. Undefined: undefined,
  102. Left: "left",
  103. Right: "right",
  104. Top: "top",
  105. Bottom: "bottom",
  106. TopLeft: "topLeft",
  107. TopRight: "topRight",
  108. BottomLeft: "bottomLeft",
  109. BottomRight: "bottomRight",
  110. LeftTop: "leftTop",
  111. LeftBottom: "leftBottom",
  112. RightTop: "rightTop",
  113. RightBottom: "rightBottom"
  114. },
  115. undefined
  116. ),
  117. trigger: select(
  118. "popoverConfigTrigger",
  119. {
  120. Undefined: undefined,
  121. Hover: "hover",
  122. Click: "click",
  123. Focus: "focus",
  124. ContextMenu: "contextMenu"
  125. },
  126. undefined
  127. )
  128. }}
  129. handleConfirm={(value: any) => {
  130. setWanted(value);
  131. }}
  132. >
  133. <Button>HoverIt{wanted}</Button>
  134. </WantedPublishPopover>
  135. </div>
  136. <Divider />
  137. {/* 下面用于分割wanted值的渲染,防止Error */}
  138. {(wanted => (
  139. <div>wanted{wanted}</div>
  140. ))(wanted)}
  141. </div>
  142. );
  143. },
  144. {
  145. info: { inline: true },
  146. notes: "A very simple example of addon notes"
  147. }
  148. );