@nationalarchives/frontend 0.1.10-prerelease → 0.1.12-prerelease

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 (115) hide show
  1. package/README.md +1 -1
  2. package/govuk-prototype-kit.config.json +0 -3
  3. package/nationalarchives/_features.scss +3 -0
  4. package/nationalarchives/all.css +1 -1
  5. package/nationalarchives/all.css.map +1 -1
  6. package/nationalarchives/all.js +1 -1
  7. package/nationalarchives/all.js.map +1 -1
  8. package/nationalarchives/all.mjs +24 -8
  9. package/nationalarchives/all.scss +8 -4
  10. package/nationalarchives/assets/images/tna-square-logo.svg +5 -24
  11. package/nationalarchives/components/_index.scss +13 -0
  12. package/nationalarchives/components/breadcrumbs/_index.scss +28 -7
  13. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +1 -1
  14. package/nationalarchives/components/breadcrumbs/fixtures.json +1 -1
  15. package/nationalarchives/components/breadcrumbs/macro.njk +1 -1
  16. package/nationalarchives/components/breadcrumbs/template.njk +14 -13
  17. package/nationalarchives/components/button/_index.scss +23 -11
  18. package/nationalarchives/components/button/button.stories.js +1 -1
  19. package/nationalarchives/components/button/fixtures.json +5 -5
  20. package/nationalarchives/components/button/macro.njk +1 -1
  21. package/nationalarchives/components/card/_index.scss +51 -7
  22. package/nationalarchives/components/card/card.js +2 -0
  23. package/nationalarchives/components/card/card.js.map +1 -0
  24. package/nationalarchives/components/card/card.mjs +45 -0
  25. package/nationalarchives/components/card/card.stories.js +18 -14
  26. package/nationalarchives/components/card/fixtures.json +14 -12
  27. package/nationalarchives/components/card/macro-options.json +18 -0
  28. package/nationalarchives/components/card/macro.njk +1 -1
  29. package/nationalarchives/components/card/template.njk +9 -4
  30. package/nationalarchives/components/filters/filters.stories.js +1 -1
  31. package/nationalarchives/components/filters/macro.njk +1 -1
  32. package/nationalarchives/components/filters/template.njk +2 -2
  33. package/nationalarchives/components/footer/_index.scss +24 -12
  34. package/nationalarchives/components/footer/fixtures.json +1 -1
  35. package/nationalarchives/components/footer/footer.stories.js +7 -7
  36. package/nationalarchives/components/footer/macro.njk +1 -1
  37. package/nationalarchives/components/footer/template.njk +4 -4
  38. package/nationalarchives/components/grid/_index.scss +10 -12
  39. package/nationalarchives/components/grid/fixtures.json +12 -12
  40. package/nationalarchives/components/grid/grid.stories.js +55 -1
  41. package/nationalarchives/components/grid/macro-options.json +30 -0
  42. package/nationalarchives/components/grid/macro.njk +1 -1
  43. package/nationalarchives/components/grid/template.njk +17 -1
  44. package/nationalarchives/components/header/_index.scss +103 -38
  45. package/nationalarchives/components/header/header.js +1 -1
  46. package/nationalarchives/components/header/header.js.map +1 -1
  47. package/nationalarchives/components/header/header.mjs +1 -12
  48. package/nationalarchives/components/header/header.stories.js +143 -2
  49. package/nationalarchives/components/header/macro-options.json +26 -0
  50. package/nationalarchives/components/header/macro.njk +1 -1
  51. package/nationalarchives/components/header/template.njk +27 -30
  52. package/nationalarchives/components/hero/_index.scss +33 -6
  53. package/nationalarchives/components/hero/fixtures.json +16 -1
  54. package/nationalarchives/components/hero/hero.stories.js +17 -3
  55. package/nationalarchives/components/hero/macro-options.json +13 -1
  56. package/nationalarchives/components/hero/macro.njk +1 -1
  57. package/nationalarchives/components/hero/template.njk +7 -5
  58. package/nationalarchives/components/phase-banner/_index.scss +17 -0
  59. package/nationalarchives/components/phase-banner/fixtures.json +69 -2
  60. package/nationalarchives/components/phase-banner/macro.njk +1 -1
  61. package/nationalarchives/components/phase-banner/phase-banner.stories.js +32 -6
  62. package/nationalarchives/components/phase-banner/template.njk +4 -4
  63. package/nationalarchives/components/picture/_index.scss +77 -0
  64. package/nationalarchives/components/picture/fixtures.json +4 -0
  65. package/nationalarchives/components/picture/macro-options.json +88 -0
  66. package/nationalarchives/components/picture/macro.njk +3 -0
  67. package/nationalarchives/components/picture/picture.js +2 -0
  68. package/nationalarchives/components/picture/picture.js.map +1 -0
  69. package/nationalarchives/components/picture/picture.mjs +57 -0
  70. package/nationalarchives/components/picture/picture.stories.js +63 -0
  71. package/nationalarchives/components/picture/template.njk +42 -0
  72. package/nationalarchives/components/profile/_index.scss +2 -0
  73. package/nationalarchives/components/profile/fixtures.json +4 -0
  74. package/nationalarchives/components/profile/macro-options.json +14 -0
  75. package/nationalarchives/components/profile/macro.njk +3 -0
  76. package/nationalarchives/components/profile/profile.stories.js +32 -0
  77. package/nationalarchives/components/profile/template.njk +15 -0
  78. package/nationalarchives/components/sensitive-image/fixtures.json +3 -3
  79. package/nationalarchives/components/sensitive-image/macro.njk +1 -1
  80. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +1 -1
  81. package/nationalarchives/components/tabs/_index.scss +148 -0
  82. package/nationalarchives/components/tabs/fixtures.json +4 -0
  83. package/nationalarchives/components/tabs/macro-options.json +52 -0
  84. package/nationalarchives/components/tabs/macro.njk +3 -0
  85. package/nationalarchives/components/tabs/tabs.js +2 -0
  86. package/nationalarchives/components/tabs/tabs.js.map +1 -0
  87. package/nationalarchives/components/tabs/tabs.mjs +214 -0
  88. package/nationalarchives/components/tabs/tabs.stories.js +302 -0
  89. package/nationalarchives/components/tabs/template.njk +20 -0
  90. package/nationalarchives/patterns/_index.scss +1 -0
  91. package/nationalarchives/patterns/featured-collection/_index.scss +13 -0
  92. package/nationalarchives/patterns/featured-collection/featured-collection.stories.js +35 -0
  93. package/nationalarchives/patterns/featured-collection/macro-options.json +20 -0
  94. package/nationalarchives/patterns/featured-collection/macro.njk +3 -0
  95. package/nationalarchives/patterns/featured-collection/template.njk +96 -0
  96. package/nationalarchives/stories/development/contributing.mdx +2 -1
  97. package/nationalarchives/stories/utilities/colour.stories.js +189 -0
  98. package/nationalarchives/stories/utilities/typography.mdx +1 -0
  99. package/nationalarchives/stories/utilities/typography.stories.js +15 -0
  100. package/nationalarchives/templates/layouts/_generic.njk +1 -1
  101. package/nationalarchives/tools/_colour.scss +129 -0
  102. package/nationalarchives/tools/_grid.scss +2 -2
  103. package/nationalarchives/tools/_index.scss +5 -0
  104. package/nationalarchives/tools/_typography.scss +15 -0
  105. package/nationalarchives/utilities/_debug.scss +11 -0
  106. package/nationalarchives/utilities/_global.scss +65 -41
  107. package/nationalarchives/utilities/_index.scss +3 -0
  108. package/nationalarchives/utilities/_typography.scss +92 -60
  109. package/nationalarchives/variables/_colour.scss +98 -71
  110. package/nationalarchives/variables/_typography.scss +1 -1
  111. package/package.json +24 -23
  112. package/nationalarchives/components/_all.scss +0 -10
  113. package/nationalarchives/tools/_all.scss +0 -4
  114. package/nationalarchives/utilities/_all.scss +0 -2
  115. /package/nationalarchives/variables/{_all.scss → _index.scss} +0 -0
