import React from 'react'; import { Card } from 'antd'; import classNames from 'classnames'; import styles from './index.less'; const renderTotal = total => { let totalDom; switch (typeof total) { case 'undefined': totalDom = null; break; case 'function': totalDom =
{total()}
; break; default: totalDom =
{total}
; } return totalDom; }; class ChartCard extends React.PureComponent { renderConnet = () => { const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props; if (loading) { return false; } return (
{avatar}
{title} {action}
{renderTotal(total)}
{children && (
{children}
)} {footer && (
{footer}
)}
); }; render() { const { loading = false, contentHeight, title, avatar, action, total, footer, children, ...rest } = this.props; return ( {this.renderConnet()} ); } } export default ChartCard;