Skip to content

Commit 1cdb999

Browse files
author
Adam Bradley
committed
feat(grid): Added classes, variables and mixins for responsive grid options
1 parent 0d92658 commit 1cdb999

File tree

4 files changed

+97
-22
lines changed

4 files changed

+97
-22
lines changed

scss/_grid.scss

+5-20
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,12 @@
123123
}
124124

125125

126-
/* Responsive Grid Attribute */
127-
/* Adding a class of responsive to a row */
126+
/* Responsive Grid Classes */
127+
/* Adding a class of responsive-X to a row */
128128
/* will trigger the flex-direction to */
129129
/* change to column and add some margin */
130130
/* to any columns in the row for clearity */
131131

132-
/* Adjust the max-width value to fit your own needs */
133-
/* Defaults to 767px (iPad portrait width)*/
134-
135-
@media (max-width: $grid-responsive-break) {
136-
.responsive .col {
137-
width: 100%;
138-
margin-bottom:15px;
139-
}
140-
.responsive {
141-
-webkit-box-direction: normal;
142-
-moz-box-direction: normal;
143-
-webkit-box-orient: vertical;
144-
-moz-box-orient: vertical;
145-
-webkit-flex-direction: column;
146-
-ms-flex-direction: column;
147-
flex-direction: column;
148-
}
149-
}
132+
@include responsive-grid-break('.responsive-sm', $grid-responsive-sm-break);
133+
@include responsive-grid-break('.responsive-md', $grid-responsive-md-break);
134+
@include responsive-grid-break('.responsive-lg', $grid-responsive-lg-break);

scss/_mixins.scss

+19
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,22 @@
589589
-moz-justify-content: $value;
590590
justify-content: $value;
591591
}
592+
593+
@mixin responsive-grid-break($selector, $max-width) {
594+
@media (max-width: $max-width) {
595+
#{$selector} {
596+
-webkit-box-direction: normal;
597+
-moz-box-direction: normal;
598+
-webkit-box-orient: vertical;
599+
-moz-box-orient: vertical;
600+
-webkit-flex-direction: column;
601+
-ms-flex-direction: column;
602+
flex-direction: column;
603+
604+
.col {
605+
width: 100%;
606+
margin-bottom: ($grid-padding-width * 3) / 2;
607+
}
608+
}
609+
}
610+
}

scss/_variables.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ $modal-bg-color: #fff !default;
495495
// -------------------------------
496496

497497
$grid-padding-width: 10px !default;
498-
$grid-responsive-break: 767px !default;
498+
$grid-responsive-sm-break: 567px !default; // smaller than landscape phone
499+
$grid-responsive-md-break: 767px !default; // smaller than portrait tablet
500+
$grid-responsive-lg-break: 1023px !default; // smaller than landscape tablet
499501

500502

501503
// Action Sheets

test/grid.html

+70-1
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,79 @@ <h3>.row</h3>
215215
</div>
216216
</div>
217217

218+
<div class="row responsive-sm">
219+
<div class="col">
220+
<div>
221+
.responsive-sm .col
222+
</div>
223+
</div>
224+
<div class="col">
225+
<div>
226+
.responsive-sm .col
227+
</div>
228+
</div>
229+
<div class="col">
230+
<div>
231+
.responsive-sm .col
232+
</div>
233+
</div>
234+
<div class="col">
235+
<div>
236+
.responsive-sm .col
237+
</div>
238+
</div>
239+
</div>
240+
241+
<div class="row responsive-md">
242+
<div class="col">
243+
<div>
244+
.responsive-md .col
245+
</div>
246+
</div>
247+
<div class="col">
248+
<div>
249+
.responsive-md .col
250+
</div>
251+
</div>
252+
<div class="col">
253+
<div>
254+
.responsive-md .col
255+
</div>
256+
</div>
257+
<div class="col">
258+
<div>
259+
.responsive-md .col
260+
</div>
261+
</div>
262+
</div>
263+
264+
<div class="row responsive-lg">
265+
<div class="col">
266+
<div>
267+
.responsive-lg .col
268+
</div>
269+
</div>
270+
<div class="col">
271+
<div>
272+
.responsive-lg .col
273+
</div>
274+
</div>
275+
<div class="col">
276+
<div>
277+
.responsive-lg .col
278+
</div>
279+
</div>
280+
<div class="col">
281+
<div>
282+
.responsive-lg .col
283+
</div>
284+
</div>
285+
</div>
286+
218287
<hr>
219288

220289
<div class="padding">
221-
<p><a class="button button-secondary" href="index.html">Homepage</a></p>
290+
<p><a class="button button-secondary" href="./">All CSS Tests</a></p>
222291
</div>
223292

224293
</div>

0 commit comments

Comments
 (0)