summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/foundation-apps/scss/components/_grid.scss
blob: 4a00fd68ffe833b8881fd8f3415c8d2da8746a52 (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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
@import "panel";

/*
  THE GRID
  --------

  Foundation's magical, flexbox-powered grid.

  Features:
   - Horizontal or vertical grids
   - Auto-sizing or percentage width grid blocks
   - Independently-scrollable blocks
   - Column alignment
   - Source ordering
   - Offsets
*/

/// @Foundation.settings
// Grid
$container-width: rem-calc(900) !default;
$block-padding: $global-padding !default;
$total-columns: 12 !default;
$block-grid-max-size: 6 !default;
///

/*
  Define the size of a grid block. Blocks are flex items. By default, they stretch to fill all available space, based on the size of sibling blocks. This is the "expand" behavior.

  If set to "shrink", the block will contract and only fill as much space as it needs for its content.

  If set to a number, the block will be given a percentage width, based on the total number of columns (12 by default). Percentage widths don't work if a block is inside a vertical grid.

  @group grid

  @param {number|string} $size - Sizing behavior of the block. Should be expand, shrink, or a number.

  @output The flex-basis, flex-grow, and flex-shrink properties.
*/
@mixin grid-size($size: expand) {
  @if (type-of($size) == 'number') {
    $pct: percentage($size / $total-columns);
    flex: 0 0 $pct;
    // max-width prevents columns from wrapping early in IE10/11
    max-width: $pct;
  }
  @else if ($size == shrink) {
    flex: 0 0 auto;
  }
  @else if ($size == expand) {
    flex: 1 1 auto;
  }
}
/*
  Set the orientation of blocks within this block. The grid is re-oriented by changing the flex direction of the block.

  @group grid

  @param {string} $orientation - Direction of the grid, either horizontal or vertical.

  @output A flex-flow property to match the direction given.
*/
@mixin grid-orient($orientation: horizontal) {
  @if ($orientation == vertical) {
    flex-flow: column nowrap;
    align-items: stretch;
  }
  @else {
    flex-flow: row wrap;
  }
}
/*
  Stretch a grid's child blocks across its cross-axis, making every column appear to have the same height.

  @group grid

  @param {bool} $stretch - Stretch blocks if true, or align blocks to top if false.

  @output Sets align-items to "stretch" if $stretch is true, or "flex-start" (the default value) if false.
*/
@mixin grid-wrap($wrap: true) {
  @if $wrap {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  @else {
    flex-wrap: nowrap;
    align-items: stretch;
  }
}
/*
  Set the alignment of blocks within a grid.

  left: Items align to the left.
  right: Items align to the right.
  center: Items align to the center.
  justify: Items are spaced equally apart so they occupy the space of the entire grid.
  spaced: Items are given equal space to their left and right.

  @group grid

  @param {string} $align - Alignment to use.

  @output An appropriate justify-content value.
*/
@mixin grid-align($align: left) {
  $options: (
    left: flex-start,
    right: flex-end,
    center: center,
    justify: space-between,
    spaced: space-around,
  );
  justify-content: map-get($options, $align);
}
/*
  Set the source order of a block. Items with lower numbers appear first. If multiple items have the same number, the one in the HTML first will appear first.

  @group grid

  @param {number} $order - Position in source order.

  @output An order property.
*/
@mixin grid-order($order: 0) {
  order: $order;
}
/*
  Collapse a content block by removing the padding.

  @group grid

  @param {bool} $collapse - Collapses the block if true.

  @output A padding value.

  @todo No way to reverse collapse using this mixin. Solution:
    - If true, add padding: 0;
    - If false, add padding: 1rem;
    - If null, add nothing, to cut down on CSS output
    - Make null the default value
*/
@mixin grid-collapse($collapse: true) {
  @if ($collapse) {
    padding: 0;
  }
}
/*
  Constrain the size of a block to the size of the average grid row, and center-align it. This imitates the behavior of ordinary Foundation rows.

  @group grid

  @param {bool} $container - Adds container styles if true.

  @output A maximum width and the good old margin: 0 auto for center alignment.
*/
@mixin grid-container($width: $container-width, $align: center) {
  $margins: (
    left:  0 auto 0 0,
    right: 0 0 0 auto,
    center: 0 auto,
  );
  max-width: $width;
  margin: map-get($margins, $align);
}
/*
  Add negative margins to a block, equal to the padding of a content block. This aligns the edges of a block nested inside a content block.

  @group grid

  @param {bool} $nest - Adds negative margins if true.

  @output Negative margin values.
*/
@mixin grid-nest($nest: true) {
  @if ($nest) {
    margin-left: -1rem;
    margin-right: -1rem;
  }
}
/*
  Offset a block by adding a left margin.

  @group grid

  @param {number | bool} $offset - If false, nothing is output. If a number, offsets the column by the specified number of columns.

  @output A left margin based on the number of columns specified, and the global number of columns.
*/
@mixin grid-offset($offset: false) {
  @if ($offset != false) {
    margin-left: percentage($offset / $total-columns);
  }
}

/*
  Resets styles set by panels. Use this when a panel transforms into a block on larger screens.

  @group grid

  @output Resets to transform, position, and a few visual styles.
*/
@mixin grid-panel-reset() {
  transform: none;
  position: relative;
  width: auto;
  height: auto;
  z-index: auto;
  box-shadow: none;
  background: transparent;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
}

/*
  Frames are containers that stretch to the full dimmensions of the browser window.
*/
@mixin grid-frame($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0) {
  display: flex;
  height: 100vh;
  position: relative;
  overflow: hidden;
  backface-visibility: hidden;

  @include grid-size($size);
  @include grid-orient($orientation);
  @include grid-wrap($wrap);
  @include grid-align($align);
  @include grid-order($order);
}

/*
  Groups are collections of content items. They're the "rows" of Foundation for Apps.
*/
@mixin grid-block($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0) {
  @include grid-frame($size, $orientation, $wrap, $align, $order);

  // Reset the height used by frames
  height: auto;

  // Blocks will scroll by default if their content overflows
  @if ($orientation == vertical) {
    overflow-x: auto;
  }
  @else {
    overflow-y: auto;
  }

  // Add scrolling with inertia
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

/*
  Blocks are containers for actual content. They're the "columns" of Foundation for Apps.
*/
@mixin grid-content($size: expand, $offset: null, $order: null) {
  // Content blocks are not flex items and have padding
  display: block;
  padding: 0 $block-padding;

  // Add scrolling with inertia
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;

  @include grid-size($size);
  @if $offset != null { @include grid-offset($offset); }
  @if $order != null  { @include grid-order($order); }
}

@mixin grid-layout($up) {
  flex-flow: row wrap;
  overflow: visible;
  list-style-type: none;

  > li, > div, > section {
    padding: 0 1rem 1rem;
    flex: 0 0 percentage(1 / $up);
  }
}

// CSS Output
// - - - - - - - - - - - - - - - - - - - -

// Shared styles for frames and blocks (parent elements)
%block-core {
  // Change the direction children flow
  &.vertical { @include grid-orient(vertical); }
  @each $size in $breakpoint-classes {
    @include breakpoint($size) {
      &.#{$size}-vertical   { @include grid-orient(vertical); }
      &.#{$size}-horizontal { @include grid-orient(horizontal); }
    }
  }

  // Align the children of a grid block
  &.align-right   { @include grid-align(right); }
  &.align-center  { @include grid-align(center); }
  &.align-justify { @include grid-align(justify); }
  &.align-spaced  { @include grid-align(spaced); }

  // Allow child elements to wrap
  &.wrap { @include grid-wrap(true); }
}

// Shared styles for blocks and content blocks (child elements)
%child-core {
  // Shrink a flex item so it only takes up the space it needs
  &.shrink { @include grid-size(shrink); }

  // Prevent an element from scrolling
  &.noscroll { overflow: hidden; }
}

@include exports(grid) {
  // The core grid elements:
  //  - Frame
  //  - Block
  //  - Content block
  //  - Container
  .grid-frame {
    @extend %block-core;
    @include grid-frame;
  }
  .grid-block {
    @extend %block-core;
    @extend %child-core;
    @include grid-block;
  }
  .grid-content {
    @extend %child-core;
    @include grid-content;

    &.collapse {
      padding: 0;
    }

    // Grids inside content blocks should wrap by default, so they mimic traditional float grids
    .grid-block {
      margin-left: -($block-padding);
      margin-right: -($block-padding);
      flex-wrap: wrap;
      overflow: visible;

      // Reverse the above wrapping behavior
      &.nowrap {
        @include grid-wrap(false);
      }

      .grid-content {
        overflow: visible;
      }
    }
  }
  .grid-container {
    @include grid-container;

    &.contain-left  { @include grid-container($align: left); }
    &.contain-right { @include grid-container($align: right); }
  }

  // Breakpoint classes for blocks
  @each $size in $breakpoint-classes {
    .#{$size}-grid-block {
      @extend %block-core;
      @extend %child-core;

      @include breakpoint($size) {
        @include grid-block;

        // Override panel styles
        &.panel { @include grid-panel-reset; }
      }
    }
    .#{$size}-grid-content {
      @extend %child-core;

      @include breakpoint($size) {
        @include grid-content;

        // Override panel styles
        &.panel { @include grid-panel-reset; }
      }
    }
  }

  // Sizing and ordering classes
  @for $i from 1 through $total-columns {
    // Source ordering
    .order-#{$i} { @include grid-order($i); }
  }
  @each $size in $breakpoint-classes {
    @for $i from 1 through $total-columns {
      @include breakpoint($size) {
        // Block sizing
        .#{$size}-#{$i} {
          @include grid-size($i);
        }
        // Source ordering
        .#{$size}-order-#{$i} {
          @include grid-order($i);
        }
        // Offsets
        .#{$size}-offset-#{$i} {
          @include grid-offset($i);
        }
        // Parent sizing (block grids)
        .#{$size}-up-#{$i} {
          @include grid-layout($i);
        }
      }
    }
  }

  .grid-content .modal .grid-block {
    flex-wrap: nowrap;
  }
}