Sfoglia il codice sorgente

dev: PriceOptions逻辑更新

Roxas 4 anni fa
parent
commit
cf13905ce1

+ 9
- 2
src/components/Payment/PriceOptions/index.tsx Vedi File

@@ -11,7 +11,8 @@ interface Props {
11 11
   size: "small" | "normal" | "large";
12 12
   focusScroll: boolean;
13 13
   withTitle: boolean;
14
-  titleText?: string;
14
+  titleText?: string | JSX.Element[] | JSX.Element;
15
+  inputPlaceholderText?: string;
15 16
   inputRef: React.RefObject<any>;
16 17
 }
17 18
 
@@ -22,6 +23,7 @@ const PriceOptions = ({
22 23
   focusScroll = true,
23 24
   withTitle = true,
24 25
   titleText = "Price",
26
+  inputPlaceholderText = "Others",
25 27
   inputRef
26 28
 }: Props) => {
27 29
   const defaultOptions = [100, 600, 800];
@@ -66,7 +68,7 @@ const PriceOptions = ({
66 68
           suffix="¥"
67 69
           className={styles.priceInput}
68 70
           value={inputStatus ? price / 100 || "" : ""}
69
-          placeholder="Others"
71
+          placeholder={inputPlaceholderText}
70 72
           onChange={e => {
71 73
             const n = +e.target.value;
72 74
             if (Number.isNaN(n)) {
@@ -80,10 +82,15 @@ const PriceOptions = ({
80 82
             setInputStatus(true);
81 83
           }}
82 84
           onFocus={e => {
85
+            e.target.placeholder = '';
86
+            setInputStatus(true);
83 87
             if (focusScroll) {
84 88
               e.target.scrollIntoView();
85 89
             }
86 90
           }}
91
+          onBlur={e => {
92
+            e.target.placeholder = inputPlaceholderText;
93
+          }}
87 94
         />
88 95
       </div>
89 96
     </div>

+ 3
- 2
stories/Payment.stories.tsx Vedi File

@@ -2,7 +2,7 @@ import React, { MouseEvent } from 'react';
2 2
 import { storiesOf } from '@storybook/react';
3 3
 import { action } from '@storybook/addon-actions';
4 4
 import { withInfo } from "@storybook/addon-info";
5
-import { withKnobs, number, boolean, select } from "@storybook/addon-knobs";
5
+import { withKnobs, number, boolean, select, text } from "@storybook/addon-knobs";
6 6
 import { addReadme } from 'storybook-readme';
7 7
 
8 8
 import ConsumeListView from '@/components/Payment/ConsumeListView';
@@ -114,7 +114,8 @@ stories.add(
114 114
         onPriceChange={(v) => setPrice(v)}
115 115
         size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
116 116
         withTitle={boolean("withTitle", false)}
117
-        titleText="Price Title"
117
+        titleText={text("titleText", "")}
118
+        inputPlaceholderText={text("inputPlaceholderText", "")}
118 119
         focusScroll={boolean("focusScroll", false)}
119 120
         inputRef={refInput}
120 121
       />