import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Icon from 'Components/Icon';
import Link from 'Components/Link/Link';
import { icons, sortDirections } from 'Helpers/Props';
import styles from './TableHeaderCell.css';
class TableHeaderCell extends Component {
//
// Listeners
onPress = () => {
const {
name,
fixedSortDirection
} = this.props;
if (fixedSortDirection) {
this.props.onSortPress(name, fixedSortDirection);
} else {
this.props.onSortPress(name);
}
};
//
// Render
render() {
const {
className,
name,
label,
columnLabel,
isSortable,
isVisible,
isModifiable,
sortKey,
sortDirection,
fixedSortDirection,
children,
onSortPress,
...otherProps
} = this.props;
const isSorting = isSortable && sortKey === name;
const sortIcon = sortDirection === sortDirections.ASCENDING ?
icons.SORT_ASCENDING :
icons.SORT_DESCENDING;
return (
isSortable ?
{children}
{
isSorting &&