import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Icon, Tooltip } from 'antd'; import styles from './index.less'; const Item = ({ title, flag, children, ...rest }, { mini }) => { const map = { xs: 0, sm: 0, md: 0, lg: 0, xlg: 0, xl: 0, xxl: 0, }; if (mini && mini.forEach) { mini.forEach((size) => { map[size] = 1; }); } const clsObj = {}; Object.keys(map).forEach((k) => { clsObj[styles[k]] = map[k]; }); const clsString = classNames(styles.trendItem, { [styles.mini]: (typeof mini === 'boolean' && mini), ...clsObj, }); const miniContent = ( {title} { flag && } ); return (
{title} {children} {flag && }
{miniContent}
); }; Item.contextTypes = { mini: PropTypes.oneOfType([ PropTypes.array, PropTypes.bool, ]), }; class Trend extends React.Component { getChildContext() { return { mini: this.props.mini, }; } render() { const { colorType, children, mini, ...rest } = this.props; return (
{children}
); } } Trend.childContextTypes = { mini: PropTypes.oneOfType([ PropTypes.array, PropTypes.bool, ]), }; Trend.Item = Item; export default Trend;