index.js 1.08 KB
Newer Older
1 2 3 4 5
import React from 'react';
import { Icon } from 'antd';
import classNames from 'classnames';
import styles from './index.less';

ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
6
const NumberInfo = ({ theme, title, subTitle, total, subTotal, status, suffix, gap, ...rest }) => (
7
  <div
jim's avatar
jim committed
8 9 10
    className={classNames(styles.numberInfo, {
      [styles[`numberInfo${theme}`]]: theme,
    })}
11 12
    {...rest}
  >
afc163's avatar
afc163 committed
13 14 15 16 17 18 19 20 21 22 23 24 25
    {title && (
      <div className={styles.numberInfoTitle} title={typeof title === 'string' ? title : ''}>
        {title}
      </div>
    )}
    {subTitle && (
      <div
        className={styles.numberInfoSubTitle}
        title={typeof subTitle === 'string' ? subTitle : ''}
      >
        {subTitle}
      </div>
    )}
偏右's avatar
偏右 committed
26
    <div className={styles.numberInfoValue} style={gap ? { marginTop: gap } : null}>
afc163's avatar
afc163 committed
27 28 29 30
      <span>
        {total}
        {suffix && <em className={styles.suffix}>{suffix}</em>}
      </span>
jim's avatar
jim committed
31 32 33 34 35 36
      {(status || subTotal) && (
        <span className={styles.subTotal}>
          {subTotal}
          {status && <Icon type={`caret-${status}`} />}
        </span>
      )}
37 38 39
    </div>
  </div>
);
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
40 41

export default NumberInfo;