Skip to content

Commit 1bee8a2

Browse files
committed
[added] responsively hiding columns
Signed-off-by: Csaba Palfi <[email protected]>
1 parent 9babe73 commit 1bee8a2

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

docs/examples/GridBasic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const gridInstance = (
88
<Row className="show-grid">
99
<Col xs={6} md={4}><code>&lt;{'Col xs={6} md={4}'} /&gt;</code></Col>
1010
<Col xs={6} md={4}><code>&lt;{'Col xs={6} md={4}'} /&gt;</code></Col>
11-
<Col xs={6} md={4}><code>&lt;{'Col xs={6} md={4}'} /&gt;</code></Col>
11+
<Col xsHidden md={4}><code>&lt;{'Col xsHidden md={4}'} /&gt;</code></Col>
1212
</Row>
1313

1414
<Row className="show-grid">

src/Col.js

+34
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ const Col = React.createClass({
3737
* class-prefix `col-lg-`
3838
*/
3939
lg: React.PropTypes.number,
40+
/**
41+
* Hide column
42+
*
43+
* on Extra small devices Phones
44+
*
45+
* adds class `hidden-xs`
46+
*/
47+
xsHidden: React.PropTypes.bool,
48+
/**
49+
* Hide column
50+
*
51+
* on Small devices Tablets
52+
*
53+
* adds class `hidden-sm`
54+
*/
55+
smHidden: React.PropTypes.bool,
56+
/**
57+
* Hide column
58+
*
59+
* on Medium devices Desktops
60+
*
61+
* adds class `hidden-md`
62+
*/
63+
mdHidden: React.PropTypes.bool,
64+
/**
65+
* Hide column
66+
*
67+
* on Large devices Desktops
68+
*
69+
* adds class `hidden-lg`
70+
*/
71+
lgHidden: React.PropTypes.bool,
4072
/**
4173
* Move columns to the right
4274
*
@@ -158,6 +190,8 @@ const Col = React.createClass({
158190
classes['col-' + classPart + this.props[prop]] = true;
159191
}
160192

193+
classes['hidden-' + size] = this.props[size + 'Hidden'];
194+
161195
prop = size + 'Offset';
162196
classPart = size + '-offset-';
163197
if (this.props[prop] >= 0) {

test/ColSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ describe('Col', () => {
4040
assert.ok(instanceClassName.match(/\bcol-md-push-0\b/));
4141
assert.ok(instanceClassName.match(/\bcol-lg-push-0\b/));
4242
});
43+
44+
it('Should set Hidden to true', () => {
45+
let instance = ReactTestUtils.renderIntoDocument(
46+
<Col xsHidden smHidden mdHidden lgHidden />
47+
);
48+
49+
let instanceClassName = ReactDOM.findDOMNode(instance).className;
50+
assert.ok(instanceClassName.match(/\bhidden-xs\b/));
51+
assert.ok(instanceClassName.match(/\bhidden-sm\b/));
52+
assert.ok(instanceClassName.match(/\bhidden-md\b/));
53+
assert.ok(instanceClassName.match(/\bhidden-lg\b/));
54+
});
4355
});

0 commit comments

Comments
 (0)