nsw-design-system 3.0.4 → 3.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +241 -88
  2. package/README.md +7 -12
  3. package/dist/css/core.css +1 -1
  4. package/dist/css/main.css +1 -1
  5. package/dist/js/main.js +91 -0
  6. package/package.json +1 -1
  7. package/src/components/_all.scss +2 -0
  8. package/src/components/accordion/_accordion.scss +22 -0
  9. package/src/components/breadcrumbs/_breadcrumbs.scss +4 -0
  10. package/src/components/button/_button.scss +46 -43
  11. package/src/components/callout/_callout.scss +4 -0
  12. package/src/components/card/_card.scss +50 -0
  13. package/src/components/content-block/_content-block.scss +4 -0
  14. package/src/components/dialog/_dialog.scss +156 -0
  15. package/src/components/dialog/dialog.js +60 -0
  16. package/src/components/filters/_filters.scss +43 -0
  17. package/src/components/header/_header.scss +15 -4
  18. package/src/components/hero-banner/_hero-banner.scss +59 -25
  19. package/src/components/in-page-alert/_in-page-alert.scss +8 -0
  20. package/src/components/link-list/_link-list.scss +4 -0
  21. package/src/components/media/_media.scss +8 -0
  22. package/src/components/pagination/_pagination.scss +4 -0
  23. package/src/components/side-nav/_side-nav.scss +12 -0
  24. package/src/components/steps/_steps.scss +315 -0
  25. package/src/components/table/_table.scss +4 -0
  26. package/src/components/tabs/_tabs.scss +17 -0
  27. package/src/components/tag/_tag.scss +28 -0
  28. package/src/core/iconography/_icon.scss +4 -0
  29. package/src/core/section/_section.scss +4 -0
  30. package/src/core/typography/_typography.scss +12 -0
  31. package/src/global/scss/base/_mixins.scss +1 -1
  32. package/src/global/scss/helpers/_all.scss +2 -0
  33. package/src/global/scss/helpers/_border.scss +20 -0
  34. package/src/global/scss/helpers/_shadow.scss +3 -0
  35. package/src/global/scss/settings/_theme.scss +3 -0
  36. package/src/main.js +6 -0
  37. package/src/main.scss +2 -0
package/dist/js/main.js CHANGED
@@ -686,6 +686,93 @@
686
686
  return Accordion;
687
687
  }();
688
688
 
