@nationalarchives/frontend 0.1.10-prerelease → 0.1.11-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 +96 -71
  110. package/nationalarchives/variables/_typography.scss +1 -1
  111. package/package.json +15 -14
  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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components/tabs/tabs.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,wBAA0BC,IAChG,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,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,m7CCLvD,IAAMC,EAAI,WACf,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GACnBG,KAAKF,QAAUA,EACfE,KA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NAFrontend/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/tabs/tabs.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/tabs/tabs\"] = 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};","export class Tabs {\n constructor($module) {\n this.$module = $module;\n this.$tabList = $module && $module.querySelector(\".tna-tabs__list\");\n this.$tabListItemLinks =\n $module &&\n this.$tabList &&\n $module.querySelectorAll(\".tna-tabs__list-item-link\");\n this.$tabItems = $module && $module.querySelectorAll(\".tna-tabs__item\");\n }\n\n init() {\n if (\n !this.$module ||\n !this.$tabList ||\n !this.$tabListItemLinks ||\n !this.$tabItems ||\n this.$tabListItemLinks.length !== this.$tabItems.length\n ) {\n return;\n }\n\n this.sticky = this.$module.classList.contains(\"tna-tabs--sticky\");\n\n const startingTarget = window.location.hash.replace(/^#/, \"\");\n\n this.$newTabList = document.createElement(\"div\");\n this.$newTabList.setAttribute(\"role\", \"tablist\");\n this.$newTabList.setAttribute(\"class\", this.$tabList.getAttribute(\"class\"));\n\n this.$tabItems.forEach(($tabItem, index) => {\n $tabItem.setAttribute(\"role\", \"tabpanel\");\n $tabItem.setAttribute(\n \"aria-labelledby\",\n `${$tabItem.getAttribute(\"id\")}-tab`,\n );\n $tabItem.setAttribute(\"tabindex\", \"0\");\n if (\n (startingTarget && $tabItem.getAttribute(\"id\") !== startingTarget) ||\n (!startingTarget && index > 0)\n ) {\n $tabItem.setAttribute(\"hidden\", true);\n }\n });\n\n this.$tabListItemLinks.forEach(($tabListItemLink) => {\n const $replacementButton = document.createElement(\"button\");\n $replacementButton.innerText = $tabListItemLink.innerText;\n $replacementButton.setAttribute(\n \"class\",\n $tabListItemLink.getAttribute(\"class\"),\n );\n $replacementButton.setAttribute(\"role\", \"tab\");\n $replacementButton.setAttribute(\n \"id\",\n $tabListItemLink.getAttribute(\"id\"),\n );\n $replacementButton.setAttribute(\n \"aria-controls\",\n $tabListItemLink.getAttribute(\"href\").replace(/^#/, \"\"),\n );\n $replacementButton.setAttribute(\"tabindex\", \"-1\");\n this.$newTabList.appendChild($replacementButton);\n });\n\n this.$tabList.replaceWith(this.$newTabList);\n\n this.$tabListItemLinks = this.$module.querySelectorAll(\n \".tna-tabs__list-item-link\",\n );\n\n this.$tabListItemLinks.forEach(($tabListItemLink, index) => {\n if (\n (startingTarget &&\n $tabListItemLink.getAttribute(\"aria-controls\") ===\n `${startingTarget}`) ||\n (!startingTarget && index === 0)\n ) {\n $tabListItemLink.classList.add(\"tna-tabs__list-item-link--selected\");\n $tabListItemLink.setAttribute(\"aria-selected\", true);\n $tabListItemLink.setAttribute(\"tabindex\", \"0\");\n } else {\n $tabListItemLink.setAttribute(\"aria-selected\", false);\n }\n\n $tabListItemLink.addEventListener(\n \"keydown\",\n (e) => this.handleItemLinkKeyDown(e),\n true,\n );\n $tabListItemLink.addEventListener(\n \"click\",\n (e) => this.handleItemLinkClick(e),\n true,\n );\n });\n }\n\n handleItemLinkClick(itemLinkClickEvent) {\n itemLinkClickEvent.preventDefault();\n const targetItem =\n itemLinkClickEvent.currentTarget.getAttribute(\"aria-controls\");\n\n this.switchTab(targetItem);\n }\n\n handleItemLinkKeyDown(itemLinkKeyDownEvent) {\n const targetItem = itemLinkKeyDownEvent.currentTarget;\n let overwriteKeyAction = false;\n\n switch (itemLinkKeyDownEvent.key) {\n case \"ArrowLeft\":\n this.setSelectedToPreviousTab(targetItem);\n overwriteKeyAction = true;\n break;\n\n case \"ArrowRight\":\n this.setSelectedToNextTab(targetItem);\n overwriteKeyAction = true;\n break;\n\n case \"Home\":\n this.switchTab(this.$tabListItemLinks[0].getAttribute(\"aria-controls\"));\n overwriteKeyAction = true;\n break;\n\n case \"End\":\n this.switchTab(\n this.$tabListItemLinks[\n this.$tabListItemLinks.length - 1\n ].getAttribute(\"aria-controls\"),\n );\n overwriteKeyAction = true;\n break;\n\n default:\n break;\n }\n\n if (overwriteKeyAction) {\n itemLinkKeyDownEvent.stopPropagation();\n itemLinkKeyDownEvent.preventDefault();\n }\n }\n\n setSelectedToNextTab(targetItem) {\n console.log(\"setSelectedToNextTab\", targetItem);\n const currentIndex = [...this.$tabListItemLinks].findIndex(\n ($tabListItemLink) =>\n $tabListItemLink.getAttribute(\"id\") === targetItem.getAttribute(\"id\"),\n );\n let newIndex;\n if (currentIndex < this.$tabListItemLinks.length - 1) {\n newIndex = currentIndex + 1;\n } else {\n newIndex = 0;\n }\n console.log(currentIndex, newIndex);\n this.switchTab(\n this.$tabListItemLinks[newIndex].getAttribute(\"aria-controls\"),\n );\n }\n\n setSelectedToPreviousTab(targetItem) {\n console.log(\"setSelectedToPreviousTab\", targetItem);\n const currentIndex = [...this.$tabListItemLinks].findIndex(\n ($tabListItemLink) =>\n $tabListItemLink.getAttribute(\"id\") === targetItem.getAttribute(\"id\"),\n );\n let newIndex;\n if (currentIndex >= 1) {\n newIndex = currentIndex - 1;\n } else {\n newIndex = this.$tabListItemLinks.length - 1;\n }\n console.log(currentIndex, newIndex);\n this.switchTab(\n this.$tabListItemLinks[newIndex].getAttribute(\"aria-controls\"),\n );\n }\n\n switchTab(targetId) {\n this.$tabListItemLinks.forEach(($tabListItemLink) => {\n if ($tabListItemLink.getAttribute(\"aria-controls\") === targetId) {\n $tabListItemLink.classList.add(\"tna-tabs__list-item-link--selected\");\n $tabListItemLink.setAttribute(\"aria-selected\", true);\n $tabListItemLink.setAttribute(\"tabindex\", \"0\");\n $tabListItemLink.focus();\n } else {\n $tabListItemLink.classList.remove(\"tna-tabs__list-item-link--selected\");\n $tabListItemLink.setAttribute(\"aria-selected\", false);\n $tabListItemLink.setAttribute(\"tabindex\", \"-1\");\n }\n });\n\n this.$tabItems.forEach(($tabItem) => {\n if ($tabItem.getAttribute(\"id\") === targetId) {\n $tabItem.removeAttribute(\"hidden\");\n $tabItem.setAttribute(\"tabindex\", \"0\");\n } else {\n $tabItem.setAttribute(\"hidden\", true);\n $tabItem.setAttribute(\"tabindex\", \"-1\");\n }\n });\n\n if (this.sticky) {\n if (history.replaceState) {\n history.replaceState(null, null, `#${targetId}`);\n } else {\n location.hash = `#${targetId}`;\n }\n }\n }\n}\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","Tabs","$module","_classCallCheck","this","$tabList","querySelector","$tabListItemLinks","querySelectorAll","$tabItems","_this","length","sticky","classList","contains","startingTarget","window","location","hash","replace","$newTabList","document","createElement","setAttribute","getAttribute","forEach","$tabItem","index","concat","$tabListItemLink","$replacementButton","innerText","appendChild","replaceWith","add","addEventListener","e","handleItemLinkKeyDown","handleItemLinkClick","itemLinkClickEvent","preventDefault","targetItem","currentTarget","switchTab","itemLinkKeyDownEvent","overwriteKeyAction","setSelectedToPreviousTab","setSelectedToNextTab","stopPropagation","console","log","newIndex","currentIndex","_toConsumableArray","findIndex","targetId","focus","remove","removeAttribute","history","replaceState"],"sourceRoot":""}
