summaryrefslogtreecommitdiff
path: root/sites/brdo.brontosaurus.cz.mrp/themes/mrp/sass-extensions/zen-grids/stylesheets/zen/_grids.scss
blob: 49d5ea2a64060022e6b9e1031197ef71ec03550e (plain)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
//
// Mixins for the Zen Grids system.
//


// Specify the number of columns in the grid. @see http://zengrids.com/help/#zen-column-count
$zen-column-count                 : 1           !default;

// Specify the width of the gutters (as padding). @see http://zengrids.com/help/#zen-gutter-width
$zen-gutter-width                 : 20px        !default;

// @see http://zengrids.com/help/#zen-auto-include-item-base
$zen-auto-include-item-base       : true        !default;
$zen-auto-include-flow-item-base  : true        !default;

// Specify the width of the entire grid. @see http://zengrids.com/help/#zen-grid-width
$zen-grid-width                   : 100%        !default;

// The box-sizing polyfill for IE6/7 requires an absolute path. @see http://zengrids.com/help/#box-sizing-polyfill-path
$box-sizing-polyfill-path         : ""          !default;

// Specify the CSS3 box-sizing method. @see http://zengrids.com/help/#zen-box-sizing
$zen-box-sizing                   : border-box  !default;

// @see http://zengrids.com/help/#legacy-support-for-ie7
$legacy-support-for-ie7           : false       !default;
$legacy-support-for-ie6           : false       !default;

// Specify the default floating direction for zen's mixins. @see http://zengrids.com/help/#zen-float-direction
$zen-float-direction              : left        !default;

// Reverse the floating direction in all zen's mixins. @see http://zengrids.com/help/#zen-reverse-all-floats
$zen-reverse-all-floats           : false       !default;


//
// Apply this to the grid container element.
// @see http://zengrids.com/help/#zen-grid-container
//
@mixin zen-grid-container {
  @if ($legacy-support-for-ie6 or $legacy-support-for-ie7) {
    *position: relative; // @TODO: This is a pre-IE8 line of code; don't remember why its needed.
  }
  // We use the "micro clearfix", instead of Compass' clearfix or pie-clearfix.
  &:before,
  &:after {
    content: "";
    display: table;
  }
  &:after {
    clear: both;
  }
  @if ($legacy-support-for-ie6 or $legacy-support-for-ie7) {
    *zoom: 1;
  }
}

//
// Apply this to any grid item that is also a grid container element for a
// nested grid. @see http://zengrids.com/help/#zen-nested-container
//
@mixin zen-nested-container {
  padding: {
    left: 0;
    right: 0;
  }
}

//
// Apply this to each grid item. @see http://zengrids.com/help/#zen-grid-item
//
@mixin zen-grid-item(
  $column-span,
  $column-position,
  $float-direction          : $zen-float-direction,
  $column-count             : $zen-column-count,
  $gutter-width             : $zen-gutter-width,
  $grid-width               : $zen-grid-width,
  $box-sizing               : $zen-box-sizing,
  $reverse-all-floats       : $zen-reverse-all-floats,
  $auto-include-item-base   : $zen-auto-include-item-base
) {

  // Calculate the unit width.
  $unit-width: zen-unit-width($column-count, $grid-width);

  // Calculate the item's width.
  $width: zen-grid-item-width($column-span, $column-count, $gutter-width, $grid-width, $box-sizing);

  // Determine the float direction and its reverse.
  $dir: $float-direction;
  @if $reverse-all-floats {
    $dir: zen-direction-flip($dir);
  }
  $rev: zen-direction-flip($dir);

  float: $dir;
  width: $width;
  margin: {
    #{$dir}: ($column-position - 1) * $unit-width;
    #{$rev}: (1 - $column-position - $column-span) * $unit-width;
  }

  // Auto-apply the unit base mixin.
  @if $auto-include-item-base {
    @include zen-grid-item-base($gutter-width, $box-sizing);
  }
}

