index.js 984 Bytes
Newer Older
1
import React from 'react';
niko's avatar
niko committed
2
import { Tooltip } from 'antd';
3
import { formatMessage } from 'umi/locale';
4 5 6

import styles from './index.less';

7 8 9 10 11 12 13
const MiniProgress = ({
  targetLabel,
  target,
  color = 'rgb(19, 194, 194)',
  strokeWidth,
  percent,
}) => (
14
  <div className={styles.miniProgress}>
15 16 17 18
    <Tooltip
      title={`${targetLabel ||
        formatMessage({ id: 'component.miniProgress.tooltipDefault' }).concat(': ')} ${target}%`}
    >
jim's avatar
jim committed
19 20 21
      <div className={styles.target} style={{ left: target ? `${target}%` : null }}>
        <span style={{ backgroundColor: color || null }} />
        <span style={{ backgroundColor: color || null }} />
nikogu's avatar
nikogu committed
22
      </div>
niko's avatar
niko committed
23
    </Tooltip>
24 25 26 27
    <div className={styles.progressWrap}>
      <div
        className={styles.progress}
        style={{
jim's avatar
jim committed
28 29 30
          backgroundColor: color || null,
          width: percent ? `${percent}%` : null,
          height: strokeWidth || null,
31 32 33 34 35 36 37
        }}
      />
    </div>
  </div>
);

export default MiniProgress;