@carbon/grid 10.0.0-rc.0 → 10.2.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/CHANGELOG.md +415 -0
- package/LICENSE +2 -2
- package/README.md +30 -26
- package/package.json +12 -5
- package/scss/12.scss +4 -0
- package/scss/_inlined/12.scss +41 -0
- package/scss/_inlined/_mixins.scss +335 -0
- package/scss/_inlined/_prefix.scss +12 -0
- package/scss/_mixins.scss +56 -41
- package/scss/_prefix.scss +4 -0
- package/scss/grid.scss +1 -1
- package/scss/index.scss +10 -0
- package/scss/vendor/@carbon/import-once/import-once.scss +27 -0
- package/scss/vendor/@carbon/import-once/index.scss +8 -0
- package/scss/vendor/@carbon/layout/_breakpoint.scss +237 -0
- package/scss/vendor/@carbon/layout/_convert.scss +30 -0
- package/scss/vendor/@carbon/layout/_key-height.scss +97 -0
- package/scss/vendor/@carbon/layout/_mini-unit.scss +23 -0
- package/scss/vendor/@carbon/layout/_spacing.scss +328 -0
- package/scss/vendor/@carbon/layout/_utilities.scss +41 -0
- package/scss/vendor/@carbon/layout/index.scss +8 -0
- package/scss/vendor/@carbon/layout/layout.scss +12 -0
- package/css/grid.css +0 -1053
- package/css/grid.min.css +0 -1
|
@@ -0,0 +1,237 @@
|
|
|
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(2px);
|
|
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(16px),
|
|
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 brekapoint
|
|
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 brekapoint
|
|
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 brekapoint
|
|
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. Usesful for generate 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 up to the width of the given breakpoint name
|
|
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
|
+
$breakpoint: map-get($breakpoints, $name);
|
|
167
|
+
$width: map-get($breakpoint, width);
|
|
168
|
+
@if carbon--is-smallest-breakpoint($name, $breakpoints) {
|
|
169
|
+
@content;
|
|
170
|
+
} @else {
|
|
171
|
+
@media (max-width: $width) {
|
|
172
|
+
@content;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} @else {
|
|
176
|
+
@error 'Unable to find a breakpoint with name `#{$name}`. Expected one of: (#{map-keys($breakpoints)})';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/// Generate a media query for the range between the lower and upper breakpoints
|
|
181
|
+
/// @param {String | Number} $lower
|
|
182
|
+
/// @param {String | Number} $upper
|
|
183
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
184
|
+
/// @content
|
|
185
|
+
/// @access public
|
|
186
|
+
/// @group @carbon/layout
|
|
187
|
+
@mixin carbon--breakpoint-between(
|
|
188
|
+
$lower,
|
|
189
|
+
$upper,
|
|
190
|
+
$breakpoints: $carbon--grid-breakpoints
|
|
191
|
+
) {
|
|
192
|
+
$is-number-lower: type-of($lower) == 'number';
|
|
193
|
+
$is-number-upper: type-of($upper) == 'number';
|
|
194
|
+
$min: if($is-number-lower, $lower, map-get($breakpoints, $lower));
|
|
195
|
+
$max: if($is-number-upper, $upper, map-get($breakpoints, $upper));
|
|
196
|
+
|
|
197
|
+
@if $min and $max {
|
|
198
|
+
$min-width: if(not $is-number-lower and $min, map-get($min, width), $min);
|
|
199
|
+
$max-width: if(not $is-number-upper and $max, map-get($max, width), $max);
|
|
200
|
+
@media (min-width: $min-width) and (max-width: $max-width) {
|
|
201
|
+
@content;
|
|
202
|
+
}
|
|
203
|
+
} @else if $min != null and $max == null {
|
|
204
|
+
@include carbon--breakpoint-up($lower) {
|
|
205
|
+
@content;
|
|
206
|
+
}
|
|
207
|
+
} @else if $min == null and $max != null {
|
|
208
|
+
@include carbon--breakpoint-down($upper) {
|
|
209
|
+
@content;
|
|
210
|
+
}
|
|
211
|
+
} @else {
|
|
212
|
+
@error 'Unable to find a breakpoint to satisfy: (#{$lower},#{$upper}). Expected both to be one of (#{map-keys($breakpoints)}).';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/// Generate media query for the largest breakpoint
|
|
217
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
218
|
+
/// @content
|
|
219
|
+
/// @access public
|
|
220
|
+
/// @group @carbon/layout
|
|
221
|
+
@mixin carbon--largest-breakpoint($breakpoints: $carbon--grid-breakpoints) {
|
|
222
|
+
@include carbon--breakpoint(carbon--largest-breakpoint-name()) {
|
|
223
|
+
@content;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/// Generate a media query for a given breakpoint
|
|
228
|
+
/// @param {String | Number} $name
|
|
229
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
230
|
+
/// @content
|
|
231
|
+
/// @access public
|
|
232
|
+
/// @group @carbon/layout
|
|
233
|
+
@mixin carbon--breakpoint($name, $breakpoints: $carbon--grid-breakpoints) {
|
|
234
|
+
@include carbon--breakpoint-up($name, $breakpoints) {
|
|
235
|
+
@content;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
/// Default font size
|
|
9
|
+
/// @type Number
|
|
10
|
+
/// @access public
|
|
11
|
+
/// @group @carbon/layout
|
|
12
|
+
$carbon--base-font-size: 16px !default;
|
|
13
|
+
|
|
14
|
+
/// Convert a given px unit to a rem unit
|
|
15
|
+
/// @param {Number} $px - Number with px unit
|
|
16
|
+
/// @return {Number} Number with rem unit
|
|
17
|
+
/// @access public
|
|
18
|
+
/// @group @carbon/layout
|
|
19
|
+
@function carbon--rem($px) {
|
|
20
|
+
@return ($px / $carbon--base-font-size) * 1rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// Convert a given px unit to a em unit
|
|
24
|
+
/// @param {Number} $px - Number with px unit
|
|
25
|
+
/// @return {Number} Number with em unit
|
|
26
|
+
/// @access public
|
|
27
|
+
/// @group @carbon/layout
|
|
28
|
+
@function carbon--em($px) {
|
|
29
|
+
@return ($px / $carbon--base-font-size) * 1em;
|
|
30
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
@import 'breakpoint';
|
|
9
|
+
@import 'utilities';
|
|
10
|
+
|
|
11
|
+
/// Get the column width for a given breakpoint
|
|
12
|
+
/// @param {String} $breakpoint
|
|
13
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints]
|
|
14
|
+
/// @return {Number} In rem
|
|
15
|
+
/// @access public
|
|
16
|
+
/// @group @carbon/layout
|
|
17
|
+
@function carbon--get-column-width(
|
|
18
|
+
$breakpoint,
|
|
19
|
+
$breakpoints: $carbon--grid-breakpoints
|
|
20
|
+
) {
|
|
21
|
+
@if map-has-key($breakpoints, $breakpoint) {
|
|
22
|
+
$values: map-get($breakpoints, $breakpoint);
|
|
23
|
+
$width: map-get($values, width);
|
|
24
|
+
$margin: map-get($values, margin);
|
|
25
|
+
$columns: map-get($values, columns);
|
|
26
|
+
|
|
27
|
+
@return ($width - (2 * $margin)) / $columns;
|
|
28
|
+
} @else {
|
|
29
|
+
@warn 'Breakpoint: `#{$breakpoint}` is not a valid breakpoint.';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// @type Map
|
|
34
|
+
/// @access public
|
|
35
|
+
/// @group @carbon/layout
|
|
36
|
+
$carbon--key-height-scales: (
|
|
37
|
+
sm: (
|
|
38
|
+
carbon--get-column-width(sm),
|
|
39
|
+
carbon--get-column-width(sm) * 2,
|
|
40
|
+
carbon--get-column-width(sm) * 3,
|
|
41
|
+
carbon--get-column-width(sm) * 4,
|
|
42
|
+
carbon--get-column-width(sm) * 5,
|
|
43
|
+
carbon--get-column-width(sm) * 6,
|
|
44
|
+
),
|
|
45
|
+
md: (
|
|
46
|
+
carbon--get-column-width(md),
|
|
47
|
+
carbon--get-column-width(md) * 2,
|
|
48
|
+
carbon--get-column-width(md) * 3,
|
|
49
|
+
carbon--get-column-width(md) * 4,
|
|
50
|
+
carbon--get-column-width(md) * 5,
|
|
51
|
+
carbon--get-column-width(md) * 6,
|
|
52
|
+
),
|
|
53
|
+
lg: (
|
|
54
|
+
carbon--get-column-width(lg),
|
|
55
|
+
carbon--get-column-width(lg) * 2,
|
|
56
|
+
carbon--get-column-width(lg) * 3,
|
|
57
|
+
carbon--get-column-width(lg) * 4,
|
|
58
|
+
carbon--get-column-width(lg) * 5,
|
|
59
|
+
carbon--get-column-width(lg) * 6,
|
|
60
|
+
carbon--get-column-width(lg) * 7,
|
|
61
|
+
carbon--get-column-width(lg) * 8,
|
|
62
|
+
),
|
|
63
|
+
xlg: (
|
|
64
|
+
carbon--get-column-width(xlg),
|
|
65
|
+
carbon--get-column-width(xlg) * 2,
|
|
66
|
+
carbon--get-column-width(xlg) * 3,
|
|
67
|
+
carbon--get-column-width(xlg) * 4,
|
|
68
|
+
carbon--get-column-width(xlg) * 5,
|
|
69
|
+
carbon--get-column-width(xlg) * 6,
|
|
70
|
+
carbon--get-column-width(xlg) * 7,
|
|
71
|
+
carbon--get-column-width(xlg) * 8,
|
|
72
|
+
),
|
|
73
|
+
max: (
|
|
74
|
+
carbon--get-column-width(max),
|
|
75
|
+
carbon--get-column-width(max) * 2,
|
|
76
|
+
carbon--get-column-width(max) * 3,
|
|
77
|
+
carbon--get-column-width(max) * 4,
|
|
78
|
+
carbon--get-column-width(max) * 5,
|
|
79
|
+
carbon--get-column-width(max) * 6,
|
|
80
|
+
carbon--get-column-width(max) * 7,
|
|
81
|
+
carbon--get-column-width(max) * 8,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/// Get the value of a key height step at a given breakpoint
|
|
86
|
+
/// @param {String} $breakpoint
|
|
87
|
+
/// @param {Number} $step
|
|
88
|
+
/// @return {Number} In rem
|
|
89
|
+
/// @access public
|
|
90
|
+
/// @group @carbon/layout
|
|
91
|
+
@function carbon--key-height($breakpoint, $step) {
|
|
92
|
+
@if map-has-key($carbon--key-height-scales, $breakpoint) {
|
|
93
|
+
@return nth(map-get($carbon--key-height-scales, $breakpoint), $step);
|
|
94
|
+
} @else {
|
|
95
|
+
@warn 'Breakpoint: `#{$breakpoint}` is not a valid breakpoint.';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
@import 'convert';
|
|
9
|
+
|
|
10
|
+
/// Default mini-unit value
|
|
11
|
+
/// @type Number
|
|
12
|
+
/// @access public
|
|
13
|
+
/// @group @carbon/layout
|
|
14
|
+
$carbon--mini-unit-size: 8px !default;
|
|
15
|
+
|
|
16
|
+
/// Get the value of the corresponding number of units
|
|
17
|
+
/// @param {Number} $count - The number of units to get the value for
|
|
18
|
+
/// @return {Number} In rem units
|
|
19
|
+
/// @access public
|
|
20
|
+
/// @group @carbon/layout
|
|
21
|
+
@function carbon--mini-units($count) {
|
|
22
|
+
@return carbon--rem($carbon--mini-unit-size * $count);
|
|
23
|
+
}
|