@@ -1,14 +1,17 @@
1
1
  @use "sass:math";
2
- @use "../../variables/colour";
2
+ @use "../../utilities/global"; // To get %tna-invert
3
+ @use "../../tools/colour";
4
+ @use "../../variables/colour" as colourVars; // TODO
3
5
  @use "../../variables/grid";
4
- @use "../../variables/typography";
6
+ @use "../../tools/typography";
5
7
  @use "../../tools/media";
6
- @use "../../tools/typography" as tools;
7
8
 
8
9
  .tna-header {
9
10
  color: #fff;
10
11
 
11
- background-color: colour.$tna-black;
12
+ background-color: colourVars.$tna-black;
13
+
14
+ // @include colour.invert;
12
15
 
13
16
  &__exit {
14
17
  padding-top: 0.5rem;
@@ -16,7 +19,7 @@
16
19
 
17
20
  text-align: right;
18
21
 
19
- background-color: colour.$dark;
22
+ background-color: colourVars.$dark-grey;
20
23
  }
21
24
 
22
25
  &__exit-link {
@@ -79,7 +82,7 @@
79
82
 
80
83
  background-color: #fff;
81
84
 
82
- outline: 0.2rem colour.$dark solid;
85
+ outline: 0.2rem colourVars.$dark-grey solid;
83
86
 
84
87
  transform: rotate(45deg) translateX(50%);
85
88
  transform-origin: 100% 0;
@@ -100,7 +103,6 @@
100
103
  }
101
104
 
102
105
  &__logo-link {
103
- display: -ms-flexbox;
104
106
  display: flex;
105
107
  align-items: flex-end;
106
108
 
@@ -126,6 +128,7 @@
126
128
  }
127
129
 
128
130
  .tna-logo__background {
131
+ fill: none;
129
132
  }
130
133
 
131
134
  &__logo-strapline {
@@ -231,7 +234,7 @@
231
234
  &--orange,
232
235
  &--green,
233
236
  &--blue {
234
- color: colour.$tna-black;
237
+ color: colourVars.$tna-black;
235
238
 
236
239
  .tna-header__logo-link {
237
240
  &:hover {
@@ -244,41 +247,82 @@
244
247
  }
245
248
 
246
249
  .tna-header__hamburger {
247
- background-color: colour.$tna-black;
250
+ background-color: colourVars.$tna-black;
248
251
  }
249
252
  }
250
253
 
251
254
  &--yellow {
252
- background-color: colour.$tna-yellow;
255
+ background-color: colourVars.$tna-yellow;
253
256
  }
254
257
 
255
258
  &--pink {
256
- background-color: colour.$tna-pink;
259
+ background-color: colourVars.$tna-pink;
257
260
  }
258
261
 
259
262
  &--orange {
260
- background-color: colour.$tna-orange;
263
+ background-color: colourVars.$tna-orange;
261
264
  }
262
265
 
263
266
  &--green {
264
- background-color: colour.$tna-green;
267
+ background-color: colourVars.$tna-green;
265
268
  }
266
269
 
267
270
  &--blue {
268
- background-color: colour.$tna-blue;
271
+ background-color: colourVars.$tna-blue;
269
272
  }
270
273
 
271
274
  &__navigation {
272
- display: -ms-flexbox;
273
275
  display: flex;
274
- justify-content: flex-end;
276
+ flex-direction: column-reverse;
277
+ justify-content: space-between;
275
278
  align-items: flex-end;
276
279
  }
277
280
 
281
+ &__top-navigation-items {
282
+ margin: 0;
283
+ padding: 1.25rem 0;
284
+
285
+ // order: 1;
286
+
287
+ list-style: none;
288
+
289
+ line-height: 1;
290
+ }
291
+
292
+ &__top-navigation-item {
293
+ margin-left: 0.75rem;
294
+
295
+ display: inline-block;
296
+ }
297
+
298
+ &__top-navigation-item-link {
299
+ display: inline-block;
300
+
301
+ text-decoration: none;
302
+
303
+ &,
304
+ &:link,
305
+ &:visited {
306
+ color: inherit;
307
+ }
308
+
309
+ &:hover,
310
+ &--selected {
311
+ &,
312
+ &:link,
313
+ &:visited {
314
+ text-decoration: underline;
315
+ text-decoration-thickness: 3px;
316
+ }
317
+ }
318
+ }
319
+
278
320
  &__navigation-items {
279
321
  margin: 0;
280
322
  padding: 0;
281
323
 
324
+ // order: 2;
325
+
282
326
  list-style: none;
283
327
 
284
328
  white-space: nowrap;
@@ -295,26 +339,32 @@
295
339
 
296
340
  display: inline-block;
297
341
 
298
- color: inherit;
299
- font-family: typography.$font-family-heading;
342
+ @include typography.heading-font;
300
343
  text-decoration: none;
301
344
  line-height: 2;
302
345
 
303
- transition:
304
- color 200ms,
305
- background-color 200ms;
346
+ // transition:
347
+ // color 200ms,
348
+ // background-color 200ms;
349
+
350
+ &,
351
+ &:link,
352
+ &:visited {
353
+ color: inherit;
354
+ }
306
355
 
307
356
  &:hover,
308
357
  &--selected {
309
- // color: colour.$tna-black;
310
- @include colour.colour-font("dark-font");
358
+ &,
359
+ &:link,
360
+ &:visited {
361
+ @include colour.colour-font("font-dark");
311
362
 
312
- // background-color: #fff;
313
- @include colour.colour-background("page-background");
314
-
315
- transition:
316
- color 50ms,
317
- background-color 50ms;
363
+ @include colour.colour-background("page-background");
364
+ }
365
+ // transition:
366
+ // color 50ms,
367
+ // background-color 50ms;
318
368
  }
319
369
  }
320
370
 
@@ -361,9 +411,8 @@
361
411
  }
362
412
 
363
413
  &__navigation {
364
- // color: colour.$base-font-colour;
365
- @include colour.colour-font("base-font");
366
- @include tools.relative-font-size(20);
414
+ @include colour.colour-font("font-base");
415
+ @include typography.relative-font-size(20);
367
416
 
368
417
  &.tna-column {
369
418
  padding-right: 0;
@@ -379,10 +428,28 @@
379
428
  }
380
429
  }
381
430
 
431
+ &__top-navigation-items {
432
+ padding: 0.5rem 1rem;
433
+
434
+ // text-align: center;
435
+
436
+ @include colour.colour-background("page-background");
437
+
438
+ border-bottom: 1px solid;
439
+ @include colour.colour-border("keyline");
440
+ }
441
+
442
+ &__top-navigation-item {
443
+ margin: 0;
444
+ padding: 0.5rem;
445
+ }
446
+
447
+ &__top-navigation-item-link {
448
+ }
449
+
382
450
  &__navigation-items {
383
451
  width: 100%;
384
452
 
385
- // background-color: #fff;
386
453
  @include colour.colour-background("page-background");
387
454
  }
388
455
 
@@ -391,7 +458,6 @@
391
458
 
392
459
  display: block;
393
460
 
394
- // border-bottom: 1px colour.$keyline-colour solid;
395
461
  border-bottom: 1px solid;
396
462
  @include colour.colour-border("keyline");
397
463
  }
@@ -414,10 +480,9 @@
414
480
  bottom: 0;
415
481
  left: 0;
416
482
 
417
- // background-color: colour.$tna-black;
418
- @include colour.colour-background("dark-font");
483
+ @include colour.colour-background("font-dark");
419
484
 
420
- transition: width 200ms;
485
+ // transition: width 200ms;
421
486
 
422
487
  content: "";
423
488
  }
