@carbon/grid 10.42.0 → 11.0.0-rc.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 +4 -7
- package/package.json +4 -5
- package/scss/{modules/_breakpoint.scss → _breakpoint.scss} +4 -72
- package/scss/_config.scss +94 -0
- package/scss/_css-grid.scss +470 -0
- package/scss/{modules/_flex-grid.scss → _flex-grid.scss} +28 -59
- package/scss/_inlined/_breakpoint.scss +198 -0
- package/scss/_inlined/_config.scss +94 -0
- package/scss/_inlined/_css-grid.scss +470 -0
- package/scss/{modules/_mixins.scss → _inlined/_flex-grid.scss} +45 -38
- package/scss/_inlined/_mixins.scss +89 -188
- package/scss/_mixins.scss +89 -188
- package/scss/vendor/@carbon/layout/_convert.import.scss +2 -4
- package/scss/vendor/@carbon/layout/_convert.scss +18 -23
- package/scss/vendor/@carbon/layout/_spacing.scss +2 -5
- package/scss/vendor/@carbon/layout/_utilities.scss +4 -4
- package/scss/vendor/@carbon/layout/generated/_container.scss +13 -43
- package/scss/vendor/@carbon/layout/generated/_fluid-spacing.scss +11 -35
- package/scss/vendor/@carbon/layout/generated/_icon-size.scss +8 -17
- package/scss/vendor/@carbon/layout/generated/_size.scss +1 -1
- package/scss/vendor/@carbon/layout/generated/_spacing.scss +29 -107
- package/scss/vendor/@carbon/layout/modules/_convert.scss +2 -4
- package/scss/12.scss +0 -41
- package/scss/_inlined/12.scss +0 -41
- package/scss/_inlined/_mixins.import.scss +0 -431
- package/scss/_inlined/_prefix.scss +0 -12
- package/scss/_mixins.import.scss +0 -431
- package/scss/_prefix.scss +0 -12
- package/scss/grid.scss +0 -10
- package/scss/index.scss +0 -10
- package/scss/modules/_config.scss +0 -18
- package/scss/modules/_css-grid.scss +0 -347
- package/scss/vendor/@carbon/import-once/import-once.scss +0 -27
- package/scss/vendor/@carbon/import-once/index.scss +0 -8
- package/scss/vendor/@carbon/layout/_breakpoint.scss +0 -246
- package/scss/vendor/@carbon/layout/_key-height.import.scss +0 -117
- package/scss/vendor/@carbon/layout/_key-height.scss +0 -111
- package/scss/vendor/@carbon/layout/_mini-unit.scss +0 -23
- package/scss/vendor/@carbon/layout/generated/_layout.scss +0 -97
- package/scss/vendor/@carbon/layout/index.scss +0 -8
- package/scss/vendor/@carbon/layout/layout.scss +0 -12
- package/scss/vendor/@carbon/layout/modules/_spacing.scss +0 -9
- package/scss/vendor/@carbon/layout/modules/_utilities.scss +0 -41
- package/scss/vendor/@carbon/layout/modules/generated/_fluid-spacing.scss +0 -37
- package/scss/vendor/@carbon/layout/modules/generated/_spacing.scss +0 -91
|
@@ -1,347 +0,0 @@
|
|
|
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
|
-
@use 'sass:list';
|
|
9
|
-
@use 'sass:map';
|
|
10
|
-
@use "sass:math";
|
|
11
|
-
@use 'sass:meta';
|
|
12
|
-
@use 'config' as *;
|
|
13
|
-
@use 'breakpoint' as *;
|
|
14
|
-
|
|
15
|
-
@mixin css-grid() {
|
|
16
|
-
display: grid;
|
|
17
|
-
max-width: 99rem;
|
|
18
|
-
padding-right: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
|
|
19
|
-
padding-left: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
|
|
20
|
-
margin-right: auto;
|
|
21
|
-
margin-left: auto;
|
|
22
|
-
column-gap: var(--cds-grid-gutter);
|
|
23
|
-
grid-template-columns: repeat(
|
|
24
|
-
var(--cds-grid-columns),
|
|
25
|
-
minmax(0, var(--cds-grid-column-size))
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@mixin subgrid() {
|
|
30
|
-
display: grid;
|
|
31
|
-
column-gap: var(--cds-grid-gutter);
|
|
32
|
-
grid-template-columns: repeat(
|
|
33
|
-
var(--cds-grid-columns),
|
|
34
|
-
minmax(0, var(--cds-grid-column-size))
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
:root {
|
|
39
|
-
--cds-grid-columns: 4;
|
|
40
|
-
--cds-grid-column-size: 1fr;
|
|
41
|
-
--cds-grid-gutter: 2rem;
|
|
42
|
-
// Used to configure appropriate margins for condensed subgrids inside wide grids
|
|
43
|
-
--cds-grid-gutter-wide: 2rem;
|
|
44
|
-
--cds-grid-hang: 1rem;
|
|
45
|
-
--cds-grid-margin: 0;
|
|
46
|
-
|
|
47
|
-
@include breakpoint(md) {
|
|
48
|
-
--cds-grid-columns: 8;
|
|
49
|
-
--cds-grid-margin: 1rem;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@include breakpoint(lg) {
|
|
53
|
-
--cds-grid-columns: 16;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@include breakpoint(max) {
|
|
57
|
-
--cds-grid-margin: 1.5rem;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.#{$prefix}--css-grid {
|
|
62
|
-
@include css-grid();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.#{$prefix}--css-grid--12 {
|
|
66
|
-
@include css-grid();
|
|
67
|
-
@include breakpoint(lg) {
|
|
68
|
-
--cds-grid-columns: 12;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.#{$prefix}--subgrid {
|
|
73
|
-
@include subgrid();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.#{$prefix}--subgrid[class*='col'] {
|
|
77
|
-
display: grid;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// -----------------------------------------------------------------------------
|
|
81
|
-
// Condensed
|
|
82
|
-
// -----------------------------------------------------------------------------
|
|
83
|
-
.#{$prefix}--css-grid--condensed {
|
|
84
|
-
--cds-grid-gutter: 1px;
|
|
85
|
-
|
|
86
|
-
column-gap: var(--cds-grid-gutter);
|
|
87
|
-
row-gap: var(--cds-grid-gutter);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// condensed subgrid inside wide
|
|
91
|
-
.#{$prefix}--css-grid .bx--subgrid.#{$prefix}--css-grid--condensed {
|
|
92
|
-
margin-right: calc((var(--cds-grid-gutter-wide) / 2) * -1);
|
|
93
|
-
margin-left: calc((var(--cds-grid-gutter-wide) / 2) * -1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// -----------------------------------------------------------------------------
|
|
97
|
-
// No Gutter
|
|
98
|
-
// -----------------------------------------------------------------------------
|
|
99
|
-
.#{$prefix}--css-grid--no-gutter {
|
|
100
|
-
// This is set to 0px (versus 0) so that the calc expression for padding for
|
|
101
|
-
// a grid container works as expected. Without the unit, the calc() will
|
|
102
|
-
// result in a value of 0.
|
|
103
|
-
// stylelint-disable-next-line length-zero-no-unit
|
|
104
|
-
--cds-grid-gutter: 0px;
|
|
105
|
-
|
|
106
|
-
column-gap: var(--cds-grid-gutter);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// -----------------------------------------------------------------------------
|
|
110
|
-
// Full width
|
|
111
|
-
// -----------------------------------------------------------------------------
|
|
112
|
-
.#{$prefix}--css-grid--full-width {
|
|
113
|
-
max-width: 100%;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// -----------------------------------------------------------------------------
|
|
117
|
-
// Column span
|
|
118
|
-
// -----------------------------------------------------------------------------
|
|
119
|
-
@mixin -column-span($i) {
|
|
120
|
-
@if $i == 0 {
|
|
121
|
-
display: none;
|
|
122
|
-
} @else {
|
|
123
|
-
--cds-grid-columns: #{$i};
|
|
124
|
-
|
|
125
|
-
display: block;
|
|
126
|
-
grid-column: span $i / span $i;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@for $i from 0 through 16 {
|
|
131
|
-
.#{$prefix}--col-span-#{$i} {
|
|
132
|
-
@include -column-span($i);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.#{$prefix}--col-span-auto {
|
|
137
|
-
grid-column: auto;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.#{$prefix}--col-span-100 {
|
|
141
|
-
grid-column: 1 / -1;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.#{$prefix}--col-span-25 {
|
|
145
|
-
--cds-grid-columns: 1;
|
|
146
|
-
|
|
147
|
-
grid-column: span 1;
|
|
148
|
-
|
|
149
|
-
@include breakpoint(md) {
|
|
150
|
-
--cds-grid-columns: 2;
|
|
151
|
-
|
|
152
|
-
grid-column: span 2;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@include breakpoint(lg) {
|
|
156
|
-
--cds-grid-columns: 4;
|
|
157
|
-
|
|
158
|
-
grid-column: span 4;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.#{$prefix}--col-span-50 {
|
|
163
|
-
--cds-grid-columns: 2;
|
|
164
|
-
|
|
165
|
-
grid-column: span 2;
|
|
166
|
-
|
|
167
|
-
@include breakpoint(md) {
|
|
168
|
-
--cds-grid-columns: 4;
|
|
169
|
-
|
|
170
|
-
grid-column: span 4;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@include breakpoint(lg) {
|
|
174
|
-
--cds-grid-columns: 8;
|
|
175
|
-
|
|
176
|
-
grid-column: span 8;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.#{$prefix}--col-span-75 {
|
|
181
|
-
--cds-grid-columns: 3;
|
|
182
|
-
|
|
183
|
-
grid-column: span 3;
|
|
184
|
-
|
|
185
|
-
@include breakpoint(md) {
|
|
186
|
-
--cds-grid-columns: 6;
|
|
187
|
-
|
|
188
|
-
grid-column: span 6;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@include breakpoint(lg) {
|
|
192
|
-
--cds-grid-columns: 12;
|
|
193
|
-
|
|
194
|
-
grid-column: span 12;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
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
|
-
|
|
240
|
-
// -----------------------------------------------------------------------------
|
|
241
|
-
// Column offset
|
|
242
|
-
// -----------------------------------------------------------------------------
|
|
243
|
-
@for $i from 1 through 17 {
|
|
244
|
-
.#{$prefix}--col-start-#{$i} {
|
|
245
|
-
grid-column-start: $i;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.#{$prefix}--col-end-#{$i} {
|
|
249
|
-
grid-column-start: $i;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.#{$prefix}--col-start-auto {
|
|
254
|
-
grid-column-start: auto;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.#{$prefix}--col-end-auto {
|
|
258
|
-
grid-column-start: end;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@each $name, $value in $grid-breakpoints {
|
|
262
|
-
$columns: map.get($value, columns);
|
|
263
|
-
|
|
264
|
-
@include breakpoint($name) {
|
|
265
|
-
// The `grid-column-start` property is *not* inclusive.
|
|
266
|
-
// It starts the column *at* the column, not *on* the column. We must
|
|
267
|
-
// ensure that there is one additional class available for each breakpoint.
|
|
268
|
-
@for $i from 1 through $columns + 1 {
|
|
269
|
-
.#{$prefix}--#{$name}\:col-start-#{$i} {
|
|
270
|
-
grid-column-start: $i;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.#{$prefix}--#{$name}\:col-end-#{$i} {
|
|
274
|
-
grid-column-end: $i;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.#{$prefix}--#{$name}\:col-start-auto {
|
|
279
|
-
grid-column-start: auto;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.#{$prefix}--#{$name}\:col-end-auto {
|
|
283
|
-
grid-column-start: end;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// -----------------------------------------------------------------------------
|
|
289
|
-
// Hang
|
|
290
|
-
// -----------------------------------------------------------------------------
|
|
291
|
-
.#{$prefix}--hang {
|
|
292
|
-
padding-left: var(--cds-grid-hang);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// -----------------------------------------------------------------------------
|
|
296
|
-
// Column gutter
|
|
297
|
-
// -----------------------------------------------------------------------------
|
|
298
|
-
.#{$prefix}--gutter {
|
|
299
|
-
padding-right: var(--cds-grid-hang);
|
|
300
|
-
padding-left: var(--cds-grid-hang);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
.#{$prefix}--gutter-start {
|
|
304
|
-
padding-left: var(--cds-grid-hang);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
[dir='rtl'] .#{$prefix}--gutter-start {
|
|
308
|
-
padding-right: var(--cds-grid-hang);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
.#{$prefix}--gutter-end {
|
|
312
|
-
padding-right: var(--cds-grid-hang);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
[dir='rtl'] .#{$prefix}--gutter-end {
|
|
316
|
-
padding-left: var(--cds-grid-hang);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// -----------------------------------------------------------------------------
|
|
320
|
-
// Utilities
|
|
321
|
-
// -----------------------------------------------------------------------------
|
|
322
|
-
|
|
323
|
-
/// Justify items
|
|
324
|
-
.#{$prefix}--justify-items-start {
|
|
325
|
-
justify-items: start;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.#{$prefix}--justify-items-end {
|
|
329
|
-
justify-items: end;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.#{$prefix}--justify-items-center {
|
|
333
|
-
justify-items: center;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/// Align items
|
|
337
|
-
.#{$prefix}--align-items-start {
|
|
338
|
-
align-items: start;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.#{$prefix}--align-items-end {
|
|
342
|
-
align-items: end;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
.#{$prefix}--align-items-center {
|
|
346
|
-
align-items: center;
|
|
347
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
/// Used by `exports` mixin to track which modules have been imported
|
|
9
|
-
/// @type Map
|
|
10
|
-
/// @access public
|
|
11
|
-
/// @group @carbon/import-once
|
|
12
|
-
$imported-modules: () !default;
|
|
13
|
-
|
|
14
|
-
/// Module export mixin that helps making sure a module is imported once and only once
|
|
15
|
-
/// @access public
|
|
16
|
-
/// @param {String} $name - Name of exported module
|
|
17
|
-
/// @param {Bool} $warn [false] - Warn when a module has been already imported
|
|
18
|
-
/// @content Declaration blocks to be imported
|
|
19
|
-
/// @group @carbon/import-once
|
|
20
|
-
@mixin exports($name, $warn: false) {
|
|
21
|
-
@if not(index($imported-modules, $name)) {
|
|
22
|
-
$imported-modules: append($imported-modules, $name) !global;
|
|
23
|
-
@content;
|
|
24
|
-
} @else if $warn == true {
|
|
25
|
-
@warn 'Module `#{$name}` has already been imported.';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
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
|
-
// https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_breakpoints.scss
|
|
9
|
-
@import 'convert';
|
|
10
|
-
@import 'utilities';
|
|
11
|
-
|
|
12
|
-
/// Carbon gutter size in rem
|
|
13
|
-
/// @type Number
|
|
14
|
-
/// @access public
|
|
15
|
-
/// @group @carbon/layout
|
|
16
|
-
$carbon--grid-gutter: carbon--rem(32px);
|
|
17
|
-
|
|
18
|
-
/// Carbon condensed gutter size in rem
|
|
19
|
-
/// @type Number
|
|
20
|
-
/// @access public
|
|
21
|
-
/// @group @carbon/layout
|
|
22
|
-
$carbon--grid-gutter--condensed: carbon--rem(1px);
|
|
23
|
-
|
|
24
|
-
// Initial map of our breakpoints and their values
|
|
25
|
-
/// @type Map
|
|
26
|
-
/// @access public
|
|
27
|
-
/// @group @carbon/layout
|
|
28
|
-
$carbon--grid-breakpoints: (
|
|
29
|
-
sm: (
|
|
30
|
-
columns: 4,
|
|
31
|
-
margin: 0,
|
|
32
|
-
width: carbon--rem(320px),
|
|
33
|
-
),
|
|
34
|
-
md: (
|
|
35
|
-
columns: 8,
|
|
36
|
-
margin: carbon--rem(16px),
|
|
37
|
-
width: carbon--rem(672px),
|
|
38
|
-
),
|
|
39
|
-
lg: (
|
|
40
|
-
columns: 16,
|
|
41
|
-
margin: carbon--rem(16px),
|
|
42
|
-
width: carbon--rem(1056px),
|
|
43
|
-
),
|
|
44
|
-
xlg: (
|
|
45
|
-
columns: 16,
|
|
46
|
-
margin: carbon--rem(16px),
|
|
47
|
-
width: carbon--rem(1312px),
|
|
48
|
-
),
|
|
49
|
-
max: (
|
|
50
|
-
columns: 16,
|
|
51
|
-
margin: carbon--rem(24px),
|
|
52
|
-
width: carbon--rem(1584px),
|
|
53
|
-
),
|
|
54
|
-
) !default;
|
|
55
|
-
|
|
56
|
-
/// Get the value of the next breakpoint, or null for the last breakpoint
|
|
57
|
-
/// @param {String} $name - The name of the breakpoint
|
|
58
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
|
|
59
|
-
/// @param {List} $breakpoint-names [map-keys($breakpoints)] - A list of names from the `$breakpoints` map
|
|
60
|
-
/// @return {String}
|
|
61
|
-
/// @access public
|
|
62
|
-
/// @group @carbon/layout
|
|
63
|
-
@function carbon--breakpoint-next(
|
|
64
|
-
$name,
|
|
65
|
-
$breakpoints: $carbon--grid-breakpoints,
|
|
66
|
-
$breakpoint-names: map-keys($breakpoints)
|
|
67
|
-
) {
|
|
68
|
-
$n: index($breakpoint-names, $name);
|
|
69
|
-
@if $n != null and $n < length($breakpoint-names) {
|
|
70
|
-
@return nth($breakpoint-names, $n + 1);
|
|
71
|
-
}
|
|
72
|
-
@return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/// Get the value of the previous breakpoint, or null for the first breakpoint
|
|
76
|
-
/// @param {String} $name - The name of the breakpoint
|
|
77
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
|
|
78
|
-
/// @param {List} $breakpoint-names [map-keys($breakpoints)] - A list of names from the `$breakpoints` map
|
|
79
|
-
/// @return {String}
|
|
80
|
-
/// @access public
|
|
81
|
-
/// @group @carbon/layout
|
|
82
|
-
@function carbon--breakpoint-prev(
|
|
83
|
-
$name,
|
|
84
|
-
$breakpoints: $carbon--grid-breakpoints,
|
|
85
|
-
$breakpoint-names: map-keys($breakpoints)
|
|
86
|
-
) {
|
|
87
|
-
$n: index($breakpoint-names, $name);
|
|
88
|
-
@if $n != null and $n > 1 {
|
|
89
|
-
@return nth($breakpoint-names, $n - 1);
|
|
90
|
-
}
|
|
91
|
-
@return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/// Check to see if the given breakpoint name
|
|
95
|
-
/// @param {String} $name - The name of the breakpoint
|
|
96
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
|
|
97
|
-
/// @return {Bool}
|
|
98
|
-
/// @access public
|
|
99
|
-
/// @group @carbon/layout
|
|
100
|
-
@function carbon--is-smallest-breakpoint(
|
|
101
|
-
$name,
|
|
102
|
-
$breakpoints: $carbon--grid-breakpoints
|
|
103
|
-
) {
|
|
104
|
-
@return index(map-keys($breakpoints), $name) == 1;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/// Returns the largest breakpoint name
|
|
108
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
109
|
-
/// @return {String}
|
|
110
|
-
/// @access public
|
|
111
|
-
/// @group @carbon/layout
|
|
112
|
-
@function carbon--largest-breakpoint-name(
|
|
113
|
-
$breakpoints: $carbon--grid-breakpoints
|
|
114
|
-
) {
|
|
115
|
-
$total-breakpoints: length($breakpoints);
|
|
116
|
-
@return carbon--key-by-index($breakpoints, $total-breakpoints);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/// Get the infix for a given breakpoint in a list of breakpoints. Useful for generating the size part in a selector, for example: `.prefix--col-sm-2`.
|
|
120
|
-
/// @param {String} $name - The name of the breakpoint
|
|
121
|
-
/// @return {String}
|
|
122
|
-
/// @access public
|
|
123
|
-
/// @group @carbon/layout
|
|
124
|
-
@function carbon--breakpoint-infix($name) {
|
|
125
|
-
@return '-#{$name}';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/// Generate a media query from the width of the given breakpoint to infinity
|
|
129
|
-
/// @param {String | Number} $name
|
|
130
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
131
|
-
/// @content
|
|
132
|
-
/// @access public
|
|
133
|
-
/// @group @carbon/layout
|
|
134
|
-
@mixin carbon--breakpoint-up($name, $breakpoints: $carbon--grid-breakpoints) {
|
|
135
|
-
@if type-of($name) == 'number' {
|
|
136
|
-
@media (min-width: $name) {
|
|
137
|
-
@content;
|
|
138
|
-
}
|
|
139
|
-
} @else if map-has-key($breakpoints, $name) {
|
|
140
|
-
$breakpoint: map-get($breakpoints, $name);
|
|
141
|
-
$width: map-get($breakpoint, width);
|
|
142
|
-
@if carbon--is-smallest-breakpoint($name, $breakpoints) {
|
|
143
|
-
@content;
|
|
144
|
-
} @else {
|
|
145
|
-
@media (min-width: $width) {
|
|
146
|
-
@content;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} @else {
|
|
150
|
-
@error 'Unable to find a breakpoint with name `#{$name}`. Expected one of: (#{map-keys($breakpoints)})';
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/// Generate a media query for the maximum width of the given styles
|
|
155
|
-
/// @param {String | Number} $name
|
|
156
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
157
|
-
/// @content
|
|
158
|
-
/// @access public
|
|
159
|
-
/// @group @carbon/layout
|
|
160
|
-
@mixin carbon--breakpoint-down($name, $breakpoints: $carbon--grid-breakpoints) {
|
|
161
|
-
@if type-of($name) == 'number' {
|
|
162
|
-
@media (max-width: $name) {
|
|
163
|
-
@content;
|
|
164
|
-
}
|
|
165
|
-
} @else if map-has-key($breakpoints, $name) {
|
|
166
|
-
// We borrow this logic from bootstrap for specifying the value of the
|
|
167
|
-
// max-width. The maximum width is calculated by finding the breakpoint and
|
|
168
|
-
// subtracting .02 from its value. This value is used instead of .01 to
|
|
169
|
-
// avoid rounding issues in Safari
|
|
170
|
-
// https://github.com/twbs/bootstrap/blob/c5b1919deaf5393fcca9e9b9d7ce9c338160d99d/scss/mixins/_breakpoints.scss#L34-L46
|
|
171
|
-
$breakpoint: map-get($breakpoints, $name);
|
|
172
|
-
$width: map-get($breakpoint, width) - 0.02;
|
|
173
|
-
@media (max-width: $width) {
|
|
174
|
-
@content;
|
|
175
|
-
}
|
|
176
|
-
} @else {
|
|
177
|
-
@error 'Unable to find a breakpoint with name `#{$name}`. Expected one of: (#{map-keys($breakpoints)})';
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/// Generate a media query for the range between the lower and upper breakpoints
|
|
182
|
-
/// @param {String | Number} $lower
|
|
183
|
-
/// @param {String | Number} $upper
|
|
184
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
185
|
-
/// @content
|
|
186
|
-
/// @access public
|
|
187
|
-
/// @group @carbon/layout
|
|
188
|
-
@mixin carbon--breakpoint-between(
|
|
189
|
-
$lower,
|
|
190
|
-
$upper,
|
|
191
|
-
$breakpoints: $carbon--grid-breakpoints
|
|
192
|
-
) {
|
|
193
|
-
$is-number-lower: type-of($lower) == 'number';
|
|
194
|
-
$is-number-upper: type-of($upper) == 'number';
|
|
195
|
-
$min: if($is-number-lower, $lower, map-get($breakpoints, $lower));
|
|
196
|
-
$max: if($is-number-upper, $upper, map-get($breakpoints, $upper));
|
|
197
|
-
|
|
198
|
-
@if $min and $max {
|
|
199
|
-
$min-width: if(
|
|
200
|
-
not $is-number-lower and $min,
|
|
201
|
-
map-get($min, width) + 0.02,
|
|
202
|
-
$min
|
|
203
|
-
);
|
|
204
|
-
$max-width: if(
|
|
205
|
-
not $is-number-upper and $max,
|
|
206
|
-
map-get($max, width) - 0.02,
|
|
207
|
-
$max
|
|
208
|
-
);
|
|
209
|
-
@media (min-width: $min-width) and (max-width: $max-width) {
|
|
210
|
-
@content;
|
|
211
|
-
}
|
|
212
|
-
} @else if $min != null and $max == null {
|
|
213
|
-
@include carbon--breakpoint-up($lower) {
|
|
214
|
-
@content;
|
|
215
|
-
}
|
|
216
|
-
} @else if $min == null and $max != null {
|
|
217
|
-
@include carbon--breakpoint-down($upper) {
|
|
218
|
-
@content;
|
|
219
|
-
}
|
|
220
|
-
} @else {
|
|
221
|
-
@error 'Unable to find a breakpoint to satisfy: (#{$lower},#{$upper}). Expected both to be one of (#{map-keys($breakpoints)}).';
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/// Generate media query for the largest breakpoint
|
|
226
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
227
|
-
/// @content
|
|
228
|
-
/// @access public
|
|
229
|
-
/// @group @carbon/layout
|
|
230
|
-
@mixin carbon--largest-breakpoint($breakpoints: $carbon--grid-breakpoints) {
|
|
231
|
-
@include carbon--breakpoint(carbon--largest-breakpoint-name()) {
|
|
232
|
-
@content;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/// Generate a media query for a given breakpoint
|
|
237
|
-
/// @param {String | Number} $name
|
|
238
|
-
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
239
|
-
/// @content
|
|
240
|
-
/// @access public
|
|
241
|
-
/// @group @carbon/layout
|
|
242
|
-
@mixin carbon--breakpoint($name, $breakpoints: $carbon--grid-breakpoints) {
|
|
243
|
-
@include carbon--breakpoint-up($name, $breakpoints) {
|
|
244
|
-
@content;
|
|
245
|
-
}
|
|
246
|
-
}
|