@carbon/grid 10.41.0-rc.0 → 10.41.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/index.scss +2 -0
- package/package.json +4 -4
- package/scss/modules/_config.scss +6 -0
- package/scss/modules/_css-grid.scss +43 -122
- package/scss/modules/_flex-grid.scss +374 -0
package/index.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/grid",
|
|
3
3
|
"description": "Grid for digital and software products using the Carbon Design System",
|
|
4
|
-
"version": "10.41.0
|
|
4
|
+
"version": "10.41.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@carbon/import-once": "^10.6.0",
|
|
36
|
-
"@carbon/layout": "^10.36.0
|
|
36
|
+
"@carbon/layout": "^10.36.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@carbon/cli": "^10.33.0
|
|
39
|
+
"@carbon/cli": "^10.33.0",
|
|
40
40
|
"rimraf": "^3.0.0"
|
|
41
41
|
},
|
|
42
42
|
"eyeglass": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"sassDir": "scss",
|
|
46
46
|
"needs": "^1.3.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6a49764a3df2cc3e3b8fce6575f4853d1400e183"
|
|
49
49
|
}
|
|
@@ -77,38 +77,6 @@
|
|
|
77
77
|
display: grid;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// -----------------------------------------------------------------------------
|
|
81
|
-
// Narrow
|
|
82
|
-
// -----------------------------------------------------------------------------
|
|
83
|
-
.#{$prefix}--css-grid--narrow {
|
|
84
|
-
--cds-grid-margin: 1rem;
|
|
85
|
-
|
|
86
|
-
padding-right: var(--cds-grid-margin);
|
|
87
|
-
padding-left: var(--cds-grid-margin);
|
|
88
|
-
|
|
89
|
-
@include breakpoint(md) {
|
|
90
|
-
padding-right: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
|
|
91
|
-
padding-left: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.#{$prefix}--css-grid--narrow > [class*='col'] {
|
|
96
|
-
margin-left: calc(var(--cds-grid-gutter) / 2 * -1);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Narrow subgrid inside wide
|
|
100
|
-
.#{$prefix}--css-grid:not(.#{$prefix}--css-grid--condensed)
|
|
101
|
-
.#{$prefix}--subgrid.#{$prefix}--css-grid--narrow {
|
|
102
|
-
padding: 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Narrow subgrid column inside wide
|
|
106
|
-
.#{$prefix}--css-grid
|
|
107
|
-
.#{$prefix}--subgrid.#{$prefix}--css-grid--narrow
|
|
108
|
-
> [class*='col'] {
|
|
109
|
-
margin-left: calc(var(--cds-grid-gutter) / 2 * -1);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
80
|
// -----------------------------------------------------------------------------
|
|
113
81
|
// Condensed
|
|
114
82
|
// -----------------------------------------------------------------------------
|
|
@@ -120,8 +88,7 @@
|
|
|
120
88
|
}
|
|
121
89
|
|
|
122
90
|
// condensed subgrid inside wide
|
|
123
|
-
.#{$prefix}--css-grid
|
|
124
|
-
.bx--subgrid.#{$prefix}--css-grid--condensed {
|
|
91
|
+
.#{$prefix}--css-grid .bx--subgrid.#{$prefix}--css-grid--condensed {
|
|
125
92
|
margin-right: calc((var(--cds-grid-gutter-wide) / 2) * -1);
|
|
126
93
|
margin-left: calc((var(--cds-grid-gutter-wide) / 2) * -1);
|
|
127
94
|
}
|
|
@@ -174,26 +141,6 @@
|
|
|
174
141
|
grid-column: 1 / -1;
|
|
175
142
|
}
|
|
176
143
|
|
|
177
|
-
@each $name, $value in $grid-breakpoints {
|
|
178
|
-
$columns: map.get($value, columns);
|
|
179
|
-
|
|
180
|
-
@include breakpoint($name) {
|
|
181
|
-
@for $i from 0 through $columns {
|
|
182
|
-
.#{$prefix}--#{$name}\:col-span-#{$i} {
|
|
183
|
-
@include -column-span($i);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.#{$prefix}--#{$name}\:col-span-auto {
|
|
188
|
-
grid-column: auto;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.#{$prefix}--#{$name}\:col-span-100 {
|
|
192
|
-
grid-column: 1 / -1;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
144
|
.#{$prefix}--col-span-25 {
|
|
198
145
|
--cds-grid-columns: 1;
|
|
199
146
|
|
|
@@ -248,6 +195,48 @@
|
|
|
248
195
|
}
|
|
249
196
|
}
|
|
250
197
|
|
|
198
|
+
@each $name, $value in $grid-breakpoints {
|
|
199
|
+
$columns: map.get($value, columns);
|
|
200
|
+
|
|
201
|
+
@include breakpoint($name) {
|
|
202
|
+
@for $i from 0 through $columns {
|
|
203
|
+
.#{$prefix}--#{$name}\:col-span-#{$i} {
|
|
204
|
+
@include -column-span($i);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.#{$prefix}--#{$name}\:col-span-auto {
|
|
209
|
+
grid-column: auto;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.#{$prefix}--#{$name}\:col-span-100 {
|
|
213
|
+
grid-column: 1 / -1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
$quarterGridColumns: math.div($columns, 4);
|
|
217
|
+
|
|
218
|
+
.#{$prefix}--#{$name}\:col-span-75 {
|
|
219
|
+
$calc: $quarterGridColumns * 3;
|
|
220
|
+
--cds-grid-columns: #{$calc};
|
|
221
|
+
|
|
222
|
+
grid-column: span $calc / span $calc;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.#{$prefix}--#{$name}\:col-span-50 {
|
|
226
|
+
$calc: $quarterGridColumns * 2;
|
|
227
|
+
--cds-grid-columns: #{$calc};
|
|
228
|
+
|
|
229
|
+
grid-column: span $calc / span $calc;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.#{$prefix}--#{$name}\:col-span-25 {
|
|
233
|
+
--cds-grid-columns: #{$quarterGridColumns};
|
|
234
|
+
|
|
235
|
+
grid-column: span $quarterGridColumns / span $quarterGridColumns;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
251
240
|
// -----------------------------------------------------------------------------
|
|
252
241
|
// Column offset
|
|
253
242
|
// -----------------------------------------------------------------------------
|
|
@@ -356,71 +345,3 @@
|
|
|
356
345
|
.#{$prefix}--align-items-center {
|
|
357
346
|
align-items: center;
|
|
358
347
|
}
|
|
359
|
-
|
|
360
|
-
// -----------------------------------------------------------------------------
|
|
361
|
-
// Aspect ratio -- TODO: in v11 should this move to a new file to live alongside the AspectRatio component?
|
|
362
|
-
// -----------------------------------------------------------------------------
|
|
363
|
-
|
|
364
|
-
/// The aspect ratios that are used to generate corresponding aspect ratio
|
|
365
|
-
/// classes in code
|
|
366
|
-
/// @type List
|
|
367
|
-
/// @access public
|
|
368
|
-
/// @group @carbon/grid
|
|
369
|
-
$carbon--aspect-ratios: (
|
|
370
|
-
(16, 9),
|
|
371
|
-
(9, 16),
|
|
372
|
-
(2, 1),
|
|
373
|
-
(1, 2),
|
|
374
|
-
(4, 3),
|
|
375
|
-
(3, 4),
|
|
376
|
-
(3, 2),
|
|
377
|
-
(2, 3),
|
|
378
|
-
(1, 1)
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
/// Generates the CSS classname utilities for the aspect ratios
|
|
382
|
-
///
|
|
383
|
-
/// CSS Tricks article on aspect ratios and all the different ways it can be done.
|
|
384
|
-
/// https://css-tricks.com/aspect-ratio-boxes/#article-header-id-6
|
|
385
|
-
///
|
|
386
|
-
/// That article references an earlier article on the topic.
|
|
387
|
-
/// https://keithjgrant.com/posts/2017/03/aspect-ratios/
|
|
388
|
-
///
|
|
389
|
-
/// @param {Number} $width width from an aspect ratio
|
|
390
|
-
/// @param {Number} $height height from an aspect ratio
|
|
391
|
-
/// @access private
|
|
392
|
-
/// @group @carbon/grid
|
|
393
|
-
@mixin carbon--aspect-ratio($aspect-ratios: $carbon--aspect-ratios) {
|
|
394
|
-
.#{$prefix}--aspect-ratio {
|
|
395
|
-
position: relative;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
.#{$prefix}--aspect-ratio::before {
|
|
399
|
-
width: 1px;
|
|
400
|
-
height: 0;
|
|
401
|
-
margin-left: -1px;
|
|
402
|
-
content: '';
|
|
403
|
-
float: left;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
.#{$prefix}--aspect-ratio::after {
|
|
407
|
-
display: table;
|
|
408
|
-
clear: both;
|
|
409
|
-
content: '';
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
@each $aspect-ratio in $aspect-ratios {
|
|
413
|
-
$width: nth($aspect-ratio, 1);
|
|
414
|
-
$height: nth($aspect-ratio, 2);
|
|
415
|
-
|
|
416
|
-
.#{$prefix}--aspect-ratio--#{$width}x#{$height}::before {
|
|
417
|
-
@if meta.function-exists('div', 'math') {
|
|
418
|
-
padding-top: percentage(math.div($height, $width));
|
|
419
|
-
} @else {
|
|
420
|
-
padding-top: percentage(($height / $width));
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
@include carbon--aspect-ratio();
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright IBM Corp. 2018, 2018
|
|
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:meta';
|
|
13
|
+
@use 'sass:math';
|
|
14
|
+
@use 'sass:map';
|
|
15
|
+
|
|
16
|
+
@use 'config' as *;
|
|
17
|
+
@use 'breakpoint' as *;
|
|
18
|
+
|
|
19
|
+
// -----------------------------------------------------------------------------
|
|
20
|
+
// Columns
|
|
21
|
+
// -----------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/// Used to initialize the default properties for a column class, most notably
|
|
24
|
+
/// for setting width and default gutters when a column's breakpoint has not been
|
|
25
|
+
/// hit yet.
|
|
26
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
27
|
+
/// @param {Number} $collapsed-gutter [$grid-gutter--condensed] - The condensed mode gutter
|
|
28
|
+
/// @access private
|
|
29
|
+
/// @group @carbon/grid
|
|
30
|
+
@mixin -make-col-ready(
|
|
31
|
+
$gutter: $grid-gutter,
|
|
32
|
+
$condensed-gutter: $grid-gutter--condensed
|
|
33
|
+
) {
|
|
34
|
+
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
|
35
|
+
// always setting `width: 100%;`. This works because we use `flex` values
|
|
36
|
+
// later on to override this initial width.
|
|
37
|
+
width: 100%;
|
|
38
|
+
padding-right: $gutter * 0.5;
|
|
39
|
+
padding-left: $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-right: $condensed-gutter * 0.5;
|
|
46
|
+
padding-left: $condensed-gutter * 0.5;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// For our narrow use-case, our container hangs 16px into the gutter
|
|
50
|
+
.#{$prefix}--row--narrow &,
|
|
51
|
+
.#{$prefix}--grid--narrow & {
|
|
52
|
+
padding-right: $gutter * 0.5;
|
|
53
|
+
padding-left: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Define the width of the column for a given span and column count.
|
|
58
|
+
/// A width of 0 will hide the column entirely.
|
|
59
|
+
/// @param {Number} $span - The number of columns covered
|
|
60
|
+
/// @param {Number} $columns - The total number of columns available
|
|
61
|
+
/// @access private
|
|
62
|
+
/// @group @carbon/grid
|
|
63
|
+
@mixin -make-col($span, $columns) {
|
|
64
|
+
@if $span == 0 {
|
|
65
|
+
display: none;
|
|
66
|
+
} @else {
|
|
67
|
+
// Explicitly include `display: block` to override
|
|
68
|
+
display: block;
|
|
69
|
+
// Add a `max-width` to ensure content within each column does not blow out
|
|
70
|
+
// the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
|
|
71
|
+
// do not appear to require this.
|
|
72
|
+
@if meta.function-exists('div', 'math') {
|
|
73
|
+
max-width: percentage(math.div($span, $columns));
|
|
74
|
+
flex: 0 0 percentage(math.div($span, $columns));
|
|
75
|
+
} @else {
|
|
76
|
+
max-width: percentage(($span / $columns));
|
|
77
|
+
flex: 0 0 percentage(($span / $columns));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Create a column offset for a given span and column count.
|
|
83
|
+
/// @param {Number} $span - The number of columns the offset should cover
|
|
84
|
+
/// @param {Number} $columns - The total number of columns available
|
|
85
|
+
/// @access private
|
|
86
|
+
/// @group @carbon/grid
|
|
87
|
+
@mixin -make-col-offset($span, $columns) {
|
|
88
|
+
$offset: 0;
|
|
89
|
+
@if meta.function-exists('div', 'math') {
|
|
90
|
+
$offset: math.div($span, $columns);
|
|
91
|
+
} @else {
|
|
92
|
+
$offset: ($span / $columns);
|
|
93
|
+
}
|
|
94
|
+
@if $offset == 0 {
|
|
95
|
+
margin-left: 0;
|
|
96
|
+
} @else {
|
|
97
|
+
margin-left: percentage($offset);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// Output the CSS required for all the columns in a given grid system.
|
|
102
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The breakpoints in the grid system
|
|
103
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
104
|
+
/// @access private
|
|
105
|
+
/// @group @carbon/grid
|
|
106
|
+
@mixin -make-grid-columns(
|
|
107
|
+
$breakpoints: $grid-breakpoints,
|
|
108
|
+
$gutter: $grid-gutter
|
|
109
|
+
) {
|
|
110
|
+
.#{$prefix}--col {
|
|
111
|
+
@include -make-col-ready($gutter);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@each $breakpoint in map-keys($breakpoints) {
|
|
115
|
+
$infix: breakpoint-infix($breakpoint);
|
|
116
|
+
$columns: map-get(map-get($breakpoints, $breakpoint), columns);
|
|
117
|
+
|
|
118
|
+
// Allow columns to stretch full width below their breakpoints
|
|
119
|
+
@for $i from 0 through $columns {
|
|
120
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
121
|
+
@include -make-col-ready($gutter);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.#{$prefix}--col#{$infix},
|
|
126
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
127
|
+
@include -make-col-ready($gutter);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@include breakpoint($breakpoint, $breakpoints) {
|
|
131
|
+
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
|
132
|
+
.#{$prefix}--col,
|
|
133
|
+
.#{$prefix}--col#{$infix} {
|
|
134
|
+
max-width: 100%;
|
|
135
|
+
flex-basis: 0;
|
|
136
|
+
flex-grow: 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.#{$prefix}--col--auto,
|
|
140
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
141
|
+
width: auto;
|
|
142
|
+
// Reset earlier grid tiers
|
|
143
|
+
max-width: 100%;
|
|
144
|
+
flex: 1 0 0%;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@for $i from 0 through $columns {
|
|
148
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
149
|
+
@include -make-col($i, $columns);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@for $i from 0 through ($columns - 1) {
|
|
154
|
+
@if not($infix == '') {
|
|
155
|
+
.#{$prefix}--offset#{$infix}-#{$i} {
|
|
156
|
+
@include -make-col-offset($i, $columns);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// -----------------------------------------------------------------------------
|
|
165
|
+
// Rows
|
|
166
|
+
// -----------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
/// Define the properties for a selector assigned to a row in the grid system.
|
|
169
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
170
|
+
/// @access private
|
|
171
|
+
/// @group @carbon/grid
|
|
172
|
+
@mixin -make-row($gutter: $grid-gutter) {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-wrap: wrap;
|
|
175
|
+
margin-right: -1 * $gutter * 0.5;
|
|
176
|
+
margin-left: -1 * $gutter * 0.5;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// -----------------------------------------------------------------------------
|
|
180
|
+
// No gutter
|
|
181
|
+
// -----------------------------------------------------------------------------
|
|
182
|
+
|
|
183
|
+
/// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
|
|
184
|
+
/// classes are useful for dropping the gutter in fluid situations.
|
|
185
|
+
/// @access private
|
|
186
|
+
/// @group @carbon/grid
|
|
187
|
+
@mixin -no-gutter {
|
|
188
|
+
.#{$prefix}--no-gutter,
|
|
189
|
+
.#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
|
|
190
|
+
padding-right: 0;
|
|
191
|
+
padding-left: 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.#{$prefix}--no-gutter--start,
|
|
195
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
|
|
196
|
+
padding-left: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.#{$prefix}--no-gutter--end,
|
|
200
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
|
|
201
|
+
padding-right: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Deprecated ☠️
|
|
205
|
+
.#{$prefix}--no-gutter--left,
|
|
206
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
|
|
207
|
+
padding-left: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.#{$prefix}--no-gutter--right,
|
|
211
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
|
|
212
|
+
padding-right: 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// -----------------------------------------------------------------------------
|
|
217
|
+
// Hang
|
|
218
|
+
// -----------------------------------------------------------------------------
|
|
219
|
+
|
|
220
|
+
/// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
|
|
221
|
+
/// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
|
|
222
|
+
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
223
|
+
/// @access private
|
|
224
|
+
/// @group @carbon/grid
|
|
225
|
+
@mixin -hang($gutter: $grid-gutter) {
|
|
226
|
+
.#{$prefix}--hang--start {
|
|
227
|
+
padding-left: $gutter * 0.5;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.#{$prefix}--hang--end {
|
|
231
|
+
padding-right: $gutter * 0.5;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Deprecated ☠️
|
|
235
|
+
.#{$prefix}--hang--left {
|
|
236
|
+
padding-left: $gutter * 0.5;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.#{$prefix}--hang--right {
|
|
240
|
+
padding-right: $gutter * 0.5;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// -----------------------------------------------------------------------------
|
|
245
|
+
// Grid
|
|
246
|
+
// -----------------------------------------------------------------------------
|
|
247
|
+
|
|
248
|
+
/// Create the container for a grid. Will cause full-bleed for the grid unless
|
|
249
|
+
/// max-width properties are added with `make-container-max-widths`
|
|
250
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
251
|
+
/// @access private
|
|
252
|
+
/// @group @carbon/grid
|
|
253
|
+
@mixin -make-container($breakpoints: $grid-breakpoints) {
|
|
254
|
+
margin-right: auto;
|
|
255
|
+
margin-left: auto;
|
|
256
|
+
|
|
257
|
+
@include -set-largest-breakpoint();
|
|
258
|
+
|
|
259
|
+
@each $name, $value in $breakpoints {
|
|
260
|
+
$prev-breakpoint: map-get($breakpoints, breakpoint-prev($name));
|
|
261
|
+
$margin: map-get($value, margin);
|
|
262
|
+
|
|
263
|
+
@if $prev-breakpoint {
|
|
264
|
+
$prev-margin: map-get($prev-breakpoint, margin);
|
|
265
|
+
@if $prev-margin != $margin {
|
|
266
|
+
@include breakpoint($name) {
|
|
267
|
+
padding-right: #{($grid-gutter * 0.5) + $margin};
|
|
268
|
+
padding-left: #{($grid-gutter * 0.5) + $margin};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
} @else {
|
|
272
|
+
@include breakpoint($name) {
|
|
273
|
+
padding-right: #{($grid-gutter * 0.5) + $margin};
|
|
274
|
+
padding-left: #{($grid-gutter * 0.5) + $margin};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/// Get the last breakpoint width and set max-width to its value
|
|
281
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
282
|
+
/// @access private
|
|
283
|
+
/// @group @carbon/grid
|
|
284
|
+
@mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
|
|
285
|
+
$largest-breakpoint: last-map-item($breakpoints);
|
|
286
|
+
|
|
287
|
+
max-width: map-get($largest-breakpoint, 'width');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// Add in the max-widths for each breakpoint to the container
|
|
291
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
292
|
+
/// @access private
|
|
293
|
+
/// @group @carbon/grid
|
|
294
|
+
@mixin -make-container-max-widths($breakpoints: $grid-breakpoints) {
|
|
295
|
+
@each $name, $value in $breakpoints {
|
|
296
|
+
@include breakpoint($name) {
|
|
297
|
+
max-width: map-get($value, width);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/// Generate the CSS for a grid for the given breakpoints and gutters
|
|
303
|
+
/// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
|
|
304
|
+
/// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
|
|
305
|
+
/// @param {Number} $condensed-gutter [$grid-gutter--condensed] - The condensed mode gutter
|
|
306
|
+
/// @access public
|
|
307
|
+
/// @group @carbon/grid
|
|
308
|
+
@mixin flex-grid(
|
|
309
|
+
$breakpoints: $grid-breakpoints,
|
|
310
|
+
$grid-gutter: $grid-gutter,
|
|
311
|
+
$condensed-gutter: $grid-gutter--condensed
|
|
312
|
+
) {
|
|
313
|
+
.#{$prefix}--grid {
|
|
314
|
+
@include -make-container($breakpoints);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@include largest-breakpoint($breakpoints) {
|
|
318
|
+
.#{$prefix}--grid--full-width {
|
|
319
|
+
max-width: 100%;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.#{$prefix}--row {
|
|
324
|
+
@include -make-row();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.#{$prefix}--row-padding [class*='#{$prefix}--col'],
|
|
328
|
+
.#{$prefix}--col-padding {
|
|
329
|
+
padding-top: $grid-gutter * 0.5;
|
|
330
|
+
padding-bottom: $grid-gutter * 0.5;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
|
|
334
|
+
padding-top: $condensed-gutter * 0.5;
|
|
335
|
+
padding-bottom: $condensed-gutter * 0.5;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
@include -make-grid-columns($breakpoints, $grid-gutter);
|
|
339
|
+
@include -no-gutter();
|
|
340
|
+
@include -hang($grid-gutter);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@if $flex-grid-columns == 12 {
|
|
344
|
+
$flex-12-column-grid: map-merge(
|
|
345
|
+
$grid-breakpoints,
|
|
346
|
+
(
|
|
347
|
+
lg:
|
|
348
|
+
map-merge(
|
|
349
|
+
map-get($grid-breakpoints, lg),
|
|
350
|
+
(
|
|
351
|
+
columns: 12,
|
|
352
|
+
)
|
|
353
|
+
),
|
|
354
|
+
xlg:
|
|
355
|
+
map-merge(
|
|
356
|
+
map-get($grid-breakpoints, xlg),
|
|
357
|
+
(
|
|
358
|
+
columns: 12,
|
|
359
|
+
)
|
|
360
|
+
),
|
|
361
|
+
max:
|
|
362
|
+
map-merge(
|
|
363
|
+
map-get($grid-breakpoints, max),
|
|
364
|
+
(
|
|
365
|
+
columns: 12,
|
|
366
|
+
)
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
@include flex-grid($breakpoints: $flex-12-column-grid);
|
|
372
|
+
} @else {
|
|
373
|
+
@include flex-grid();
|
|
374
|
+
}
|