import cn from 'classnames'; import { Button } from 'UI'; import stl from './table.css'; export default class Table extends React.PureComponent { state = { showAll: false }; onLoadMoreClick = () => { this.setState({ showAll: true }); } render() { const { cols, rows = [], rowProps, rowClass = '', small = false, compare = false } = this.props; const { showAll } = this.state; return (
{ cols.map(({ key, title, width, }) =>
{ title }
) }
{ rows.take(showAll ? 10 : (small ? 3 : 5)).map(row => (
{ cols.map(({ cellClass = '', className = '', Component, key, toText = t => t, width }) => (
{ Component ? :
{ toText(row[ key ]) }
}
)) }
)) } { rows.size > (small ? 3 : 5) && !showAll &&
}
); } }