//
// Applies a standard set of properites to all grid items in the layout.
// @see http://zengrids.com/help/#zen-grid-item-base
//
@mixin zen-grid-item-base(
  $gutter-width       : $zen-gutter-width,
  $box-sizing         : $zen-box-sizing,
  $flow-direction     : $zen-float-direction,
  $reverse-all-flows  : $zen-reverse-all-floats
) {

  $dir: $flow-direction;
  @if $reverse-all-flows {
    $dir: zen-direction-flip($dir);
  }

  padding: {
    left: zen-half-gutter($gutter-width, left, $dir);
    right: zen-half-gutter($gutter-width, right, $dir);
  }
  // Specify the border-box properties.
  @if $box-sizing == border-box {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
  }
  // Prevent left/right borders since they'll break the layout with content-box.
  @if $box-sizing == content-box {
    border: {
      left: 0 !important;
      right: 0 !important;
    }
  }
  // Prevent overflowing content from being hidden beneath other grid items.
  word-wrap: break-word; // A very nice CSS3 property.

  @if ($legacy-support-for-ie6 or $legacy-support-for-ie7) {
    @if $box-sizing == border-box and $box-sizing-polyfill-path == "" {
      @warn "IE legacy support is on, but $box-sizing is set to #{$box-sizing} and the $box-sizing-polyfill-path is empty.";
    }
    @if $box-sizing-polyfill-path != "" {
      *behavior: url($box-sizing-polyfill-path);
    }
    @if $legacy-support-for-ie6 {
      _display: inline; // Display inline or double your floated margin! [1]
      _overflow: hidden; // Prevent overflowing content from breaking the layout.
      _overflow-y: visible; // In IE6, overflow visible is broken [2]
      // 1. http://www.positioniseverything.net/explorer/doubled-margin.html
      // 2. http://www.howtocreate.co.uk/wrongWithIE/?chapter=overflow%3Avisible%3B
    }
  }
}

//
// Apply this to grid items that need to be cleared below other grid items.
// @see http://zengrids.com/help/#zen-clear
//
@mixin zen-clear(
  $float-direction      : $zen-float-direction,
  $reverse-all-floats   : $zen-reverse-all-floats
) {
  // Determine the float direction.
  $dir: $float-direction;
  @if $reverse-all-floats {
    $dir: zen-direction-flip($dir);
  }
  clear: $dir;
}

//
// Apply this to flow items that need to be floated.
// @see http://zengrids.com/help/#zen-float
//
@mixin zen-float(
  $float-direction      : $zen-float-direction,
  $reverse-all-floats   : $zen-reverse-all-floats
) {
  // Determine the float direction.
  $dir: $float-direction;
  @if $reverse-all-floats {
    $dir: zen-direction-flip($dir);
  }
  float: $dir;
}

