@nice-digital/nds-grid 1.2.17 → 1.2.20-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-grid",
3
- "version": "1.2.17",
3
+ "version": "1.2.20-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": "^1.3.2",
40
+ "@nice-digital/nds-core": "^1.3.5-alpha.0",
41
41
  "classnames": "^2.2.6",
42
42
  "prop-types": "^15.7.2"
43
43
  },
44
44
  "peerDependencies": {
45
- "react": "^16 || ^17"
45
+ "react": "^16 || ^17 || ^18"
46
46
  },
47
- "gitHead": "db5e29bc9fa8afa7e33c19a8e06a65adafd99bc5"
47
+ "gitHead": "0ddae81edebd757a52ca6a2838610049a83acebd"
48
48
  }
@@ -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
- $nds-grid-gutter: rem($nds-spacing-medium);
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
- $nds-grid-gutter-compact: rem($nds-spacing-small);
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
- $nds-grid-gutter-loose: rem($nds-spacing-large);
14
+ $grid-gutter-loose: utils.rem(spacing.$large);
package/scss/grid.scss CHANGED
@@ -1,13 +1,14 @@
1
1
  @use "sass:math";
2
-
3
- @import '~@nice-digital/nds-core/scss/core';
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,17 @@
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: #{$nds-grid-gutter};
32
+ --nds-grid-gutter: #{grid-settings.$grid-gutter};
32
33
  display: flex;
33
34
  flex-direction: row;
34
35
  flex-wrap: wrap;
35
36
  justify-content: flex-start;
36
37
  list-style: none; // Allow the grid system to be used on lists.
37
- margin-left: -#{$nds-grid-gutter * 0.5};
38
- margin-right: -#{$nds-grid-gutter * 0.5};
38
+ margin-left: -#{grid-settings.$grid-gutter * 0.5};
39
+ margin-right: -#{grid-settings.$grid-gutter * 0.5};
39
40
  max-width: none; // To override the 66ch max width on lists
40
41
  padding: 0; // Remove any paddings that might affect the grid system.
41
- width: calc(100% + #{$nds-grid-gutter});
42
+ width: calc(100% + #{grid-settings.$grid-gutter});
42
43
 
43
44
  // Fallback to fixed gutter grid in IE11, but use CSS vars where supported.
44
45
  // IE11 doesn't support custom properties: https://caniuse.com/css-variables
@@ -57,11 +58,11 @@
57
58
  }
58
59
 
59
60
  &--compact {
60
- --nds-grid-gutter: #{$nds-grid-gutter-compact};
61
+ --nds-grid-gutter: #{grid-settings.$grid-gutter-compact};
61
62
  }
62
63
 
63
64
  &--loose {
64
- --nds-grid-gutter: #{$nds-grid-gutter-loose};
65
+ --nds-grid-gutter: #{grid-settings.$grid-gutter-loose};
65
66
  }
66
67
 
67
68
  &--right {
@@ -87,16 +88,16 @@
87
88
  // Defensive warning for grids with children that aren't items
88
89
  > :not([data-g]) {
89
90
  --error: 'Grids (`.grid`) should only have grid items (`[data-g]`) as direct children';
90
- background: $nds-colour-error-background;
91
+ background: colours.$error-background;
91
92
  cursor: help;
92
- outline: rem($nds-spacing-x-small) solid $nds-colour-error;
93
+ outline: utils.rem(spacing.$x-small) solid colours.$error;
93
94
  }
94
95
 
95
96
  .debug-grid &,
96
97
  &--debug,
97
98
  .grid--debug & {
98
- outline: rem($nds-spacing-xx-small) dashed red;
99
- outline-offset: rem($nds-spacing-x-small);
99
+ outline: utils.rem(spacing.$xx-small) dashed red;
100
+ outline-offset: utils.rem(spacing.$x-small);
100
101
  }
101
102
  }
102
103
 
@@ -116,11 +117,11 @@
116
117
  [data-g] {
117
118
  // Auto flex-basis with separate width property for IE11 because of https://github.com/philipwalton/flexbugs#flexbug-8
118
119
  flex: 0 0 auto;
119
- margin-left: #{$nds-grid-gutter * 0.5};
120
- margin-right: #{$nds-grid-gutter * 0.5};
120
+ margin-left: #{grid-settings.$grid-gutter * 0.5};
121
+ margin-right: #{grid-settings.$grid-gutter * 0.5};
121
122
  position: relative;
122
123
  // Fixed gutters fallback for IE11, due to lack of custom property support:
123
- width: calc(100% - #{$nds-grid-gutter});
124
+ width: calc(100% - #{grid-settings.$grid-gutter});
124
125
 
125
126
  @supports ((--a: 0)) {
126
127
  --grid-item-width: 100%;
@@ -136,9 +137,9 @@
136
137
  // See https://github.com/nice-digital/nice-design-system/issues/73
137
138
  :not(.grid) > & {
138
139
  --error: 'Put grid items (`[data-g]`) directly inside a `.grid`';
139
- background: $nds-colour-error-background;
140
+ background: colours.$error-background;
140
141
  cursor: help;
141
- outline: rem($nds-spacing-x-small) solid $nds-colour-error;
142
+ outline: utils.rem(spacing.$x-small) solid colours.$error;
142
143
  }
143
144
 
144
145
  // Warning for single grid items within a grid
@@ -148,7 +149,7 @@
148
149
 
149
150
  .debug-grid &,
150
151
  .grid--debug & {
151
- outline: rem($nds-spacing-xx-small) dashed blue;
152
+ outline: utils.rem(spacing.$xx-small) dashed blue;
152
153
  }
153
154
  }
154
155
 
@@ -159,7 +160,9 @@
159
160
  [data-g~='#{ $prefix }#{ $index }'] {
160
161
  --grid-item-width: #{percentage(math.div($index, 12))};
161
162
  // IE 11 fallback, due to lack of custom property support:
162
- width: calc(#{percentage(math.div($index, 12))} - #{$nds-grid-gutter});
163
+ width: calc(
164
+ #{percentage(math.div($index, 12))} - #{grid-settings.$grid-gutter}
165
+ );
163
166
  }
164
167
  }
165
168
 
@@ -175,10 +178,8 @@
175
178
 
176
179
  @include _nds-generate-grid-items;
177
180
 
178
- @if $nds-responsive {
179
- @each $brkpnt-key, $brkpnt-value in $mq-breakpoints {
180
- @include mq($from: $brkpnt-key) {
181
- @include _nds-generate-grid-items($brkpnt-key);
182
- }
181
+ @each $brkpnt-key, $brkpnt-value in media-queries.$breakpoints {
182
+ @include media-queries.mq($from: $brkpnt-key) {
183
+ @include _nds-generate-grid-items($brkpnt-key);
183
184
  }
184
185
  }