nsw-design-system 2.13.0 → 3.0.2

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 (95) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +50 -20
  3. package/dist/css/core.css +2 -0
  4. package/dist/css/main.css +1 -1
  5. package/dist/js/main.js +208 -124
  6. package/package.json +4 -2
  7. package/src/components/_all.scss +27 -0
  8. package/src/components/accordion/_accordion.scss +68 -30
  9. package/src/components/accordion/accordion.js +61 -14
  10. package/src/components/breadcrumbs/_breadcrumbs.scss +34 -43
  11. package/src/components/button/_button.scss +171 -27
  12. package/src/components/callout/_callout.scss +13 -57
  13. package/src/components/card/_card.scss +222 -71
  14. package/src/components/content-block/_content-block.scss +16 -45
  15. package/src/components/filters/_filters.scss +25 -85
  16. package/src/components/filters/filters.js +0 -5
  17. package/src/components/footer/_footer.scss +80 -132
  18. package/src/components/{forms/_forms.scss → form/_form.scss} +122 -75
  19. package/src/components/global-alert/_global-alert.scss +68 -0
  20. package/src/components/{site-wide-message/site-wide-message.js → global-alert/global-alert.js} +3 -3
  21. package/src/components/header/_header.scss +196 -227
  22. package/src/components/hero-banner/_hero-banner.scss +152 -86
  23. package/src/components/hero-search/_hero-search.scss +26 -38
  24. package/src/components/in-page-alert/_in-page-alert.scss +54 -0
  25. package/src/components/in-page-nav/_in-page-nav.scss +22 -0
  26. package/src/components/link-list/_link-list.scss +28 -47
  27. package/src/components/list-item/_list-item.scss +31 -43
  28. package/src/components/main-nav/_main-nav.scss +272 -0
  29. package/src/components/{main-navigation/main-navigation.js → main-nav/main-nav.js} +40 -39
  30. package/src/components/masthead/_masthead.scss +61 -0
  31. package/src/components/media/_media.scss +14 -2
  32. package/src/components/pagination/_pagination.scss +37 -41
  33. package/src/components/progress-indicator/_progress-indicator.scss +11 -11
  34. package/src/components/side-nav/_side-nav.scss +73 -0
  35. package/src/components/table/_table.scss +56 -0
  36. package/src/components/tables/_tables.scss +0 -71
  37. package/src/components/tabs/_tabs.scss +79 -0
  38. package/src/components/{tab-navigation/tab-navigation.js → tabs/tabs.js} +9 -9
  39. package/src/components/tag/_tag.scss +60 -0
  40. package/src/core/_all.scss +6 -0
  41. package/src/core/grid/_grid.scss +117 -0
  42. package/src/core/iconography/_icon.scss +83 -0
  43. package/src/core/layout/_layout.scss +42 -0
  44. package/src/core/section/_section.scss +95 -0
  45. package/src/{global/scss/helpers → core/spacing}/_spacing.scss +27 -4
  46. package/src/core/typography/_typography.scss +266 -0
  47. package/src/global/scss/base/_all.scss +4 -0
  48. package/src/global/scss/base/_functions.scss +44 -0
  49. package/src/global/scss/{style/_base.scss → base/_global.scss} +1 -2
  50. package/src/global/scss/base/_mixins.scss +241 -0
  51. package/src/global/scss/{tools → base}/_print.scss +3 -3
  52. package/src/global/scss/helpers/_all.scss +4 -3
  53. package/src/global/scss/helpers/_colour.scss +86 -0
  54. package/src/global/scss/helpers/_list.scss +21 -0
  55. package/src/global/scss/helpers/_text.scss +9 -0
  56. package/src/global/scss/helpers/_visibility.scss +31 -0
  57. package/src/global/scss/settings/_palette.scss +69 -0
  58. package/src/global/scss/settings/_settings.scss +12 -296
  59. package/src/global/scss/settings/_theme.scss +82 -0
  60. package/src/main.js +8 -11
  61. package/src/main.scss +17 -21
  62. package/dist/assets/svg/sprite.svg +0 -1
  63. package/src/components/banner/_banner.scss +0 -170
  64. package/src/components/direction-links/_direction-links.scss +0 -62
  65. package/src/components/feature-tile/_feature-tile.scss +0 -175
  66. package/src/components/forms/_forms-prev.scss +0 -357
  67. package/src/components/in-page-navigation/_in-page-navigation.scss +0 -26
  68. package/src/components/main-navigation/_main-navigation.scss +0 -405
  69. package/src/components/notification/_notification.scss +0 -69
  70. package/src/components/side-navigation/_side-navigation.scss +0 -85
  71. package/src/components/site-wide-message/_site-wide-message.scss +0 -148
  72. package/src/components/social-bar/_social-bar.scss +0 -27
  73. package/src/components/social-bar/social-bar.js +0 -24
  74. package/src/components/tab-navigation/_tab-navigation.scss +0 -69
  75. package/src/components/tags/_tags.scss +0 -65
  76. package/src/global/scss/helpers/_section.scss +0 -50
  77. package/src/global/scss/helpers/_sr-only.scss +0 -8
  78. package/src/global/scss/style/_all.scss +0 -4
  79. package/src/global/scss/style/_docs.scss +0 -538
  80. package/src/global/scss/style/_grid.scss +0 -171
  81. package/src/global/scss/style/_icons.scss +0 -68
  82. package/src/global/scss/tools/_all.scss +0 -10
  83. package/src/global/scss/tools/_breakpoint.scss +0 -16
  84. package/src/global/scss/tools/_buttons.scss +0 -15
  85. package/src/global/scss/tools/_focus.scss +0 -26
  86. package/src/global/scss/tools/_general.scss +0 -189
  87. package/src/global/scss/tools/_grid.scss +0 -129
  88. package/src/global/scss/tools/_links.scss +0 -18
  89. package/src/global/scss/tools/_spacing.scss +0 -37
  90. package/src/global/scss/tools/_sr-only.scss +0 -21
  91. package/src/global/scss/tools/_typography.scss +0 -90
  92. package/src/styles/grid/_grid.scss +0 -0
  93. package/src/styles/iconography/_iconography.scss +0 -0
  94. package/src/styles/layout/_layout.scss +0 -0
  95. package/src/styles/typography/_typography.scss +0 -219
