content: import React from 'react';
  import SortTypes from './sortTypes';
  
  function reverseSortDirection(sortDir) {
    return sortDir === SortTypes.DESC ? SortTypes.ASC : SortTypes.DESC;
  }
  
  export default class SortHeader extends React.Component {
    constructor(props) {
      super(props);
  
      this._onSortChange = this._onSortChange.bind(this);
    }
  
    render() {
      var {onSortChange, sortDir, children, ...props} = this.props;
      return (
        <th>
          <a onClick={this._onSortChange}>
            {children} {sortDir ? (sortDir === SortTypes.DESC ? '↓' : '↑') : ''}
          </a>
          <style jsx>{`
            a { cursor: pointer; }
          `}</style>
        </th>
      );
    }
  
    _onSortChange(e) {
      e.preventDefault();
  
      if (this.props.onSortChange) {
        this.props.onSortChange(
          this.props.columnKey,
          this.props.sortDir ?
            reverseSortDirection(this.props.sortDir) :
            SortTypes.DESC
        );
      }
    }
  }
  