This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
forked from chris-pearce/scally
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_l-grid.scss
231 lines (182 loc) · 5.18 KB
/
_l-grid.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/* ============================================================================
@LAYOUT -> GRID
========================================================================= */
/**
* A powerful fluid and nestable mobile first grid system.
*
* Combine with the viewport specific width classes found in Utilities ->
* Widths which all feed from the width settings set here: Core -> Settings ->
* Widths to apply grid widths at specific viewports, for example:
*
<div class="l-grid__item u-one-half-from-lap u-one-third-from-desk">
*
* This would give you a grid item which is 100% width unless it is on a lap
* device, at which point it becomes 50% wide, or it is on a desktop device,
* at which point it becomes 33.333% width. See breakpoints set here: Core ->
* Settings -> Breakpoints.
*
* N.B. grid systems should be thought of as shelves. They contain content but
* are not content in themselves. You put up your shelves then fill them with
* your stuff. By setting up our grids separately to our components you can
* move components around a lot more easily than if they had dimensions
* applied to them; this makes our front-ends a lot more adaptable and quick
* to work with.
*
* N.B. you should never apply any styles to a grid item, they are for layout
* purposes only. Apply styling to content inside a grid item.
*
* @markup
<div class="l-grid [modifier(s)]">
<div class="l-grid__item u-one-half"> [...] </div>
<div class="l-grid__item u-one-half"> [...] </div>
</div>
<div class="l-grid [modifier(s)]">
<div class="l-grid__item u-one-third"> [...] </div>
<div class="l-grid__item u-one-third"> [...] </div>
<div class="l-grid__item u-one-third"> [...] </div>
</div>
*
* @demo
* http://codepen.io/chris-pearce/full/emQqxo
*
* @credit
* https://github.com/csswizardry/csswizardry-grids/blob/master/csswizardry-grids.scss
*/
/**
* Settings.
*/
/**
* Gutter sizes.
*/
$l-grid-gutter-base: $spacing-base !default;
$l-grid-gutter-tiny: $spacing-third !default;
$l-grid-gutter-small: $spacing-half !default;
$l-grid-gutter-large: $spacing-base-plus-half !default;
$l-grid-gutter-huge: $spacing-double !default;
/**
* Box sizing.
*
* Here we set a variable assuming that `box-sizing: border-box;` is not set
* globally. If it has been previously been defined, the following variable
* will be overridden and will be set to `true`.
*/
$apply-friendly-box-model: false !default;
/**
* Grid container.
*
* 1. Negative `margin-left` to negate the columns gutters.
* 2. So it can work on inline elements e.g. `span`.
* 3. Dirty hack to remove browser generated whitespace between elements that
* render as `display: inline-block`.
*/
.l-grid {
@include to-rem(margin-left, -$l-grid-gutter-base); // [1]
display: block; // [2]
font-size: 0; // [3]
}
/**
* 1. Cause columns to stack side-by-side.
* 2. Space columns apart.
* 3. Full-width unless told to behave otherwise.
* 4. Align columns to the top of each other.
* 5. Reset font size to be the global default.
* 6. Required to combine fluid widths and fixed gutters.
*/
.l-grid__item {
display: inline-block; // [1]
@include to-rem(padding-left, $l-grid-gutter-base); // [2]
width: 100%; // [3]
vertical-align: top; // [4]
@include font-size($font-size); // [5]
@if $apply-friendly-box-model == false {
box-sizing: border-box; // [6]
}
}
/**
* Modifiers: gutters.
*/
// Gutterless
.l-grid--gutterless {
margin-left: 0;
> .l-grid__item {
padding-left: 0;
}
}
// Gutter tiny
.l-grid--gutter-tiny {
@include to-rem(margin-left, -$l-grid-gutter-tiny);
> .l-grid__item {
@include to-rem(padding-left, $l-grid-gutter-tiny);
}
}
// Gutter small
.l-grid--gutter-small {
@include to-rem(margin-left, -$l-grid-gutter-small);
> .l-grid__item {
@include to-rem(padding-left, $l-grid-gutter-small);
}
}
// Gutter large
.l-grid--gutter-large {
@include to-rem(margin-left, -$l-grid-gutter-large);
> .l-grid__item {
@include to-rem(padding-left, $l-grid-gutter-large);
}
}
// Gutter huge
.l-grid--gutter-huge {
@include to-rem(margin-left, -$l-grid-gutter-huge);
> .l-grid__item {
@include to-rem(padding-left, $l-grid-gutter-huge);
}
}
/**
* Modifier: reversed.
*
* Reversed rendered order of layout items, e.g. items 1, 2, 3, 4 in your
* markup will display in order 4, 3, 2, 1 on your page.
*/
.l-grid--reversed {
direction: rtl;
text-align: left;
> .l-grid__item {
direction: ltr;
text-align: left;
}
}
/**
* Modifiers: vertical alignments.
*/
// Middle alignment
.l-grid--align-middle > .l-grid__item {
vertical-align: middle;
}
// Bottom alignment
.l-grid--align-bottom > .l-grid__item {
vertical-align: bottom;
}
/**
* Modifiers: horizontal alignments.
*/
// Right alignment
.l-grid--align-right {
text-align: right;
> .l-grid__item {
text-align: left;
}
}
// Center alignment
.l-grid--align-center {
text-align: center;
> .l-grid__item {
text-align: left;
}
}
/**
* Modifier: shrink wrap.
*
* Make it be the width of it's content.
*/
.l-grid--shrink-wrap > .l-grid__item {
width: auto;
}