index.js 818 Bytes
Newer Older
1
import React from 'react';
afc163's avatar
afc163 committed
2
import { Icon } from 'antd';
3 4 5

import styles from './index.less';

afc163's avatar
afc163 committed
6
const Item = ({ title, flag, children, ...rest }) => {
niko's avatar
niko committed
7
  return (
afc163's avatar
afc163 committed
8
    <div {...rest} className={styles.trendItem}>
niko's avatar
niko committed
9 10 11
      <div className={styles.content}>
        <span className={styles.title}>{title}</span>
        <span className={styles.value}>{children}</span>
afc163's avatar
afc163 committed
12
        {flag && <span className={styles[flag]}><Icon type={`caret-${flag}`} /></span>}
niko's avatar
niko committed
13 14 15 16 17 18 19
      </div>
    </div>
  );
};

class Trend extends React.Component {
  render() {
afc163's avatar
afc163 committed
20
    const { colorType, children, ...rest } = this.props;
niko's avatar
niko committed
21
    return (
afc163's avatar
afc163 committed
22 23 24 25
      <div
        className={colorType ? (styles[`trend${colorType}`] || styles.trend) : styles.trend}
        {...rest}
      >
niko's avatar
niko committed
26 27 28 29 30 31
        {children}
      </div>
    );
  }
}

32 33 34
Trend.Item = Item;

export default Trend;