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

fix(TableContentWrapper): add ability to set thProps on cols #485

Merged
merged 2 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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