@@ -0,0 +1,214 @@
1
+ export class Tabs {
2
+ constructor($module) {
3
+ this.$module = $module;
4
+ this.$tabList = $module && $module.querySelector(".tna-tabs__list");
5
+ this.$tabListItemLinks =
6
+ $module &&
7
+ this.$tabList &&
8
+ $module.querySelectorAll(".tna-tabs__list-item-link");
9
+ this.$tabItems = $module && $module.querySelectorAll(".tna-tabs__item");
10
+ }
11
+
12
+ init() {
13
+ if (
14
+ !this.$module ||
15
+ !this.$tabList ||
16
+ !this.$tabListItemLinks ||
17
+ !this.$tabItems ||
18
+ this.$tabListItemLinks.length !== this.$tabItems.length
19
+ ) {
20
+ return;
21
+ }
22
+
23
+ this.sticky = this.$module.classList.contains("tna-tabs--sticky");
24
+
25
+ const startingTarget = window.location.hash.replace(/^#/, "");
26
+
27
+ this.$newTabList = document.createElement("div");
28
+ this.$newTabList.setAttribute("role", "tablist");
29
+ this.$newTabList.setAttribute("class", this.$tabList.getAttribute("class"));
30
+
31
+ this.$tabItems.forEach(($tabItem, index) => {
32
+ $tabItem.setAttribute("role", "tabpanel");
33
+ $tabItem.setAttribute(
34
+ "aria-labelledby",
35
+ `${$tabItem.getAttribute("id")}-tab`,
36
+ );
37
+ $tabItem.setAttribute("tabindex", "0");
38
+ if (
39
+ (startingTarget && $tabItem.getAttribute("id") !== startingTarget) ||
40
+ (!startingTarget && index > 0)
41
+ ) {
42
+ $tabItem.setAttribute("hidden", true);
43
+ }
44
+ });
45
+
46
+ this.$tabListItemLinks.forEach(($tabListItemLink) => {
47
+ const $replacementButton = document.createElement("button");
48
+ $replacementButton.innerText = $tabListItemLink.innerText;
49
+ $replacementButton.setAttribute(
50
+ "class",
51
+ $tabListItemLink.getAttribute("class"),
52
+ );
53
+ $replacementButton.setAttribute("role", "tab");
54
+ $replacementButton.setAttribute(
55
+ "id",
56
+ $tabListItemLink.getAttribute("id"),
57
+ );
58
+ $replacementButton.setAttribute(
59
+ "aria-controls",
60
+ $tabListItemLink.getAttribute("href").replace(/^#/, ""),
61
+ );
62
+ $replacementButton.setAttribute("tabindex", "-1");
63
+ this.$newTabList.appendChild($replacementButton);
64
+ });
65
+
66
+ this.$tabList.replaceWith(this.$newTabList);
67
+
68
+ this.$tabListItemLinks = this.$module.querySelectorAll(
69
+ ".tna-tabs__list-item-link",
70
+ );
71
+
72
+ this.$tabListItemLinks.forEach(($tabListItemLink, index) => {
73
+ if (
74
+ (startingTarget &&
75
+ $tabListItemLink.getAttribute("aria-controls") ===
76
+ `${startingTarget}`) ||
77
+ (!startingTarget && index === 0)
78
+ ) {
79
+ $tabListItemLink.classList.add("tna-tabs__list-item-link--selected");
80
+ $tabListItemLink.setAttribute("aria-selected", true);
81
+ $tabListItemLink.setAttribute("tabindex", "0");
82
+ } else {
83
+ $tabListItemLink.setAttribute("aria-selected", false);
84
+ }
85
+
86
+ $tabListItemLink.addEventListener(
87
+ "keydown",
88
+ (e) => this.handleItemLinkKeyDown(e),
89
+ true,
90
+ );
91
+ $tabListItemLink.addEventListener(
92
+ "click",
93
+ (e) => this.handleItemLinkClick(e),
94
+ true,
95
+ );
96
+ });
97
+ }
98
+
99
+ handleItemLinkClick(itemLinkClickEvent) {
100
+ itemLinkClickEvent.preventDefault();
101
+ const targetItem =
102
+ itemLinkClickEvent.currentTarget.getAttribute("aria-controls");
103
+
104
+ this.switchTab(targetItem);
105
+ }
106
+
107
+ handleItemLinkKeyDown(itemLinkKeyDownEvent) {
108
+ const targetItem = itemLinkKeyDownEvent.currentTarget;
109
+ let overwriteKeyAction = false;
110
+
111
+ switch (itemLinkKeyDownEvent.key) {
112
+ case "ArrowLeft":
113
+ this.setSelectedToPreviousTab(targetItem);
114
+ overwriteKeyAction = true;
115
+ break;
116
+
117
+ case "ArrowRight":
118
+ this.setSelectedToNextTab(targetItem);
119
+ overwriteKeyAction = true;
120
+ break;
121
+
122
+ case "Home":
123
+ this.switchTab(this.$tabListItemLinks[0].getAttribute("aria-controls"));
124
+ overwriteKeyAction = true;
125
+ break;
126
+
127
+ case "End":
128
+ this.switchTab(
129
+ this.$tabListItemLinks[
130
+ this.$tabListItemLinks.length - 1
131
+ ].getAttribute("aria-controls"),
132
+ );
133
+ overwriteKeyAction = true;
134
+ break;
135
+
136
+ default:
137
+ break;
138
+ }
139
+
140
+ if (overwriteKeyAction) {
141
+ itemLinkKeyDownEvent.stopPropagation();
142
+ itemLinkKeyDownEvent.preventDefault();
143
+ }
144
+ }
145
+
146
+ setSelectedToNextTab(targetItem) {
147
+ console.log("setSelectedToNextTab", targetItem);
148
+ const currentIndex = [...this.$tabListItemLinks].findIndex(
149
+ ($tabListItemLink) =>
150
+ $tabListItemLink.getAttribute("id") === targetItem.getAttribute("id"),
151
+ );
152
+ let newIndex;
153
+ if (currentIndex < this.$tabListItemLinks.length - 1) {
154
+ newIndex = currentIndex + 1;
155
+ } else {
156
+ newIndex = 0;
157
+ }
158
+ console.log(currentIndex, newIndex);
159
+ this.switchTab(
160
+ this.$tabListItemLinks[newIndex].getAttribute("aria-controls"),
161
+ );
162
+ }
163
+
164
+ setSelectedToPreviousTab(targetItem) {
165
+ console.log("setSelectedToPreviousTab", targetItem);
166
+ const currentIndex = [...this.$tabListItemLinks].findIndex(
167
+ ($tabListItemLink) =>
168
+ $tabListItemLink.getAttribute("id") === targetItem.getAttribute("id"),
169
+ );
170
+ let newIndex;
171
+ if (currentIndex >= 1) {
172
+ newIndex = currentIndex - 1;
173
+ } else {
174
+ newIndex = this.$tabListItemLinks.length - 1;
175
+ }
176
+ console.log(currentIndex, newIndex);
177
+ this.switchTab(
178
+ this.$tabListItemLinks[newIndex].getAttribute("aria-controls"),
179
+ );
180
+ }
181
+
182
+ switchTab(targetId) {
183
+ this.$tabListItemLinks.forEach(($tabListItemLink) => {
184
+ if ($tabListItemLink.getAttribute("aria-controls") === targetId) {
185
+ $tabListItemLink.classList.add("tna-tabs__list-item-link--selected");
186
+ $tabListItemLink.setAttribute("aria-selected", true);
187
+ $tabListItemLink.setAttribute("tabindex", "0");
188
+ $tabListItemLink.focus();
189
+ } else {
190
+ $tabListItemLink.classList.remove("tna-tabs__list-item-link--selected");
191
+ $tabListItemLink.setAttribute("aria-selected", false);
192
+ $tabListItemLink.setAttribute("tabindex", "-1");
193
+ }
194
+ });
195
+
196
+ this.$tabItems.forEach(($tabItem) => {
197
+ if ($tabItem.getAttribute("id") === targetId) {
198
+ $tabItem.removeAttribute("hidden");
199
+ $tabItem.setAttribute("tabindex", "0");
200
+ } else {
201
+ $tabItem.setAttribute("hidden", true);
202
+ $tabItem.setAttribute("tabindex", "-1");
203
+ }
204
+ });
205
+
206
+ if (this.sticky) {
207
+ if (history.replaceState) {
208
+ history.replaceState(null, null, `#${targetId}`);
209
+ } else {
210
+ location.hash = `#${targetId}`;
211
+ }
212
+ }
213
+ }
214
+ }
@@ -0,0 +1,302 @@
1
+ import Tabs from "./template.njk";
2
+ import macroOptions from "./macro-options.json";
3
+ import { expect } from "@storybook/jest";
4
+ import { within, userEvent } from "@storybook/testing-library";
5
+
6
+ const argTypes = {
7
+ title: { control: "text" },
8
+ items: { control: "array" },
9
+ sticky: { control: "boolean" },
10
+ classes: { control: "text" },
11
+ attributes: { control: "object" },
12
+ };
13
+
14
+ Object.keys(argTypes).forEach((argType) => {
15
+ argTypes[argType].description = macroOptions.find(
16
+ (option) => option.name === argType,
17
+ )?.description;
18
+ });
19
+
20
+ export default {
21
+ title: "Work in progress/Components/Tabs",
22
+ argTypes,
23
+ };
24
+
25
+ const Template = ({ title, items, sticky, classes, attributes }) => {
26
+ return Tabs({
27
+ params: {
28
+ title,
29
+ items,
30
+ sticky,
31
+ classes,
32
+ attributes,
33
+ },
34
+ });
35
+ };
36
+
37
+ export const Standard = Template.bind({});
38
+ Standard.args = {
39
+ title: "Example tabs",
40
+ items: [
41
+ {
42
+ id: "unique-id-a",
43
+ title: "Alpha section",
44
+ body: "<h2>Alpha title</h2><p>Lorem ipsum</p>",
45
+ },
46
+ {
47
+ id: "unique-id-b",
48
+ title: "Beta section",
49
+ body: "<h2>Beta title</h2><p>Lorem ipsum</p>",
50
+ },
51
+ {
52
+ id: "unique-id-c",
53
+ title: "Gamma section",
54
+ body: "<h2>Gamma title</h2><p>Lorem ipsum</p>",
55
+ },
56
+ ],
57
+ classes: "tna-tabs--demo",
58
+ };
59
+
60
+ export const Test = Template.bind({});
61
+ Test.args = {
62
+ title: "Example tabs",
63
+ items: [
64
+ {
65
+ id: "unique-id-a",
66
+ title: "Alpha section",
67
+ body: "<h2>Alpha title</h2><p>Lorem ipsum</p>",
68
+ },
69
+ {
70
+ id: "unique-id-b",
71
+ title: "Beta section",
72
+ body: "<h2>Beta title</h2><p>Lorem ipsum</p>",
73
+ },
74
+ {
75
+ id: "unique-id-c",
76
+ title: "Gamma section",
77
+ body: "<h2>Gamma title</h2><p>Lorem ipsum</p>",
78
+ },
79
+ ],
80
+ classes: "tna-tabs--demo",
81
+ };
82
+
83
+ Test.play = async ({ args, canvasElement, step }) => {
84
+ const canvas = within(canvasElement);
85
+
86
+ const tablist = canvas.getByRole("tablist");
87
+ const [buttonA, buttonB, buttonC] = args.items.map((item) =>
88
+ canvas.getByText(item.title),
89
+ );
90
+ const [sectionA, sectionB, sectionC] = args.items.map((item) =>
91
+ canvasElement.querySelector(`#${item.id}`),
92
+ );
93
+
94
+ const expectButtonToBeCurrent = async (button) => {
95
+ await expect(button).toHaveAttribute("tabindex", "0");
96
+ await expect(button).toHaveAttribute("aria-selected", "true");
97
+ await expect(button).toHaveFocus();
98
+ };
99
+
100
+ const expectButtonNotToBeCurrent = async (button) => {
101
+ await expect(button).toHaveAttribute("tabindex", "-1");
102
+ await expect(button).toHaveAttribute("aria-selected", "false");
103
+ };
104
+
105
+ const expectSectionToBeCurrent = async (section) => {
106
+ await expect(section).toBeVisible();
107
+ await expect(section).toHaveAttribute("tabindex", "0");
108
+ };
109
+
110
+ const expectSectionNotToBeCurrent = async (section) => {
111
+ await expect(section).not.toBeVisible();
112
+ await expect(section).toHaveAttribute("tabindex", "-1");
113
+ };
114
+
115
+ const expectButtonAndSectionAToBeCurrent = async (section) => {
116
+ await step("Test tab buttons", async () => {
117
+ await expectButtonToBeCurrent(buttonA);
118
+ await expectButtonNotToBeCurrent(buttonB);
119
+ await expectButtonNotToBeCurrent(buttonC);
120
+ });
121
+
122
+ await step("Test tab sections", async () => {
123
+ await expectSectionToBeCurrent(sectionA);
124
+ await expectSectionNotToBeCurrent(sectionB);
125
+ await expectSectionNotToBeCurrent(sectionC);
126
+ });
127
+ };
128
+
129
+ const expectButtonAndSectionBToBeCurrent = async (section) => {
130
+ await step("Test tab buttons", async () => {
131
+ await expectButtonNotToBeCurrent(buttonA);
132
+ await expectButtonToBeCurrent(buttonB);
133
+ await expectButtonNotToBeCurrent(buttonC);
134
+ });
135
+
136
+ await step("Test tab sections", async () => {
137
+ await expectSectionNotToBeCurrent(sectionA);
138
+ await expectSectionToBeCurrent(sectionB);
139
+ await expectSectionNotToBeCurrent(sectionC);
140
+ });
141
+ };
142
+
143
+ const expectButtonAndSectionCToBeCurrent = async (section) => {
144
+ await step("Test tab buttons", async () => {
145
+ await expectButtonNotToBeCurrent(buttonA);
146
+ await expectButtonNotToBeCurrent(buttonB);
147
+ await expectButtonToBeCurrent(buttonC);
148
+ });
149
+
150
+ await step("Test tab sections", async () => {
151
+ await expectSectionNotToBeCurrent(sectionA);
152
+ await expectSectionNotToBeCurrent(sectionB);
153
+ await expectSectionToBeCurrent(sectionC);
154
+ });
155
+ };
156
+
157
+ await step("Initial load", async () => {
158
+ await step("Test tablist", async () => {
159
+ await expect(tablist).toBeDefined();
160
+ await expect(tablist).toBeVisible();
161
+ });
162
+
163
+ await step("Test tab buttons", async () => {
164
+ await step("First tab button", async () => {
165
+ await expect(buttonA).toBeVisible();
166
+ await expect(buttonA).toHaveAttribute("id", `${args.items[0].id}-tab`);
167
+ await expect(buttonA).toHaveAttribute("role", "tab");
168
+ await expect(buttonA).toHaveAttribute("tabindex", "0");
169
+ await expect(buttonA).toHaveAttribute("aria-selected", "true");
170
+ await expect(buttonA).toHaveAttribute(
171
+ "aria-controls",
172
+ args.items[0].id,
173
+ );
174
+ });
175
+
176
+ await step("Second tab button", async () => {
177
+ await expect(buttonB).toBeVisible();
178
+ await expect(buttonB).toHaveAttribute("id", `${args.items[1].id}-tab`);
179
+ await expect(buttonB).toHaveAttribute("role", "tab");
180
+ await expect(buttonB).toHaveAttribute("tabindex", "-1");
181
+ await expect(buttonB).toHaveAttribute("aria-selected", "false");
182
+ await expect(buttonB).toHaveAttribute(
183
+ "aria-controls",
184
+ args.items[1].id,
185
+ );
186
+ });
187
+
188
+ await step("Third tab button", async () => {
189
+ await expect(buttonC).toBeVisible();
190
+ await expect(buttonC).toHaveAttribute("id", `${args.items[2].id}-tab`);
191
+ await expect(buttonC).toHaveAttribute("role", "tab");
192
+ await expect(buttonC).toHaveAttribute("tabindex", "-1");
193
+ await expect(buttonC).toHaveAttribute("aria-selected", "false");
194
+ await expect(buttonC).toHaveAttribute(
195
+ "aria-controls",
196
+ args.items[2].id,
197
+ );
198
+ });
199
+ });
200
+
201
+ await step("Test tab sections", async () => {
202
+ await expect(sectionA).toBeVisible();
203
+ await expect(sectionA).toHaveAttribute("id", args.items[0].id);
204
+ await expect(sectionA).toHaveAttribute("role", "tabpanel");
205
+ await expect(sectionA).toHaveAttribute(
206
+ "aria-labelledby",
207
+ `${args.items[0].id}-tab`,
208
+ );
209
+ await expect(sectionA).toHaveAttribute("tabindex", "0");
210
+
211
+ await expect(sectionB).not.toBeVisible();
212
+ await expect(sectionB).toHaveAttribute("id", args.items[1].id);
213
+ await expect(sectionB).toHaveAttribute("role", "tabpanel");
214
+ await expect(sectionB).toHaveAttribute(
215
+ "aria-labelledby",
216
+ `${args.items[1].id}-tab`,
217
+ );
218
+ await expect(sectionB).toHaveAttribute("tabindex", "0");
219
+
220
+ await expect(sectionC).not.toBeVisible();
221
+ await expect(sectionC).toHaveAttribute("id", args.items[2].id);
222
+ await expect(sectionC).toHaveAttribute("role", "tabpanel");
223
+ await expect(sectionC).toHaveAttribute(
224
+ "aria-labelledby",
225
+ `${args.items[2].id}-tab`,
226
+ );
227
+ await expect(sectionC).toHaveAttribute("tabindex", "0");
228
+ });
229
+ });
230
+
231
+ await userEvent.click(buttonA);
232
+
233
+ await step("First tab (already selected)", async () => {
234
+ await userEvent.click(buttonA);
235
+ await expectButtonAndSectionAToBeCurrent();
236
+ });
237
+
238
+ await step("Second tab", async () => {
239
+ await userEvent.click(buttonB);
240
+ await expectButtonAndSectionBToBeCurrent();
241
+ });
242
+
243
+ await step("Third tab", async () => {
244
+ await userEvent.click(buttonC);
245
+ await expectButtonAndSectionCToBeCurrent();
246
+ });
247
+
248
+ await step("First tab", async () => {
249
+ await userEvent.click(buttonA);
250
+ await expectButtonAndSectionAToBeCurrent();
251
+ });
252
+
253
+ await step("Keyboard interaciton", async () => {
254
+ await step("Left/right", async () => {
255
+ await userEvent.click(buttonA);
256
+ await expectButtonAndSectionAToBeCurrent();
257
+
258
+ await userEvent.keyboard("[ArrowRight]");
259
+ await expectButtonAndSectionBToBeCurrent();
260
+
261
+ await userEvent.keyboard("[ArrowRight]");
262
+ await expectButtonAndSectionCToBeCurrent();
263
+
264
+ await userEvent.keyboard("[ArrowRight]");
265
+ await expectButtonAndSectionAToBeCurrent();
266
+
267
+ await userEvent.keyboard("[ArrowRight]");
268
+ await expectButtonAndSectionBToBeCurrent();
269
+
270
+ await userEvent.keyboard("[ArrowLeft]");
271
+ await expectButtonAndSectionAToBeCurrent();
272
+
273
+ await userEvent.keyboard("[ArrowLeft]");
274
+ await expectButtonAndSectionCToBeCurrent();
275
+
276
+ await userEvent.keyboard("[ArrowLeft]");
277
+ await expectButtonAndSectionBToBeCurrent();
278
+
279
+ await userEvent.keyboard("[ArrowLeft]");
280
+ await expectButtonAndSectionAToBeCurrent();
281
+ });
282
+
283
+ await step("Home/end", async () => {
284
+ await userEvent.click(buttonA);
285
+ await expectButtonAndSectionAToBeCurrent();
286
+
287
+ await userEvent.keyboard("[Home]");
288
+ await expectButtonAndSectionAToBeCurrent();
289
+
290
+ await userEvent.keyboard("[End]");
291
+ await expectButtonAndSectionCToBeCurrent();
292
+
293
+ await userEvent.keyboard("[End]");
294
+ await expectButtonAndSectionCToBeCurrent();
295
+
296
+ await userEvent.keyboard("[Home]");
297
+ await expectButtonAndSectionAToBeCurrent();
298
+ });
299
+
300
+ buttonA.blur();
301
+ });
302
+ };
@@ -0,0 +1,20 @@
1
+ {%- set containerClasses = [params.classes] if params.classes else [] -%}
2
+ {%- if params.sticky -%}
3
+ {%- set containerClasses = containerClasses.concat('tna-tabs--sticky') -%}
4
+ {%- endif -%}
5
+ <div class="tna-tabs {{ containerClasses | join(' ') }}" data-module="tna-tabs" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
6
+ <ul class="tna-tabs__list" aria-label="{{ params.title }}">
7
+ {% for item in params.items %}
8
+ <li class="tna-tabs__list-item">
9
+ <a href="#{{ item.id }}" class="tna-tabs__list-item-link" id="{{ item.id }}-tab">{{ item.title }}</a>
10
+ </li>
11
+ {% endfor %}
12
+ </ul>
13
+ <div class="tna-tabs__items">
14
+ {% for item in params.items %}
15
+ <section id="{{ item.id }}" class="tna-tabs__item">
16
+ {{ item.body | safe }}
17
+ </section>
18
+ {% endfor %}
19
+ </div>
20
+ </div>
@@ -0,0 +1 @@
1
+ @forward "featured-collection/index";
@@ -0,0 +1,13 @@
1
+ @use "../../variables/colour" as colourVars;
2
+
3
+ .tna-featured-collection {
4
+ padding-top: 2rem;
5
+ padding-bottom: 2rem;
6
+
7
+ background-color: colourVars.$tna-cream;
8
+
9
+ .tna-card {
10
+ margin-top: 1rem;
11
+ margin-bottom: 1rem;
12
+ }
13
+ }
@@ -0,0 +1,35 @@
1
+ import FeaturedCollection from "./template.njk";
2
+ import macroOptions from "./macro-options.json";
3
+
4
+ const argTypes = {
5
+ heading: { control: "text" },
6
+ classes: { control: "text" },
7
+ attributes: { control: "object" },
8
+ };
9
+
10
+ Object.keys(argTypes).forEach((argType) => {
11
+ argTypes[argType].description = macroOptions.find(
12
+ (option) => option.name === argType,
13
+ )?.description;
14
+ });
15
+
16
+ export default {
17
+ title: "Experimental/Patterns/Featured collection",
18
+ argTypes,
19
+ };
20
+
21
+ const Template = ({ heading, classes, attributes }) => {
22
+ return FeaturedCollection({
23
+ params: {
24
+ heading,
25
+ classes,
26
+ attributes,
27
+ },
28
+ });
29
+ };
30
+
31
+ export const Standard = Template.bind({});
32
+ Standard.args = {
33
+ heading: "Records from the collection",
34
+ classes: "tna-featured-collection--demo",
35
+ };
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "name": "heading",
4
+ "type": "string",
5
+ "required": true,
6
+ "description": ""
7
+ },
8
+ {
9
+ "name": "classes",
10
+ "type": "string",
11
+ "required": false,
12
+ "description": "Classes to add to the featured collection."
13
+ },
14
+ {
15
+ "name": "attributes",
16
+ "type": "object",
17
+ "required": false,
18
+ "description": "HTML attributes (for example data attributes) to add to the featured collection."
19
+ }
20
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro tnaFeaturedCollection(params) %}
2
+ {%- include "nationalarchives/patterns/featured-collection/template.njk" -%}
3
+ {% endmacro %}