UNPKG

zarm-web

Version:
33 lines (30 loc) 854 B
import React, { Component } from 'react'; import classnames from 'classnames'; class Sorter extends Component { render() { const { prefixCls, column, sort, onSort } = this.props; const sorted = sort[column.dataIndex]; const sortUpCls = classnames({ [`${prefixCls}-sorter-up`]: true, [`${prefixCls}-sorter-active`]: !!sorted }); const sortDownCls = classnames({ [`${prefixCls}-sorter-down`]: true, [`${prefixCls}-sorter-active`]: sorted !== undefined && !sorted }); return column.sorter ? React.createElement("span", { className: `${prefixCls}-sorter`, onClick: () => onSort(column) }, React.createElement("span", { className: sortUpCls }), React.createElement("span", { className: sortDownCls })) : null; } } export default Sorter;