Skip to content

Commit

Permalink
fix(Col): account for 0 col properties (#378)
Browse files Browse the repository at this point in the history
fixes: #374
  • Loading branch information
TheSharpieOne authored and eddywashere committed Mar 31, 2017
1 parent be34d19 commit fe48e9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Col.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ const Col = (props) => {

colClasses.push(mapToCssModules(classNames({
[colClass]: columnProp.size || columnProp.size === '',
[`push${colSizeInterfix}${columnProp.push}`]: columnProp.push,
[`pull${colSizeInterfix}${columnProp.pull}`]: columnProp.pull,
[`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset
[`push${colSizeInterfix}${columnProp.push}`]: columnProp.push || columnProp.push === 0,
[`pull${colSizeInterfix}${columnProp.pull}`]: columnProp.pull || columnProp.pull === 0,
[`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset || columnProp.offset === 0
})), cssModule);
} else {
colClass = getColumnSizeClass(isXs, colWidth, columnProp);
Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/Col.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ describe('Col', () => {
expect(wrapper.hasClass('offset-sm-2')).toBe(true);
});

it('should pass col size specific classes via Objects including 0', () => {
const wrapper = shallow(<Col sm={{ size: 6, push: 0, pull: 0, offset: 0 }} />);

expect(wrapper.hasClass('col-sm-6')).toBe(true);
expect(wrapper.hasClass('col')).toBe(true);
expect(wrapper.hasClass('push-sm-0')).toBe(true);
expect(wrapper.hasClass('pull-sm-0')).toBe(true);
expect(wrapper.hasClass('offset-sm-0')).toBe(true);
});

it('should pass col size when passing via object with size "auto"', () => {
const wrapper = shallow(<Col
sm={{ size: 'auto', push: 2, pull: 2, offset: 2 }}
Expand Down

0 comments on commit fe48e9e

Please sign in to comment.