1441 |
ariadna |
1 |
// Grid system
|
1 |
efrain |
2 |
//
|
|
|
3 |
// Generate semantic grid columns with these mixins.
|
|
|
4 |
|
|
|
5 |
@mixin make-row($gutter: $grid-gutter-width) {
|
1441 |
ariadna |
6 |
--#{$prefix}gutter-x: #{$gutter};
|
|
|
7 |
--#{$prefix}gutter-y: 0;
|
1 |
efrain |
8 |
display: flex;
|
|
|
9 |
flex-wrap: wrap;
|
1441 |
ariadna |
10 |
// TODO: Revisit calc order after https://github.com/react-bootstrap/react-bootstrap/issues/6039 is fixed
|
|
|
11 |
margin-top: calc(-1 * var(--#{$prefix}gutter-y)); // stylelint-disable-line function-disallowed-list
|
|
|
12 |
margin-right: calc(-.5 * var(--#{$prefix}gutter-x)); // stylelint-disable-line function-disallowed-list
|
|
|
13 |
margin-left: calc(-.5 * var(--#{$prefix}gutter-x)); // stylelint-disable-line function-disallowed-list
|
1 |
efrain |
14 |
}
|
|
|
15 |
|
1441 |
ariadna |
16 |
@mixin make-col-ready() {
|
|
|
17 |
// Add box sizing if only the grid is loaded
|
|
|
18 |
box-sizing: if(variable-exists(include-column-box-sizing) and $include-column-box-sizing, border-box, null);
|
1 |
efrain |
19 |
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
1441 |
ariadna |
20 |
// always setting `width: 100%;`. This works because we set the width
|
1 |
efrain |
21 |
// later on to override this initial width.
|
1441 |
ariadna |
22 |
flex-shrink: 0;
|
1 |
efrain |
23 |
width: 100%;
|
1441 |
ariadna |
24 |
max-width: 100%; // Prevent `.col-auto`, `.col` (& responsive variants) from breaking out the grid
|
|
|
25 |
padding-right: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list
|
|
|
26 |
padding-left: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list
|
|
|
27 |
margin-top: var(--#{$prefix}gutter-y);
|
1 |
efrain |
28 |
}
|
|
|
29 |
|
1441 |
ariadna |
30 |
@mixin make-col($size: false, $columns: $grid-columns) {
|
|
|
31 |
@if $size {
|
|
|
32 |
flex: 0 0 auto;
|
|
|
33 |
width: percentage(divide($size, $columns));
|
|
|
34 |
|
|
|
35 |
} @else {
|
|
|
36 |
flex: 1 1 0;
|
|
|
37 |
max-width: 100%;
|
|
|
38 |
}
|
1 |
efrain |
39 |
}
|
|
|
40 |
|
|
|
41 |
@mixin make-col-auto() {
|
|
|
42 |
flex: 0 0 auto;
|
|
|
43 |
width: auto;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
@mixin make-col-offset($size, $columns: $grid-columns) {
|
|
|
47 |
$num: divide($size, $columns);
|
|
|
48 |
margin-left: if($num == 0, 0, percentage($num));
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
// Row columns
|
|
|
52 |
//
|
|
|
53 |
// Specify on a parent element(e.g., .row) to force immediate children into NN
|
1441 |
ariadna |
54 |
// number of columns. Supports wrapping to new lines, but does not do a Masonry
|
1 |
efrain |
55 |
// style grid.
|
|
|
56 |
@mixin row-cols($count) {
|
|
|
57 |
> * {
|
1441 |
ariadna |
58 |
flex: 0 0 auto;
|
|
|
59 |
width: percentage(divide(1, $count));
|
1 |
efrain |
60 |
}
|
|
|
61 |
}
|
1441 |
ariadna |
62 |
|
|
|
63 |
// Framework grid generation
|
|
|
64 |
//
|
|
|
65 |
// Used only by Bootstrap to generate the correct number of grid classes given
|
|
|
66 |
// any value of `$grid-columns`.
|
|
|
67 |
|
|
|
68 |
@mixin make-grid-columns($columns: $grid-columns, $gutter: $grid-gutter-width, $breakpoints: $grid-breakpoints) {
|
|
|
69 |
@each $breakpoint in map-keys($breakpoints) {
|
|
|
70 |
$infix: breakpoint-infix($breakpoint, $breakpoints);
|
|
|
71 |
|
|
|
72 |
@include media-breakpoint-up($breakpoint, $breakpoints) {
|
|
|
73 |
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
|
|
74 |
.col#{$infix} {
|
|
|
75 |
flex: 1 0 0%; // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
.row-cols#{$infix}-auto > * {
|
|
|
79 |
@include make-col-auto();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
@if $grid-row-columns > 0 {
|
|
|
83 |
@for $i from 1 through $grid-row-columns {
|
|
|
84 |
.row-cols#{$infix}-#{$i} {
|
|
|
85 |
@include row-cols($i);
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
.col#{$infix}-auto {
|
|
|
91 |
@include make-col-auto();
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
@if $columns > 0 {
|
|
|
95 |
@for $i from 1 through $columns {
|
|
|
96 |
.col#{$infix}-#{$i} {
|
|
|
97 |
@include make-col($i, $columns);
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
// `$columns - 1` because offsetting by the width of an entire row isn't possible
|
|
|
102 |
@for $i from 0 through ($columns - 1) {
|
|
|
103 |
@if not ($infix == "" and $i == 0) { // Avoid emitting useless .offset-0
|
|
|
104 |
.offset#{$infix}-#{$i} {
|
|
|
105 |
@include make-col-offset($i, $columns);
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
// Gutters
|
|
|
112 |
//
|
|
|
113 |
// Make use of `.g-*`, `.gx-*` or `.gy-*` utilities to change spacing between the columns.
|
|
|
114 |
@each $key, $value in $gutters {
|
|
|
115 |
.g#{$infix}-#{$key},
|
|
|
116 |
.gx#{$infix}-#{$key} {
|
|
|
117 |
--#{$prefix}gutter-x: #{$value};
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
.g#{$infix}-#{$key},
|
|
|
121 |
.gy#{$infix}-#{$key} {
|
|
|
122 |
--#{$prefix}gutter-y: #{$value};
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
@mixin make-cssgrid($columns: $grid-columns, $breakpoints: $grid-breakpoints) {
|
|
|
130 |
@each $breakpoint in map-keys($breakpoints) {
|
|
|
131 |
$infix: breakpoint-infix($breakpoint, $breakpoints);
|
|
|
132 |
|
|
|
133 |
@include media-breakpoint-up($breakpoint, $breakpoints) {
|
|
|
134 |
@if $columns > 0 {
|
|
|
135 |
@for $i from 1 through $columns {
|
|
|
136 |
.g-col#{$infix}-#{$i} {
|
|
|
137 |
grid-column: auto / span $i;
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
// Start with `1` because `0` is an invalid value.
|
|
|
142 |
// Ends with `$columns - 1` because offsetting by the width of an entire row isn't possible.
|
|
|
143 |
@for $i from 1 through ($columns - 1) {
|
|
|
144 |
.g-start#{$infix}-#{$i} {
|
|
|
145 |
grid-column-start: $i;
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
}
|