index.js 741 Bytes
Newer Older
偏右's avatar
偏右 committed
1 2 3 4 5
import React from 'react';
import { Icon } from 'antd';
import classNames from 'classnames';
import styles from './index.less';

6
const Trend = ({ colorful = true, reverseColor = false, flag, children, className, ...rest }) => {
jim's avatar
jim committed
7 8 9 10
  const classString = classNames(
    styles.trendItem,
    {
      [styles.trendItemGrey]: !colorful,
11
      [styles.reverseColor]: reverseColor && colorful,
jim's avatar
jim committed
12 13 14
    },
    className
  );
偏右's avatar
偏右 committed
15
  return (
jim's avatar
jim committed
16
    <div {...rest} className={classString} title={typeof children === 'string' ? children : ''}>
偏右's avatar
偏右 committed
17
      <span className={styles.value}>{children}</span>
jim's avatar
jim committed
18 19 20 21 22
      {flag && (
        <span className={styles[flag]}>
          <Icon type={`caret-${flag}`} />
        </span>
      )}
偏右's avatar
偏右 committed
23 24 25 26 27
    </div>
  );
};

export default Trend;