Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
fix(TableContentWrapper): add ability to set thProps on cols (#485)
Browse files Browse the repository at this point in the history
* fix(TableContentWrapper): add ability to set thProps on cols

* fix(TableContentWrapper): use css vertical-align instead of valign
  • Loading branch information
Unic0arn authored Dec 19, 2018
1 parent d1aeb25 commit 1de324b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/table-content-wrapper/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const colShape = PropTypes.shape({
type: PropTypes.string,
padding: PropTypes.bool,
tdProps: PropTypes.shape({}),
thProps: PropTypes.shape({}),
responsiveProps: PropTypes.shape({
flexOrder: PropTypes.number,
flexBasisMobile: PropTypes.number,
Expand Down
13 changes: 11 additions & 2 deletions src/components/table-content-wrapper/table-head/table-head.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ TableHeadIcon.propTypes = {
isSortedOn: PropTypes.bool.isRequired,
};

const TableHeadContent = ({ colSpec: { headerLabel, align, sortable }, classes, sortHandler, sortField, sortOrder, isSortedOn }) => {
const TableHeadContent = ({
colSpec: { headerLabel, align = 'left', sortable },
classes,
sortHandler,
sortField,
sortOrder,
isSortedOn,
}) => {
const iconBefore = sortable && align === 'right';
const iconAfter = sortable && align === 'left';

Expand All @@ -50,7 +57,7 @@ const TableHeadContent = ({ colSpec: { headerLabel, align, sortable }, classes,
>
{iconBefore && <TableHeadIcon classes={classes} sortOrder={sortOrder} isSortedOn={isSortedOn} />}
{headerLabel}
{(!align || iconAfter) && <TableHeadIcon classes={classes} sortOrder={sortOrder} isSortedOn={isSortedOn} />}
{iconAfter && <TableHeadIcon classes={classes} sortOrder={sortOrder} isSortedOn={isSortedOn} />}
</span>
);
};
Expand Down Expand Up @@ -113,6 +120,8 @@ class TableHead extends Component {
scope="col"
role="columnheader"
unstyledChild
className={classes.th}
{...col.thProps}
>
<span className={cn({ [classes.screenReadersOnly]: col.hideHeaderLabel })}>
{!col.sortable ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default ({ typography, palette, mixins }) => ({
display: 'none',
},
},
th: {
verticalAlign: 'bottom',
},
button: {
position: 'relative',
fontFamily: typography.primary.fontFamily,
Expand Down

0 comments on commit 1de324b

Please sign in to comment.