Initial coomit for AAI-UI(sparky-fe)
[aai/sparky-fe.git] / resources / scss / bootstrap / mixins / _grid-framework.scss
1 // Framework grid generation
2 //
3 // Used only by Bootstrap to generate the correct number of grid classes given
4 // any value of `$grid-columns`.
5
6 // [converter] This is defined recursively in LESS, but Sass supports real loops
7 @mixin make-grid-columns($i: 1, $list: ".col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}") {
8   @for $i from (1 + 1) through $grid-columns {
9         $list: "#{$list}, .col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}";
10   }
11   #{$list} {
12         position: relative;
13         // Prevent columns from collapsing when empty
14         min-height: 1px;
15         // Inner gutter via padding
16         padding-left: ceil(($grid-gutter-width / 2));
17         padding-right: floor(($grid-gutter-width / 2));
18   }
19 }
20
21 // [converter] This is defined recursively in LESS, but Sass supports real loops
22 @mixin float-grid-columns($class, $i: 1, $list: ".col-#{$class}-#{$i}") {
23   @for $i from (1 + 1) through $grid-columns {
24         $list: "#{$list}, .col-#{$class}-#{$i}";
25   }
26   #{$list} {
27         float: left;
28   }
29 }
30
31 @mixin calc-grid-column($index, $class, $type) {
32   @if ($type == width) and ($index > 0) {
33         .col-#{$class}-#{$index} {
34           width: percentage(($index / $grid-columns));
35         }
36   }
37   @if ($type == push) and ($index > 0) {
38         .col-#{$class}-push-#{$index} {
39           left: percentage(($index / $grid-columns));
40         }
41   }
42   @if ($type == push) and ($index == 0) {
43         .col-#{$class}-push-0 {
44           left: auto;
45         }
46   }
47   @if ($type == pull) and ($index > 0) {
48         .col-#{$class}-pull-#{$index} {
49           right: percentage(($index / $grid-columns));
50         }
51   }
52   @if ($type == pull) and ($index == 0) {
53         .col-#{$class}-pull-0 {
54           right: auto;
55         }
56   }
57   @if ($type == offset) {
58         .col-#{$class}-offset-#{$index} {
59           margin-left: percentage(($index / $grid-columns));
60         }
61   }
62 }
63
64 // [converter] This is defined recursively in LESS, but Sass supports real loops
65 @mixin loop-grid-columns($columns, $class, $type) {
66   @for $i from 0 through $columns {
67         @include calc-grid-column($i, $class, $type);
68   }
69 }
70
71 // Create grid for specific class
72 @mixin make-grid($class) {
73   @include float-grid-columns($class);
74   @include loop-grid-columns($grid-columns, $class, width);
75   @include loop-grid-columns($grid-columns, $class, pull);
76   @include loop-grid-columns($grid-columns, $class, push);
77   @include loop-grid-columns($grid-columns, $class, offset);
78 }