@carbon/type 10.44.0 → 11.1.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/README.md +3 -7
- package/index.scss +7 -7
- package/package.json +6 -6
- package/scss/_classes.scss +8 -7
- package/scss/{modules/_default-type.scss → _default-type.scss} +2 -8
- package/scss/_font-family.scss +51 -17
- package/scss/_inlined/_classes.scss +8 -7
- package/scss/_inlined/_default-type.scss +49 -0
- package/scss/_inlined/_font-family.scss +51 -17
- package/scss/_inlined/_reset.scss +11 -59
- package/scss/_inlined/_scale.scss +13 -15
- package/scss/_inlined/_styles.scss +146 -214
- package/scss/_reset.scss +11 -59
- package/scss/_scale.scss +13 -15
- package/scss/_styles.scss +146 -214
- package/scss/vendor/@carbon/grid/{modules/_breakpoint.scss → _breakpoint.scss} +1 -1
- package/scss/vendor/@carbon/grid/{modules/_config.scss → _config.scss} +1 -1
- package/scss/vendor/@carbon/grid/{modules/_css-grid.scss → _css-grid.scss} +0 -0
- package/scss/vendor/@carbon/grid/{modules/_flex-grid.scss → _flex-grid.scss} +0 -20
- package/scss/vendor/@carbon/grid/_inlined/_breakpoint.scss +198 -0
- package/scss/vendor/@carbon/grid/_inlined/_config.scss +94 -0
- package/scss/vendor/@carbon/grid/_inlined/_css-grid.scss +470 -0
- package/scss/vendor/@carbon/grid/{modules/_mixins.scss → _inlined/_flex-grid.scss} +45 -38
- package/scss/vendor/@carbon/grid/_inlined/_mixins.scss +89 -188
- package/scss/vendor/@carbon/grid/_mixins.scss +89 -188
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_convert.import.scss +2 -4
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_convert.scss +18 -23
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_spacing.scss +2 -5
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_utilities.scss +4 -4
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_container.scss +13 -43
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_fluid-spacing.scss +11 -35
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_icon-size.scss +8 -17
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_size.scss +1 -1
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_spacing.scss +29 -107
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_convert.scss +2 -4
- package/scss/_inlined/_styles.import.scss +0 -766
- package/scss/_inlined/font-face/_mono.scss +0 -1166
- package/scss/_inlined/font-face/_sans-condensed.scss +0 -1009
- package/scss/_inlined/font-face/_sans.scss +0 -1326
- package/scss/_inlined/font-face/_serif.scss +0 -1166
- package/scss/_inlined/font-face/_settings.scss +0 -12
- package/scss/_styles.import.scss +0 -766
- package/scss/font-face/_mono.scss +0 -1166
- package/scss/font-face/_sans-condensed.scss +0 -1009
- package/scss/font-face/_sans.scss +0 -1326
- package/scss/font-face/_serif.scss +0 -1166
- package/scss/font-face/_settings.scss +0 -12
- package/scss/index.scss +0 -8
- package/scss/modules/_classes.scss +0 -42
- package/scss/modules/_font-family.scss +0 -104
- package/scss/modules/_prefix.scss +0 -11
- package/scss/modules/_reset.scss +0 -44
- package/scss/modules/_scale.scss +0 -57
- package/scss/modules/_styles.scss +0 -876
- package/scss/type.scss +0 -8
- package/scss/vendor/@carbon/grid/12.scss +0 -41
- package/scss/vendor/@carbon/grid/_inlined/12.scss +0 -41
- package/scss/vendor/@carbon/grid/_inlined/_mixins.import.scss +0 -431
- package/scss/vendor/@carbon/grid/_inlined/_prefix.scss +0 -12
- package/scss/vendor/@carbon/grid/_mixins.import.scss +0 -431
- package/scss/vendor/@carbon/grid/_prefix.scss +0 -12
- package/scss/vendor/@carbon/grid/grid.scss +0 -10
- package/scss/vendor/@carbon/grid/index.scss +0 -10
- package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/import-once.scss +0 -27
- package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/index.scss +0 -8
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_breakpoint.scss +0 -246
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_key-height.import.scss +0 -117
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_key-height.scss +0 -111
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_mini-unit.scss +0 -23
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_layout.scss +0 -97
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/index.scss +0 -8
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/layout.scss +0 -12
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_spacing.scss +0 -9
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_utilities.scss +0 -41
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/generated/_fluid-spacing.scss +0 -37
- package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/generated/_spacing.scss +0 -91
- package/scss/vendor/@carbon/import-once/import-once.scss +0 -27
- package/scss/vendor/@carbon/import-once/index.scss +0 -8
|
@@ -0,0 +1,470 @@
|
|
|
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
|
+
/// Emit all the styles related to the CSS Grid, these include:
|
|
16
|
+
/// - The base grid class
|
|
17
|
+
/// - The various grid modes
|
|
18
|
+
/// - The ability to specifiy column span
|
|
19
|
+
/// - The ability to specifiy column start,end position
|
|
20
|
+
/// - Support for subgrid
|
|
21
|
+
/// - Support for hanging content on a grid column
|
|
22
|
+
/// - Support for controlling grid gutter on a cell basis
|
|
23
|
+
/// - Support for specifying content alignment
|
|
24
|
+
///
|
|
25
|
+
///
|
|
26
|
+
/// In general, this mixin is structured in a way to emit the fewest CSS styles
|
|
27
|
+
/// as possible. To do this, we will (as much as possible) not emit a value if
|
|
28
|
+
/// one is already defined at a previous breakpoint.
|
|
29
|
+
///
|
|
30
|
+
/// In addition, this mixin will break down emitting styles into several stages:
|
|
31
|
+
/// 1. Emit styles for the smallest breakpoint without any breakpoint. By
|
|
32
|
+
/// default, these styles will be on
|
|
33
|
+
/// 2. For every other breakpoint, wrap it in a breakpoint so that it only is
|
|
34
|
+
/// triggered when that breakpoint is applied
|
|
35
|
+
/// 3. In situations where it is appropriate, we also will emit "unconditional"
|
|
36
|
+
/// selectors that will always apply. For example, if you wanted a column to
|
|
37
|
+
/// always span four columns
|
|
38
|
+
@mixin css-grid($breakpoints: $grid-breakpoints) {
|
|
39
|
+
/// The :root selector is responsible for setting several top-level CSS Custom
|
|
40
|
+
/// Properties, including the overall grid gutter, grid column count, and grid
|
|
41
|
+
/// margin
|
|
42
|
+
:root {
|
|
43
|
+
--cds-grid-gutter: #{$grid-gutter};
|
|
44
|
+
|
|
45
|
+
// Iterate through the grid breakpoints and only emit the grid-columns and
|
|
46
|
+
// grid-margin CSS Custom Properties if they've changed from the previous
|
|
47
|
+
// breakpoint. By default, we emit the smallest breakpoint values on the
|
|
48
|
+
// :root selector
|
|
49
|
+
@each $key, $value in $breakpoints {
|
|
50
|
+
@if is-smallest-breakpoint($key, $breakpoints) {
|
|
51
|
+
--cds-grid-columns: #{get-column-count($breakpoints, $key)};
|
|
52
|
+
--cds-grid-margin: #{get-margin($breakpoints, $key)};
|
|
53
|
+
} @else {
|
|
54
|
+
$previous-breakpoint: breakpoint-prev($key, $breakpoints);
|
|
55
|
+
$changes: ();
|
|
56
|
+
|
|
57
|
+
@if get-column-count($breakpoints, $key) !=
|
|
58
|
+
get-column-count($breakpoints, $previous-breakpoint)
|
|
59
|
+
{
|
|
60
|
+
$changes: map.set(
|
|
61
|
+
$changes,
|
|
62
|
+
grid-columns,
|
|
63
|
+
get-column-count($breakpoints, $key)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@if get-margin($breakpoints, $key) !=
|
|
68
|
+
get-margin($breakpoints, $previous-breakpoint)
|
|
69
|
+
{
|
|
70
|
+
$changes: map.set(
|
|
71
|
+
$changes,
|
|
72
|
+
grid-margin,
|
|
73
|
+
get-margin($breakpoints, $key)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@include breakpoint($key) {
|
|
78
|
+
@each $name, $value in $changes {
|
|
79
|
+
--cds-#{$name}: #{$value};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// -----------------------------------------------------------------------------
|
|
87
|
+
// Base CSS Grid
|
|
88
|
+
// -----------------------------------------------------------------------------
|
|
89
|
+
.#{$prefix}--css-grid {
|
|
90
|
+
--cds-grid-gutter-start: calc(var(--cds-grid-gutter) / 2);
|
|
91
|
+
--cds-grid-gutter-end: calc(var(--cds-grid-gutter) / 2);
|
|
92
|
+
// We split out a separate "column hang" since "gutter-start" is set
|
|
93
|
+
// dynamically and could be 0
|
|
94
|
+
--cds-grid-column-hang: calc(var(--cds-grid-gutter) / 2);
|
|
95
|
+
|
|
96
|
+
display: grid;
|
|
97
|
+
max-width: get-grid-width(
|
|
98
|
+
$breakpoints,
|
|
99
|
+
largest-breakpoint-name($breakpoints)
|
|
100
|
+
);
|
|
101
|
+
padding-right: var(--cds-grid-margin);
|
|
102
|
+
padding-left: var(--cds-grid-margin);
|
|
103
|
+
margin-right: auto;
|
|
104
|
+
margin-left: auto;
|
|
105
|
+
grid-template-columns: repeat(var(--cds-grid-columns), minmax(0, 1fr));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// -----------------------------------------------------------------------------
|
|
109
|
+
// Full width
|
|
110
|
+
// -----------------------------------------------------------------------------
|
|
111
|
+
.#{$prefix}--css-grid--full-width {
|
|
112
|
+
max-width: 100%;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// -----------------------------------------------------------------------------
|
|
116
|
+
// Column
|
|
117
|
+
// -----------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
// Add gutter to columns in a CSS Grid. Unfortunately, we cannot use
|
|
120
|
+
// `grid-gap`, `column-gap`, etc. as we need to conditionally remove leading
|
|
121
|
+
// and trailing gutter from a column.
|
|
122
|
+
.#{$prefix}--css-grid-column {
|
|
123
|
+
// grid-mode-start, grid-mode-end are meant to capture the "grid settings"
|
|
124
|
+
// so that subgrids can correctly fit in parent grids by reverting the
|
|
125
|
+
// grid's outer padding
|
|
126
|
+
--cds-grid-mode-start: var(--cds-grid-gutter-start);
|
|
127
|
+
--cds-grid-mode-end: var(--cds-grid-gutter-end);
|
|
128
|
+
|
|
129
|
+
margin-right: var(--cds-grid-gutter-end);
|
|
130
|
+
margin-left: var(--cds-grid-gutter-start);
|
|
131
|
+
|
|
132
|
+
[dir='rtl'] & {
|
|
133
|
+
margin-right: var(--cds-grid-gutter-start);
|
|
134
|
+
margin-left: var(--cds-grid-gutter-end);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// -----------------------------------------------------------------------------
|
|
139
|
+
// Grid modes
|
|
140
|
+
// -----------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
// Narrow
|
|
143
|
+
.#{$prefix}--css-grid--narrow {
|
|
144
|
+
--cds-grid-gutter-start: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Condensed
|
|
148
|
+
.#{$prefix}--css-grid--condensed {
|
|
149
|
+
--cds-grid-gutter: #{$grid-gutter-condensed};
|
|
150
|
+
--cds-grid-column-hang: #{math.div($grid-gutter, 2) -
|
|
151
|
+
math.div($grid-gutter-condensed, 2)};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// -----------------------------------------------------------------------------
|
|
155
|
+
// Subgrid
|
|
156
|
+
// -----------------------------------------------------------------------------
|
|
157
|
+
.#{$prefix}--subgrid {
|
|
158
|
+
display: grid;
|
|
159
|
+
margin-right: calc(var(--cds-grid-mode-end) * -1);
|
|
160
|
+
margin-left: calc(var(--cds-grid-mode-start) * -1);
|
|
161
|
+
grid-template-columns: repeat(var(--cds-grid-columns), minmax(0, 1fr));
|
|
162
|
+
|
|
163
|
+
[dir='rtl'] & {
|
|
164
|
+
margin-right: calc(var(--cds-grid-mode-start) * -1);
|
|
165
|
+
margin-left: calc(var(--cds-grid-mode-end) * -1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Support the grid modes in subgrids
|
|
170
|
+
.#{$prefix}--subgrid--wide {
|
|
171
|
+
--cds-grid-gutter-start: #{math.div($grid-gutter, 2)};
|
|
172
|
+
--cds-grid-gutter-end: #{math.div($grid-gutter, 2)};
|
|
173
|
+
--cds-grid-column-hang: 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.#{$prefix}--subgrid--narrow {
|
|
177
|
+
--cds-grid-gutter-start: 0;
|
|
178
|
+
--cds-grid-gutter-end: #{math.div($grid-gutter, 2)};
|
|
179
|
+
--cds-grid-column-hang: #{math.div($grid-gutter, 2)};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.#{$prefix}--subgrid--condensed {
|
|
183
|
+
--cds-grid-gutter-start: #{math.div($grid-gutter-condensed, 2)};
|
|
184
|
+
--cds-grid-gutter-end: #{math.div($grid-gutter-condensed, 2)};
|
|
185
|
+
--cds-grid-column-hang: #{math.div($grid-gutter, 2) -
|
|
186
|
+
math.div($grid-gutter-condensed, 2)};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// -----------------------------------------------------------------------------
|
|
190
|
+
// Column hang
|
|
191
|
+
// -----------------------------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
// Helper class to allow for text alignment in columns where the leading
|
|
194
|
+
// gutter is missing (like narrow) or is reduced (like in condensed).
|
|
195
|
+
.#{$prefix}--grid-column-hang {
|
|
196
|
+
margin-left: var(--cds-grid-column-hang);
|
|
197
|
+
|
|
198
|
+
[dir='rtl'] & {
|
|
199
|
+
margin-right: var(--cds-grid-column-hang);
|
|
200
|
+
margin-left: initial;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// -----------------------------------------------------------------------------
|
|
205
|
+
// Column span
|
|
206
|
+
// -----------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
// Generate col-span-{0-16} classes which unconditionally set column span
|
|
209
|
+
// regardless of breakpoint
|
|
210
|
+
@for $i from 0 through get-grid-columns($breakpoints) {
|
|
211
|
+
.#{$prefix}--col-span-#{$i} {
|
|
212
|
+
@include -column-span($i);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Responsive column span
|
|
217
|
+
@each $name, $value in $breakpoints {
|
|
218
|
+
// Column span per breakpoint
|
|
219
|
+
@for $i from 0 through get-column-count($breakpoints, $name) {
|
|
220
|
+
@if is-smallest-breakpoint($name, $breakpoints) {
|
|
221
|
+
.#{$prefix}--#{$name}\:col-span-#{$i} {
|
|
222
|
+
@include -column-span($i);
|
|
223
|
+
}
|
|
224
|
+
} @else {
|
|
225
|
+
@include breakpoint($name) {
|
|
226
|
+
.#{$prefix}--#{$name}\:col-span-#{$i} {
|
|
227
|
+
@include -column-span($i);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Percent column span per breakpoint
|
|
234
|
+
@if is-smallest-breakpoint($name, $breakpoints) {
|
|
235
|
+
.#{$prefix}--#{$name}\:col-span-auto {
|
|
236
|
+
grid-column: auto;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.#{$prefix}--#{$name}\:col-span-100 {
|
|
240
|
+
grid-column: 1 / -1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
$columns: get-column-count($breakpoints, $name);
|
|
244
|
+
|
|
245
|
+
.#{$prefix}--#{$name}\:col-span-75 {
|
|
246
|
+
$span: $columns * 0.75;
|
|
247
|
+
--cds-grid-columns: #{$span};
|
|
248
|
+
|
|
249
|
+
grid-column: span #{$span} / span #{$span};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.#{$prefix}--#{$name}\:col-span-50 {
|
|
253
|
+
$span: $columns * 0.5;
|
|
254
|
+
--cds-grid-columns: #{$span};
|
|
255
|
+
|
|
256
|
+
grid-column: span #{$span} / span #{$span};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.#{$prefix}--#{$name}\:col-span-25 {
|
|
260
|
+
$span: $columns * 0.25;
|
|
261
|
+
--cds-grid-columns: #{$span};
|
|
262
|
+
|
|
263
|
+
grid-column: span #{$span} / span #{$span};
|
|
264
|
+
}
|
|
265
|
+
} @else {
|
|
266
|
+
@include breakpoint($name) {
|
|
267
|
+
.#{$prefix}--#{$name}\:col-span-auto {
|
|
268
|
+
grid-column: auto;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.#{$prefix}--#{$name}\:col-span-100 {
|
|
272
|
+
grid-column: 1 / -1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
$columns: get-column-count($breakpoints, $name);
|
|
276
|
+
|
|
277
|
+
.#{$prefix}--#{$name}\:col-span-75 {
|
|
278
|
+
$span: $columns * 0.75;
|
|
279
|
+
--cds-grid-columns: #{$span};
|
|
280
|
+
|
|
281
|
+
grid-column: span #{$span} / span #{$span};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.#{$prefix}--#{$name}\:col-span-50 {
|
|
285
|
+
$span: $columns * 0.5;
|
|
286
|
+
--cds-grid-columns: #{$span};
|
|
287
|
+
|
|
288
|
+
grid-column: span #{$span} / span #{$span};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.#{$prefix}--#{$name}\:col-span-25 {
|
|
292
|
+
$span: $columns * 0.25;
|
|
293
|
+
--cds-grid-columns: #{$span};
|
|
294
|
+
|
|
295
|
+
grid-column: span #{$span} / span #{$span};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// -----------------------------------------------------------------------------
|
|
302
|
+
// Column percent span
|
|
303
|
+
// -----------------------------------------------------------------------------
|
|
304
|
+
.#{$prefix}--col-span-auto {
|
|
305
|
+
grid-column: auto;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.#{$prefix}--col-span-100 {
|
|
309
|
+
grid-column: 1 / -1;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.#{$prefix}--col-span-75 {
|
|
313
|
+
@include -percent-column-span($breakpoints, 0.75);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.#{$prefix}--col-span-50 {
|
|
317
|
+
@include -percent-column-span($breakpoints, 0.5);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.#{$prefix}--col-span-25 {
|
|
321
|
+
@include -percent-column-span($breakpoints, 0.25);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// -----------------------------------------------------------------------------
|
|
325
|
+
// Column offset
|
|
326
|
+
// -----------------------------------------------------------------------------
|
|
327
|
+
// Unconditional column start
|
|
328
|
+
// Note: we start at 1 and end at column-count to match grid lines. We do not
|
|
329
|
+
// start at column-count + 1 since starting at the end of the grid would mean
|
|
330
|
+
// a column would have no width available
|
|
331
|
+
@for $i from 1 through get-grid-columns($breakpoints) {
|
|
332
|
+
.#{$prefix}--col-start-#{$i} {
|
|
333
|
+
grid-column-start: $i;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Unconditional column end
|
|
338
|
+
// Note: we start at 2 since a column ending at line 1 would have no width. We
|
|
339
|
+
// end at column-count + 1 since grid lines start at 1
|
|
340
|
+
@for $i from 2 through get-grid-columns($breakpoints) + 1 {
|
|
341
|
+
.#{$prefix}--col-end-#{$i} {
|
|
342
|
+
grid-column-end: $i;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.#{$prefix}--col-start-auto {
|
|
347
|
+
grid-column-start: auto;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.#{$prefix}--col-end-auto {
|
|
351
|
+
grid-column-end: auto;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Responsive column start, end
|
|
355
|
+
@each $name, $value in $breakpoints {
|
|
356
|
+
@if is-smallest-breakpoint($name, $breakpoints) {
|
|
357
|
+
// Responsive column start
|
|
358
|
+
@for $i from 1 through get-grid-columns($breakpoints) {
|
|
359
|
+
.#{$prefix}--#{$name}\:col-start-#{$i} {
|
|
360
|
+
grid-column-start: $i;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Responsive column end
|
|
365
|
+
@for $i from 2 through get-grid-columns($breakpoints) + 1 {
|
|
366
|
+
.#{$prefix}--#{$name}\:col-end-#{$i} {
|
|
367
|
+
grid-column-end: $i;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.#{$prefix}--#{$name}\:col-start-auto {
|
|
372
|
+
grid-column-start: auto;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.#{$prefix}--#{$name}\:col-end-auto {
|
|
376
|
+
grid-column-end: auto;
|
|
377
|
+
}
|
|
378
|
+
} @else {
|
|
379
|
+
@include breakpoint($name) {
|
|
380
|
+
// Responsive column start
|
|
381
|
+
@for $i from 1 through get-grid-columns($breakpoints) {
|
|
382
|
+
.#{$prefix}--#{$name}\:col-start-#{$i} {
|
|
383
|
+
grid-column-start: $i;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Responsive column end
|
|
388
|
+
@for $i from 2 through get-grid-columns($breakpoints) + 1 {
|
|
389
|
+
.#{$prefix}--#{$name}\:col-end-#{$i} {
|
|
390
|
+
grid-column-end: $i;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.#{$prefix}--#{$name}\:col-start-auto {
|
|
395
|
+
grid-column-start: auto;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.#{$prefix}--#{$name}\:col-end-auto {
|
|
399
|
+
grid-column-end: auto;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/// Generate the styles for a grid column
|
|
407
|
+
@mixin -column-span($i) {
|
|
408
|
+
@if $i == 0 {
|
|
409
|
+
display: none;
|
|
410
|
+
} @else {
|
|
411
|
+
--cds-grid-columns: #{$i};
|
|
412
|
+
|
|
413
|
+
display: block;
|
|
414
|
+
grid-column: span $i / span $i;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/// Generate the styles for an unconditional class that represents a percent
|
|
419
|
+
/// span of a grid
|
|
420
|
+
@mixin -percent-column-span($breakpoints, $percent) {
|
|
421
|
+
@each $key, $value in $breakpoints {
|
|
422
|
+
$columns: get-column-count($breakpoints, $key);
|
|
423
|
+
$span: $columns * $percent;
|
|
424
|
+
|
|
425
|
+
@if is-smallest-breakpoint($key, $breakpoints) {
|
|
426
|
+
--cds-grid-columns: #{$span};
|
|
427
|
+
|
|
428
|
+
grid-column: span #{$span} / span #{$span};
|
|
429
|
+
} @else {
|
|
430
|
+
$previous-breakpoint: breakpoint-prev($key, $breakpoints);
|
|
431
|
+
$previous-column-count: get-column-count(
|
|
432
|
+
$breakpoints,
|
|
433
|
+
$previous-breakpoint
|
|
434
|
+
);
|
|
435
|
+
$previous-span: $previous-column-count * $percent;
|
|
436
|
+
|
|
437
|
+
@if $span != $previous-span {
|
|
438
|
+
@include breakpoint($key) {
|
|
439
|
+
--cds-grid-columns: #{$span};
|
|
440
|
+
|
|
441
|
+
grid-column: span #{$span} / span #{$span};
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/// Get the grid width for a specific breakpoint name
|
|
449
|
+
@function get-grid-width($breakpoints, $breakpoint) {
|
|
450
|
+
@return map.get(map.get($breakpoints, $breakpoint), width);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/// Get the grid column count for a specific breakpoint name
|
|
454
|
+
@function get-column-count($breakpoints, $breakpoint) {
|
|
455
|
+
@return map.get(map.get($breakpoints, $breakpoint), columns);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/// Get the grid margin for a specific breakpoint name
|
|
459
|
+
@function get-margin($breakpoints, $breakpoint) {
|
|
460
|
+
$value: map.get(map.get($breakpoints, $breakpoint), margin);
|
|
461
|
+
@if $value == 0 {
|
|
462
|
+
@return 0;
|
|
463
|
+
}
|
|
464
|
+
@return $value;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/// Return the largest column count from a set of breakpoints
|
|
468
|
+
@function get-grid-columns($breakpoints) {
|
|
469
|
+
@return get-column-count($breakpoints, largest-breakpoint-name($breakpoints));
|
|
470
|
+
}
|
|
@@ -5,8 +5,14 @@
|
|
|
5
5
|
// LICENSE file in the root directory of this source tree.
|
|
6
6
|
//
|
|
7
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';
|
|
8
13
|
@use 'sass:meta';
|
|
9
|
-
@use
|
|
14
|
+
@use 'sass:math';
|
|
15
|
+
@use 'sass:map';
|
|
10
16
|
|
|
11
17
|
@use 'config' as *;
|
|
12
18
|
@use 'breakpoint' as *;
|
|
@@ -19,32 +25,32 @@
|
|
|
19
25
|
/// for setting width and default gutters when a column's breakpoint has not been
|
|
20
26
|
/// hit yet.
|
|
21
27
|
/// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
|
|
22
|
-
/// @param {Number} $collapsed-gutter [$grid-gutter
|
|
28
|
+
/// @param {Number} $collapsed-gutter [$grid-gutter-condensed] - The condensed mode gutter
|
|
23
29
|
/// @access private
|
|
24
30
|
/// @group @carbon/grid
|
|
25
31
|
@mixin -make-col-ready(
|
|
26
32
|
$gutter: $grid-gutter,
|
|
27
|
-
$condensed-gutter: $grid-gutter
|
|
33
|
+
$condensed-gutter: $grid-gutter-condensed
|
|
28
34
|
) {
|
|
29
35
|
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
|
30
36
|
// always setting `width: 100%;`. This works because we use `flex` values
|
|
31
37
|
// later on to override this initial width.
|
|
32
38
|
width: 100%;
|
|
33
|
-
padding-right:
|
|
34
|
-
padding-left:
|
|
39
|
+
padding-right: $gutter * 0.5;
|
|
40
|
+
padding-left: $gutter * 0.5;
|
|
35
41
|
|
|
36
42
|
// For our condensed use-case, our gutters collapse to 2px solid, 1px on each
|
|
37
43
|
// side.
|
|
38
44
|
.#{$prefix}--row--condensed &,
|
|
39
45
|
.#{$prefix}--grid--condensed & {
|
|
40
|
-
padding-right:
|
|
41
|
-
padding-left:
|
|
46
|
+
padding-right: $condensed-gutter * 0.5;
|
|
47
|
+
padding-left: $condensed-gutter * 0.5;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
// For our narrow use-case, our container hangs 16px into the gutter
|
|
45
51
|
.#{$prefix}--row--narrow &,
|
|
46
52
|
.#{$prefix}--grid--narrow & {
|
|
47
|
-
padding-right:
|
|
53
|
+
padding-right: $gutter * 0.5;
|
|
48
54
|
padding-left: 0;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -164,7 +170,7 @@
|
|
|
164
170
|
/// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
|
|
165
171
|
/// @access private
|
|
166
172
|
/// @group @carbon/grid
|
|
167
|
-
@mixin make-row($gutter: $grid-gutter) {
|
|
173
|
+
@mixin -make-row($gutter: $grid-gutter) {
|
|
168
174
|
display: flex;
|
|
169
175
|
flex-wrap: wrap;
|
|
170
176
|
margin-right: -1 * $gutter * 0.5;
|
|
@@ -195,17 +201,6 @@
|
|
|
195
201
|
.#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
|
|
196
202
|
padding-right: 0;
|
|
197
203
|
}
|
|
198
|
-
|
|
199
|
-
// Deprecated ☠️
|
|
200
|
-
.#{$prefix}--no-gutter--left,
|
|
201
|
-
.#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
|
|
202
|
-
padding-left: 0;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.#{$prefix}--no-gutter--right,
|
|
206
|
-
.#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
|
|
207
|
-
padding-right: 0;
|
|
208
|
-
}
|
|
209
204
|
}
|
|
210
205
|
|
|
211
206
|
// -----------------------------------------------------------------------------
|
|
@@ -219,20 +214,11 @@
|
|
|
219
214
|
/// @group @carbon/grid
|
|
220
215
|
@mixin -hang($gutter: $grid-gutter) {
|
|
221
216
|
.#{$prefix}--hang--start {
|
|
222
|
-
padding-left:
|
|
217
|
+
padding-left: $gutter * 0.5;
|
|
223
218
|
}
|
|
224
219
|
|
|
225
220
|
.#{$prefix}--hang--end {
|
|
226
|
-
padding-right:
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Deprecated ☠️
|
|
230
|
-
.#{$prefix}--hang--left {
|
|
231
|
-
padding-left: ($gutter * 0.5);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.#{$prefix}--hang--right {
|
|
235
|
-
padding-right: ($gutter * 0.5);
|
|
221
|
+
padding-right: $gutter * 0.5;
|
|
236
222
|
}
|
|
237
223
|
}
|
|
238
224
|
|
|
@@ -241,7 +227,7 @@
|
|
|
241
227
|
// -----------------------------------------------------------------------------
|
|
242
228
|
|
|
243
229
|
/// Create the container for a grid. Will cause full-bleed for the grid unless
|
|
244
|
-
/// max-width properties are added with
|
|
230
|
+
/// max-width properties are added with `make-container-max-widths`
|
|
245
231
|
/// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
|
|
246
232
|
/// @access private
|
|
247
233
|
/// @group @carbon/grid
|
|
@@ -249,7 +235,7 @@
|
|
|
249
235
|
margin-right: auto;
|
|
250
236
|
margin-left: auto;
|
|
251
237
|
|
|
252
|
-
@include -set-largest-breakpoint();
|
|
238
|
+
@include -set-largest-breakpoint($breakpoints);
|
|
253
239
|
|
|
254
240
|
@each $name, $value in $breakpoints {
|
|
255
241
|
$prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
|
|
@@ -277,7 +263,7 @@
|
|
|
277
263
|
/// @access private
|
|
278
264
|
/// @group @carbon/grid
|
|
279
265
|
@mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
|
|
280
|
-
$largest-breakpoint: last-map-item($breakpoints);
|
|
266
|
+
$largest-breakpoint: -last-map-item($breakpoints);
|
|
281
267
|
|
|
282
268
|
max-width: map.get($largest-breakpoint, 'width');
|
|
283
269
|
}
|
|
@@ -294,16 +280,37 @@
|
|
|
294
280
|
}
|
|
295
281
|
}
|
|
296
282
|
|
|
283
|
+
/// Pass in a map, and get the last one in the list back
|
|
284
|
+
/// @access public
|
|
285
|
+
/// @param {Map} $map - Map
|
|
286
|
+
/// @return {*} Desired value
|
|
287
|
+
/// @group @carbon/layout
|
|
288
|
+
@function -last-map-item($map) {
|
|
289
|
+
$total-length: list.length($map);
|
|
290
|
+
@return map-get($map, -key-by-index($map, $total-length));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/// Provide a map and index, and get back the relevant key value
|
|
294
|
+
/// @access public
|
|
295
|
+
/// @param {Map} $map - Map
|
|
296
|
+
/// @param {Integer} $index - Key chain
|
|
297
|
+
/// @return {String} Desired value
|
|
298
|
+
/// @group @carbon/layout
|
|
299
|
+
@function -key-by-index($map, $index) {
|
|
300
|
+
$keys: map.keys($map);
|
|
301
|
+
@return nth($keys, $index);
|
|
302
|
+
}
|
|
303
|
+
|
|
297
304
|
/// Generate the CSS for a grid for the given breakpoints and gutters
|
|
298
305
|
/// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
|
|
299
306
|
/// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
|
|
300
|
-
/// @param {Number} $condensed-gutter [$grid-gutter
|
|
307
|
+
/// @param {Number} $condensed-gutter [$grid-gutter-condensed] - The condensed mode gutter
|
|
301
308
|
/// @access public
|
|
302
309
|
/// @group @carbon/grid
|
|
303
|
-
@mixin grid(
|
|
310
|
+
@mixin flex-grid(
|
|
304
311
|
$breakpoints: $grid-breakpoints,
|
|
305
312
|
$grid-gutter: $grid-gutter,
|
|
306
|
-
$condensed-gutter: $grid-gutter
|
|
313
|
+
$condensed-gutter: $grid-gutter-condensed
|
|
307
314
|
) {
|
|
308
315
|
.#{$prefix}--grid {
|
|
309
316
|
@include -make-container($breakpoints);
|
|
@@ -316,7 +323,7 @@
|
|
|
316
323
|
}
|
|
317
324
|
|
|
318
325
|
.#{$prefix}--row {
|
|
319
|
-
@include make-row();
|
|
326
|
+
@include -make-row();
|
|
320
327
|
}
|
|
321
328
|
|
|
322
329
|
.#{$prefix}--row-padding [class*='#{$prefix}--col'],
|