diff --git a/src/components/Table/TableHead.jsx b/src/components/Table/TableHead.jsx new file mode 100644 index 00000000..cd02a4a9 --- /dev/null +++ b/src/components/Table/TableHead.jsx @@ -0,0 +1,65 @@ +// @flow +import * as React from 'react' +import { List } from 'immutable' +import TableCell from '@material-ui/core/TableCell' +import TableHead from '@material-ui/core/TableHead' +import TableRow from '@material-ui/core/TableRow' +import TableSortLabel from '@material-ui/core/TableSortLabel' +import Tooltip from '@material-ui/core/Tooltip' +import { type Order } from '~/components/Table/sorting' + +export type Column = { + id: string, + numeric: boolean, + disablePadding: boolean, + label: string, + tooltip?: string, +} + +type Props = { + columns: List, + orderBy: string, // id of one of the described columns + order: Order, + onSort: (property: string) => void, +} + +class GnoTableHead extends React.PureComponent { + changeSort = (property: string) => () => { + this.props.onSort(property) + } + + render() { + const { columns, order, orderBy } = this.props + + return ( + + + {columns.map((column: Column) => ( + + + + {column.label} + + + + ))} + + + ) + } +} + +export default GnoTableHead