//
// Apply this to an HTML item that is in the normal flow of a document to help
// align it to the grid. @see http://zengrids.com/help/#zen-float
//
@mixin zen-grid-flow-item(
  $column-span,
  $parent-column-count          : false,
  $alpha-gutter                 : false,
  $omega-gutter                 : true,
  $flow-direction               : $zen-float-direction,
  $column-count                 : $zen-column-count,
  $gutter-width                 : $zen-gutter-width,
  $grid-width                   : $zen-grid-width,
  $box-sizing                   : $zen-box-sizing,
  $reverse-all-flows            : $zen-reverse-all-floats,
  $auto-include-flow-item-base  : $zen-auto-include-flow-item-base
) {

  $columns: $column-count;
  @if unit($grid-width) == "%" {
    @if $parent-column-count == false {
      @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.";
    }
    @else {
      $columns: $parent-column-count;
    }
  }

  $dir: $flow-direction;
  @if $reverse-all-flows {
    $dir: zen-direction-flip($dir);
  }
  $rev: zen-direction-flip($dir);

  // Auto-apply the unit base mixin.
  @if $auto-include-flow-item-base {
    @include zen-grid-item-base($gutter-width, $box-sizing);
  }

  // Calculate the item's width.
  $width: zen-grid-item-width($column-span, $columns, $gutter-width, $grid-width, $box-sizing);

  @if unit($grid-width) == "%" {
    // Our percentage $width is off if the parent has $gutter-width padding.
    // Calculate an adjusted gutter to fix the width.
    $adjusted-gutter: ($columns - $column-span) * $gutter-width / $columns;

    width: $width;

    // Ensure the HTML item either has a full gutter or no gutter on each side.
    padding-#{$dir}: 0;
    @if $alpha-gutter {
      margin-#{$dir}: $gutter-width;
    }
    padding-#{$rev}: $adjusted-gutter;
    @if $omega-gutter {
      margin-#{$rev}: $gutter-width - $adjusted-gutter;
    }
    @else {
      margin-#{$rev}: -($adjusted-gutter);
    }
  }
  @else {
    @if $alpha-gutter and $omega-gutter {
      width: $width;
      @if $gutter-width != 0 {
        margin: {
          #{$dir}: zen-half-gutter($gutter-width, left, $dir);
          #{$rev}: zen-half-gutter($gutter-width, right, $dir);
        }
      }
    }
    @else if not $alpha-gutter and not $omega-gutter {
      width: if($box-sizing == border-box, ($width - $gutter-width), $width);
      @if $gutter-width != 0 {
        padding: {
          left: 0;
          right: 0;
        }
      }
    }
    @else {
      width: $width;
      @if $omega-gutter {
        padding-#{$dir}: 0;
        padding-#{$rev}: $gutter-width;
      }
      @else {
        padding-#{$dir}: $gutter-width;
        padding-#{$rev}: 0;
      }
    }
  }
}


//
// Helper functions for the Zen mixins.
//

// Returns a half gutter width. @see http://zengrids.com/help/#zen-half-gutter
@function zen-half-gutter(
  $gutter-width     : $zen-gutter-width,
  $gutter-side      : $zen-float-direction,
  $flow-direction   : $zen-float-direction
) {
  $half-gutter: $gutter-width / 2;
  // Special handling in case gutter has an odd number of pixels.
  @if unit($gutter-width) == "px" {
    @if $gutter-side == $flow-direction {
      @return floor($half-gutter);
    }
    @else {
      @return ceil($half-gutter);
    }
  }
  @return $half-gutter;
}

// Calculates the unit width of a column. @see http://zengrids.com/help/#zen-unit-width
@function zen-unit-width(
  $column-count   : $zen-column-count,
  $grid-width     : $zen-grid-width
) {
  $unit-width: $grid-width / $column-count;
  @if unit($unit-width) == "px" and floor($unit-width) != ceil($unit-width) {
    @warn "You may experience rounding errors as the grid width, #{$grid-width}, does not divide evenly into #{$column-count} columns.";
  }
  @return $unit-width;
}

// Calculates the width of a grid item that spans the specified number of columns.
// @see http://zengrids.com/help/#zen-grid-item-width
@function zen-grid-item-width(
  $column-span,
  $column-count   : $zen-column-count,
  $gutter-width   : $zen-gutter-width,
  $grid-width     : $zen-grid-width,
  $box-sizing     : $zen-box-sizing
) {
  $width: $column-span * zen-unit-width($column-count, $grid-width);
  @if $box-sizing == content-box {
    @if not comparable($width, $gutter-width) {
      $units-gutter: unit($gutter-width);
      $units-grid: unit($grid-width);
      @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}).";
    }
    $width: $width - $gutter-width;
  }
  @return $width;
}

// Returns the opposite direction, given "left" or "right".
// @see http://zengrids.com/help/#zen-direction-flip
@function zen-direction-flip(
  $dir
) {
  @if $dir == left {
    @return right;
  }
  @else if $dir == right {
    @return left;
  }
  @else if $dir == none or $dir == both {
    @return $dir;
  }
  @warn "Invalid direction passed to zen-direction-flip().";
  @return both;
}