Skip to content

Commit 0a147e2

Browse files
author
James Kolce
committed
[fix: #214] Add x-*, sm-*, md-*, lg-*, xl-* columns and offsets
1 parent 6a80255 commit 0a147e2

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

_globals.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ $scale-ratio-secondary: $perfect-fourth !default;
9393
// Grid
9494
// ----
9595

96+
// Create x-*, sm-*, md-*, lg-*, xl-* columns and offsets
97+
$full-grid: false;
98+
9699
// Max width for container
97100
$container-width: 1200px !default;
98101

src/_atgrid.scss

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
//
108108
// Column widths
109109
//
110-
111110
@for $i from 1 through $num-columns {
112111
[#{$prefix}column~="#{$i}"] {
113112
flex: 0 1 ($i/$num-columns) * 100%;
@@ -118,10 +117,116 @@
118117
//
119118
// Column offsets
120119
//
121-
122120
@for $i from 1 through $num-columns {
123121
[#{$prefix}column~="+#{$i}"] {
124122
margin-left: ($i/$num-columns) * 100%;
125123
}
126124
}
127125
}
126+
127+
@if ($full-grid) {
128+
@media (--extra-small) {
129+
//
130+
// Column widths
131+
//
132+
@for $i from 1 through $num-columns {
133+
[#{$prefix}column~="xs-#{$i}"] {
134+
flex: 0 1 ($i/$num-columns) * 100%;
135+
max-width: ($i/$num-columns) * 100%;
136+
}
137+
}
138+
139+
//
140+
// Column offsets
141+
//
142+
@for $i from 1 through $num-columns {
143+
[#{$prefix}column~="+xs-#{$i}"] {
144+
margin-left: ($i/$num-columns) * 100%;
145+
}
146+
}
147+
}
148+
149+
@media (--small) {
150+
//
151+
// Column widths
152+
//
153+
@for $i from 1 through $num-columns {
154+
[#{$prefix}column~="sm-#{$i}"] {
155+
flex: 0 1 ($i/$num-columns) * 100%;
156+
max-width: ($i/$num-columns) * 100%;
157+
}
158+
}
159+
160+
//
161+
// Column offsets
162+
//
163+
@for $i from 1 through $num-columns {
164+
[#{$prefix}column~="+sm-#{$i}"] {
165+
margin-left: ($i/$num-columns) * 100%;
166+
}
167+
}
168+
}
169+
170+
@media (--medium) {
171+
//
172+
// Column widths
173+
//
174+
@for $i from 1 through $num-columns {
175+
[#{$prefix}column~="md-#{$i}"] {
176+
flex: 0 1 ($i/$num-columns) * 100%;
177+
max-width: ($i/$num-columns) * 100%;
178+
}
179+
}
180+
181+
//
182+
// Column offsets
183+
//
184+
@for $i from 1 through $num-columns {
185+
[#{$prefix}column~="+md-#{$i}"] {
186+
margin-left: ($i/$num-columns) * 100%;
187+
}
188+
}
189+
}
190+
191+
@media (--large) {
192+
//
193+
// Column widths
194+
//
195+
@for $i from 1 through $num-columns {
196+
[#{$prefix}column~="lg-#{$i}"] {
197+
flex: 0 1 ($i/$num-columns) * 100%;
198+
max-width: ($i/$num-columns) * 100%;
199+
}
200+
}
201+
202+
//
203+
// Column offsets
204+
//
205+
@for $i from 1 through $num-columns {
206+
[#{$prefix}column~="+lg-#{$i}"] {
207+
margin-left: ($i/$num-columns) * 100%;
208+
}
209+
}
210+
}
211+
212+
@media (--extra-large) {
213+
//
214+
// Column widths
215+
//
216+
@for $i from 1 through $num-columns {
217+
[#{$prefix}column~="xl-#{$i}"] {
218+
flex: 0 1 ($i/$num-columns) * 100%;
219+
max-width: ($i/$num-columns) * 100%;
220+
}
221+
}
222+
223+
//
224+
// Column offsets
225+
//
226+
@for $i from 1 through $num-columns {
227+
[#{$prefix}column~="+xl-#{$i}"] {
228+
margin-left: ($i/$num-columns) * 100%;
229+
}
230+
}
231+
}
232+
}

test.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,18 @@ <h6>Heading 6 <small>Helper text</small></h6>
236236
</div>
237237
</div>
238238

239+
<div grid>
240+
<div column="xs-1 sm-2 md-3 lg-4 xl-5">
241+
<span class="grid--example">xs-1 sm-2 md-3 lg-4 xl-5</span>
242+
</div>
243+
</div>
244+
245+
<div grid>
246+
<div column="1 +xs-1 +sm-2 +md-3 +lg-4 +xl-5">
247+
<span class="grid--example">1 +xs-1 +sm-2 +md-3 +lg-4 +xl-5</span>
248+
</div>
249+
</div>
250+
239251
<table>
240252
<thead>
241253
<tr>

0 commit comments

Comments
 (0)