Explorar el Código

feat: Optimize the display of toolTips

chen shuai hace 6 años
padre
commit
81ff030b63

+ 20 - 22
src/components/Charts/MiniProgress/index.js

@@ -1,6 +1,5 @@
 import React from 'react';
 import React from 'react';
 import { Tooltip } from 'antd';
 import { Tooltip } from 'antd';
-import { formatMessage } from 'umi/locale';
 
 
 import styles from './index.less';
 import styles from './index.less';
 
 
@@ -10,28 +9,27 @@ const MiniProgress = ({
   color = 'rgb(19, 194, 194)',
   color = 'rgb(19, 194, 194)',
   strokeWidth,
   strokeWidth,
   percent,
   percent,
-}) => (
-  <div className={styles.miniProgress}>
-    <Tooltip
-      title={`${targetLabel ||
-        formatMessage({ id: 'component.miniProgress.tooltipDefault' }).concat(': ')} ${target}%`}
-    >
-      <div className={styles.target} style={{ left: target ? `${target}%` : null }}>
-        <span style={{ backgroundColor: color || null }} />
-        <span style={{ backgroundColor: color || null }} />
+}) => {
+  return (
+    <div className={styles.miniProgress}>
+      <Tooltip title={targetLabel}>
+        <div className={styles.target} style={{ left: target ? `${target}%` : null }}>
+          <span style={{ backgroundColor: color || null }} />
+          <span style={{ backgroundColor: color || null }} />
+        </div>
+      </Tooltip>
+      <div className={styles.progressWrap}>
+        <div
+          className={styles.progress}
+          style={{
+            backgroundColor: color || null,
+            width: percent ? `${percent}%` : null,
+            height: strokeWidth || null,
+          }}
+        />
       </div>
       </div>
-    </Tooltip>
-    <div className={styles.progressWrap}>
-      <div
-        className={styles.progress}
-        style={{
-          backgroundColor: color || null,
-          width: percent ? `${percent}%` : null,
-          height: strokeWidth || null,
-        }}
-      />
     </div>
     </div>
-  </div>
-);
+  );
+};
 
 
 export default MiniProgress;
 export default MiniProgress;

+ 2 - 0
src/components/Charts/MiniProgress/index.less

@@ -19,6 +19,8 @@
     position: absolute;
     position: absolute;
     top: 0;
     top: 0;
     bottom: 0;
     bottom: 0;
+    z-index: 9;
+    width: 20px;
     span {
     span {
       position: absolute;
       position: absolute;
       top: 0;
       top: 0;

+ 10 - 2
src/pages/Dashboard/IntroduceRow.js

@@ -1,6 +1,6 @@
 import React, { memo } from 'react';
 import React, { memo } from 'react';
 import { Row, Col, Icon, Tooltip } from 'antd';
 import { Row, Col, Icon, Tooltip } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage, formatMessage } from 'umi/locale';
 import styles from './Analysis.less';
 import styles from './Analysis.less';
 import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts';
 import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts';
 import Trend from '@/components/Trend';
 import Trend from '@/components/Trend';
@@ -135,7 +135,15 @@ const IntroduceRow = memo(({ loading, visitData }) => (
         }
         }
         contentHeight={46}
         contentHeight={46}
       >
       >
-        <MiniProgress percent={78} strokeWidth={8} target={80} color="#13C2C2" />
+        <MiniProgress
+          percent={78}
+          strokeWidth={8}
+          target={80}
+          targetLabel={`${formatMessage({ id: 'component.miniProgress.tooltipDefault' }).concat(
+            ': '
+          )}80%`}
+          color="#13C2C2"
+        />
       </ChartCard>
       </ChartCard>
     </Col>
     </Col>
   </Row>
   </Row>