@nice-digital/nds-grid 1.2.19-alpha.0 → 2.0.1-alpha.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/package.json +4 -4
- package/scss/_grid-settings.scss +6 -3
- package/scss/grid.scss +37 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-digital/nds-grid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1-alpha.0",
|
|
4
4
|
"description": "Grid component for the NICE Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grid"
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"url": "https://github.com/nice-digital/nice-design-system/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nice-digital/nds-core": "^
|
|
40
|
+
"@nice-digital/nds-core": "^2.0.1-alpha.0",
|
|
41
41
|
"classnames": "^2.2.6",
|
|
42
42
|
"prop-types": "^15.7.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"react": "^16 || ^17 ^18"
|
|
45
|
+
"react": "^16 || ^17 || ^18"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "520ec14c3198c5224e5ea6f007616c408d96acbc"
|
|
48
48
|
}
|
package/scss/_grid-settings.scss
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
@use '@nice-digital/nds-core/scss/spacing';
|
|
2
|
+
@use '@nice-digital/nds-core/scss/utils';
|
|
3
|
+
|
|
1
4
|
/// The width of the default spacing between grid items, in rems
|
|
2
5
|
/// @since 0.2.0
|
|
3
|
-
$
|
|
6
|
+
$grid-gutter: utils.rem(spacing.$medium);
|
|
4
7
|
|
|
5
8
|
/// The width of the spacing between grid items in a compact grid, in rems
|
|
6
9
|
/// @since 0.2.0
|
|
7
|
-
$
|
|
10
|
+
$grid-gutter-compact: utils.rem(spacing.$small);
|
|
8
11
|
|
|
9
12
|
/// The width of the spacing between grid items in a loose grid, in rems
|
|
10
13
|
/// @since 0.2.0
|
|
11
|
-
$
|
|
14
|
+
$grid-gutter-loose: utils.rem(spacing.$large);
|
package/scss/grid.scss
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
@use
|
|
2
|
-
|
|
3
|
-
@
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
@use '@nice-digital/nds-core/scss/colours';
|
|
3
|
+
@use '@nice-digital/nds-core/scss/media-queries';
|
|
4
|
+
@use '@nice-digital/nds-core/scss/spacing';
|
|
5
|
+
@use '@nice-digital/nds-core/scss/utils';
|
|
6
|
+
@use 'grid-settings';
|
|
4
7
|
|
|
5
8
|
////
|
|
6
9
|
/// @group grid
|
|
7
10
|
////
|
|
8
11
|
|
|
9
|
-
@import 'grid-settings';
|
|
10
|
-
|
|
11
12
|
/// Grid class for the grid wrapper. Expects direct children to be `[data-g]`
|
|
12
13
|
/// grid items. Use modifiers to affect grid behaviour as shown below:
|
|
13
14
|
///
|
|
@@ -28,17 +29,16 @@
|
|
|
28
29
|
/// <div data-g="12 xs:6 md:4 lg:3 xl:2">Grid item</div>
|
|
29
30
|
/// </div>
|
|
30
31
|
.grid {
|
|
31
|
-
--nds-grid-gutter: #{
|
|
32
|
+
--nds-grid-gutter: #{grid-settings.$grid-gutter};
|
|
32
33
|
display: flex;
|
|
33
|
-
flex-
|
|
34
|
-
flex-wrap: wrap;
|
|
34
|
+
flex-flow: row wrap;
|
|
35
35
|
justify-content: flex-start;
|
|
36
36
|
list-style: none; // Allow the grid system to be used on lists.
|
|
37
|
-
margin-left: -#{
|
|
38
|
-
margin-right: -#{
|
|
37
|
+
margin-left: -#{grid-settings.$grid-gutter * 0.5};
|
|
38
|
+
margin-right: -#{grid-settings.$grid-gutter * 0.5};
|
|
39
39
|
max-width: none; // To override the 66ch max width on lists
|
|
40
40
|
padding: 0; // Remove any paddings that might affect the grid system.
|
|
41
|
-
width: calc(100% + #{
|
|
41
|
+
width: calc(100% + #{grid-settings.$grid-gutter});
|
|
42
42
|
|
|
43
43
|
// Fallback to fixed gutter grid in IE11, but use CSS vars where supported.
|
|
44
44
|
// IE11 doesn't support custom properties: https://caniuse.com/css-variables
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
&--compact {
|
|
60
|
-
--nds-grid-gutter: #{
|
|
60
|
+
--nds-grid-gutter: #{grid-settings.$grid-gutter-compact};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
&--loose {
|
|
64
|
-
--nds-grid-gutter: #{
|
|
64
|
+
--nds-grid-gutter: #{grid-settings.$grid-gutter-loose};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
&--right {
|
|
@@ -87,16 +87,16 @@
|
|
|
87
87
|
// Defensive warning for grids with children that aren't items
|
|
88
88
|
> :not([data-g]) {
|
|
89
89
|
--error: 'Grids (`.grid`) should only have grid items (`[data-g]`) as direct children';
|
|
90
|
-
background:
|
|
90
|
+
background: colours.$error-background;
|
|
91
91
|
cursor: help;
|
|
92
|
-
outline: rem(
|
|
92
|
+
outline: utils.rem(spacing.$x-small) solid colours.$error;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
.debug-grid &,
|
|
96
96
|
&--debug,
|
|
97
97
|
.grid--debug & {
|
|
98
|
-
outline: rem(
|
|
99
|
-
outline-offset: rem(
|
|
98
|
+
outline: utils.rem(spacing.$xx-small) dashed red;
|
|
99
|
+
outline-offset: utils.rem(spacing.$x-small);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -116,16 +116,18 @@
|
|
|
116
116
|
[data-g] {
|
|
117
117
|
// Auto flex-basis with separate width property for IE11 because of https://github.com/philipwalton/flexbugs#flexbug-8
|
|
118
118
|
flex: 0 0 auto;
|
|
119
|
-
margin-left: #{
|
|
120
|
-
margin-right: #{
|
|
119
|
+
margin-left: #{grid-settings.$grid-gutter * 0.5};
|
|
120
|
+
margin-right: #{grid-settings.$grid-gutter * 0.5};
|
|
121
121
|
position: relative;
|
|
122
|
+
|
|
122
123
|
// Fixed gutters fallback for IE11, due to lack of custom property support:
|
|
123
|
-
width: calc(100% - #{
|
|
124
|
+
width: calc(100% - #{grid-settings.$grid-gutter});
|
|
124
125
|
|
|
125
126
|
@supports ((--a: 0)) {
|
|
126
127
|
--grid-item-width: 100%;
|
|
127
128
|
margin-left: calc(var(--nds-grid-gutter) / 2) !important;
|
|
128
129
|
margin-right: calc(var(--nds-grid-gutter) / 2) !important;
|
|
130
|
+
|
|
129
131
|
// Slightly hacky 0.1px because of subpixel rounding e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=1323735
|
|
130
132
|
width: calc(
|
|
131
133
|
var(--grid-item-width) - var(--nds-grid-gutter) - 0.1px
|
|
@@ -136,9 +138,9 @@
|
|
|
136
138
|
// See https://github.com/nice-digital/nice-design-system/issues/73
|
|
137
139
|
:not(.grid) > & {
|
|
138
140
|
--error: 'Put grid items (`[data-g]`) directly inside a `.grid`';
|
|
139
|
-
background:
|
|
141
|
+
background: colours.$error-background;
|
|
140
142
|
cursor: help;
|
|
141
|
-
outline: rem(
|
|
143
|
+
outline: utils.rem(spacing.$x-small) solid colours.$error;
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
// Warning for single grid items within a grid
|
|
@@ -148,37 +150,38 @@
|
|
|
148
150
|
|
|
149
151
|
.debug-grid &,
|
|
150
152
|
.grid--debug & {
|
|
151
|
-
outline: rem(
|
|
153
|
+
outline: utils.rem(spacing.$xx-small) dashed blue;
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
|
|
155
|
-
@mixin
|
|
157
|
+
@mixin -nds-generate-grid-items($prefix: null) {
|
|
156
158
|
$prefix: if($prefix, $prefix + ':', '');
|
|
157
159
|
|
|
158
160
|
@for $index from 1 through 12 {
|
|
159
161
|
[data-g~='#{ $prefix }#{ $index }'] {
|
|
160
|
-
--grid-item-width: #{percentage(math.div($index, 12))};
|
|
162
|
+
--grid-item-width: #{math.percentage(math.div($index, 12))};
|
|
163
|
+
|
|
161
164
|
// IE 11 fallback, due to lack of custom property support:
|
|
162
|
-
width: calc(
|
|
165
|
+
width: calc(
|
|
166
|
+
#{math.percentage(math.div($index, 12))} - #{grid-settings.$grid-gutter}
|
|
167
|
+
);
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
@for $index from 0 through 12 {
|
|
167
172
|
[data-g~='#{ $prefix }push:#{ $index }'] {
|
|
168
|
-
left: percentage(math.div($index, 12));
|
|
173
|
+
left: math.percentage(math.div($index, 12));
|
|
169
174
|
}
|
|
170
175
|
[data-g~='#{ $prefix }pull:#{ $index }'] {
|
|
171
|
-
right: percentage(math.div($index, 12));
|
|
176
|
+
right: math.percentage(math.div($index, 12));
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
@include
|
|
181
|
+
@include -nds-generate-grid-items;
|
|
177
182
|
|
|
178
|
-
@
|
|
179
|
-
@
|
|
180
|
-
@include
|
|
181
|
-
@include _nds-generate-grid-items($brkpnt-key);
|
|
182
|
-
}
|
|
183
|
+
@each $brkpnt-key, $brkpnt-value in media-queries.$breakpoints {
|
|
184
|
+
@include media-queries.mq($from: $brkpnt-key) {
|
|
185
|
+
@include -nds-generate-grid-items($brkpnt-key);
|
|
183
186
|
}
|
|
184
187
|
}
|