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

Commit

Permalink
fix: make caption visible if wanted (#488)
Browse files Browse the repository at this point in the history
* fix: make caption visible if wanted

* fix: remove caption classes when not visible
  • Loading branch information
mjmonline authored Dec 20, 2018
1 parent 81eafb4 commit 9416c05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/components/table-content-wrapper/table-content-wrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import injectSheet from 'react-jss';
import cn from 'classnames';
import { Table, Pagination, Button } from '../../';
import TableHead from './table-head/table-head';
import TableBody from './table-body/table-body';
Expand All @@ -20,6 +21,7 @@ class TableContentWrapper extends Component {
render() {
const {
classes,
captionHidden,
pageSize,
page,
sortField,
Expand Down Expand Up @@ -47,7 +49,15 @@ class TableContentWrapper extends Component {
return (
<div className={classes.root}>
<Table tableLayoutFixed>
<caption className={classes.screenReadersOnly}>{localization.caption}</caption>
<caption
className={cn({
[classes.screenReadersOnly]: captionHidden,
[classes.caption]: !captionHidden,
'smart-table__caption': !captionHidden,
})}
>
{localization.caption}
</caption>
<TableHead
columns={columns}
sortField={sortField}
Expand Down Expand Up @@ -89,6 +99,7 @@ class TableContentWrapper extends Component {

TableContentWrapper.propTypes = {
classes: PropTypes.shape().isRequired,
captionHidden: PropTypes.bool,
columns: PropTypes.arrayOf(colShape),
pageSize: PropTypes.number,
nrResults: PropTypes.number,
Expand Down Expand Up @@ -118,6 +129,7 @@ TableContentWrapper.propTypes = {

TableContentWrapper.defaultProps = {
columns: [],
captionHidden: true,
rowData: [],
borderlessRows: [],
pageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export default ({ mixins, palette }) => ({
export default ({ mixins, palette, typography }) => ({
caption: {
fontSize: 12,
fontWeight: typography.fontWeightSemiBold,
textAlign: 'left',
padding: [10, 4],
borderBottom: [2, 'solid', palette.color.grayDarker],
},
screenReadersOnly: mixins.screenReadersOnly,
feedback: {
fontStyle: 'italic',
Expand Down

0 comments on commit 9416c05

Please sign in to comment.