@octaviaflow/grid 1.0.0
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.
- package/README.md +106 -0
- package/index.scss +11 -0
- package/package.json +46 -0
- package/scss/_breakpoint.scss +222 -0
- package/scss/_config.scss +94 -0
- package/scss/_css-grid.scss +484 -0
- package/scss/_flex-grid.scss +324 -0
- package/scss/_inlined/_breakpoint.scss +222 -0
- package/scss/_inlined/_config.scss +94 -0
- package/scss/_inlined/_css-grid.scss +484 -0
- package/scss/_inlined/_flex-grid.scss +324 -0
- package/scss/_inlined/_mixins.scss +297 -0
- package/scss/_mixins.scss +297 -0
- package/scss/vendor/@octaviaflow/layout/_convert.scss +56 -0
- package/scss/vendor/@octaviaflow/layout/_spacing.scss +10 -0
- package/scss/vendor/@octaviaflow/layout/_utilities.scss +41 -0
- package/scss/vendor/@octaviaflow/layout/generated/_container.scss +43 -0
- package/scss/vendor/@octaviaflow/layout/generated/_fluid-spacing.scss +37 -0
- package/scss/vendor/@octaviaflow/layout/generated/_icon-size.scss +25 -0
- package/scss/vendor/@octaviaflow/layout/generated/_layout.scss +55 -0
- package/scss/vendor/@octaviaflow/layout/generated/_size.scss +17 -0
- package/scss/vendor/@octaviaflow/layout/generated/_spacing.scss +91 -0
- package/scss/vendor/@octaviaflow/layout/modules/_convert.scss +56 -0
- package/telemetry.yml +17 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright OctaviaFlow. 2025
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// Helpers for defining columns, rows, and containers are heavily inspired by,
|
|
9
|
+
// and often derived from, bootstrap:
|
|
10
|
+
// https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid.scss
|
|
11
|
+
|
|
12
|
+
@use 'sass:list';
|
|
13
|
+
@use 'sass:meta';
|
|
14
|
+
@use 'sass:math';
|
|
15
|
+
@use 'sass:map';
|
|
16
|
+
|
|
17
|
+
@use 'config' as *;
|
|
18
|
+
@use 'breakpoint' as *;
|
|
19
|
+
|
|
20
|
+
// -----------------------------------------------------------------------------
|
|
21
|
+
// Columns
|
|
22
|
+
// -----------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
/// Used to initialize the default properties for a column class, most notably
|
|
25
|
+
/// for setting width and default gutters when a column's breakpoint has not been
|
|
26
|
+
/// hit yet.
|
|
27
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
28
|
+
/// @param {Number} $collapsed-gutter [$grid-gutter-condensed] - The condensed mode gutter
|
|
29
|
+
/// @access private
|
|
30
|
+
/// @group @octaviaflow/grid
|
|
31
|
+
@mixin -make-col-ready(
|
|
32
|
+
$gutter: $grid-gutter,
|
|
33
|
+
$condensed-gutter: $grid-gutter-condensed
|
|
34
|
+
) {
|
|
35
|
+
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
|
36
|
+
// always setting `width: 100%;`. This works because we use `flex` values
|
|
37
|
+
// later on to override this initial width.
|
|
38
|
+
inline-size: 100%;
|
|
39
|
+
padding-inline: $gutter * 0.5;
|
|
40
|
+
|
|
41
|
+
// For our condensed use-case, our gutters collapse to 2px solid, 1px on each
|
|
42
|
+
// side.
|
|
43
|
+
.#{$prefix}--row--condensed &,
|
|
44
|
+
.#{$prefix}--grid--condensed & {
|
|
45
|
+
padding-inline: $condensed-gutter * 0.5;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// For our narrow use-case, our container hangs 16px into the gutter
|
|
49
|
+
.#{$prefix}--row--narrow &,
|
|
50
|
+
.#{$prefix}--grid--narrow & {
|
|
51
|
+
padding-inline: 0 $gutter * 0.5;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// Define the width of the column for a given span and column count.
|
|
56
|
+
/// A width of 0 will hide the column entirely.
|
|
57
|
+
/// @param {Number} $span - The number of columns covered
|
|
58
|
+
/// @param {Number} $columns - The total number of columns available
|
|
59
|
+
/// @access private
|
|
60
|
+
/// @group @octaviaflow/grid
|
|
61
|
+
@mixin -make-col($span, $columns) {
|
|
62
|
+
@if $span == 0 {
|
|
63
|
+
display: none;
|
|
64
|
+
} @else {
|
|
65
|
+
// Explicitly include `display: block` to override
|
|
66
|
+
display: block;
|
|
67
|
+
// Add a `max-width` to ensure content within each column does not blow out
|
|
68
|
+
// the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
|
|
69
|
+
// do not appear to require this.
|
|
70
|
+
flex: 0 0 math.percentage(math.div($span, $columns));
|
|
71
|
+
max-inline-size: math.percentage(math.div($span, $columns));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// Create a column offset for a given span and column count.
|
|
76
|
+
/// @param {Number} $span - The number of columns the offset should cover
|
|
77
|
+
/// @param {Number} $columns - The total number of columns available
|
|
78
|
+
/// @access private
|
|
79
|
+
/// @group @octaviaflow/grid
|
|
80
|
+
@mixin -make-col-offset($span, $columns) {
|
|
81
|
+
$offset: 0;
|
|
82
|
+
$offset: math.div($span, $columns);
|
|
83
|
+
@if $offset == 0 {
|
|
84
|
+
margin-inline-start: 0;
|
|
85
|
+
} @else {
|
|
86
|
+
margin-inline-start: math.percentage($offset);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// Output the CSS required for all the columns in a given grid system.
|
|
91
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The breakpoints in the grid system
|
|
92
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
93
|
+
/// @access private
|
|
94
|
+
/// @group @octaviaflow/grid
|
|
95
|
+
@mixin -make-grid-columns(
|
|
96
|
+
$breakpoints: $grid-breakpoints,
|
|
97
|
+
$gutter: $grid-gutter
|
|
98
|
+
) {
|
|
99
|
+
.#{$prefix}--col {
|
|
100
|
+
@include -make-col-ready($gutter);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@each $breakpoint in map-keys($breakpoints) {
|
|
104
|
+
$infix: breakpoint-infix($breakpoint);
|
|
105
|
+
$columns: map.get(map.get($breakpoints, $breakpoint), columns);
|
|
106
|
+
|
|
107
|
+
// Allow columns to stretch full width below their breakpoints
|
|
108
|
+
@for $i from 0 through $columns {
|
|
109
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
110
|
+
@include -make-col-ready($gutter);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.#{$prefix}--col#{$infix},
|
|
115
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
116
|
+
@include -make-col-ready($gutter);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@include breakpoint($breakpoint, $breakpoints) {
|
|
120
|
+
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
|
121
|
+
.#{$prefix}--col,
|
|
122
|
+
.#{$prefix}--col#{$infix} {
|
|
123
|
+
flex-basis: 0;
|
|
124
|
+
flex-grow: 1;
|
|
125
|
+
max-inline-size: 100%;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.#{$prefix}--col--auto,
|
|
129
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
130
|
+
flex: 1 0 0%;
|
|
131
|
+
inline-size: auto;
|
|
132
|
+
// Reset earlier grid tiers
|
|
133
|
+
max-inline-size: 100%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@for $i from 0 through $columns {
|
|
137
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
138
|
+
@include -make-col($i, $columns);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@for $i from 0 through ($columns - 1) {
|
|
143
|
+
@if not($infix == '') {
|
|
144
|
+
.#{$prefix}--offset#{$infix}-#{$i} {
|
|
145
|
+
@include -make-col-offset($i, $columns);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// -----------------------------------------------------------------------------
|
|
154
|
+
// Rows
|
|
155
|
+
// -----------------------------------------------------------------------------
|
|
156
|
+
|
|
157
|
+
/// Define the properties for a selector assigned to a row in the grid system.
|
|
158
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
159
|
+
/// @access private
|
|
160
|
+
/// @group @octaviaflow/grid
|
|
161
|
+
@mixin -make-row($gutter: $grid-gutter) {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-wrap: wrap;
|
|
164
|
+
margin-inline: -1 * $gutter * 0.5;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// -----------------------------------------------------------------------------
|
|
168
|
+
// No gutter
|
|
169
|
+
// -----------------------------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
/// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
|
|
172
|
+
/// classes are useful for dropping the gutter in fluid situations.
|
|
173
|
+
/// @access private
|
|
174
|
+
/// @group @octaviaflow/grid
|
|
175
|
+
@mixin -no-gutter {
|
|
176
|
+
.#{$prefix}--no-gutter,
|
|
177
|
+
.#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
|
|
178
|
+
padding-inline: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.#{$prefix}--no-gutter--start,
|
|
182
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
|
|
183
|
+
padding-inline-start: 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.#{$prefix}--no-gutter--end,
|
|
187
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
|
|
188
|
+
padding-inline-end: 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// -----------------------------------------------------------------------------
|
|
193
|
+
// Hang
|
|
194
|
+
// -----------------------------------------------------------------------------
|
|
195
|
+
|
|
196
|
+
/// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
|
|
197
|
+
/// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
|
|
198
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
199
|
+
/// @access private
|
|
200
|
+
/// @group @octaviaflow/grid
|
|
201
|
+
@mixin -hang($gutter: $grid-gutter) {
|
|
202
|
+
.#{$prefix}--hang--start {
|
|
203
|
+
padding-inline-start: $gutter * 0.5;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.#{$prefix}--hang--end {
|
|
207
|
+
padding-inline-end: $gutter * 0.5;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// -----------------------------------------------------------------------------
|
|
212
|
+
// Grid
|
|
213
|
+
// -----------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
/// Create the container for a grid. Will cause full-bleed for the grid unless
|
|
216
|
+
/// max-width properties are added with `make-container-max-widths`
|
|
217
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
218
|
+
/// @access private
|
|
219
|
+
/// @group @octaviaflow/grid
|
|
220
|
+
@mixin -make-container($breakpoints: $grid-breakpoints) {
|
|
221
|
+
margin-inline: auto;
|
|
222
|
+
|
|
223
|
+
@include -set-largest-breakpoint($breakpoints);
|
|
224
|
+
|
|
225
|
+
@each $name, $value in $breakpoints {
|
|
226
|
+
$prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
|
|
227
|
+
$margin: map.get($value, margin);
|
|
228
|
+
|
|
229
|
+
@if $prev-breakpoint {
|
|
230
|
+
$prev-margin: map.get($prev-breakpoint, margin);
|
|
231
|
+
@if $prev-margin != $margin {
|
|
232
|
+
@include breakpoint($name) {
|
|
233
|
+
padding-inline: #{($grid-gutter * 0.5) + $margin};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} @else {
|
|
237
|
+
@include breakpoint($name) {
|
|
238
|
+
padding-inline: #{($grid-gutter * 0.5) + $margin};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// Get the last breakpoint width and set max-width to its value
|
|
245
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
246
|
+
/// @access private
|
|
247
|
+
/// @group @octaviaflow/grid
|
|
248
|
+
@mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
|
|
249
|
+
$largest-breakpoint: -last-map-item($breakpoints);
|
|
250
|
+
|
|
251
|
+
max-inline-size: map.get($largest-breakpoint, 'width');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/// Add in the max-widths for each breakpoint to the container
|
|
255
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
256
|
+
/// @access private
|
|
257
|
+
/// @group @octaviaflow/grid
|
|
258
|
+
@mixin -make-container-max-widths($breakpoints: $grid-breakpoints) {
|
|
259
|
+
@each $name, $value in $breakpoints {
|
|
260
|
+
@include breakpoint($name) {
|
|
261
|
+
max-inline-size: map.get($value, width);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/// Pass in a map, and get the last one in the list back
|
|
267
|
+
/// @access public
|
|
268
|
+
/// @param {Map} $map - Map
|
|
269
|
+
/// @return {*} Desired value
|
|
270
|
+
/// @group @octaviaflow/layout
|
|
271
|
+
@function -last-map-item($map) {
|
|
272
|
+
$total-length: list.length($map);
|
|
273
|
+
@return map-get($map, -key-by-index($map, $total-length));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/// Provide a map and index, and get back the relevant key value
|
|
277
|
+
/// @access public
|
|
278
|
+
/// @param {Map} $map - Map
|
|
279
|
+
/// @param {Integer} $index - Key chain
|
|
280
|
+
/// @return {String} Desired value
|
|
281
|
+
/// @group @octaviaflow/layout
|
|
282
|
+
@function -key-by-index($map, $index) {
|
|
283
|
+
$keys: map.keys($map);
|
|
284
|
+
@return nth($keys, $index);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// Generate the CSS for a grid for the given breakpoints and gutters
|
|
288
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
|
|
289
|
+
/// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
|
|
290
|
+
/// @param {Number} $condensed-gutter [$grid-gutter-condensed] - The condensed mode gutter
|
|
291
|
+
/// @access public
|
|
292
|
+
/// @group @octaviaflow/grid
|
|
293
|
+
@mixin flex-grid(
|
|
294
|
+
$breakpoints: $grid-breakpoints,
|
|
295
|
+
$grid-gutter: $grid-gutter,
|
|
296
|
+
$condensed-gutter: $grid-gutter-condensed
|
|
297
|
+
) {
|
|
298
|
+
.#{$prefix}--grid {
|
|
299
|
+
@include -make-container($breakpoints);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@include largest-breakpoint($breakpoints) {
|
|
303
|
+
.#{$prefix}--grid--full-width {
|
|
304
|
+
max-inline-size: 100%;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.#{$prefix}--row {
|
|
309
|
+
@include -make-row();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.#{$prefix}--row-padding [class*='#{$prefix}--col'],
|
|
313
|
+
.#{$prefix}--col-padding {
|
|
314
|
+
padding-block: $grid-gutter * 0.5;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
|
|
318
|
+
padding-block: $condensed-gutter * 0.5;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@include -make-grid-columns($breakpoints, $grid-gutter);
|
|
322
|
+
@include -no-gutter();
|
|
323
|
+
@include -hang($grid-gutter);
|
|
324
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright OctaviaFlow. 2025
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
@use 'sass:meta';
|
|
9
|
+
@use 'sass:math';
|
|
10
|
+
|
|
11
|
+
@use 'config' as *;
|
|
12
|
+
@use 'breakpoint' as *;
|
|
13
|
+
|
|
14
|
+
// -----------------------------------------------------------------------------
|
|
15
|
+
// Columns
|
|
16
|
+
// -----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/// Used to initialize the default properties for a column class, most notably
|
|
19
|
+
/// for setting width and default gutters when a column's breakpoint has not been
|
|
20
|
+
/// hit yet.
|
|
21
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
22
|
+
/// @param {Number} $collapsed-gutter [$grid-gutter--condensed] - The condensed mode gutter
|
|
23
|
+
/// @access private
|
|
24
|
+
/// @group @octaviaflow/grid
|
|
25
|
+
@mixin -make-col-ready(
|
|
26
|
+
$gutter: $grid-gutter,
|
|
27
|
+
$condensed-gutter: $grid-gutter--condensed
|
|
28
|
+
) {
|
|
29
|
+
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
|
30
|
+
// always setting `width: 100%;`. This works because we use `flex` values
|
|
31
|
+
// later on to override this initial width.
|
|
32
|
+
inline-size: 100%;
|
|
33
|
+
padding-inline: ($gutter * 0.5);
|
|
34
|
+
|
|
35
|
+
// For our condensed use-case, our gutters collapse to 2px solid, 1px on each
|
|
36
|
+
// side.
|
|
37
|
+
.#{$prefix}--row--condensed &,
|
|
38
|
+
.#{$prefix}--grid--condensed & {
|
|
39
|
+
padding-inline: ($condensed-gutter * 0.5);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// For our narrow use-case, our container hangs 16px into the gutter
|
|
43
|
+
.#{$prefix}--row--narrow &,
|
|
44
|
+
.#{$prefix}--grid--narrow & {
|
|
45
|
+
padding-inline: 0 ($gutter * 0.5);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Define the width of the column for a given span and column count.
|
|
50
|
+
/// A width of 0 will hide the column entirely.
|
|
51
|
+
/// @param {Number} $span - The number of columns covered
|
|
52
|
+
/// @param {Number} $columns - The total number of columns available
|
|
53
|
+
/// @access private
|
|
54
|
+
/// @group @octaviaflow/grid
|
|
55
|
+
@mixin -make-col($span, $columns) {
|
|
56
|
+
@if $span == 0 {
|
|
57
|
+
display: none;
|
|
58
|
+
} @else {
|
|
59
|
+
// Explicitly include `display: block` to override
|
|
60
|
+
display: block;
|
|
61
|
+
// Add a `max-width` to ensure content within each column does not blow out
|
|
62
|
+
// the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
|
|
63
|
+
// do not appear to require this.
|
|
64
|
+
flex: 0 0 math.percentage(math.div($span, $columns));
|
|
65
|
+
max-inline-size: math.percentage(math.div($span, $columns));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Create a column offset for a given span and column count.
|
|
70
|
+
/// @param {Number} $span - The number of columns the offset should cover
|
|
71
|
+
/// @param {Number} $columns - The total number of columns available
|
|
72
|
+
/// @access private
|
|
73
|
+
/// @group @octaviaflow/grid
|
|
74
|
+
@mixin -make-col-offset($span, $columns) {
|
|
75
|
+
$offset: 0;
|
|
76
|
+
$offset: math.div($span, $columns);
|
|
77
|
+
@if $offset == 0 {
|
|
78
|
+
margin-inline-start: 0;
|
|
79
|
+
} @else {
|
|
80
|
+
margin-inline-start: math.percentage($offset);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// Output the CSS required for all the columns in a given grid system.
|
|
85
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The breakpoints in the grid system
|
|
86
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
87
|
+
/// @access private
|
|
88
|
+
/// @group @octaviaflow/grid
|
|
89
|
+
@mixin -make-grid-columns(
|
|
90
|
+
$breakpoints: $grid-breakpoints,
|
|
91
|
+
$gutter: $grid-gutter
|
|
92
|
+
) {
|
|
93
|
+
.#{$prefix}--col {
|
|
94
|
+
@include -make-col-ready($gutter);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@each $breakpoint in map-keys($breakpoints) {
|
|
98
|
+
$infix: breakpoint-infix($breakpoint);
|
|
99
|
+
$columns: map.get(map.get($breakpoints, $breakpoint), columns);
|
|
100
|
+
|
|
101
|
+
// Allow columns to stretch full width below their breakpoints
|
|
102
|
+
@for $i from 0 through $columns {
|
|
103
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
104
|
+
@include -make-col-ready($gutter);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.#{$prefix}--col#{$infix},
|
|
109
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
110
|
+
@include -make-col-ready($gutter);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@include breakpoint($breakpoint, $breakpoints) {
|
|
114
|
+
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
|
115
|
+
.#{$prefix}--col,
|
|
116
|
+
.#{$prefix}--col#{$infix} {
|
|
117
|
+
flex-basis: 0;
|
|
118
|
+
flex-grow: 1;
|
|
119
|
+
max-inline-size: 100%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.#{$prefix}--col--auto,
|
|
123
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
124
|
+
flex: 1 0 0%;
|
|
125
|
+
inline-size: auto;
|
|
126
|
+
// Reset earlier grid tiers
|
|
127
|
+
max-inline-size: 100%;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@for $i from 0 through $columns {
|
|
131
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
132
|
+
@include -make-col($i, $columns);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@for $i from 0 through ($columns - 1) {
|
|
137
|
+
@if not($infix == '') {
|
|
138
|
+
.#{$prefix}--offset#{$infix}-#{$i} {
|
|
139
|
+
@include -make-col-offset($i, $columns);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// -----------------------------------------------------------------------------
|
|
148
|
+
// Rows
|
|
149
|
+
// -----------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
/// Define the properties for a selector assigned to a row in the grid system.
|
|
152
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
153
|
+
/// @access private
|
|
154
|
+
/// @group @octaviaflow/grid
|
|
155
|
+
@mixin make-row($gutter: $grid-gutter) {
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-wrap: wrap;
|
|
158
|
+
margin-inline: -1 * $gutter * 0.5;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// -----------------------------------------------------------------------------
|
|
162
|
+
// No gutter
|
|
163
|
+
// -----------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
/// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
|
|
166
|
+
/// classes are useful for dropping the gutter in fluid situations.
|
|
167
|
+
/// @access private
|
|
168
|
+
/// @group @octaviaflow/grid
|
|
169
|
+
@mixin -no-gutter {
|
|
170
|
+
.#{$prefix}--no-gutter,
|
|
171
|
+
.#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
|
|
172
|
+
padding-inline: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.#{$prefix}--no-gutter--start,
|
|
176
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
|
|
177
|
+
padding-inline-start: 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.#{$prefix}--no-gutter--end,
|
|
181
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
|
|
182
|
+
padding-inline-end: 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// -----------------------------------------------------------------------------
|
|
187
|
+
// Hang
|
|
188
|
+
// -----------------------------------------------------------------------------
|
|
189
|
+
|
|
190
|
+
/// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
|
|
191
|
+
/// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
|
|
192
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
193
|
+
/// @access private
|
|
194
|
+
/// @group @octaviaflow/grid
|
|
195
|
+
@mixin -hang($gutter: $grid-gutter) {
|
|
196
|
+
.#{$prefix}--hang--start {
|
|
197
|
+
padding-inline-start: ($gutter * 0.5);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.#{$prefix}--hang--end {
|
|
201
|
+
padding-inline-end: ($gutter * 0.5);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// -----------------------------------------------------------------------------
|
|
206
|
+
// Grid
|
|
207
|
+
// -----------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
/// Create the container for a grid. Will cause full-bleed for the grid unless
|
|
210
|
+
/// max-width properties are added with `-make-container-max-widths`
|
|
211
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
212
|
+
/// @access private
|
|
213
|
+
/// @group @octaviaflow/grid
|
|
214
|
+
@mixin -make-container($breakpoints: $grid-breakpoints) {
|
|
215
|
+
margin-inline: auto;
|
|
216
|
+
|
|
217
|
+
@include -set-largest-breakpoint();
|
|
218
|
+
|
|
219
|
+
@each $name, $value in $breakpoints {
|
|
220
|
+
$prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
|
|
221
|
+
$margin: map.get($value, margin);
|
|
222
|
+
|
|
223
|
+
@if $prev-breakpoint {
|
|
224
|
+
$prev-margin: map.get($prev-breakpoint, margin);
|
|
225
|
+
@if $prev-margin != $margin {
|
|
226
|
+
@include breakpoint($name) {
|
|
227
|
+
padding-inline: #{($grid-gutter * 0.5) + $margin};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} @else {
|
|
231
|
+
@include breakpoint($name) {
|
|
232
|
+
padding-inline: #{($grid-gutter * 0.5) + $margin};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/// Get the last breakpoint width and set max-width to its value
|
|
239
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
240
|
+
/// @access private
|
|
241
|
+
/// @group @octaviaflow/grid
|
|
242
|
+
@mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
|
|
243
|
+
$largest-breakpoint: last-map-item($breakpoints);
|
|
244
|
+
|
|
245
|
+
max-inline-size: map.get($largest-breakpoint, 'width');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/// Add in the max-widths for each breakpoint to the container
|
|
249
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
250
|
+
/// @access private
|
|
251
|
+
/// @group @octaviaflow/grid
|
|
252
|
+
@mixin -make-container-max-widths($breakpoints: $grid-breakpoints) {
|
|
253
|
+
@each $name, $value in $breakpoints {
|
|
254
|
+
@include breakpoint($name) {
|
|
255
|
+
max-inline-size: map.get($value, width);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/// Generate the CSS for a grid for the given breakpoints and gutters
|
|
261
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
|
|
262
|
+
/// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
|
|
263
|
+
/// @param {Number} $condensed-gutter [$grid-gutter--condensed] - The condensed mode gutter
|
|
264
|
+
/// @access public
|
|
265
|
+
/// @group @octaviaflow/grid
|
|
266
|
+
@mixin grid(
|
|
267
|
+
$breakpoints: $grid-breakpoints,
|
|
268
|
+
$grid-gutter: $grid-gutter,
|
|
269
|
+
$condensed-gutter: $grid-gutter--condensed
|
|
270
|
+
) {
|
|
271
|
+
.#{$prefix}--grid {
|
|
272
|
+
@include -make-container($breakpoints);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@include largest-breakpoint($breakpoints) {
|
|
276
|
+
.#{$prefix}--grid--full-width {
|
|
277
|
+
max-inline-size: 100%;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.#{$prefix}--row {
|
|
282
|
+
@include make-row();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.#{$prefix}--row-padding [class*='#{$prefix}--col'],
|
|
286
|
+
.#{$prefix}--col-padding {
|
|
287
|
+
padding-block: $grid-gutter * 0.5;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
|
|
291
|
+
padding-block: $condensed-gutter * 0.5;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@include -make-grid-columns($breakpoints, $grid-gutter);
|
|
295
|
+
@include -no-gutter();
|
|
296
|
+
@include -hang($grid-gutter);
|
|
297
|
+
}
|