zen-grids 1.2 → 1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. data/README.txt +2 -0
  2. data/stylesheets/zen/_background-grid.scss +7 -0
  3. data/stylesheets/zen/_grids.scss +148 -139
  4. data/templates/project/_init.scss +20 -0
  5. data/templates/project/_layout.scss +102 -0
  6. data/templates/project/_modules.scss +72 -0
  7. data/templates/project/_visually-hidden.scss +51 -0
  8. data/templates/project/example.html +12 -12
  9. data/templates/project/manifest.rb +6 -4
  10. data/templates/project/styles.scss +5 -2
  11. data/templates/unit-tests/sass/function-zen-grid-item-width.scss +8 -2
  12. data/templates/unit-tests/sass/zen-grid-flow-item.scss +22 -1
  13. data/templates/unit-tests/sass/zen-grid-item.scss +16 -0
  14. data/templates/unit-tests/test-results/function-zen-direction-flip.css +0 -1
  15. data/templates/unit-tests/test-results/function-zen-grid-item-width.css +6 -3
  16. data/templates/unit-tests/test-results/function-zen-half-gutter.css +0 -1
  17. data/templates/unit-tests/test-results/function-zen-unit-width.css +0 -1
  18. data/templates/unit-tests/test-results/zen-clear.css +0 -1
  19. data/templates/unit-tests/test-results/zen-float.css +0 -1
  20. data/templates/unit-tests/test-results/zen-grid-container.css +0 -9
  21. data/templates/unit-tests/test-results/zen-grid-flow-item.css +46 -13
  22. data/templates/unit-tests/test-results/zen-grid-item-base.css +2 -2
  23. data/templates/unit-tests/test-results/zen-grid-item.css +2 -2
  24. data/templates/unit-tests/test-results/zen-nested-container.css +0 -3
  25. data/zen-grids.gemspec +6 -4
  26. metadata +8 -6
  27. data/templates/project/common.scss +0 -57
  28. data/templates/project/layout.scss +0 -137
data/README.txt CHANGED
@@ -7,6 +7,8 @@ designs. With an easy-to-use Sass mixin set, the Zen Grids system can be applied
7
7
  to an infinite number of layouts, including responsive, adaptive, fluid and
8
8
  fixed-width layouts.
9
9
 
10
+ More information can be found at http://zengrids.com
11
+
10
12
 
11
13
  USAGE
12
14
  -----
@@ -1,3 +1,8 @@
1
+ //
2
+ // THIS MIXIN IS DEPRECATED. It has been completely re-written (and renamed)
3
+ // in Zen Grids 2.0.
4
+ //
5
+
1
6
  @import "zen/grids";
2
7
 
3
8
  // Specify the column background color.
@@ -19,6 +24,8 @@ $bg-grid-color: #ffdede !default;
19
24
  $flow-direction: $zen-float-direction