689
+ var Dialog = /*#__PURE__*/function () {
690
+ function Dialog(element) {
691
+ var _this = this;
692
+
693
+ _classCallCheck(this, Dialog);
694
+
695
+ this.dialog = element;
696
+ this.dialogWrapper = element.querySelector('.nsw-dialog__wrapper');
697
+ this.openBtn = document.querySelectorAll('.js-open-dialog-'.concat(element.getAttribute('id')));
698
+ this.closeBtn = element.querySelectorAll('.js-close-dialog'); // eslint-disable-next-line max-len
699
+
700
+ this.focusableEls = element.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
701
+ this.body = document.body;
702
+
703
+ this.openEvent = function (e) {
704
+ return _this.openDialog(e);
705
+ };
706
+
707
+ this.closeEvent = function (e) {
708
+ return _this.closeDialog(e);
709
+ };
710
+
711
+ this.clickEvent = function (e) {
712
+ return _this.clickDialog(e);
713
+ };
714
+
715
+ this.trapEvent = function (e) {
716
+ return _this.trapFocus(e);
717
+ };
718
+ }
719
+
720
+ _createClass(Dialog, [{
721
+ key: "init",
722
+ value: function init() {
723
+ this.controls();
724
+ }
725
+ }, {
726
+ key: "controls",
727
+ value: function controls() {
728
+ var _this2 = this;
729
+
730
+ this.openBtn.forEach(function (btn) {
731
+ btn.addEventListener('click', _this2.openEvent, false);
732
+ });
733
+ this.closeBtn.forEach(function (btn) {
734
+ btn.addEventListener('click', _this2.closeEvent, false);
735
+ });
736
+
737
+ if (this.dialog.classList.contains('js-dialog-dismiss')) {
738
+ this.dialog.addEventListener('click', this.clickEvent, false);
739
+ }
740
+
741
+ this.focusableEls[this.focusableEls.length - 1].addEventListener('blur', this.trapEvent, false);
742
+ }
743
+ }, {
744
+ key: "openDialog",
745
+ value: function openDialog() {
746
+ this.dialog.setAttribute('aria-expanded', 'true');
747
+ this.dialog.classList.add('active');
748
+ this.body.classList.add('dialog-active');
749
+ this.focusableEls[0].focus();
750
+ }
751
+ }, {
752
+ key: "closeDialog",
753
+ value: function closeDialog() {
754
+ this.dialog.setAttribute('aria-expanded', 'false');
755
+ this.dialog.classList.remove('active');
756
+ this.body.classList.remove('dialog-active');
757
+ }
758
+ }, {
759
+ key: "clickDialog",
760
+ value: function clickDialog(e) {
761
+ if (!this.dialogWrapper.contains(e.target)) {
762
+ this.closeDialog();
763
+ }
764
+ }
765
+ }, {
766
+ key: "trapFocus",
767
+ value: function trapFocus(e) {
768
+ e.preventDefault();
769
+ this.focusableEls[0].focus();
770
+ }
771
+ }]);
772
+
773
+ return Dialog;
774
+ }();
775
+
689
776
  var Filters = /*#__PURE__*/function () {
690
777
  function Filters(element) {
691
778
  var _this = this;
@@ -1001,6 +1088,7 @@
1001
1088
  var openSearchButton = document.querySelectorAll('.js-open-search');
1002
1089
  var closeSearchButton = document.querySelectorAll('.js-close-search');
1003
1090
  var accordions = document.querySelectorAll('.js-accordion');
1091
+ var dialogs = document.querySelectorAll('.js-dialog');
1004
1092
  var filters = document.querySelectorAll('.js-filters');
1005
1093
  var tabs = document.querySelectorAll('.js-tabs');
1006
1094
  var globalAlert = document.querySelectorAll('.js-global-alert');
@@ -1015,6 +1103,9 @@
1015
1103
  accordions.forEach(function (element) {
1016
1104
  new Accordion(element).init();
1017
1105
  });
1106
+ dialogs.forEach(function (element) {
1107
+ new Dialog(element).init();
1108
+ });
1018
1109
 
1019
1110
  if (filters) {
1020
1111
  filters.forEach(function (element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.0.4",
3
+ "version": "3.2.0",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/main.js",
6
6
  "style": "dist/main.css",
@@ -1,4 +1,5 @@
1
1
  @import 'accordion/accordion';
2
+ @import 'dialog/dialog';
2
3
  @import 'breadcrumbs/breadcrumbs';
3
4
  @import 'button/button';
4
5
  @import 'callout/callout';
@@ -22,6 +23,7 @@
22
23
  @import 'progress-indicator/progress-indicator';
23
24
  @import 'results-bar/results-bar';
24
25
  @import 'side-nav/side-nav';
26
+ @import 'steps/steps';
25
27
  @import 'table/table';
26
28
  @import 'tabs/tabs';
27
29
  @import 'tag/tag';
@@ -19,6 +19,15 @@
19
19
  background-color: var(--nsw-brand-dark);
20
20
  color: var(--nsw-text-light);
21
21
 
22
+ .nsw-section--invert & {
23
+ background-color: var(--nsw-brand-light);
24
+ color: var(--nsw-text-dark);
25
+
26
+ .nsw-material-icons {
27
+ color: var(--nsw-brand-dark);
28
+ }
29
+ }
30
+
22
31
  .nsw-material-icons {
23
32
  color: var(--nsw-text-light);
24
33
  }
@@ -43,6 +52,11 @@
43
52
  &:hover:enabled {
44
53
  @include nsw-hover;
45
54
  outline: 2px solid var(--nsw-text-hover);
55
+
56
+ .nsw-section--invert & {
57
+ background-color: var(--nsw-text-hover-light);
58
+ outline-color: var(--nsw-text-hover-light);
59
+ }
46
60
  }
47
61
 
48
62
  &:focus {
@@ -56,6 +70,14 @@
56
70
  &:disabled {
57
71
  opacity: 0.4;
58
72
  cursor: not-allowed;
73
+ }
74
+
75
+ .nsw-section--invert & {
76
+ color: var(--nsw-text-light);
77
+
78
+ &:focus {
79
+ outline-color: var(--nsw-white);
80
+ }
59
81
  }
60
82
  }
61
83
  }
@@ -58,6 +58,10 @@
58
58
  text-decoration: none;
59
59
  pointer-events: none;
60
60
  color: var(--nsw-text-dark);
61
+
62
+ .nsw-section--invert & {
63
+ color: var(--nsw-text-light);
64
+ }
61
65
  }
62
66
  }
63
67
  }
@@ -107,49 +107,6 @@ $nsw-buttons: (
107
107
  @include nsw-focus;
108
108
  }
109
109
 
110
- @each $color, $property-map in $nsw-buttons {
111
- &--#{"" + $color} {
112
- color: map-get($property-map, text-color);
113
- background-color: map-get($property-map, background);
114
- border-color: map-get($property-map, border);
115
-
116
- &:visited {
117
- color: map-get($property-map, text-color);
118
- }
119
-
120
- &:focus {
121
- outline-color: map-get($property-map, focus);
122
- }
123
-
124
- &:hover {
125
- color: map-get($property-map, text-color-hover);
126
- background-color: map-get($property-map, background-hover);
127
- border-color: map-get($property-map, border-hover);
128
- @if map-get($property-map, hover) == white {
129
- background-image: linear-gradient(rgba(var(--nsw-white-rgb), 0.15), rgba(var(--nsw-white-rgb), 0.15));
130
- }
131
- @if map-get($property-map, hover) == black {
132
- background-image: linear-gradient(rgba(var(--nsw-black-rgb), 0.07), rgba(var(--nsw-black-rgb), 0.07));
133
- }
134
-
135
- .nsw-material-icons {
136
- color: map-get($property-map, text-color-hover);
137
- }
138
- }
139
-
140
- &:disabled,
141
- &.disabled {
142
- color: map-get($property-map, text-color);
143
- background-color: map-get($property-map, background);
144
- border-color: map-get($property-map, border);
145
- }
146
-
147
- .nsw-material-icons {
148
- color: map-get($property-map, text-color);
149
- }
150
- }
151
- }
152
-
153
110
  &:disabled,
