Skip to content

Commit

Permalink
feat(Table): BS4 beta 3 revert responsive table (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
supergibbs authored and TheSharpieOne committed Jan 2, 2018
1 parent c3a483a commit ee08d21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ const Table = (props) => {
hover,
responsive,
tag: Tag,
responsiveTag: ResponsiveTag,
...attributes
} = props;

let responsiveClassName = false;
if (responsive) {
responsiveClassName = responsive === true ? 'table-responsive' : `table-responsive-${responsive}`;
}

const classes = mapToCssModules(classNames(
className,
'table',
Expand All @@ -50,11 +46,18 @@ const Table = (props) => {
striped ? 'table-striped' : false,
(dark || inverse) ? 'table-dark' : false,
hover ? 'table-hover' : false,
responsiveClassName
), cssModule);

const table = <Tag {...attributes} className={classes} />;

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

return (
<ResponsiveTag className={responsiveClassName}>{table}</ResponsiveTag>
);
}

return table;
};

Expand Down
12 changes: 10 additions & 2 deletions src/__tests__/Table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Table', () => {
});

it('should render modifier classes', () => {
const wrapper = shallow(<Table size="sm" bordered striped dark hover responsive>Yo!</Table>);
const wrapper = shallow(<Table size="sm" bordered striped dark hover>Yo!</Table>);

expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('table')).toBe(true);
Expand All @@ -35,13 +35,21 @@ describe('Table', () => {
expect(wrapper.hasClass('table-striped')).toBe(true);
expect(wrapper.hasClass('table-hover')).toBe(true);
expect(wrapper.hasClass('table-dark')).toBe(true);
});

it('should render responsive wrapper class', () => {
const wrapper = shallow(<Table responsive>Yo!</Table>);

expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('table-responsive')).toBe(true);
expect(wrapper.find('.table').length).toBe(1);
});

it('should render responsive class for md', () => {
it('should render responsive wrapper class for md', () => {
const wrapper = shallow(<Table responsive="md">Yo!</Table>);

expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('table-responsive-md')).toBe(true);
expect(wrapper.find('.table').length).toBe(1);
});
});

0 comments on commit ee08d21

Please sign in to comment.