20
25
  ) {
21
26
 
27
+ @warn "The -experimental-bg-grid() mixin has been DEPRECATED and will be removed in Zen Grids 2.0.";
28
+
22
29
  // Internal variables.
23
30
  $dir: $flow-direction;
24
31
  @if $zen-reverse-all-floats {
@@ -3,47 +3,41 @@
3
3
  //
4
4
 
5
5
 
6
- // Specify the number of columns in the grid.
7
- $zen-column-count: 1 !default;
6
+ // Specify the number of columns in the grid. @see http://zengrids.com/help/#zen-column-count
7
+ $zen-column-count : 1 !default;
8
8
 
9
- // Specify the width of the gutters; half of the gutter will be placed on each
10
- // side of a grid column.
11
- $zen-gutter-width: 20px !default;
9
+ // Specify the width of the gutters (as padding). @see http://zengrids.com/help/#zen-gutter-width
10
+ $zen-gutter-width : 20px !default;
12
11
 
13
- // You can generate more efficient CSS if you manually apply the
14
- // zen-grid-item-base mixin to all grid items from within a single ruleset.
15
- $zen-auto-include-item-base: true !default;
16
- $zen-auto-include-flow-item-base: true !default;
12
+ // @see http://zengrids.com/help/#zen-auto-include-item-base
13
+ $zen-auto-include-item-base : true !default;
14
+ $zen-auto-include-flow-item-base : true !default;
17
15
 
18
- // Specify the width of the entire grid. Defaults to 100% for a fluid responsive
19
- // design, but you can change this to a pixel value if you need a fixed grid.
20
- $zen-grid-width: 100% !default;
16
+ // Specify the width of the entire grid. @see http://zengrids.com/help/#zen-grid-width
17
+ $zen-grid-width : 100% !default;
21
18
 
22
- // The box-sizing polyfill for IE6/7 requires an absolute path to the
23
- // boxsizing.htc file. See https://github.com/Schepp/box-sizing-polyfill
24
- $box-sizing-polyfill-path: "" !default;
19
+ // The box-sizing polyfill for IE6/7 requires an absolute path. @see http://zengrids.com/help/#box-sizing-polyfill-path
20
+ $box-sizing-polyfill-path : "" !default;
25
21
 
26
- // Specify the CSS3 box-sizing method. The default, "border-box", is compatible
27
- // with all modern browsers, including IE 8 and later. Use "content-box" for
28
- // wider compatibility (Note: you'll also need to set $legacy-support-for-ie7
29
- // and $legacy-support-for-ie6 to true.)
30
- $zen-box-sizing: border-box !default;
22
+ // Specify the CSS3 box-sizing method. @see http://zengrids.com/help/#zen-box-sizing
23
+ $zen-box-sizing : border-box !default;
31
24
 
32
- // Turn off IE6/7 support since we're defaulting to box-sizing: border-box.
33
- $legacy-support-for-ie7: false !default;
34
- $legacy-support-for-ie6: false !default;
25
+ // @see http://zengrids.com/help/#legacy-support-for-ie7
26
+ $legacy-support-for-ie7 : false !default;
27
+ $legacy-support-for-ie6 : false !default;
35
28
 
36
- // Specify the default floating direction for zen's mixins.
37
- $zen-float-direction: left !default;
29
+ // Specify the default floating direction for zen's mixins. @see http://zengrids.com/help/#zen-float-direction
30
+ $zen-float-direction : left !default;
38
31
 
39
- // This is a helper variable for RTL layouts.
40
- $zen-reverse-all-floats: false !default;
32
+ // Reverse the floating direction in all zen's mixins. @see http://zengrids.com/help/#zen-reverse-all-floats
33
+ $zen-reverse-all-floats : false !default;
41
34
 
42
35
 
43
36
  //
44
37
  // Apply this to the grid container element.
38
+ // @see http://zengrids.com/help/#zen-grid-container
45
39
  //
46
- @mixin zen-grid-container () {
40
+ @mixin zen-grid-container {
47
41
  @if ($legacy-support-for-ie6 or $legacy-support-for-ie7) {
48
42
  *position: relative; // @TODO: This is a pre-IE8 line of code; don't remember why its needed.
49
43
  }
@@ -63,9 +57,9 @@ $zen-reverse-all-floats: false !default;
63
57
 
64
58
  //
65
59
  // Apply this to any grid item that is also a grid container element for a
66
- // nested grid. It must be applied after the zen-grid-item() mixin.
60
+ // nested grid. @see http://zengrids.com/help/#zen-nested-container
67
61
  //
68
- @mixin zen-nested-container () {
62
+ @mixin zen-nested-container {
69
63
  padding: {
70
64
  left: 0;
71
65
  right: 0;
@@ -73,28 +67,26 @@ $zen-reverse-all-floats: false !default;
73
67
  }
74
68
 
75
69
  //
76
- // Apply this to each grid item. Set the $column-span to the number of columns
77
- // that the grid item spans. And set the $column-position to the column number
78
- // the grid item starts on.
70
+ // Apply this to each grid item. @see http://zengrids.com/help/#zen-grid-item
79
71
  //
80
- // For grid items that are floated right, the $column-position is counted
81
- // from the right instead of from the left.
82
- //
83
- @mixin zen-grid-item (
72
+ @mixin zen-grid-item(
84
73
  $column-span,
85
74
  $column-position,
86
- $float-direction: $zen-float-direction,
87
- $column-count: $zen-column-count,
88
- $gutter-width: $zen-gutter-width,
89
- $grid-width: $zen-grid-width,
90
- $box-sizing: $zen-box-sizing,
91
- $reverse-all-floats: $zen-reverse-all-floats,
92
- $auto-include-item-base: $zen-auto-include-item-base
75
+ $float-direction : $zen-float-direction,
76
+ $column-count : $zen-column-count,
77
+ $gutter-width : $zen-gutter-width,
78
+ $grid-width : $zen-grid-width,
79
+ $box-sizing : $zen-box-sizing,
80
+ $reverse-all-floats : $zen-reverse-all-floats,
81
+ $auto-include-item-base : $zen-auto-include-item-base
93
82
  ) {
94
83
 
95
84
  // Calculate the unit width.
96
85
  $unit-width: zen-unit-width($column-count, $grid-width);
97
86
 
87
+ // Calculate the item's width.
88
+ $width: zen-grid-item-width($column-span, $column-count, $gutter-width, $grid-width, $box-sizing);
89
+
98
90
  // Determine the float direction and its reverse.
99
91
  $dir: $float-direction;
100
92
  @if $reverse-all-floats {
@@ -103,15 +95,6 @@ $zen-reverse-all-floats: false !default;
103
95
  $rev: zen-direction-flip($dir);
104
96
 
105
97
  float: $dir;
106
- $width: $column-span * $unit-width;
107
- @if $box-sizing == content-box {
108
- @if not comparable($width, $gutter-width) {
109
- $units-gutter: unit($gutter-width);
110
- $units-grid: unit($grid-width);
111
- @warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
112
- }
113
- $width: $width - $gutter-width;
114
- }
115
98
  width: $width;
116
99
  margin: {
117
100
  #{$dir}: ($column-position - 1) * $unit-width;
@@ -126,22 +109,13 @@ $zen-reverse-all-floats: false !default;
126
109
 
127
110
  //
128
111
  // Applies a standard set of properites to all grid items in the layout.
112
+ // @see http://zengrids.com/help/#zen-grid-item-base
129
113
  //
130
- // See the note about the $zen-auto-include-item-base and
131
- // $zen-auto-include-flow-item-base variables for when to use this mixin.
132
- //
133
- // The mixin has the following optional parameters, but its better to use the
134
- // $zen-gutter-width and $zen-box-sizing variables instead:
135
- // - $gutter-width: Half of this value is applied as padding to the left and
136
- // right sides of the item.
137
- // - $box-sizing: The type of CSS3 box model each box should use. Can be set to
138
- // content-box or border-box. Defaults to content-box, but border-box is way
139
- // cooler. IE 6 and 7 don't support border-box.
140
- @mixin zen-grid-item-base (
141
- $gutter-width: $zen-gutter-width,
142
- $box-sizing: $zen-box-sizing,
143
- $flow-direction: $zen-float-direction,
144
- $reverse-all-flows: $zen-reverse-all-floats
114
+ @mixin zen-grid-item-base(
115
+ $gutter-width : $zen-gutter-width,
116
+ $box-sizing : $zen-box-sizing,
117
+ $flow-direction : $zen-float-direction,
118
+ $reverse-all-flows : $zen-reverse-all-floats
145
119
  ) {
146
120
 
147
121
  $dir: $flow-direction;
@@ -160,9 +134,12 @@ $zen-reverse-all-floats: false !default;
160
134
  -ms-box-sizing: border-box;
161
135
  box-sizing: border-box;
162
136
  }
163
- // Prevent borders since they'll break the layout with content-box.
137
+ // Prevent left/right borders since they'll break the layout with content-box.
164
138
  @if $box-sizing == content-box {
165
- border: 0 !important;
139
+ border: {
140
+ left: 0 !important;
141
+ right: 0 !important;
142
+ }
166
143
  }
167
144
  // Prevent overflowing content from being hidden beneath other grid items.
168
145
  word-wrap: break-word; // A very nice CSS3 property.
@@ -185,11 +162,12 @@ $zen-reverse-all-floats: false !default;
185
162
  }
186
163
 
187
164
  //
188
- // Apply this to content boxes that need to be cleared below other content boxes.
165
+ // Apply this to grid items that need to be cleared below other grid items.
166
+ // @see http://zengrids.com/help/#zen-clear
189
167
  //
190
- @mixin zen-clear (
191
- $float-direction: $zen-float-direction,
192
- $reverse-all-floats: $zen-reverse-all-floats
168
+ @mixin zen-clear(
169
+ $float-direction : $zen-float-direction,
170
+ $reverse-all-floats : $zen-reverse-all-floats
193
171
  ) {
194
172
  // Determine the float direction.
195
173
  $dir: $float-direction;
@@ -201,10 +179,11 @@ $zen-reverse-all-floats: false !default;
201
179
 
202
180
  //
203
181
  // Apply this to flow items that need to be floated.
182
+ // @see http://zengrids.com/help/#zen-float
204
183
  //
205
- @mixin zen-float (
206
- $float-direction: $zen-float-direction,
207
- $reverse-all-floats: $zen-reverse-all-floats
184
+ @mixin zen-float(
185
+ $float-direction : $zen-float-direction,
186
+ $reverse-all-floats : $zen-reverse-all-floats
208
187
  ) {
209
188
  // Determine the float direction.
210
189
  $dir: $float-direction;
@@ -216,40 +195,26 @@ $zen-reverse-all-floats: false !default;
216
195
 
217
196
  //
218
197
  // Apply this to an HTML item that is in the normal flow of a document to help
219
- // align it to the grid. Set the $column-span to the number of columns that the
220
- // HTML element should span. For responsive layouts with a percentage-based grid
221
- // width, set the $parent-column-count to the number of columns that the parent
222
- // element spans; fixed-unit layouts using px, em, etc. do not need to specify
223
- // this.
198
+ // align it to the grid. @see http://zengrids.com/help/#zen-float
224
199
  //
225
- // Unlike the zen-grid-item() mixin, this mixin does not float the HTML item; it
226
- // also does not have a half-gutter on each side. By default, it has no gutter
227
- // in the "alpha position" (the left side) and a full gutter in the "omega
228
- // position" (the right side.) You can turn on or off the alpha and omega
229
- // gutters by setting the $alpha-gutter and $omega-gutter parameters to true or
230
- // false.
231
- //
232
- // Note: when the $flow-direction is set to right (for RTL languages), the alpha
233
- // position is on the right and the omega position is on the left.
234
- //
235
- @mixin zen-grid-flow-item (
200
+ @mixin zen-grid-flow-item(
236
201
  $column-span,
237
- $parent-column-count: false,
238
- $alpha-gutter: false,
239
- $omega-gutter: true,
240
- $flow-direction: $zen-float-direction,
241
- $column-count: $zen-column-count,
242
- $gutter-width: $zen-gutter-width,
243
- $grid-width: $zen-grid-width,
244
- $box-sizing: $zen-box-sizing,
245
- $reverse-all-flows: $zen-reverse-all-floats,
246
- $auto-include-flow-item-base: $zen-auto-include-flow-item-base
202
+ $parent-column-count : false,
203
+ $alpha-gutter : false,
204
+ $omega-gutter : true,
205
+ $flow-direction : $zen-float-direction,
206
+ $column-count : $zen-column-count,
207
+ $gutter-width : $zen-gutter-width,
208
+ $grid-width : $zen-grid-width,
209
+ $box-sizing : $zen-box-sizing,
210
+ $reverse-all-flows : $zen-reverse-all-floats,
211
+ $auto-include-flow-item-base : $zen-auto-include-flow-item-base
247
212
  ) {
248
213
 
249
214
  $columns: $column-count;
250
215
  @if unit($grid-width) == "%" {
251
216
  @if $parent-column-count == false {
252
- @warn "For responsive layouts with a percentage-based grid width, you must set the $column-count to the number of columns that the parent element spans.";
217
+ @warn "For responsive layouts with a percentage-based grid width, you must set the $parent-column-count to the number of columns that the parent element spans.";
253
218
  }
254
219
  @else {
255
220
  $columns: $parent-column-count;
@@ -262,35 +227,64 @@ $zen-reverse-all-floats: false !default;
262
227
  }
263
228
  $rev: zen-direction-flip($dir);
264
229
 
265
- // Calculate the item's width.
266
- $width: zen-grid-item-width($column-span, $columns, $grid-width);
267
- @if $box-sizing == content-box {
268
- @if not comparable($width, $gutter-width) {
269
- $units-gutter: unit($gutter-width);
270
- $units-grid: unit($grid-width);
271
- @warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
272
- }
273
- $width: $width - $gutter-width;
274
- }
275
- width: $width;
276
-
277
230
  // Auto-apply the unit base mixin.
278
231
  @if $auto-include-flow-item-base {
279
232
  @include zen-grid-item-base($gutter-width, $box-sizing);
280
233
  }
281
234
 
282
- // Ensure the HTML item either has a full gutter or no gutter on each side.
283
- padding-#{$dir}: 0;
284
- @if $alpha-gutter {
285
- margin-#{$dir}: $gutter-width;
286
- }
287
- $offset: ($columns - $column-span) * $gutter-width / $columns;
288
- padding-#{$rev}: $offset;
289
- @if $omega-gutter {
290
- margin-#{$rev}: $gutter-width - $offset;
235
+ // Calculate the item's width.
236
+ $width: zen-grid-item-width($column-span, $columns, $gutter-width, $grid-width, $box-sizing);
237
+
238
+ @if unit($grid-width) == "%" {
239
+ // Our percentage $width is off if the parent has $gutter-width padding.
240
+ // Calculate an adjusted gutter to fix the width.
241
+ $adjusted-gutter: ($columns - $column-span) * $gutter-width / $columns;
242
+
243
+ width: $width;
244
+
245
+ // Ensure the HTML item either has a full gutter or no gutter on each side.
246
+ padding-#{$dir}: 0;
247
+ @if $alpha-gutter {
248
+ margin-#{$dir}: $gutter-width;
249
+ }
250
+ padding-#{$rev}: $adjusted-gutter;
251
+ @if $omega-gutter {
252
+ margin-#{$rev}: $gutter-width - $adjusted-gutter;
253
+ }
254
+ @else {
255
+ margin-#{$rev}: -($adjusted-gutter);
256
+ }
291
257
  }
292
258
  @else {
293
- margin-#{$rev}: -($offset);
259
+ @if $alpha-gutter and $omega-gutter {
260
+ width: $width;
261
+ @if $gutter-width != 0 {
262
+ margin: {
263
+ #{$dir}: zen-half-gutter($gutter-width, left, $dir);
264
+ #{$rev}: zen-half-gutter($gutter-width, right, $dir);
265
+ }
266
+ }
267
+ }
268
+ @else if not $alpha-gutter and not $omega-gutter {
269
+ width: if($box-sizing == border-box, ($width - $gutter-width), $width);
270
+ @if $gutter-width != 0 {
271
+ padding: {
272
+ left: 0;
273
+ right: 0;
274
+ }
275
+ }
276
+ }
277
+ @else {
278
+ width: $width;
279
+ @if $omega-gutter {
280
+ padding-#{$dir}: 0;
281
+ padding-#{$rev}: $gutter-width;
282
+ }
283
+ @else {
284
+ padding-#{$dir}: $gutter-width;
285
+ padding-#{$rev}: 0;
286
+ }
287
+ }
294
288
  }
295
289
  }
296
290
 
@@ -299,11 +293,11 @@ $zen-reverse-all-floats: false !default;
299
293
  // Helper functions for the Zen mixins.
300
294
  //
301
295
 
302
- // Returns a half gutter width.
296
+ // Returns a half gutter width. @see http://zengrids.com/help/#zen-half-gutter
303
297
  @function zen-half-gutter(
304
- $gutter-width: $zen-gutter-width,
305
- $gutter-side: $zen-float-direction,
306
- $flow-direction: $zen-float-direction
298
+ $gutter-width : $zen-gutter-width,
299
+ $gutter-side : $zen-float-direction,
300
+ $flow-direction : $zen-float-direction
307
301
  ) {
308
302
  $half-gutter: $gutter-width / 2;
309
303
  // Special handling in case gutter has an odd number of pixels.
@@ -318,10 +312,10 @@ $zen-reverse-all-floats: false !default;
318
312
  @return $half-gutter;
319
313
  }
320
314
 
321
- // Calculates the unit width of a column.
322
- @function zen-unit-width (
323
- $column-count: $zen-column-count,
324
- $grid-width: $zen-grid-width
315
+ // Calculates the unit width of a column. @see http://zengrids.com/help/#zen-unit-width
316
+ @function zen-unit-width(
317
+ $column-count : $zen-column-count,
318
+ $grid-width : $zen-grid-width
325
319
  ) {
326
320
  $unit-width: $grid-width / $column-count;
327
321
  @if unit($unit-width) == "px" and floor($unit-width) != ceil($unit-width) {
@@ -331,16 +325,31 @@ $zen-reverse-all-floats: false !default;
331
325
  }
332
326
 
333
327
  // Calculates the width of a grid item that spans the specified number of columns.
334
- @function zen-grid-item-width (
328
+ // @see http://zengrids.com/help/#zen-grid-item-width
329
+ @function zen-grid-item-width(
335
330
  $column-span,
336
- $column-count: $zen-column-count,
337
- $grid-width: $zen-grid-width
331
+ $column-count : $zen-column-count,
332
+ $gutter-width : $zen-gutter-width,
333
+ $grid-width : $zen-grid-width,
334
+ $box-sizing : $zen-box-sizing
338
335
  ) {
339
- @return $column-span * zen-unit-width($column-count, $grid-width);
336
+ $width: $column-span * zen-unit-width($column-count, $grid-width);
337
+ @if $box-sizing == content-box {
338
+ @if not comparable($width, $gutter-width) {
339
+ $units-gutter: unit($gutter-width);
340
+ $units-grid: unit($grid-width);
341
+ @warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
342
+ }
343
+ $width: $width - $gutter-width;
344
+ }
345
+ @return $width;
340
346
  }
341
347
 
342
348
  // Returns the opposite direction, given "left" or "right".
343
- @function zen-direction-flip($dir) {
349
+ // @see http://zengrids.com/help/#zen-direction-flip
350
+ @function zen-direction-flip(
351
+ $dir
352
+ ) {
344
353
  @if $dir == left {
345
354
  @return right;
346
355
  }
@@ -0,0 +1,20 @@
1
+ //
2
+ // @file
3
+ // This file sets up all our variables and load all the modules we need for all
4
+ // generated CSS in this project. To use it, simply: @import "init";
5
+ //
6
+
7
+ // Legacy browser variables for Compass.
8
+ $legacy-support-for-ie6 : false;
9
+ $legacy-support-for-ie7 : false;
10
+
11
+ // Set up Zen Grids.
12
+ $zen-column-count : 1;
13
+ $zen-gutter-width : 20px;
14
+ $zen-auto-include-item-base : false;
15
+
16
+ //
17
+ // Import our modules.
18
+ //
19
+ @import "zen";
20
+ @import "visually-hidden";