index.tsx 1.04 KB
Newer Older
陈帅's avatar
陈帅 committed
1 2 3 4
import React from 'react';
import { Tooltip } from 'antd';
import styles from './index.less';

陈帅's avatar
陈帅 committed
5
export interface MiniProgressProps {
陈帅's avatar
陈帅 committed
6 7 8 9 10 11 12 13
  target: number;
  targetLabel?: string;
  color?: string;
  strokeWidth?: number;
  percent?: number;
  style?: React.CSSProperties;
}

陈帅's avatar
陈帅 committed
14
const MiniProgress: React.SFC<MiniProgressProps> = ({
陈帅's avatar
陈帅 committed
15 16 17 18 19
  targetLabel,
  target,
  color = 'rgb(19, 194, 194)',
  strokeWidth,
  percent,
陈帅's avatar
陈帅 committed
20
}) => (
陈帅's avatar
陈帅 committed
21 22 23 24 25
  <div className={styles.miniProgress}>
    <Tooltip title={targetLabel}>
      <div className={styles.target} style={{ left: target ? `${target}%` : undefined }}>
        <span style={{ backgroundColor: color || undefined }} />
        <span style={{ backgroundColor: color || undefined }} />
陈帅's avatar
陈帅 committed
26
      </div>
陈帅's avatar
陈帅 committed
27 28 29 30 31 32 33 34 35 36
    </Tooltip>
    <div className={styles.progressWrap}>
      <div
        className={styles.progress}
        style={{
          backgroundColor: color || undefined,
          width: percent ? `${percent}%` : undefined,
          height: strokeWidth || undefined,
        }}
      />
陈帅's avatar
陈帅 committed
37
    </div>
陈帅's avatar
陈帅 committed
38 39
  </div>
);
陈帅's avatar
陈帅 committed
40 41

export default MiniProgress;