@@ -426,7 +491,7 @@
426
491
  &::after {
427
492
  width: 0.25rem;
428
493
 
429
- transition: width 50ms;
494
+ // transition: width 50ms;
430
495
  }
431
496
  }
432
497
 
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("TNAFrontend",[],e):"object"==typeof exports?exports.TNAFrontend=e():(t.TNAFrontend=t.TNAFrontend||{},t.TNAFrontend["components/header/header"]=e())}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Header:()=>o});function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,a=function(t,e){if("object"!==n(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}var o=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.$module=e,this.$toggleButtonWrapper=e&&e.querySelector(".tna-header__navigation-toggle"),this.$navigation=e&&e.querySelector(".tna-header__navigation"),this.$links=e&&this.$navigation&&this.$navigation.querySelectorAll("[tabindex='0']"),this.menuOpened=!1,this.mql=window.matchMedia("(max-width: 768px)")}var e,n;return e=t,(n=[{key:"init",value:function(){var t=this;if(this.$module&&this.$toggleButtonWrapper&&this.$navigation){var e="menu-content-".concat(([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(t){return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})));this.$navigation.setAttribute("id",e),this.$toggleButton=document.createElement("button"),this.$toggleButton.innerText="Menu",this.$toggleButton.setAttribute("aria-controls",e),this.$toggleButton.setAttribute("aria-haspopup","true"),this.$toggleButton.classList.add("tna-header__navigation-toggle-button"),this.$hamburger=document.createElement("div"),this.$hamburger.classList.add("tna-header__hamburger"),this.$toggleButton.appendChild(this.$hamburger),this.$toggleButtonWrapper.appendChild(this.$toggleButton),this.syncState(),this.$toggleButton.addEventListener("click",(function(){return t.handleToggleNavigation()})),"addEventListener"in this.mql?this.mql.addEventListener("change",(function(){return t.syncState()})):this.mql.addListener((function(){return t.syncState()}))}}},{key:"handleToggleNavigation",value:function(){this.menuOpened=!this.menuOpened,this.syncState()}},{key:"syncState",value:function(){if(this.mql.matches)if(this.menuOpened){this.$navigation.classList.add("tna-header__navigation--open"),this.$navigation.hidden=!1,this.$navigation.setAttribute("aria-hidden","false"),this.$toggleButton.setAttribute("aria-expanded","true"),this.$toggleButton.setAttribute("title","Close menu"),this.$toggleButton.classList.add("tna-header__navigation-toggle-button--opened");for(var t=0;t<this.$links.length;t++)this.$links[t].setAttribute("tabindex","0")}else{this.$navigation.classList.remove("tna-header__navigation--open"),this.$navigation.hidden=!0,this.$navigation.setAttribute("aria-hidden","true"),this.$toggleButton.setAttribute("aria-expanded","false"),this.$toggleButton.setAttribute("title","Open menu"),this.$toggleButton.classList.remove("tna-header__navigation-toggle-button--opened");for(var e=0;e<this.$links.length;e++)this.$links[e].setAttribute("tabindex","-1")}else{this.$navigation.classList.add("tna-header__navigation--open"),this.$navigation.hidden=!1,this.$navigation.setAttribute("aria-hidden","false"),this.$toggleButton.setAttribute("aria-expanded","true"),this.$toggleButton.setAttribute("title","Close menu");for(var n=0;n<this.$links.length;n++)this.$links[n].setAttribute("tabindex","0")}}}])&&i(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();return e})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("TNAFrontend",[],e):"object"==typeof exports?exports.TNAFrontend=e():(t.TNAFrontend=t.TNAFrontend||{},t.TNAFrontend["components/header/header"]=e())}(self,(()=>(()=>{"use strict";var t={948:(t,e,n)=>{n.d(e,{Z:()=>i});const i=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(t){return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var a=e[i]={exports:{}};return t[i](a,a.exports,n),a.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{Header:()=>a});var t=n(948);function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function o(t,n){for(var i=0;i<n.length;i++){var o=n[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,a=function(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,"string");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===e(a)?a:String(a)),o)}var a}var a=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$toggleButtonWrapper=t&&t.querySelector(".tna-header__navigation-toggle"),this.$navigation=t&&t.querySelector(".tna-header__navigation"),this.$links=t&&this.$navigation&&this.$navigation.querySelectorAll("[tabindex='0']"),this.menuOpened=!1,this.mql=window.matchMedia("(max-width: 768px)")}var n,i;return n=e,(i=[{key:"init",value:function(){var e=this;if(this.$module&&this.$toggleButtonWrapper&&this.$navigation){var n="tna-menu-content-".concat((0,t.Z)());this.$navigation.setAttribute("id",n),this.$toggleButton=document.createElement("button"),this.$toggleButton.innerText="Menu",this.$toggleButton.setAttribute("aria-controls",n),this.$toggleButton.setAttribute("aria-haspopup","true"),this.$toggleButton.classList.add("tna-header__navigation-toggle-button"),this.$hamburger=document.createElement("div"),this.$hamburger.classList.add("tna-header__hamburger"),this.$toggleButton.appendChild(this.$hamburger),this.$toggleButtonWrapper.appendChild(this.$toggleButton),this.syncState(),this.$toggleButton.addEventListener("click",(function(){return e.handleToggleNavigation()})),"addEventListener"in this.mql?this.mql.addEventListener("change",(function(){return e.syncState()})):this.mql.addListener((function(){return e.syncState()}))}}},{key:"handleToggleNavigation",value:function(){this.menuOpened=!this.menuOpened,this.syncState()}},{key:"syncState",value:function(){if(this.mql.matches)if(this.menuOpened){this.$navigation.classList.add("tna-header__navigation--open"),this.$navigation.hidden=!1,this.$navigation.setAttribute("aria-hidden","false"),this.$toggleButton.setAttribute("aria-expanded","true"),this.$toggleButton.setAttribute("title","Close menu"),this.$toggleButton.classList.add("tna-header__navigation-toggle-button--opened");for(var t=0;t<this.$links.length;t++)this.$links[t].setAttribute("tabindex","0")}else{this.$navigation.classList.remove("tna-header__navigation--open"),this.$navigation.hidden=!0,this.$navigation.setAttribute("aria-hidden","true"),this.$toggleButton.setAttribute("aria-expanded","false"),this.$toggleButton.setAttribute("title","Open menu"),this.$toggleButton.classList.remove("tna-header__navigation-toggle-button--opened");for(var e=0;e<this.$links.length;e++)this.$links[e].setAttribute("tabindex","-1")}else{this.$navigation.classList.add("tna-header__navigation--open"),this.$navigation.hidden=!1,this.$navigation.setAttribute("aria-hidden","false"),this.$toggleButton.setAttribute("aria-expanded","true"),this.$toggleButton.setAttribute("title","Close menu");for(var n=0;n<this.$links.length;n++)this.$links[n].setAttribute("tabindex","0")}}}])&&o(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}()})(),i})()));
2
2
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components/header/header.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,KAEzBD,EAAkB,YAAIA,EAAkB,aAAK,CAAC,EAAGA,EAAkB,YAAE,4BAA8BC,IACpG,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,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AAI,EAAGA,EAAIlC,KAAKI,OAAO+B,OAAQD,IACtClC,KAAKI,OAAO8B,GAAGf,aAAa,WAAY,IAE5C,CACF,M,oEAACtB,CAAA,CAxGgB,G","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/header/header.mjs","webpack://TNAFrontend/./src/nationalarchives/lib/uuid.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = root[\"TNAFrontend\"] || {}, root[\"TNAFrontend\"][\"components/header/header\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import uuidv4 from \"../../lib/uuid.mjs\";\n\nexport class Header {\n constructor($module) {\n this.$module = $module;\n this.$toggleButtonWrapper =\n $module && $module.querySelector(\".tna-header__navigation-toggle\");\n this.$navigation =\n $module && $module.querySelector(\".tna-header__navigation\");\n this.$links =\n $module &&\n this.$navigation &&\n this.$navigation.querySelectorAll(\"[tabindex='0']\");\n this.menuOpened = false;\n this.mql = window.matchMedia(\"(max-width: 768px)\");\n }\n\n init() {\n if (!this.$module || !this.$toggleButtonWrapper || !this.$navigation) {\n return;\n }\n\n // const uniqueLinkIds = []\n\n // for (let i = 0; i < this.$links.length; i++) {\n // const uniqueLinkId = uuidv4()\n // this.$links[i].setAttribute(\"id\", uniqueLinkId);\n // uniqueLinkIds.push(uniqueLinkId)\n // }\n\n const uniqueId = `menu-content-${uuidv4()}`;\n this.$navigation.setAttribute(\"id\", uniqueId);\n // this.$navigation.setAttribute(\"aria-owns\", uniqueLinkIds.join(\",\"));\n\n this.$toggleButton = document.createElement(\"button\");\n this.$toggleButton.innerText = \"Menu\";\n this.$toggleButton.setAttribute(\"aria-controls\", uniqueId);\n this.$toggleButton.setAttribute(\"aria-haspopup\", \"true\");\n this.$toggleButton.classList.add(\"tna-header__navigation-toggle-button\");\n\n this.$hamburger = document.createElement(\"div\");\n this.$hamburger.classList.add(\"tna-header__hamburger\");\n\n this.$toggleButton.appendChild(this.$hamburger);\n this.$toggleButtonWrapper.appendChild(this.$toggleButton);\n\n this.syncState();\n\n this.$toggleButton.addEventListener(\"click\", () =>\n this.handleToggleNavigation(),\n );\n\n if (\"addEventListener\" in this.mql) {\n this.mql.addEventListener(\"change\", () => this.syncState());\n // this.mql.addEventListener(\"change\", this.syncState.bind(this));\n } else {\n this.mql.addListener(() => this.syncState());\n // this.mql.addListener(this.syncState.bind(this));\n }\n }\n\n handleToggleNavigation() {\n this.menuOpened = !this.menuOpened;\n this.syncState();\n }\n\n syncState() {\n if (this.mql.matches) {\n if (this.menuOpened) {\n this.$navigation.classList.add(\"tna-header__navigation--open\");\n this.$navigation.hidden = false;\n this.$navigation.setAttribute(\"aria-hidden\", \"false\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"true\");\n this.$toggleButton.setAttribute(\"title\", \"Close menu\");\n this.$toggleButton.classList.add(\n \"tna-header__navigation-toggle-button--opened\",\n );\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"0\");\n }\n } else {\n this.$navigation.classList.remove(\"tna-header__navigation--open\");\n this.$navigation.hidden = true;\n this.$navigation.setAttribute(\"aria-hidden\", \"true\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"false\");\n this.$toggleButton.setAttribute(\"title\", \"Open menu\");\n this.$toggleButton.classList.remove(\n \"tna-header__navigation-toggle-button--opened\",\n );\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"-1\");\n }\n }\n } else {\n this.$navigation.classList.add(\"tna-header__navigation--open\");\n this.$navigation.hidden = false;\n this.$navigation.setAttribute(\"aria-hidden\", \"false\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"true\");\n this.$toggleButton.setAttribute(\"title\", \"Close menu\");\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"0\");\n }\n }\n }\n}\n","const uuidv4 = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16),\n );\n\nexport default uuidv4;\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","Header","$module","_classCallCheck","this","$toggleButtonWrapper","querySelector","$navigation","$links","querySelectorAll","menuOpened","mql","window","matchMedia","_this","uniqueId","concat","replace","c","crypto","getRandomValues","Uint8Array","toString","setAttribute","$toggleButton","document","createElement","innerText","classList","add","$hamburger","appendChild","syncState","addEventListener","handleToggleNavigation","addListener","matches","hidden","i","length","remove"],"sourceRoot":""}
1
+ {"version":3,"file":"components/header/header.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA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AC7Cd,KAAKe,cAAcD,aAAa,gBAAiB,QACjDd,KAAKe,cAAcD,aAAa,QAAS,cACzCd,KAAKe,cAAcI,UAAUC,IAC3B,gDAGF,IAAK,IAAIS,EAAI,EAAGA,EAAI7B,KAAKI,OAAO0B,OAAQD,IACtC7B,KAAKI,OAAOyB,GAAGf,aAAa,WAAY,IAE5C,KAAO,CACLd,KAAKG,YAAYgB,UAAUY,OAAO,gCAClC/B,KAAKG,YAAYyB,QAAS,EAC1B5B,KAAKG,YAAYW,aAAa,cAAe,QAC7Cd,KAAKe,cAAcD,aAAa,gBAAiB,SACjDd,KAAKe,cAAcD,aAAa,QAAS,aACzCd,KAAKe,cAAcI,UAAUY,OAC3B,gDAGF,IAAK,IAAIF,EAAI,EAAGA,EAAI7B,KAAKI,OAAO0B,OAAQD,IACtC7B,KAAKI,OAAOyB,GAAGf,aAAa,WAAY,KAE5C,KACK,CACLd,KAAKG,YAAYgB,UAAUC,IAAI,gCAC/BpB,KAAKG,YAAYyB,QAAS,EAC1B5B,KAAKG,YAAYW,aAAa,cAAe,SAC7Cd,KAAKe,cAAcD,aAAa,gBAAiB,QACjDd,KAAKe,cAAcD,aAAa,QAAS,cAEzC,IAAK,IAAIe,EAAI,EAAGA,EAAI7B,KAAKI,OAAO0B,OAAQD,IACtC7B,KAAKI,OAAOyB,GAAGf,aAAa,WAAY,IAE5C,CACF,M,oEAACjB,CAAA,CA7FgB,E","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/./src/nationalarchives/lib/uuid.mjs","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/header/header.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = root[\"TNAFrontend\"] || {}, root[\"TNAFrontend\"][\"components/header/header\"] = factory();\n})(self, () => {\nreturn ","const uuidv4 = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16),\n );\n\nexport default uuidv4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import uuidv4 from \"../../lib/uuid.mjs\";\n\nexport class Header {\n constructor($module) {\n this.$module = $module;\n this.$toggleButtonWrapper =\n $module && $module.querySelector(\".tna-header__navigation-toggle\");\n this.$navigation =\n $module && $module.querySelector(\".tna-header__navigation\");\n this.$links =\n $module &&\n this.$navigation &&\n this.$navigation.querySelectorAll(\"[tabindex='0']\");\n this.menuOpened = false;\n this.mql = window.matchMedia(\"(max-width: 768px)\");\n }\n\n init() {\n if (!this.$module || !this.$toggleButtonWrapper || !this.$navigation) {\n return;\n }\n\n const uniqueId = `tna-menu-content-${uuidv4()}`;\n this.$navigation.setAttribute(\"id\", uniqueId);\n\n this.$toggleButton = document.createElement(\"button\");\n this.$toggleButton.innerText = \"Menu\";\n this.$toggleButton.setAttribute(\"aria-controls\", uniqueId);\n this.$toggleButton.setAttribute(\"aria-haspopup\", \"true\");\n this.$toggleButton.classList.add(\"tna-header__navigation-toggle-button\");\n\n this.$hamburger = document.createElement(\"div\");\n this.$hamburger.classList.add(\"tna-header__hamburger\");\n\n this.$toggleButton.appendChild(this.$hamburger);\n this.$toggleButtonWrapper.appendChild(this.$toggleButton);\n\n this.syncState();\n\n this.$toggleButton.addEventListener(\"click\", () =>\n this.handleToggleNavigation(),\n );\n\n if (\"addEventListener\" in this.mql) {\n this.mql.addEventListener(\"change\", () => this.syncState());\n } else {\n this.mql.addListener(() => this.syncState());\n }\n }\n\n handleToggleNavigation() {\n this.menuOpened = !this.menuOpened;\n this.syncState();\n }\n\n syncState() {\n if (this.mql.matches) {\n if (this.menuOpened) {\n this.$navigation.classList.add(\"tna-header__navigation--open\");\n this.$navigation.hidden = false;\n this.$navigation.setAttribute(\"aria-hidden\", \"false\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"true\");\n this.$toggleButton.setAttribute(\"title\", \"Close menu\");\n this.$toggleButton.classList.add(\n \"tna-header__navigation-toggle-button--opened\",\n );\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"0\");\n }\n } else {\n this.$navigation.classList.remove(\"tna-header__navigation--open\");\n this.$navigation.hidden = true;\n this.$navigation.setAttribute(\"aria-hidden\", \"true\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"false\");\n this.$toggleButton.setAttribute(\"title\", \"Open menu\");\n this.$toggleButton.classList.remove(\n \"tna-header__navigation-toggle-button--opened\",\n );\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"-1\");\n }\n }\n } else {\n this.$navigation.classList.add(\"tna-header__navigation--open\");\n this.$navigation.hidden = false;\n this.$navigation.setAttribute(\"aria-hidden\", \"false\");\n this.$toggleButton.setAttribute(\"aria-expanded\", \"true\");\n this.$toggleButton.setAttribute(\"title\", \"Close menu\");\n\n for (let i = 0; i < this.$links.length; i++) {\n this.$links[i].setAttribute(\"tabindex\", \"0\");\n }\n }\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","replace","c","crypto","getRandomValues","Uint8Array","toString","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","Header","$module","_classCallCheck","this","$toggleButtonWrapper","querySelector","$navigation","$links","querySelectorAll","menuOpened","mql","window","matchMedia","_this","uniqueId","concat","uuidv4","setAttribute","$toggleButton","document","createElement","innerText","classList","add","$hamburger","appendChild","syncState","addEventListener","handleToggleNavigation","addListener","matches","hidden","i","length","remove"],"sourceRoot":""}
@@ -20,17 +20,8 @@ export class Header {
20
20
  return;
21
21
  }
