Skip to content

Commit

Permalink
feat: add className to DataTable td element
Browse files Browse the repository at this point in the history
  • Loading branch information
Carla Duarte committed Sep 7, 2021
1 parent 7c13754 commit e8b5bf5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/DataTable/TableCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';

const TableCell = ({ getCellProps, render, column }) => (
<td {...getCellProps()}>
<span className={classNames('pgn__data-table-cell-wrap', column.cellClassName)}>
<td {...getCellProps([
{
className: column.tdClassName,
},
])}
>
<span className={classNames('pgn__data-table-cell-wrap', column.cellWrapperClassName)}>
{render('Cell')}
</span>
</td>
Expand All @@ -17,7 +22,10 @@ TableCell.propTypes = {
render: PropTypes.func.isRequired,
/** Table column */
column: PropTypes.shape({
cellClassName: PropTypes.string,
/** Class names for the cell wrapper */
cellWrapperClassName: PropTypes.string,
/** Class names for the td element */
tdClassName: PropTypes.string,
}).isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/tests/TableCell.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('<TableCell />', () => {
<table>
<tbody>
<tr>
<TableCell {...{ ...props, column: { cellClassName: addedClass } }} />
<TableCell {...{ ...props, column: { cellWrapperClassName: addedClass } }} />
</tr>
</tbody>
</table>,
Expand Down

0 comments on commit e8b5bf5

Please sign in to comment.