Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(Table): add CSS Module support for responsive Table (#1429) (#1430)
  • Loading branch information
huan086 authored and TheSharpieOne committed Mar 6, 2019
1 parent fc2ce2e commit 1e2dc5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Table.js
Expand Up @@ -56,7 +56,7 @@ const Table = (props) => {
const table = <Tag {...attributes} ref={innerRef} className={classes} />;

if (responsive) {
const responsiveClassName = responsive === true ? 'table-responsive' : `table-responsive-${responsive}`;
const responsiveClassName = mapToCssModules(responsive === true ? 'table-responsive' : `table-responsive-${responsive}`, cssModule);

return (
<ResponsiveTag className={responsiveClassName}>{table}</ResponsiveTag>
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/Table.spec.js
Expand Up @@ -60,4 +60,16 @@ describe('Table', () => {
expect(wrapper.hasClass('table-responsive-md')).toBe(true);
expect(wrapper.find('.table').length).toBe(1);
});

it('should render responsive wrapper cssModule', () => {
const cssModule = {
table: 'scopedTable',
'table-responsive': 'scopedResponsive',
};
const wrapper = shallow(<Table responsive cssModule={cssModule}>Yo!</Table>);

expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('scopedResponsive')).toBe(true);
expect(wrapper.find('.scopedTable').length).toBe(1);
});
});

0 comments on commit 1e2dc5b

Please sign in to comment.