154
111
  &.disabled {
155
112
  opacity: 0.4;
@@ -216,3 +173,49 @@ $nsw-buttons: (
216
173
  }
217
174
  }
218
175
  }
176
+
177
+ .nsw-section--invert .nsw-button,
178
+ .nsw-button {
179
+ @each $color, $property-map in $nsw-buttons {
180
+ &--#{"" + $color} {
181
+ color: map-get($property-map, text-color);
182
+ background-color: map-get($property-map, background);
183
+ border-color: map-get($property-map, border);
184
+
185
+ &:visited {
186
+ color: map-get($property-map, text-color);
187
+ }
188
+
189
+ &:focus {
190
+ outline-color: map-get($property-map, focus);
191
+ }
192
+
193
+ &:hover {
194
+ color: map-get($property-map, text-color-hover);
195
+ background-color: map-get($property-map, background-hover);
196
+ border-color: map-get($property-map, border-hover);
197
+ @if map-get($property-map, hover) == white {
198
+ background-image: linear-gradient(rgba(var(--nsw-white-rgb), 0.15), rgba(var(--nsw-white-rgb), 0.15));
199
+ }
200
+ @if map-get($property-map, hover) == black {
201
+ background-image: linear-gradient(rgba(var(--nsw-black-rgb), 0.07), rgba(var(--nsw-black-rgb), 0.07));
202
+ }
203
+
204
+ .nsw-material-icons {
205
+ color: map-get($property-map, text-color-hover);
206
+ }
207
+ }
208
+
209
+ &:disabled,
210
+ &.disabled {
211
+ color: map-get($property-map, text-color);
212
+ background-color: map-get($property-map, background);
213
+ border-color: map-get($property-map, border);
214
+ }
215
+
216
+ .nsw-material-icons {
217
+ color: map-get($property-map, text-color);
218
+ }
219
+ }
220
+ }
221
+ }
@@ -2,4 +2,8 @@
2
2
  @include component-spacing();
3
3
  padding: rem(16px);
4
4
  border-left: solid 4px var(--nsw-brand-dark);
5
+
6
+ .nsw-section--invert & {
7
+ border-color: var(--nsw-brand-light);
8
+ }
5
9
  }
@@ -32,6 +32,18 @@
32
32
  .nsw-material-icons {
33
33
  color: var(--nsw-text-light);
34
34
  }
35
+
36
+ .nsw-section--invert & {
37
+ color: var(--nsw-text-dark);
38
+
39
+ .nsw-card__content {
40
+ background-color: var(--nsw-brand-light);
41
+
42
+ &::after {
43
+ background-color: transparent;
44
+ }
45
+ }
46
+ }
35
47
  }
36
48
 
37
49
  &:focus-within {
@@ -56,6 +68,10 @@
56
68
  @include breakpoint('lg') {
57
69
  padding: rem(32px) rem(32px) rem(94px) rem(32px);
58
70
  }
71
+
72
+ .nsw-section--invert & {
73
+ border-color: transparent;
74
+ }
59
75
  }
60
76
 
61
77
  &__title {
@@ -76,6 +92,10 @@
76
92
  background-color: transparent;
77
93
  outline: none;
78
94
  }