22
22
 
23
- // const uniqueLinkIds = []
24
-
25
- // for (let i = 0; i < this.$links.length; i++) {
26
- // const uniqueLinkId = uuidv4()
27
- // this.$links[i].setAttribute("id", uniqueLinkId);
28
- // uniqueLinkIds.push(uniqueLinkId)
29
- // }
30
-
31
- const uniqueId = `menu-content-${uuidv4()}`;
23
+ const uniqueId = `tna-menu-content-${uuidv4()}`;
32
24
  this.$navigation.setAttribute("id", uniqueId);
33
- // this.$navigation.setAttribute("aria-owns", uniqueLinkIds.join(","));
34
25
 
35
26
  this.$toggleButton = document.createElement("button");
36
27
  this.$toggleButton.innerText = "Menu";
@@ -52,10 +43,8 @@ export class Header {
52
43
 
53
44
  if ("addEventListener" in this.mql) {
54
45
  this.mql.addEventListener("change", () => this.syncState());
55
- // this.mql.addEventListener("change", this.syncState.bind(this));
56
46
  } else {
57
47
  this.mql.addListener(() => this.syncState());
58
- // this.mql.addListener(this.syncState.bind(this));
59
48
  }
60
49
  }
61
50
 
@@ -1,8 +1,12 @@
1
1
  import Header from "./template.njk";