package/dist/js/main.js CHANGED
@@ -26,6 +26,62 @@
26
26
  return Constructor;
27
27
  }
28
28
 
29
+ function _slicedToArray(arr, i) {
30
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
31
+ }
32
+
33
+ function _arrayWithHoles(arr) {
34
+ if (Array.isArray(arr)) return arr;
35
+ }
36
+
37
+ function _iterableToArrayLimit(arr, i) {
38
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
39
+ var _arr = [];
40
+ var _n = true;
41
+ var _d = false;
42
+ var _e = undefined;
43
+
44
+ try {
45
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
46
+ _arr.push(_s.value);
47
+
48
+ if (i && _arr.length === i) break;
49
+ }
50
+ } catch (err) {
51
+ _d = true;
52
+ _e = err;
53
+ } finally {
54
+ try {
55
+ if (!_n && _i["return"] != null) _i["return"]();
56
+ } finally {
57
+ if (_d) throw _e;
58
+ }
59
+ }
60
+
61
+ return _arr;
62
+ }
63
+
64
+ function _unsupportedIterableToArray(o, minLen) {
65
+ if (!o) return;
66
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
67
+ var n = Object.prototype.toString.call(o).slice(8, -1);
68
+ if (n === "Object" && o.constructor) n = o.constructor.name;
69
+ if (n === "Map" || n === "Set") return Array.from(n);
70
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
71
+ }
72
+
73
+ function _arrayLikeToArray(arr, len) {
74
+ if (len == null || len > arr.length) len = arr.length;
75
+
76
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
77
+
78
+ return arr2;
79
+ }
80
+
81
+ function _nonIterableRest() {
82
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
+ }
84
+
29
85
  var SiteSearch = /*#__PURE__*/function () {
30
86
  function SiteSearch(element) {
31
87
  _classCallCheck(this, SiteSearch);
@@ -122,11 +178,6 @@
122
178
  var prefixValue = prefix === undefined ? 'nsw' : prefix;
123
179
  return "".concat(prefixValue, "-").concat(Math.random().toString(36).substr(2, 16));
124
180
  };
125
- var popupWindow = function popupWindow(url, width, height) {
126
- var y = window.top.outerHeight / 2 + window.top.screenY - height / 2;
127
- var x = window.top.outerWidth / 2 + window.top.screenX - width / 2;
128
- window.open(url, '', "toolbar=no,location=no,directories=no, status=no,\n menubar=no, scrollbars=no, resizable=no, copyhistory=no,\n width=".concat(width, ", height=").concat(height, ", top=").concat(y, ", left=").concat(x));
129
- };
130
181
 
131
182
  var Navigation = /*#__PURE__*/function () {
132
183
  function Navigation() {
@@ -134,11 +185,11 @@
134
185
 
135
186
  _classCallCheck(this, Navigation);
136
187
 
137
- this.openNavButton = document.querySelector('.js-open-navigation');
138
- this.closeNavButtons = document.querySelectorAll('.js-close-navigation');
139
- this.openSubnavButtons = document.querySelectorAll('.js-open-subnav');
140
- this.closeSubnavButtons = document.querySelectorAll('.js-close-subnav');
141
- this.mainNavElement = document.getElementById('main-navigation');
188
+ this.openNavButton = document.querySelector('.js-open-nav');
189
+ this.closeNavButtons = document.querySelectorAll('.js-close-nav');
190
+ this.openSubNavButtons = document.querySelectorAll('.js-open-sub-nav');
191
+ this.closeSubNavButtons = document.querySelectorAll('.js-close-sub-nav');
192
+ this.mainNavElement = document.getElementById('main-nav');
142
193
  this.isMegaMenuElement = !!document.querySelector('.js-mega-menu');
143
194
  this.transitionEvent = whichTransitionEvent();
144
195
 
@@ -146,8 +197,8 @@
146
197
  return _this.mobileToggleMainNav(e);
147
198
  };
148
199
 
149
- this.mobileToggleSubnavEvent = function () {
150
- return _this.closeSubnav();
200
+ this.mobileToggleSubNavEvent = function () {
201
+ return _this.closeSubNav();
151
202
  };
152
203
 
153
204
  this.mobileShowMainTransitionEndEvent = function (e) {
@@ -210,8 +261,8 @@
210
261
  var megaMenuListItems = [];
211
262
 
212
263
  if (e.matches) {
213
- megaMenuListItems = [].slice.call(this.mainNavElement.querySelectorAll('.nsw-navigation__list > li'));
214
- this.body.classList.remove('navigation-open');
264
+ megaMenuListItems = [].slice.call(this.mainNavElement.querySelectorAll('ul > li'));
265
+ this.body.classList.remove('main-nav-active');
215
266
  } else {
216
267
  megaMenuListItems = [].slice.call(this.mainNavElement.querySelectorAll('li'));
217
268
  }
@@ -227,7 +278,7 @@
227
278
  if (this.isMegaMenuElement) {
228
279
  var listItems = [].slice.call(this.mainNavElement.querySelectorAll('li'));
229
280
  listItems.forEach(function (item) {
230
- var submenu = item.querySelector('[id^=subnav-]');
281
+ var submenu = item.querySelector('[id^=sub-nav-]');
231
282
  var link = item.querySelector('a');
232
283
 
233
284
  if (submenu) {
@@ -249,8 +300,8 @@
249
300
  this.closeNavButtons.forEach(function (element) {
250
301
  element.addEventListener('click', _this4.mobileToggleMainNavEvent, false);
251
302
  });
252
- this.closeSubnavButtons.forEach(function (element) {
253
- element.addEventListener('click', _this4.mobileToggleSubnavEvent, false);
303
+ this.closeSubNavButtons.forEach(function (element) {
304
+ element.addEventListener('click', _this4.mobileToggleSubNavEvent, false);
254
305
  });
255
306
  }
256
307
  }, {
@@ -266,7 +317,7 @@
266
317
 
267
318
  if (this.isMegaMenuElement) {
268
319
  listItems.forEach(function (item) {
269
- var submenu = item.querySelector('[id^=subnav-]');
320
+ var submenu = item.querySelector('[id^=sub-nav-]');
270
321
  var link = item.querySelector('a');
271
322
 
272
323
  if (submenu) {
@@ -286,8 +337,8 @@
286
337
  var propertyName = _ref.propertyName;
287
338
  if (!propertyName === 'transform') return;
288
339
  getFocusableElementBySelector(this.mainNavElement.id, ['> div button', '> ul > li > a']).all[1].focus();
289
- this.mainNavElement.classList.add('is-open');
290
- this.mainNavElement.classList.remove('is-opening');
340
+ this.mainNavElement.classList.add('active');
341
+ this.mainNavElement.classList.remove('activating');
291
342
  this.mainNavElement.removeEventListener(this.transitionEvent, this.mobileShowMainTransitionEndEvent, false);
292
343
  this.mainNavElement.addEventListener('keydown', this.mobileTrapTabKeyEvent, false);
293
344
  }
@@ -296,16 +347,16 @@
296
347
  value: function mobileHideMainNav(_ref2) {
297
348
  var propertyName = _ref2.propertyName;
298
349
  if (!propertyName === 'transform') return;
299
- this.mainNavElement.classList.remove('is-open');
300
- this.mainNavElement.classList.remove('is-closing');
350
+ this.mainNavElement.classList.remove('active');
351
+ this.mainNavElement.classList.remove('closing');
301
352
 
302
353
  while (this.openSubNavElements.length > 0) {
303
354
  var _this$whichSubNavLate = this.whichSubNavLatest(),
304
355
  submenu = _this$whichSubNavLate.submenu;
305
356
 
306
357
  submenu.removeEventListener('keydown', this.mobileSubNavTrapTabKeyEvent, false);
307
- submenu.classList.remove('is-open');
308
- submenu.classList.remove('is-closing');
358
+ submenu.classList.remove('active');
359
+ submenu.classList.remove('closing');
309
360
  this.openSubNavElements.pop();
310
361
  }
311
362
 
@@ -319,13 +370,13 @@
319
370
  var isExpanded = currentTarget.getAttribute('aria-expanded') === 'true';
320
371
 
321
372
  if (isExpanded) {
322
- this.body.classList.remove('navigation-open');
373
+ this.body.classList.remove('main-nav-active');
323
374
  this.openNavButton.focus();
324
- this.mainNavElement.classList.add('is-closing');
375
+ this.mainNavElement.classList.add('closing');
325
376
  this.mainNavElement.addEventListener(this.transitionEvent, this.mobileHideMainTransitionEndEvent, false);
326
377
  } else {
327
- this.body.classList.add('navigation-open');
328
- this.mainNavElement.classList.add('is-opening');
378
+ this.body.classList.add('main-nav-active');
379
+ this.mainNavElement.classList.add('activating');
329
380
  this.mainNavElement.addEventListener(this.transitionEvent, this.mobileShowMainTransitionEndEvent, false);
330
381
  }
331
382
  }
@@ -333,7 +384,7 @@
333
384
  key: "buttonClickDesktop",
334
385
  value: function buttonClickDesktop(e) {
335
386
  this.saveElements(e);
336
- this.toggleSubnavDesktop();
387
+ this.toggleSubNavDesktop();
337
388
  e.preventDefault();
338
389
  }
339
390
  }, {
@@ -341,7 +392,7 @@
341
392
  value: function buttonKeydownDesktop(e) {
342
393
  if (e.key === ' ' || e.key === 'Enter' || e.key === 'Spacebar') {
343
394
  this.saveElements(e);
344
- this.toggleSubnavDesktop();
395
+ this.toggleSubNavDesktop();
345
396
  e.preventDefault();
346
397
  }
347
398
  }
@@ -355,7 +406,7 @@
355
406
  var isExpanded = link.getAttribute('aria-expanded') === 'true';
356
407
 
357
408
  if (isExpanded) {
358
- this.toggleSubnavDesktop(true);
409
+ this.toggleSubNavDesktop(true);
359
410
  e.preventDefault();
360
411
  link.focus();
361
412
  }
@@ -381,62 +432,62 @@
381
432
  submenu = _this$whichSubNavLate3.submenu;
382
433
 
383
434
  if (!propertyName === 'transform') return;
384
- getFocusableElementBySelector(submenu.id, ['> div button', '> h2 a', '> ul > li > a']).all[2].focus();
435
+ getFocusableElementBySelector(submenu.id, ['> div button', '> .nsw-main-nav__title a', '> ul > li > a']).all[2].focus();
385
436
  submenu.removeEventListener(this.transitionEvent, this.showSubNavTransitionEndEvent, false);
386
437
  }
387
438
  }, {
388
- key: "closeSubnav",
389
- value: function closeSubnav() {
439
+ key: "closeSubNav",
440
+ value: function closeSubNav() {
390
441
  var _this$whichSubNavLate4 = this.whichSubNavLatest(),
391
442
  submenu = _this$whichSubNavLate4.submenu,
392
443
  link = _this$whichSubNavLate4.link;
393
444
 
394
445
  if (this.breakpoint.matches) {
395
446
  link.setAttribute('aria-expanded', false);
396
- link.classList.remove('is-open');
447
+ link.classList.remove('active');
397
448
  this.mainNavElement.removeEventListener('focus', this.checkFocusEvent, true); // fix: workaround for safari because it doesn't support focus event
398
449
 
399
- this.mainNavElement.removeEventListener('mousedown', this.checkFocusEvent, true);
450
+ this.mainNavElement.removeEventListener('click', this.checkFocusEvent, true);
400
451
  } else {
401
452
  link.focus();
402
453
  submenu.removeEventListener('keydown', this.mobileSubNavTrapTabKeyEvent, false);
403
454
  }
404
455
 
405
- submenu.classList.remove('is-open');
456
+ submenu.classList.remove('active');
406
457
  this.openSubNavElements.pop();
407
458
  }
408
459
  }, {
409
- key: "opensubnav",
410
- value: function opensubnav() {
460
+ key: "openSubNav",
461
+ value: function openSubNav() {
411
462
  var _this$whichSubNavLate5 = this.whichSubNavLatest(),
412
463
  submenu = _this$whichSubNavLate5.submenu,
413
464
  link = _this$whichSubNavLate5.link;
414
465
 
415
466
  if (this.breakpoint.matches) {
416
467
  link.setAttribute('aria-expanded', true);
417
- link.classList.add('is-open');
468
+ link.classList.add('active');
418
469
  this.mainNavElement.addEventListener('focus', this.checkFocusEvent, true); // fix: workaround for safari because it doesn't support focus event
419
470
 
420
- this.mainNavElement.addEventListener('mousedown', this.checkFocusEvent, true);
471
+ this.mainNavElement.addEventListener('click', this.checkFocusEvent, true);
421
472
  } else {
422
473
  submenu.addEventListener('keydown', this.mobileSubNavTrapTabKeyEvent, false);
423
474
  submenu.addEventListener(this.transitionEvent, this.showSubNavTransitionEndEvent, false);
424
475
  }
425
476
 
426
- submenu.classList.add('is-open');
477
+ submenu.classList.add('active');
427
478
  }
428
479
  }, {
429
- key: "toggleSubnavDesktop",
430
- value: function toggleSubnavDesktop() {
480
+ key: "toggleSubNavDesktop",
481
+ value: function toggleSubNavDesktop() {
431
482
  var _this$whichSubNavLate6 = this.whichSubNavLatest(),
432
483
  link = _this$whichSubNavLate6.link;
433
484
 
434
485
  var isExpanded = link.getAttribute('aria-expanded') === 'true';
435
486
 
436
487
  if (isExpanded) {
437
- this.closeSubnav();
488
+ this.closeSubNav();
438
489
  } else {
439
- this.opensubnav();
490
+ this.openSubNav();
440
491
  }
441
492
  }
442
493
  }, {
@@ -446,9 +497,10 @@
446
497
  linkParent = _this$whichSubNavLate7.linkParent;
447
498
 
448
499
  var focusWithin = linkParent.contains(e.target);
500
+ var isButton = e.target.getAttribute('role');
449
501
 
450
- if (!focusWithin) {
451
- this.toggleSubnavDesktop();
502
+ if (!focusWithin && isButton) {
503
+ this.toggleSubNavDesktop();
452
504
  }
453
505
  }
454
506
  }, {
@@ -481,7 +533,7 @@
481
533
  button.setAttribute('aria-expanded', 'false');
482
534
  button.setAttribute('aria-controls', uID);
483
535
  button.classList.add('nsw-accordion__button');
484
- button.insertAdjacentHTML('beforeend', "\n <i class=\"material-icons nsw-material-icons nsw-accordion__icon\" focusable=\"false\" aria-hidden=\"true\">keyboard_arrow_right</i>\n ");
536
+ button.insertAdjacentHTML('beforeend', "\n <span class=\"material-icons nsw-material-icons\" focusable=\"false\" aria-hidden=\"true\">keyboard_arrow_down</span>\n ");
485
537
  fragment.appendChild(button);
486
538
  return fragment;
487
539
  }
@@ -492,14 +544,29 @@
492
544
 
493
545
  _classCallCheck(this, Accordion);
494
546
 
547
+ var _Array$from = Array.from(element.querySelectorAll('.nsw-accordion__toggle button')),
548
+ _Array$from2 = _slicedToArray(_Array$from, 2),
549
+ expandAll = _Array$from2[0],
550
+ collapseAll = _Array$from2[1];
551
+
495
552
  this.accordionHeadingClass = '.nsw-accordion__title';
496
553
  this.accordion = element;
497
554
  this.headings = element.querySelectorAll(this.accordionHeadingClass);
555
+ this.expandAllBtn = expandAll;
556
+ this.collapseAllBtn = collapseAll;
498
557
  this.buttons = [];
499
558
  this.content = [];
500
559
 
501
- this.showHideEvent = function (e) {
502
- return _this.showHide(e);
560
+ this.toggleEvent = function (e) {
561
+ return _this.toggle(e);
562
+ };
563
+
564
+ this.expandAllEvent = function (e) {
565
+ return _this.expandAll(e);
566
+ };
567
+
568
+ this.collapseAllEvent = function (e) {
569
+ return _this.collapseAll(e);
503
570
  };
504
571
  }
505
572
 
@@ -514,7 +581,12 @@
514
581
  value: function setUpDom() {
515
582
  var _this2 = this;
516
583
 
517
- this.accordion.classList.add('is-ready');
584
+ this.accordion.classList.add('ready');
585
+
586
+ if (this.collapseAllBtn) {
587
+ this.collapseAllBtn.disabled = true;
588
+ }
589
+
518
590
  this.headings.forEach(function (heading) {
519
591
  var headingElem = heading;
520
592
  var contentElem = heading.nextElementSibling;
@@ -536,27 +608,79 @@
536
608
  var _this3 = this;
537
609
 
538
610
  this.buttons.forEach(function (element) {
539
- element.addEventListener('click', _this3.showHideEvent, false);
611
+ element.addEventListener('click', _this3.toggleEvent, false);
540
612
  });
613
+
614
+ if (this.expandAllBtn && this.collapseAllBtn) {
615
+ this.expandAllBtn.addEventListener('click', this.expandAllEvent, false);
616
+ this.collapseAllBtn.addEventListener('click', this.collapseAllEvent, false);
617
+ }
541
618
  }
542
619
  }, {
543
- key: "showHide",
544
- value: function showHide(e) {
620
+ key: "getTargetContent",
621
+ value: function getTargetContent(element) {
622
+ var currentIndex = this.buttons.indexOf(element);
623
+ return this.content[currentIndex];
624
+ }
625
+ }, {
626
+ key: "setAccordionState",
627
+ value: function setAccordionState(element, state) {
628
+ var targetContent = this.getTargetContent(element);
629
+
630
+ if (state === 'open') {
631
+ element.classList.add('active');
632
+ element.setAttribute('aria-expanded', 'true');
633
+ targetContent.hidden = false;
634
+ } else if (state === 'close') {
635
+ element.classList.remove('active');
636
+ element.setAttribute('aria-expanded', 'false');
637
+ targetContent.hidden = true;
638
+ }
639
+ }
640
+ }, {
641
+ key: "toggle",
642
+ value: function toggle(e) {
545
643
  var currentTarget = e.currentTarget;
546
- var currentIndex = this.buttons.indexOf(currentTarget);
547
- var targetContent = this.content[currentIndex];
644
+ var targetContent = this.getTargetContent(currentTarget);
548
645
  var isHidden = targetContent.hidden;
549
646
 
550
647
  if (isHidden) {
551
- currentTarget.classList.add('is-open');
552
- currentTarget.setAttribute('aria-expanded', 'true');
553
- targetContent.hidden = false;
648
+ this.setAccordionState(currentTarget, 'open');
554
649
  } else {
555
- currentTarget.classList.remove('is-open');
556
- currentTarget.setAttribute('aria-expanded', 'false');
557
- targetContent.hidden = true;
650
+ this.setAccordionState(currentTarget, 'close');
651
+ }
652
+
653
+ if (this.expandAllBtn && this.collapseAllBtn) {
654
+ this.expandAllBtn.disabled = this.content.every(function (item) {
655
+ return item.hidden === false;
656
+ });
657
+ this.collapseAllBtn.disabled = this.content.every(function (item) {
658
+ return item.hidden === true;
659
+ });
558
660
  }
559
661
  }
662
+ }, {
663
+ key: "expandAll",
664
+ value: function expandAll() {
665
+ var _this4 = this;
666
+
667
+ this.buttons.forEach(function (element) {
668
+ _this4.setAccordionState(element, 'open');
669
+ });
670
+ this.expandAllBtn.disabled = true;
671
+ this.collapseAllBtn.disabled = false;
672
+ }
673
+ }, {
674
+ key: "collapseAll",
675
+ value: function collapseAll() {
676
+ var _this5 = this;
677
+
678
+ this.buttons.forEach(function (element) {
679
+ _this5.setAccordionState(element, 'close');
680
+ });
681
+ this.expandAllBtn.disabled = false;
682
+ this.collapseAllBtn.disabled = true;
683
+ }
560
684
  }]);
561
685
 
562
686
  return Accordion;
@@ -593,14 +717,8 @@
593
717
  _createClass(Filters, [{
594
718
  key: "init",
595
719
  value: function init() {
596
- this.setUpDom();
597
720
  this.controls();
598
721
  }
599
- }, {
600
- key: "setUpDom",
601
- value: function setUpDom() {
602
- this.filters.classList.add('is-ready');
603
- }
604
722
  }, {
605
723
  key: "controls",
606
724
  value: function controls() {
@@ -644,38 +762,6 @@
644
762
  return Filters;
645
763
  }();
646
764
 
647
- var ShareThis = /*#__PURE__*/function () {
648
- function ShareThis() {
649
- _classCallCheck(this, ShareThis);
650
-
651
- this.sharelinks = document.querySelectorAll('.js-share-this');
652
- }
653
-
654
- _createClass(ShareThis, [{
655
- key: "init",
656
- value: function init() {
657
- this.controls();
658
- }
659
- }, {
660
- key: "controls",
661
- value: function controls() {
662
- var _this = this;
663
-
664
- this.sharelinks.forEach(function (element) {
665
- element.addEventListener('click', _this.popup, false);
666
- });
667
- }
668
- }, {
669
- key: "popup",
670
- value: function popup(e) {
671
- e.preventDefault();
672
- popupWindow(this.href, 600, 600);
673
- }
674
- }]);
675
-
676
- return ShareThis;
677
- }();
678
-
679
765
  var Tabs = /*#__PURE__*/function () {
680
766
  function Tabs(element, showTab) {
681
767
  var _this = this;
@@ -683,8 +769,8 @@
683
769
  _classCallCheck(this, Tabs);
684
770
 
685
771
  this.tablistClass = '.nsw-tabs__list';
686
- this.tablistItemClass = '.nsw-tabs__list-item';
687
- this.tablistLinkClass = '.nsw-tabs__link';
772
+ this.tablistItemClass = 'li';
773
+ this.tablistLinkClass = 'a';
688
774
  this.tab = element;
689
775
  this.showTab = showTab;
690
776
  this.tabList = element.querySelector(this.tablistClass);
@@ -719,7 +805,6 @@
719
805
  tabListWrapper.classList.add('nsw-tabs__list-wrapper');
720
806
  this.tab.prepend(tabListWrapper);
721
807
  tabListWrapper.prepend(this.tabList);
722
- this.tab.classList.add('is-ready');
723
808
  this.tabList.setAttribute('role', 'tablist');
724
809
  this.tabItems.forEach(function (item) {
725
810
  var itemElem = item;
@@ -758,13 +843,12 @@
758
843
  }, {
759
844
  key: "setInitalTab",
760
845
  value: function setInitalTab() {
761
- var tabItems = this.tabItems,
762
- tabLinks = this.tabLinks,
846
+ var tabLinks = this.tabLinks,
763
847
  tabPanel = this.tabPanel,
764
848
  showTab = this.showTab;
765
849
  var index = showTab === undefined ? 0 : showTab;
766
850
  var selectedLink = tabLinks[index];
767
- tabItems[index].classList.add('is-selected');
851
+ selectedLink.classList.add('active');
768
852
  selectedLink.removeAttribute('tabindex');
769
853
  selectedLink.setAttribute('aria-selected', true);
770
854
  tabPanel[index].hidden = false;
@@ -785,16 +869,19 @@
785
869
  clickedTab.focus();
786
870
  clickedTab.removeAttribute('tabindex');
787
871
  clickedTab.setAttribute('aria-selected', true);
872
+ clickedTab.classList.add('active');
788
873
  this.selectedTab.setAttribute('aria-selected', false);
789
874
  this.selectedTab.setAttribute('tabindex', '-1');
875
+ this.selectedTab.classList.remove('active');
790
876
  var clickedTabIndex = this.tabLinks.indexOf(clickedTab);
791
877
  var selectedTabIndex = this.tabLinks.indexOf(this.selectedTab);
792
- this.tabItems[clickedTabIndex].classList.add('is-selected');
793
- this.tabItems[selectedTabIndex].classList.remove('is-selected');
794
878
  this.tabPanel[clickedTabIndex].hidden = false;
795
879
  this.tabPanel[selectedTabIndex].hidden = true;
796
880
  this.selectedTab = clickedTab;
797
- this.selectedTab.scrollIntoView();
881
+
882
+ if (!clickedTab.classList.contains('js-tabs-fixed')) {
883
+ this.selectedTab.scrollIntoView();
884
+ }
798
885
  }
799
886
  }
800
887
  }, {
@@ -852,21 +939,21 @@
852
939
  return Tabs;
853
940
  }();
854
941
 
855
- var SitewideMessage = /*#__PURE__*/function () {
856
- function SitewideMessage(element) {
942
+ var GlobalAlert = /*#__PURE__*/function () {
943
+ function GlobalAlert(element) {
857
944
  var _this = this;
858
945
 
859
- _classCallCheck(this, SitewideMessage);
946
+ _classCallCheck(this, GlobalAlert);
860
947
 
861
948
  this.messageElement = element;
862
- this.closeButton = element.querySelector('.nsw-sitewide-message__close');
949
+ this.closeButton = element.querySelector('.js-close-alert');
863
950
 
864
951
  this.closeMessageEvent = function (e) {
865
952
  return _this.closeMessage(e);
866
953
  };
867
954
  }
868
955
 
869
- _createClass(SitewideMessage, [{
956
+ _createClass(GlobalAlert, [{
870
957
  key: "init",
871
958
  value: function init() {
872
959
  this.controls();
@@ -883,7 +970,7 @@
883
970
  }
884
971
  }]);
885
972
 
886
- return SitewideMessage;
973
+ return GlobalAlert;
887
974
  }();
888
975
 
889
976
  if (window.NodeList && !NodeList.prototype.forEach) {
@@ -916,7 +1003,7 @@
916
1003
  var accordions = document.querySelectorAll('.js-accordion');
917
1004
  var filters = document.querySelectorAll('.js-filters');
918
1005
  var tabs = document.querySelectorAll('.js-tabs');
919
- var siteMessages = document.querySelectorAll('.js-sitewide-message');
1006
+ var globalAlert = document.querySelectorAll('.js-global-alert');
920
1007
  openSearchButton.forEach(function (element) {
921
1008
  new SiteSearch(element).init();
922
1009
  });
@@ -941,20 +1028,17 @@
941
1028
  });
942
1029
  }
943
1030
 
944
- new ShareThis().init();
945
-
946
- if (siteMessages) {
947
- siteMessages.forEach(function (element) {
948
- new SitewideMessage(element).init();
1031
+ if (globalAlert) {
1032
+ globalAlert.forEach(function (element) {
1033
+ new GlobalAlert(element).init();
949
1034
  });
950
1035
  }
951
1036
  }
952
1037
 
953
1038
  exports.Accordion = Accordion;
1039
+ exports.GlobalAlert = GlobalAlert;
954
1040
  exports.Navigation = Navigation;
955
- exports.ShareThis = ShareThis;
956
1041
  exports.SiteSearch = SiteSearch;
957
- exports.SitewideMessage = SitewideMessage;
958
1042
  exports.Tabs = Tabs;
959
1043
  exports.initSite = initSite;
960
1044
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "2.13.0",
3
+ "version": "3.0.2",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/main.js",
6
6
  "style": "dist/main.css",
7
7
  "files": [
8
8
  "dist/{css,js,assets/svg}/*.{css,js,svg}",
9
- "src/{components,patterns,styles}/**/*.{scss,js}",
9
+ "src/{components,patterns,styles,core}/**/*.{scss,js}",
10
10
  "src/global/{scripts,scss}/**/*.{scss,js}",
11
11
  "src/main.{scss,js}"
12
12
  ],
@@ -21,6 +21,7 @@
21
21
  "scripts": {
22
22
  "dev": "gulp",
23
23
  "starterkit:build": "gulp build",
24
+ "prod:build": "gulp buildprod",
24
25
  "surge": "gulp surge",
25
26
  "add": "node add-component.js",
26
27
  "git-tag": "git tag v$npm_package_version && git push origin v$npm_package_version",
@@ -63,6 +64,7 @@
63
64
  "gulp-replace": "^1.0.0",
64
65
  "gulp-sass": "^4.0.2",
65
66
  "gulp-sass-glob": "^1.1.0",
67
+ "gulp-sitemap": "^8.0.0",
66
68
  "gulp-sourcemaps": "^2.6.5",
67
69
  "gulp-stylelint": "^13.0.0",
68
70
  "gulp-surge": "^0.1.4",
@@ -0,0 +1,27 @@
1
+ @import 'accordion/accordion';
2
+ @import 'breadcrumbs/breadcrumbs';
3
+ @import 'button/button';
4
+ @import 'callout/callout';
5
+ @import 'card/card';
6
+ @import 'content-block/content-block';
7
+ @import 'filters/filters';
8
+ @import 'footer/footer';
9
+ @import 'form/form';
10
+ @import 'global-alert/global-alert';
11
+ @import 'header/header';
12
+ @import 'hero-banner/hero-banner';
13
+ @import 'hero-search/hero-search';
14
+ @import 'in-page-alert/in-page-alert';
15
+ @import 'in-page-nav/in-page-nav';
16
+ @import 'link-list/link-list';
17
+ @import 'list-item/list-item';
18
+ @import 'main-nav/main-nav';
19
+ @import 'masthead/masthead';
20
+ @import 'media/media';
21
+ @import 'pagination/pagination';
22
+ @import 'progress-indicator/progress-indicator';
23
+ @import 'results-bar/results-bar';
24
+ @import 'side-nav/side-nav';
25
+ @import 'table/table';
26
+ @import 'tabs/tabs';
27
+ @import 'tag/tag';