95
+
96
+ .nsw-section--invert & {
97
+ color: var(--nsw-text-dark);
98
+ }
79
99
  }
80
100
  }
81
101
 
@@ -111,6 +131,10 @@
111
131
  bottom: rem(32px);
112
132
  left: rem(32px);
113
133
  }
134
+
135
+ .nsw-section--invert & {
136
+ color: var(--nsw-brand-dark);
137
+ }
114
138
  }
115
139
 
116
140
  &__image {
@@ -136,6 +160,14 @@
136
160
  }
137
161
 
138
162
  &--light {
163
+ &:hover {
164
+ .nsw-section--invert & {
165
+ .nsw-card__content {
166
+ background-color: var(--nsw-white);
167
+ }
168
+ }
169
+ }
170
+
139
171
  .nsw-card__content {
140
172
  background-color: var(--nsw-brand-light);
141
173
  border-color: transparent;
@@ -171,6 +203,16 @@
171
203
  .nsw-material-icons {
172
204
  color: var(--nsw-brand-dark);
173
205
  }
206
+
207
+ .nsw-section--invert & {
208
+ .nsw-card__content {
209
+ background-color: var(--nsw-white);
210
+ }
211
+
212
+ .nsw-material-icons {
213
+ color: var(--nsw-brand-dark);
214
+ }
215
+ }
174
216
  }
175
217
 
176
218
  .nsw-card__content {
@@ -181,6 +223,10 @@
181
223
  &::after {
182
224
  display: none;
183
225
  }
226
+
227
+ .nsw-section--invert & {
228
+ border-color: var(--nsw-white);
229
+ }
184
230
  }
185
231
 
186
232
  .nsw-card__image {
@@ -195,6 +241,10 @@
195
241
 
196
242
  .nsw-material-icons {
197
243
  color: var(--nsw-text-light);
244
+
245
+ .nsw-section--invert & {
246
+ color: var(--nsw-text-light);
247
+ }
198
248
  }
199
249
  }
200
250
 
@@ -22,6 +22,10 @@
22
22
  background-color: var(--nsw-text-dark);
23
23
  top: rem(18px);
24
24
  left: 0;
25
+
26
+ .nsw-section--invert & {
27
+ background-color: var(--nsw-text-light);
28
+ }
25
29
  }
26
30
  }
27
31
  }