2
2
  import macroOptions from "./macro-options.json";
3
+ import { expect } from "@storybook/jest";
4
+ import { within, userEvent } from "@storybook/testing-library";
5
+ import { MINIMAL_VIEWPORTS } from "@storybook/addon-viewport";
3
6
 
4
7
  const argTypes = {
5
8
  logo: { control: "object" },
9
+ topNavigation: { control: "object" },
6
10
  navigation: { control: "object" },
7
11
  colour: {
8
12
  control: "radio",
@@ -20,14 +24,26 @@ Object.keys(argTypes).forEach((argType) => {
20
24
  });
21
25
 
22
26
  export default {
23
- title: "Components/Header",
27
+ title: "Work in progress/Components/Header",
24
28
  argTypes,
29
+ parameters: {
30
+ chromatic: { delay: 1000 },
31
+ },
25
32
  };
26
33
 
27
- const Template = ({ logo, navigation, colour, exit, classes, attributes }) => {
34
+ const Template = ({
35
+ logo,
36
+ topNavigation,
37
+ navigation,
38
+ colour,
39
+ exit,
40
+ classes,
41
+ attributes,
42
+ }) => {
28
43
  return Header({
29
44
  params: {
30
45
  logo,
46
+ topNavigation,
31
47
  navigation,
32
48
  colour,
33
49
  exit,
@@ -43,6 +59,20 @@ Standard.args = {
43
59
  strapline: "Beta",
44
60
  href: "#/",
45
61
  },
62
+ // topNavigation: [
63
+ // {
64
+ // text: "Top item 1",
65
+ // href: "#/top-1"
66
+ // },
67
+ // {
68
+ // text: "Top item 2",
69
+ // href: "#/top-2",
70
+ // },
71
+ // {
72
+ // text: "Top item 3",
73
+ // href: "#/top-3",
74
+ // },
75
+ // ],
46
76
  navigation: [
47
77
  {
48
78
  text: "Alpha",
@@ -66,3 +96,114 @@ Standard.args = {
66
96
  },
67
97
  classes: "tna-header--demo",
68
98
  };
99
+
100
+ export const Desktop = Template.bind({});
101
+ Desktop.parameters = {
102
+ viewport: {
103
+ defaultViewport: "tablet",
104
+ },
105
+ chromatic: {
106
+ viewports: [MINIMAL_VIEWPORTS["tablet"].styles.width.replace(/px$/, "")],
107
+ },
108
+ };
109
+ Desktop.args = {
110
+ navigation: [
111
+ {
112
+ text: "Alpha",
113
+ href: "#/alpha",
114
+ selected: true,
115
+ },
116
+ {
117
+ text: "Beta",
118
+ href: "#/beta",
119
+ },
120
+ {
121
+ text: "Gamma",
122
+ href: "#/gamma",
123
+ },
124
+ ],
125
+ classes: "tna-header--demo",
126
+ };
127
+ Desktop.play = async ({ canvasElement }) => {
128
+ const navigationItems = canvasElement.querySelector(
129
+ `.tna-header__navigation-items`,
130
+ );
131
+ const navigationToggle = canvasElement.querySelector(
132
+ `.tna-header__navigation-toggle-button`,
133
+ );
134
+
135
+ await expect(navigationItems).toBeVisible();
136
+ await expect(navigationToggle).not.toBeVisible();
137
+ };
138
+
139
+ export const Mobile = Template.bind({});
140
+ Mobile.parameters = {
141
+ viewport: {
142
+ defaultViewport: "mobile2",
143
+ },
144
+ chromatic: {
145
+ viewports: [MINIMAL_VIEWPORTS["mobile2"].styles.width.replace(/px$/, "")],
146
+ },
147
+ };
148
+ Mobile.args = {
149
+ navigation: [
150
+ {
151
+ text: "Alpha",
152
+ href: "#/alpha",
153
+ selected: true,
154
+ },
155
+ {
156
+ text: "Beta",
157
+ href: "#/beta",
158
+ },
159
+ {
160
+ text: "Gamma",
161
+ href: "#/gamma",
162
+ },
163
+ ],
164
+ classes: "tna-header--demo",
165
+ };
166
+ Mobile.play = async ({ args, canvasElement, step }) => {
167
+ const canvas = within(canvasElement);
168
+
169
+ const navigationItems = canvasElement.querySelector(
170
+ `.tna-header__navigation-items`,
171
+ );
172
+ const [linkA, linkB, linkC] = args.navigation.map((navigationItem) =>
173
+ canvas.getByText(navigationItem.text),
174
+ );
175
+ const navigationToggle = canvasElement.querySelector(
176
+ `.tna-header__navigation-toggle-button`,
177
+ );
178
+
179
+ await step("Initial load", async () => {
180
+ await expect(navigationItems).not.toBeVisible();
181
+ await expect(navigationToggle).toBeVisible();
182
+ await expect(navigationToggle).toHaveAttribute("aria-expanded", "false");
183
+ await expect(linkA).not.toBeVisible();
184
+ await expect(linkB).not.toBeVisible();
185
+ await expect(linkC).not.toBeVisible();
186
+ });
187
+
188
+ await step("Open the menu", async () => {
189
+ await userEvent.click(navigationToggle);
190
+ await expect(navigationItems).toBeVisible();
191
+ await expect(navigationToggle).toBeVisible();
192
+ await expect(navigationToggle).toHaveAttribute("aria-expanded", "true");
193
+ await expect(linkA).toBeVisible();
194
+ await expect(linkB).toBeVisible();
195
+ await expect(linkC).toBeVisible();
196
+ });
197
+
198
+ await step("Close the menu", async () => {
199
+ await userEvent.click(navigationToggle);
200
+ await expect(navigationItems).not.toBeVisible();
201
+ await expect(navigationToggle).toBeVisible();
202
+ await expect(navigationToggle).toHaveAttribute("aria-expanded", "false");
203
+ await expect(linkA).not.toBeVisible();
204
+ await expect(linkB).not.toBeVisible();
205
+ await expect(linkC).not.toBeVisible();
206
+ });
207
+
208
+ navigationToggle.blur();
209
+ };
@@ -57,6 +57,32 @@
57
57
  }
58
58
  ]
59
59
  },
60
+ {
61
+ "name": "topNavigation",
62
+ "type": "array",
63
+ "required": false,
64
+ "description": "",
65
+ "params": [
66
+ {
67
+ "name": "text",
68
+ "type": "string",
69
+ "required": true,
70
+ "description": ""
71
+ },
72
+ {
73
+ "name": "href",
74
+ "type": "string",
75
+ "required": true,
76
+ "description": ""
77
+ },
78
+ {
79
+ "name": "title",
80
+ "type": "string",
81
+ "required": false,
82
+ "description": ""
83
+ }
84
+ ]
85
+ },
60
86
  {
61
87
  "name": "colour",
62
88
  "type": "string",
@@ -1,3 +1,3 @@
1
1
  {% macro tnaHeader(params) %}
2
- {%- include "./template.njk" -%}
2
+ {%- include "nationalarchives/components/header/template.njk" -%}
3
3
  {% endmacro %}