@@ -0,0 +1,156 @@
1
+ .dialog-active {
2
+ overflow: hidden;
3
+ }
4
+
5
+ .nsw-dialog {
6
+ @include z-index('upper');
7
+ display: none;
8
+ position: fixed;
9
+ left: 0;
10
+ right: 0;
11
+ top: 0;
12
+ bottom: 0;
13
+ background-color: rgba(var(--nsw-black-rgb), 0.7);
14
+ justify-content: center;
15
+ align-items: flex-end;
16
+
17
+ @include breakpoint('sm') {
18
+ align-items: center;
19
+ padding: 0 rem(16px);
20
+ }
21
+
22
+ &.active {
23
+ display: flex;
24
+ }
25
+
26
+ &__wrapper {
27
+ background-color: var(--nsw-white);
28
+ width: 100%;
29
+ max-width: rem(736px);
30
+ position: relative;
31
+ padding-bottom: rem(145px);
32
+
33
+ @include breakpoint('sm') {
34
+ border-radius: var(--nsw-border-radius);
35
+ align-items: center;
36
+ max-height: 90%;
37
+ }
38
+
39
+ @include breakpoint('md') {
40
+ padding-bottom: rem(81px);
41
+ }
42
+
43
+ @include breakpoint('lg') {
44
+ padding-bottom: rem(113px);
45
+ }
46
+
47
+ .nsw-dialog--single-action & {
48
+ padding-bottom: rem(81px);
49
+
50
+ @include breakpoint('lg') {
51
+ padding-bottom: rem(113px);
52
+ }
53
+ }
54
+ }
55
+
56
+ &__container {
57
+ height: 100%;
58
+ max-height: calc(100vh - #{rem(145px)});
59
+ overflow-y: auto;
60
+
61
+ @include breakpoint('sm') {
62
+ max-height: calc(90vh - #{rem(145px)});
63
+ }
64
+
65
+ @include breakpoint('md') {
66
+ max-height: calc(90vh - #{rem(81px)});
67
+ }
68
+
69
+ @include breakpoint('lg') {
70
+ max-height: calc(90vh - #{rem(113px)});
71
+ }
72
+
73
+ .nsw-dialog--single-action & {
74
+ max-height: calc(100vh - #{rem(81px)});
75
+
76
+ @include breakpoint('sm') {
77
+ max-height: calc(90vh - #{rem(81px)});
78
+ }
79
+
80
+ @include breakpoint('lg') {
81
+ max-height: calc(90vh - #{rem(113px)});
82
+ }
83
+ }
84
+ }
85
+
86
+ &__top {
87
+ border-bottom: 1px solid var(--nsw-grey-04);
88
+ display: flex;
89
+ }
90
+
91
+ &__title {
92
+ padding: rem(16px);
93
+ width: 100%;
94
+
95
+ @include breakpoint('lg') {
96
+ padding: rem(32px);
97
+ }
98
+ }
99
+
100
+ &__close {
101
+ min-width: rem(48px);
102
+ max-width: rem(48px);
103
+ padding: rem(8px) rem(8px) rem(8px) 0;
104
+
105
+ @include breakpoint('lg') {
106
+ min-width: rem(64px);
107
+ max-width: rem(64px);
108
+ padding: rem(24px) rem(24px) rem(24px) 0;
109
+ }
110
+ }
111
+
112
+ &__content {
113
+ padding: rem(16px);
114
+
115
+ @include breakpoint('lg') {
116
+ padding: rem(32px);
117
+ }
118
+ }
119
+
120
+ &__bottom {
121
+ border-top: 1px solid var(--nsw-grey-04);
122
+ position: absolute;
123
+ bottom: 0;
124
+ left: 0;
125
+ right: 0;
126
+ display: flex;
127
+ flex-direction: column;
128
+ padding: rem(16px);
129
+
130
+ @include breakpoint('md') {
131
+ flex-direction: row-reverse;
132
+ justify-content: flex-start;
133
+ }
134
+
135
+ @include breakpoint('lg') {
136
+ padding: rem(32px);
137
+ }
138
+
139
+ button {
140
+ margin-bottom: rem(16px);
141
+
142
+ @include breakpoint('md') {
143
+ margin-left: rem(16px);
144
+ margin-bottom: 0;
145
+ }
146
+
147
+ &:last-child {
148
+ margin-bottom: 0;
149
+
150
+ @include breakpoint('md') {
151
+ margin-left: 0;
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
@@ -0,0 +1,60 @@
1
+ class Dialog {
2
+ constructor(element) {
3
+ this.dialog = element
4
+ this.dialogWrapper = element.querySelector('.nsw-dialog__wrapper')
5
+ this.openBtn = document.querySelectorAll('.js-open-dialog-'.concat(element.getAttribute('id')))
6
+ this.closeBtn = element.querySelectorAll('.js-close-dialog')
7
+ // eslint-disable-next-line max-len
8
+ this.focusableEls = element.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])')
9
+ this.body = document.body
10
+ this.openEvent = (e) => this.openDialog(e)
11
+ this.closeEvent = (e) => this.closeDialog(e)
12
+ this.clickEvent = (e) => this.clickDialog(e)
13
+ this.trapEvent = (e) => this.trapFocus(e)
14
+ }
15
+
16
+ init() {
17
+ this.controls()
18
+ }
19
+
20
+ controls() {
21
+ this.openBtn.forEach((btn) => {
22
+ btn.addEventListener('click', this.openEvent, false)
23
+ })
24
+ this.closeBtn.forEach((btn) => {
25
+ btn.addEventListener('click', this.closeEvent, false)
26
+ })
27
+
28
+ if (this.dialog.classList.contains('js-dialog-dismiss')) {
29
+ this.dialog.addEventListener('click', this.clickEvent, false)
30
+ }
31
+
32
+ this.focusableEls[this.focusableEls.length - 1].addEventListener('blur', this.trapEvent, false)
33
+ }
34
+
35
+ openDialog() {
36
+ this.dialog.setAttribute('aria-expanded', 'true')
37
+ this.dialog.classList.add('active')
38
+ this.body.classList.add('dialog-active')
39
+ this.focusableEls[0].focus()
40
+ }
41
+
42
+ closeDialog() {
43
+ this.dialog.setAttribute('aria-expanded', 'false')
44
+ this.dialog.classList.remove('active')
45
+ this.body.classList.remove('dialog-active')
46
+ }
47
+
48
+ clickDialog(e) {
49
+ if (!this.dialogWrapper.contains(e.target)) {
50
+ this.closeDialog()
51
+ }
52
+ }
53
+
54
+ trapFocus(e) {
55
+ e.preventDefault()
56
+ this.focusableEls[0].focus()
57
+ }
58
+ }
59
+
60
+ export default Dialog