@nationalarchives/frontend 0.2.6 → 0.2.8

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 (113) hide show
  1. package/nationalarchives/all.css +1 -1
  2. package/nationalarchives/all.css.map +1 -1
  3. package/nationalarchives/all.js +1 -1
  4. package/nationalarchives/all.js.map +1 -1
  5. package/nationalarchives/analytics.js +1 -1
  6. package/nationalarchives/analytics.js.map +1 -1
  7. package/nationalarchives/components/accordion/accordion.css.map +1 -1
  8. package/nationalarchives/components/accordion/accordion.scss +1 -3
  9. package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
  10. package/nationalarchives/components/button/button.css.map +1 -1
  11. package/nationalarchives/components/card/card.css +1 -1
  12. package/nationalarchives/components/card/card.css.map +1 -1
  13. package/nationalarchives/components/card/card.scss +2 -0
  14. package/nationalarchives/components/card/fixtures.json +25 -1
  15. package/nationalarchives/components/card/macro-options.json +6 -0
  16. package/nationalarchives/components/card/template.njk +3 -3
  17. package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
  18. package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
  19. package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
  20. package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
  21. package/nationalarchives/components/cookie-banner/fixtures.json +22 -10
  22. package/nationalarchives/components/cookie-banner/macro-options.json +24 -0
  23. package/nationalarchives/components/cookie-banner/template.njk +15 -7
  24. package/nationalarchives/components/date-input/date-input.css.map +1 -1
  25. package/nationalarchives/components/date-search/date-search.css.map +1 -1
  26. package/nationalarchives/components/details/details.css +1 -1
  27. package/nationalarchives/components/details/details.css.map +1 -1
  28. package/nationalarchives/components/details/details.scss +5 -1
  29. package/nationalarchives/components/error-summary/error-summary.css.map +1 -1
  30. package/nationalarchives/components/files-list/files-list.css +1 -1
  31. package/nationalarchives/components/files-list/files-list.css.map +1 -1
  32. package/nationalarchives/components/files-list/files-list.scss +2 -1
  33. package/nationalarchives/components/footer/fixtures.json +1 -1
  34. package/nationalarchives/components/footer/footer.css.map +1 -1
  35. package/nationalarchives/components/footer/template.njk +1 -1
  36. package/nationalarchives/components/gallery/fixtures.json +31 -1
  37. package/nationalarchives/components/gallery/gallery.css +1 -1
  38. package/nationalarchives/components/gallery/gallery.css.map +1 -1
  39. package/nationalarchives/components/gallery/gallery.js +1 -1
  40. package/nationalarchives/components/gallery/gallery.js.map +1 -1
  41. package/nationalarchives/components/gallery/gallery.mjs +11 -2
  42. package/nationalarchives/components/gallery/gallery.scss +9 -7
  43. package/nationalarchives/components/gallery/macro-options.json +3 -3
  44. package/nationalarchives/components/gallery/template.njk +4 -5
  45. package/nationalarchives/components/global-header/fixtures.json +203 -2
  46. package/nationalarchives/components/global-header/global-header.css.map +1 -1
  47. package/nationalarchives/components/global-header/template.njk +3 -3
  48. package/nationalarchives/components/header/analytics.js +1 -1
  49. package/nationalarchives/components/header/header.css.map +1 -1
  50. package/nationalarchives/components/hero/fixtures.json +7 -7
  51. package/nationalarchives/components/hero/hero.css +1 -1
  52. package/nationalarchives/components/hero/hero.css.map +1 -1
  53. package/nationalarchives/components/hero/hero.scss +2 -0
  54. package/nationalarchives/components/hero/template.njk +1 -1
  55. package/nationalarchives/components/index-grid/fixtures.json +9 -9
  56. package/nationalarchives/components/index-grid/index-grid.css +1 -1
  57. package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
  58. package/nationalarchives/components/index-grid/index-grid.scss +2 -0
  59. package/nationalarchives/components/index-grid/template.njk +1 -1
  60. package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
  61. package/nationalarchives/components/picture/fixtures.json +6 -3
  62. package/nationalarchives/components/picture/macro-options.json +6 -0
  63. package/nationalarchives/components/picture/picture.css +1 -1
  64. package/nationalarchives/components/picture/picture.css.map +1 -1
  65. package/nationalarchives/components/picture/picture.js +1 -1
  66. package/nationalarchives/components/picture/picture.js.map +1 -1
  67. package/nationalarchives/components/picture/picture.mjs +27 -12
  68. package/nationalarchives/components/picture/picture.scss +19 -10
  69. package/nationalarchives/components/picture/template.njk +7 -2
  70. package/nationalarchives/components/quick-filters/quick-filters.css +1 -1
  71. package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -1
  72. package/nationalarchives/components/radios/radios.css +1 -1
  73. package/nationalarchives/components/radios/radios.css.map +1 -1
  74. package/nationalarchives/components/radios/radios.scss +1 -1
  75. package/nationalarchives/components/records-list/records-list.css.map +1 -1
  76. package/nationalarchives/components/search-field/search-field.css.map +1 -1
  77. package/nationalarchives/components/select/select.css.map +1 -1
  78. package/nationalarchives/components/sidebar/sidebar.css +1 -1
  79. package/nationalarchives/components/sidebar/sidebar.css.map +1 -1
  80. package/nationalarchives/components/sidebar/sidebar.scss +47 -14
  81. package/nationalarchives/components/skip-link/skip-link.css +1 -1
  82. package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
  83. package/nationalarchives/components/skip-link/skip-link.scss +8 -11
  84. package/nationalarchives/components/tabs/fixtures.json +5 -5
  85. package/nationalarchives/components/tabs/macro-options.json +6 -6
  86. package/nationalarchives/components/tabs/tabs.css +1 -1
  87. package/nationalarchives/components/tabs/tabs.css.map +1 -1
  88. package/nationalarchives/components/tabs/tabs.js +1 -1
  89. package/nationalarchives/components/tabs/tabs.js.map +1 -1
  90. package/nationalarchives/components/tabs/tabs.mjs +52 -134
  91. package/nationalarchives/components/tabs/tabs.scss +91 -76
  92. package/nationalarchives/components/tabs/template.njk +9 -2
  93. package/nationalarchives/components/text-input/text-input.css.map +1 -1
  94. package/nationalarchives/components/textarea/textarea.css.map +1 -1
  95. package/nationalarchives/components/warning/warning.css.map +1 -1
  96. package/nationalarchives/global-header-package.css +1 -1
  97. package/nationalarchives/global-header-package.css.map +1 -1
  98. package/nationalarchives/global-header-package.scss +1 -1
  99. package/nationalarchives/print.css.map +1 -1
  100. package/nationalarchives/prototype-kit.css +1 -1
  101. package/nationalarchives/prototype-kit.css.map +1 -1
  102. package/nationalarchives/templates/fixtures.json +5 -5
  103. package/nationalarchives/tools/_a11y.scss +6 -0
  104. package/nationalarchives/tools/_colour.scss +25 -1
  105. package/nationalarchives/utilities/_animations.scss +10 -0
  106. package/nationalarchives/utilities/_index.scss +1 -0
  107. package/nationalarchives/utilities/grid/_index.scss +28 -24
  108. package/nationalarchives/utilities/grid/macro-options.json +1 -1
  109. package/nationalarchives/utilities/grid/template.njk +2 -2
  110. package/nationalarchives/utilities/lists/_index.scss +11 -0
  111. package/nationalarchives/utilities/typography/_index.scss +5 -0
  112. package/nationalarchives/variables/_features.scss +1 -0
  113. package/package.json +1 -1
@@ -1 +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,IAEzBD,EAAkB,YAAIC,GACvB,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,g6CCLvD,IAAMC,EAAI,WAkGd,O,EAjGD,SAAAA,EAAYC,GAAS,IAAAC,EAAA,KASnB,G,4FATmBC,CAAA,KAAAH,GACnBI,KAAKH,QAAUA,EACfG,KAAKC,SAAWJ,GAAWA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B,GAAgB,OACfA,EAAiBR,aAAa,QAAUqB,EAAWrB,aAAa,KAAK,IAIvE6B,EADEC,EAAejD,KAAKG,kBAAkBG,OAAS,EACtC2C,EAAe,EAEf,EAEbjD,KAAK0C,UACH1C,KAAKG,kBAAkB6C,GAAU7B,aAAa,iBAElD,GAAC,CAAArC,IAAA,2BAAAa,MAED,SAAyB6C,GACvB,IAIIQ,EAJEC,EAAejC,EAAIhB,KAAKG,mBAAmB+C,WAC/C,SAACvB,GAAgB,OACfA,EAAiBR,aAAa,QAAUqB,EAAWrB,aAAa,KAAK,IAIvE6B,EADEC,GAAgB,EACPA,EAAe,EAEfjD,KAAKG,kBAAkBG,OAAS,EAE7CN,KAAK0C,UACH1C,KAAKG,kBAAkB6C,GAAU7B,aAAa,iBAElD,GAAC,CAAArC,IAAA,YAAAa,MAED,SAAUwD,GACRnD,KAAKG,kBAAkBqB,SAAQ,SAACG,GAC1BA,EAAiBR,aAAa,mBAAqBgC,GACrDxB,EAAiBnB,UAAUyB,IAAI,sCAC/BN,EAAiBJ,aAAa,iBAAiB,GAC/CI,EAAiBJ,aAAa,WAAY,KAC1CI,EAAiByB,UAEjBzB,EAAiBnB,UAAU6C,OAAO,sCAClC1B,EAAiBJ,aAAa,iBAAiB,GAC/CI,EAAiBJ,aAAa,WAAY,MAE9C,IAEAvB,KAAKK,UAAUmB,SAAQ,SAACN,GAClBA,EAASC,aAAa,QAAUgC,GAClCjC,EAASoC,gBAAgB,UACzBpC,EAASK,aAAa,WAAY,OAElCL,EAASK,aAAa,UAAU,GAChCL,EAASK,aAAa,WAAY,MAEtC,IAEIvB,KAAKO,SACHgD,QAAQC,aACVD,QAAQC,aAAa,KAAM,KAAM,IAAF9B,OAAMyB,IAErCvC,SAASC,KAAO,IAAHa,OAAOyB,GAG1B,M,6EAAC,CApNc,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/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\"] = 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 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 const doesStartingTargetExist = [...this.$tabItems].some(\n ($tabItem) => $tabItem.getAttribute(\"id\") === startingTarget,\n );\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 (doesStartingTargetExist &&\n $tabItem.getAttribute(\"id\") !== startingTarget) ||\n (!doesStartingTargetExist && 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 case \"ArrowUp\":\n this.setSelectedToPreviousTab(targetItem);\n overwriteKeyAction = true;\n break;\n\n case \"ArrowRight\":\n case \"ArrowDown\":\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 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 this.switchTab(\n this.$tabListItemLinks[newIndex].getAttribute(\"aria-controls\"),\n );\n }\n\n 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 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","_this","_classCallCheck","this","$tabList","querySelector","$tabListItemLinks","querySelectorAll","$tabItems","length","sticky","classList","contains","startingTarget","window","location","hash","replace","doesStartingTargetExist","_toConsumableArray","some","$tabItem","getAttribute","$newTabList","document","createElement","setAttribute","forEach","index","concat","$tabListItemLink","_$tabListItemLink$get","$replacementButton","innerText","appendChild","replaceWith","add","addEventListener","e","handleItemLinkKeyDown","handleItemLinkClick","itemLinkClickEvent","preventDefault","targetItem","currentTarget","switchTab","itemLinkKeyDownEvent","overwriteKeyAction","setSelectedToPreviousTab","setSelectedToNextTab","stopPropagation","newIndex","currentIndex","findIndex","targetId","focus","remove","removeAttribute","history","replace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BAAiBzB,KAAKG,kBAAkBG,OAAS,GAAG,EAE7D,GAAC,CAAAvB,IAAA,mBAAAa,MAED,SAAiByC,GAA+B,IAAAC,EAAA,KAArBC,EAAWC,UAAAlC,OAAA,QAAAmC,IAAAD,UAAA,IAAAA,UAAA,GACpCxC,KAAKO,gBAAkB8B,EAEvBrC,KAAKG,kBAAkBU,SAAQ,SAACC,EAAkB4B,GAC5CA,IAAUJ,EAAK/B,iBACjBO,EAAiBG,aAAa,iBAAiB,GAC/CH,EAAiBG,aAAa,WAAY,KACtCsB,GACFzB,EAAiB6B,UAGnB7B,EAAiBG,aAAa,iBAAiB,GAC/CH,EAAiBG,aAAa,WAAY,MAE9C,IAEAjB,KAAKK,UAAUQ,SAAQ,SAAC+B,EAAUF,GAC5BA,IAAUJ,EAAK/B,iBACjBqC,EAAShC,gBAAgB,UACzBgC,EAAS3B,aAAa,WAAY,OAElC2B,EAAS3B,aAAa,SAAU,eAChC2B,EAAS3B,aAAa,WAAY,MAEtC,GACF,GAAC,CAAAlC,IAAA,gBAAAa,MAED,SAAciD,GACZ,IAAMH,EAAQI,MAAMC,KAAK/C,KAAKK,WAAW2C,WACvC,SAACJ,GAAQ,OAAKA,EAAS5B,aAAa,QAAU6B,CAAQ,IAExD7C,KAAKyB,iBAAiBiB,EACxB,I,gFAAC,CAlIc,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/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\"] = 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 this.$tabList.querySelectorAll(\".tna-tabs__button\");\n this.$tabItems = $module && $module.querySelectorAll(\".tna-tabs__item\");\n\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.currentTabIndex = 0;\n this.init();\n }\n\n init() {\n this.$module.classList.add(\"tna-tabs--interactive\");\n this.$tabList.removeAttribute(\"hidden\");\n this.$tabListItemLinks.forEach(($tabListItemLink) => {\n const tabPanelID = $tabListItemLink.getAttribute(\"aria-controls\");\n $tabListItemLink.setAttribute(\"aria-selected\", false);\n const $tabPanel = document.getElementById(tabPanelID);\n $tabPanel.setAttribute(\"aria-labelledby\", $tabListItemLink.id);\n $tabPanel.setAttribute(\"role\", \"tabpanel\");\n $tabListItemLink.addEventListener(\n \"click\",\n (e) => this.handleItemLinkClick(e),\n true,\n );\n });\n this.switchTabByIndex(this.currentTabIndex);\n this.$module.addEventListener(\"keydown\", (e) =>\n this.handleItemLinkKeyDown(e),\n );\n }\n\n handleItemLinkClick(itemLinkClickEvent) {\n itemLinkClickEvent.preventDefault();\n const targetItem =\n itemLinkClickEvent.currentTarget.getAttribute(\"aria-controls\");\n this.switchTabByID(targetItem);\n }\n\n handleItemLinkKeyDown(itemLinkKeyDownEvent) {\n let preventDefaultKeyAction = false;\n switch (itemLinkKeyDownEvent.key) {\n case \"ArrowLeft\":\n case \"ArrowUp\":\n this.previousTab();\n preventDefaultKeyAction = true;\n break;\n case \"ArrowRight\":\n case \"ArrowDown\":\n this.nextTab();\n preventDefaultKeyAction = true;\n break;\n case \"Home\":\n this.switchTabByIndex(0, true);\n preventDefaultKeyAction = true;\n break;\n case \"End\":\n this.switchTabByIndex(this.$tabListItemLinks.length - 1, true);\n preventDefaultKeyAction = true;\n break;\n default:\n break;\n }\n if (preventDefaultKeyAction) {\n itemLinkKeyDownEvent.stopPropagation();\n itemLinkKeyDownEvent.preventDefault();\n }\n }\n\n nextTab() {\n if (this.currentTabIndex < this.$tabListItemLinks.length - 1) {\n this.switchTabByIndex(this.currentTabIndex + 1, true);\n } else {\n this.switchTabByIndex(0, true);\n }\n }\n\n previousTab() {\n if (this.currentTabIndex >= 1) {\n this.switchTabByIndex(this.currentTabIndex - 1, true);\n } else {\n this.switchTabByIndex(this.$tabListItemLinks.length - 1, true);\n }\n }\n\n switchTabByIndex(newIndex, switchFocus = false) {\n this.currentTabIndex = newIndex;\n\n this.$tabListItemLinks.forEach(($tabListItemLink, index) => {\n if (index === this.currentTabIndex) {\n $tabListItemLink.setAttribute(\"aria-selected\", true);\n $tabListItemLink.setAttribute(\"tabindex\", \"0\");\n if (switchFocus) {\n $tabListItemLink.focus();\n }\n } else {\n $tabListItemLink.setAttribute(\"aria-selected\", false);\n $tabListItemLink.setAttribute(\"tabindex\", \"-1\");\n }\n });\n\n this.$tabItems.forEach(($tabItem, index) => {\n if (index === this.currentTabIndex) {\n $tabItem.removeAttribute(\"hidden\");\n $tabItem.setAttribute(\"tabindex\", \"0\");\n } else {\n $tabItem.setAttribute(\"hidden\", \"until-found\");\n $tabItem.setAttribute(\"tabindex\", \"-1\");\n }\n });\n }\n\n switchTabByID(targetId) {\n const index = Array.from(this.$tabItems).findIndex(\n ($tabItem) => $tabItem.getAttribute(\"id\") === targetId,\n );\n this.switchTabByIndex(index);\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","length","currentTabIndex","init","_this","classList","add","removeAttribute","forEach","$tabListItemLink","tabPanelID","getAttribute","setAttribute","$tabPanel","document","getElementById","id","addEventListener","e","handleItemLinkClick","switchTabByIndex","handleItemLinkKeyDown","itemLinkClickEvent","preventDefault","targetItem","currentTarget","switchTabByID","itemLinkKeyDownEvent","preventDefaultKeyAction","previousTab","nextTab","stopPropagation","newIndex","_this2","switchFocus","arguments","undefined","index","focus","$tabItem","targetId","Array","from","findIndex"],"sourceRoot":""}
@@ -5,7 +5,7 @@ export class Tabs {
5
5
  this.$tabListItemLinks =
6
6
  $module &&
7
7
  this.$tabList &&
8
- $module.querySelectorAll(".tna-tabs__list-item-link");
8
+ this.$tabList.querySelectorAll(".tna-tabs__button");
9
9
  this.$tabItems = $module && $module.querySelectorAll(".tna-tabs__item");
10
10
 
11
11
  if (
@@ -18,197 +18,115 @@ export class Tabs {
18
18
  return;
19
19
  }
20
20
 
21
- this.sticky = this.$module.classList.contains("tna-tabs--sticky");
22
-
23
- const startingTarget = window.location.hash.replace(/^#/, "");
24
- const doesStartingTargetExist = [...this.$tabItems].some(
25
- ($tabItem) => $tabItem.getAttribute("id") === startingTarget,
26
- );
27
-
28
- this.$newTabList = document.createElement("div");
29
- this.$newTabList.setAttribute("role", "tablist");
30
- this.$newTabList.setAttribute("class", this.$tabList.getAttribute("class"));
31
-
32
- this.$tabItems.forEach(($tabItem, index) => {
33
- $tabItem.setAttribute("role", "tabpanel");
34
- $tabItem.setAttribute(
35
- "aria-labelledby",
36
- `${$tabItem.getAttribute("id")}-tab`,
37
- );
38
- $tabItem.setAttribute("tabindex", "0");
39
- if (
40
- (doesStartingTargetExist &&
41
- $tabItem.getAttribute("id") !== startingTarget) ||
42
- (!doesStartingTargetExist && index > 0)
43
- ) {
44
- $tabItem.setAttribute("hidden", true);
45
- }
46
- });
21
+ this.currentTabIndex = 0;
22
+ this.init();
23
+ }
47
24
 
25
+ init() {
26
+ this.$module.classList.add("tna-tabs--interactive");
27
+ this.$tabList.removeAttribute("hidden");
48
28
  this.$tabListItemLinks.forEach(($tabListItemLink) => {
49
- const $replacementButton = document.createElement("button");
50
- $replacementButton.innerText = $tabListItemLink.innerText;
51
- $replacementButton.setAttribute(
52
- "class",
53
- $tabListItemLink.getAttribute("class"),
54
- );
55
- $replacementButton.setAttribute("role", "tab");
56
- $replacementButton.setAttribute(
57
- "id",
58
- $tabListItemLink.getAttribute("id"),
59
- );
60
- $replacementButton.setAttribute(
61
- "aria-controls",
62
- $tabListItemLink.getAttribute("href")?.replace(/^#/, ""),
63
- );
64
- $replacementButton.setAttribute("tabindex", "-1");
65
- this.$newTabList.appendChild($replacementButton);
66
- });
67
-
68
- this.$tabList.replaceWith(this.$newTabList);
69
-
70
- this.$tabListItemLinks = this.$module.querySelectorAll(
71
- ".tna-tabs__list-item-link",
72
- );
73
-
74
- this.$tabListItemLinks.forEach(($tabListItemLink, index) => {
75
- if (
76
- (startingTarget &&
77
- $tabListItemLink.getAttribute("aria-controls") ===
78
- `${startingTarget}`) ||
79
- (!startingTarget && index === 0)
80
- ) {
81
- $tabListItemLink.classList.add("tna-tabs__list-item-link--selected");
82
- $tabListItemLink.setAttribute("aria-selected", true);
83
- $tabListItemLink.setAttribute("tabindex", "0");
84
- } else {
85
- $tabListItemLink.setAttribute("aria-selected", false);
86
- }
87
-
88
- $tabListItemLink.addEventListener(
89
- "keydown",
90
- (e) => this.handleItemLinkKeyDown(e),
91
- true,
92
- );
29
+ const tabPanelID = $tabListItemLink.getAttribute("aria-controls");
30
+ $tabListItemLink.setAttribute("aria-selected", false);
31
+ const $tabPanel = document.getElementById(tabPanelID);
32
+ $tabPanel.setAttribute("aria-labelledby", $tabListItemLink.id);
33
+ $tabPanel.setAttribute("role", "tabpanel");
93
34
  $tabListItemLink.addEventListener(
94
35
  "click",
95
36
  (e) => this.handleItemLinkClick(e),
96
37
  true,
97
38
  );
98
39
  });
40
+ this.switchTabByIndex(this.currentTabIndex);
41
+ this.$module.addEventListener("keydown", (e) =>
42
+ this.handleItemLinkKeyDown(e),
43
+ );
99
44
  }
100
45
 
101
46
  handleItemLinkClick(itemLinkClickEvent) {
102
47
  itemLinkClickEvent.preventDefault();
103
48
  const targetItem =
104
49
  itemLinkClickEvent.currentTarget.getAttribute("aria-controls");
105
-
106
- this.switchTab(targetItem);
50
+ this.switchTabByID(targetItem);
107
51
  }
108
52
 
109
53
  handleItemLinkKeyDown(itemLinkKeyDownEvent) {
110
- const targetItem = itemLinkKeyDownEvent.currentTarget;
111
- let overwriteKeyAction = false;
112
-
54
+ let preventDefaultKeyAction = false;
113
55
  switch (itemLinkKeyDownEvent.key) {
114
56
  case "ArrowLeft":
115
57
  case "ArrowUp":
116
- this.setSelectedToPreviousTab(targetItem);
117
- overwriteKeyAction = true;
58
+ this.previousTab();
59
+ preventDefaultKeyAction = true;
118
60
  break;
119
-
120
61
  case "ArrowRight":
121
62
  case "ArrowDown":
122
- this.setSelectedToNextTab(targetItem);
123
- overwriteKeyAction = true;
63
+ this.nextTab();
64
+ preventDefaultKeyAction = true;
124
65
  break;
125
-
126
66
  case "Home":
127
- this.switchTab(this.$tabListItemLinks[0].getAttribute("aria-controls"));
128
- overwriteKeyAction = true;
67
+ this.switchTabByIndex(0, true);
68
+ preventDefaultKeyAction = true;
129
69
  break;
130
-
131
70
  case "End":
132
- this.switchTab(
133
- this.$tabListItemLinks[
134
- this.$tabListItemLinks.length - 1
135
- ].getAttribute("aria-controls"),
136
- );
137
- overwriteKeyAction = true;
71
+ this.switchTabByIndex(this.$tabListItemLinks.length - 1, true);
72
+ preventDefaultKeyAction = true;
138
73
  break;
139
-
140
74
  default:
141
75
  break;
142
76
  }
143
-
144
- if (overwriteKeyAction) {
77
+ if (preventDefaultKeyAction) {
145
78
  itemLinkKeyDownEvent.stopPropagation();
146
79
  itemLinkKeyDownEvent.preventDefault();
147
80
  }
148
81
  }
149
82
 
150
- setSelectedToNextTab(targetItem) {
151
- const currentIndex = [...this.$tabListItemLinks].findIndex(
152
- ($tabListItemLink) =>
153
- $tabListItemLink.getAttribute("id") === targetItem.getAttribute("id"),
154
- );
155
- let newIndex;
156
- if (currentIndex < this.$tabListItemLinks.length - 1) {
157
- newIndex = currentIndex + 1;
83
+ nextTab() {
84
+ if (this.currentTabIndex < this.$tabListItemLinks.length - 1) {
85
+ this.switchTabByIndex(this.currentTabIndex + 1, true);
158
86
  } else {
159
- newIndex = 0;
87
+ this.switchTabByIndex(0, true);
160
88
  }
161
- this.switchTab(
162
- this.$tabListItemLinks[newIndex].getAttribute("aria-controls"),
163
- );
164
89
  }
165
90
 
166
- setSelectedToPreviousTab(targetItem) {
167
- const currentIndex = [...this.$tabListItemLinks].findIndex(
168
- ($tabListItemLink) =>
169
- $tabListItemLink.getAttribute("id") === targetItem.getAttribute("id"),
170
- );
171
- let newIndex;
172
- if (currentIndex >= 1) {
173
- newIndex = currentIndex - 1;
91
+ previousTab() {
92
+ if (this.currentTabIndex >= 1) {
93
+ this.switchTabByIndex(this.currentTabIndex - 1, true);
174
94
  } else {
175
- newIndex = this.$tabListItemLinks.length - 1;
95
+ this.switchTabByIndex(this.$tabListItemLinks.length - 1, true);
176
96
  }
177
- this.switchTab(
178
- this.$tabListItemLinks[newIndex].getAttribute("aria-controls"),
179
- );
180
97
  }
181
98
 
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");
99
+ switchTabByIndex(newIndex, switchFocus = false) {
100
+ this.currentTabIndex = newIndex;
101
+
102
+ this.$tabListItemLinks.forEach(($tabListItemLink, index) => {
103
+ if (index === this.currentTabIndex) {
186
104
  $tabListItemLink.setAttribute("aria-selected", true);
187
105
  $tabListItemLink.setAttribute("tabindex", "0");
188
- $tabListItemLink.focus();
106
+ if (switchFocus) {
107
+ $tabListItemLink.focus();
108
+ }
189
109
  } else {
190
- $tabListItemLink.classList.remove("tna-tabs__list-item-link--selected");
191
110
  $tabListItemLink.setAttribute("aria-selected", false);
192
111
  $tabListItemLink.setAttribute("tabindex", "-1");
193
112
  }
194
113
  });
195
114
 
196
- this.$tabItems.forEach(($tabItem) => {
197
- if ($tabItem.getAttribute("id") === targetId) {
115
+ this.$tabItems.forEach(($tabItem, index) => {
116
+ if (index === this.currentTabIndex) {
198
117
  $tabItem.removeAttribute("hidden");
199
118
  $tabItem.setAttribute("tabindex", "0");
200
119
  } else {
201
- $tabItem.setAttribute("hidden", true);
120
+ $tabItem.setAttribute("hidden", "until-found");
202
121
  $tabItem.setAttribute("tabindex", "-1");
203
122
  }
204
123
  });
124
+ }
205
125
 
206
- if (this.sticky) {
207
- if (history.replaceState) {
208
- history.replaceState(null, null, `#${targetId}`);
209
- } else {
210
- location.hash = `#${targetId}`;
211
- }
212
- }
126
+ switchTabByID(targetId) {
127
+ const index = Array.from(this.$tabItems).findIndex(
128
+ ($tabItem) => $tabItem.getAttribute("id") === targetId,
129
+ );
130
+ this.switchTabByIndex(index);
213
131
  }
214
132
  }
@@ -1,3 +1,6 @@
1
+ @use "../../variables/a11y" as a11yVariables;
2
+ @use "../../variables/borders";
3
+ @use "../../tools/a11y";
1
4
  @use "../../tools/colour";
2
5
  @use "../../tools/media";
3
6
  @use "../../tools/spacing";
@@ -7,135 +10,147 @@
7
10
  @include spacing.space-above;
8
11
 
9
12
  &__list {
10
- margin: 0 0 spacing.space(1);
13
+ margin: 0;
11
14
  padding: 0;
12
15
 
13
16
  display: flex;
14
17
  flex-wrap: nowrap;
15
18
  align-items: stretch;
16
- gap: spacing.space(1);
19
+ gap: spacing.space(0.5);
20
+
21
+ position: relative;
22
+ z-index: 2;
17
23
 
18
24
  list-style: none;
19
25
  }
20
26
 
21
- &__list-item {
27
+ &--small &__list {
28
+ gap: spacing.space(0.25);
22
29
  }
23
30
 
24
- &__list-item-link {
25
- padding: spacing.space(0.5) 0;
26
-
27
- display: flex;
31
+ &__list-item {
32
+ }
28
33
 
29
- align-items: center;
34
+ &__button {
35
+ padding: borders.$thick-border-width 0;
30
36
 
31
37
  position: relative;
32
38
 
33
39
  text-align: center;
34
- text-decoration: none;
35
40
 
36
41
  background: transparent;
37
42
 
38
43
  border: none;
39
44
 
40
45
  cursor: pointer;
46
+ }
41
47
 
42
- @include typography.font-size(20);
43
- @include typography.heading-font;
48
+ &--interactive &__button {
49
+ background: transparent;
44
50
 
45
- &,
46
- &:link,
47
- &:visited {
48
- @include colour.colour-font("font-dark");
49
- }
51
+ border: 1px transparent solid;
52
+ border-bottom: none;
53
+ }
54
+
55
+ &--interactive &__button[aria-selected="true"] {
56
+ padding-top: 0;
57
+
58
+ @include colour.colour-border("keyline");
50
59
 
51
60
  &::after {
52
61
  content: "";
53
62
 
63
+ height: 1px;
64
+
54
65
  position: absolute;
66
+ top: 100%;
55
67
  right: 0;
56
- bottom: 0;
57
68
  left: 0;
69
+
70
+ @include colour.colour-background("background");
58
71
  }
72
+ }
59
73
 
60
- &:hover,
61
- &--selected,
62
- &--selected:hover {
63
- text-decoration: none;
74
+ &__button-inner {
75
+ padding: spacing.space(0.5) spacing.space(0.75);
64
76
 
65
- &::after {
66
- @include colour.thick-keyline-dark(top);
67
- }
68
- }
77
+ display: block;
69
78
 
70
- .tna-template--js-enabled & {
71
- @include colour.colour-font("font-light");
79
+ text-decoration: underline;
72
80
 
73
- &:hover {
74
- &::after {
75
- @include colour.thick-keyline(top);
76
- }
77
- }
81
+ @include colour.colour-font("font-dark");
82
+ }
78
83
 
79
- &--selected {
80
- @include colour.colour-font("font-dark");
84
+ &--small &__button-inner {
85
+ padding: spacing.space(0.25) spacing.space(0.5) spacing.space(0.125);
81
86
 
82
- &::after,
83
- &:hover::after {
84
- @include colour.thick-keyline-dark(top);
85
- }
86
- }
87
- }
87
+ @include typography.font-size(16);
88
88
  }
89
89
 
90
- &__items {
91
- // &:not(:target-within) {
92
- // .tna-tabs__item:first-child {
93
- // display: block;
94
- // }
95
- // }
90
+ &__button:hover &__button-inner {
91
+ @include typography.interacted-text-decoration;
96
92
  }
97
93
 
98
- &__item {
99
- display: none;
94
+ &__button[aria-selected="true"] &__button-inner {
95
+ text-decoration: none;
100
96
 
101
- &:first-child {
102
- display: block;
103
- }
97
+ @include colour.thick-keyline-accent(top);
98
+ }
104
99
 
105
- &:has(~ :target) {
106
- display: none;
107
- }
100
+ &__items {
101
+ display: flex;
102
+ flex-direction: column;
103
+ gap: spacing.space(2);
108
104
 
109
- &:target {
110
- display: block;
111
- }
105
+ position: relative;
106
+ z-index: 1;
107
+ }
112
108
 
113
- .tna-template--js-enabled & {
114
- display: block;
109
+ &__item {
110
+ border-radius: 0.1px;
111
+ @include a11y.no-focus-outline-on-click;
115
112
 
116
- &[hidden] {
117
- display: none;
118
- }
113
+ &:focus {
114
+ outline-offset: -#{a11yVariables.$focus-outline-width};
119
115
  }
116
+ }
120
117
 
121
- .tna-template--clicked &:focus {
122
- outline: none;
123
- }
118
+ &--interactive &__item {
119
+ padding: spacing.space(1);
120
+ @include colour.colour-border("keyline", 1px, solid);
124
121
  }
125
122
 
126
- @include colour.on-high-contrast-and-forced-colours {
127
- &__list {
128
- @include colour.colour-border("keyline-dark", 1px, solid, bottom);
129
- }
123
+ &--tint#{&}--interactive &__button[aria-selected="true"],
124
+ &--tint#{&}--interactive &__button:hover &__button-inner,
125
+ &--tint#{&}--interactive &__items {
126
+ @include colour.tint;
130
127
  }
131
128
 
132
- // @include colour.on-forced-colours {
133
- // &__list-item-link {
134
- // &--selected {
135
- // padding-bottom: spacing.space(0.125);
129
+ // &--contrast#{&}--interactive &__button[aria-selected="true"],
130
+ // &--contrast#{&}--interactive &__button:hover &__button-inner,
131
+ // &--contrast#{&}--interactive &__items {
132
+ // @include colour.contrast;
133
+ // }
134
+
135
+ // &--accent#{&}--interactive &__button[aria-selected="true"],
136
+ // &--accent#{&}--interactive &__button:hover &__button-inner,
137
+ // &--accent#{&}--interactive &__items {
138
+ // @include colour.accent;
139
+ // }
136
140
 
137
- // border-bottom-width: 0.375rem;
138
- // }
139
- // }
141
+ // &--contrast &__list,
142
+ // &--contrast &__button,
143
+ // &--contrast &__item,
144
+ // &--accent &__list,
145
+ // &--accent &__button,
146
+ // &--accent &__item {
147
+ // border: none;
140
148
  // }
149
+
150
+ @include colour.on-forced-colours {
151
+ // &__button,
152
+ // &__item {
153
+ // @include colour.colour-border("keyline", 1px, solid);
154
+ // }
155
+ }
141
156
  }
@@ -4,16 +4,23 @@
4
4
  {%- endif -%}
5
5
  {%- set classes = containerClasses | join(' ') -%}
6
6
  <div class="tna-tabs{% if classes %} {{ classes }}{% endif %}" data-module="tna-tabs"{% for attribute, value in params.attributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
7
- <ul class="tna-tabs__list">
7
+ <ul class="tna-tabs__list" role="tablist" hidden>
8
8
  {%- for item in params.items %}
9
9
  <li class="tna-tabs__list-item">
10
- <a href="#{{ item.id }}" class="tna-tabs__list-item-link" id="{{ item.id }}-tab">{{ item.title }}</a>
10
+ <button type="button" class="tna-tabs__button" id="{{ item.id }}-tab" aria-controls="{{ item.id }}" role="tab">
11
+ <span class="tna-tabs__button-inner">
12
+ {{ item.title }}
13
+ </span>
14
+ </button>
11
15
  </li>
12
16
  {%- endfor %}
13
17
  </ul>
14
18
  <div class="tna-tabs__items">
15
19
  {%- for item in params.items %}
16
20
  <section id="{{ item.id }}" class="tna-tabs__item">
21
+ <h{{ params.itemHeadingLevel }} class="tna-tabs__heading tna-heading-m">
22
+ {{ item.title }}
23
+ </h{{ params.itemHeadingLevel }}>
17
24
  {{ item.body | safe }}
18
25
  </section>
19
26
  {%- endfor %}
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../../../../src/nationalarchives/tools/_colour.scss","../../../../src/nationalarchives/components/text-input/text-input.scss"],"names":[],"mappings":"AA6KA,gBAhKM,oxDAmKJ,+BAHF,gBAhJM,8vDCzBN,gBACE,WACA,cAEA,cACA,sBDyCA,4CCrCA,iBDyCA,6DA0BI,mDC9DJ,mBAEA,wCDiEI,+CC7DJ,oBACE,eAGF,mBACE,gBAGF,mBACE,gBAGF,mBACE,gBAGF,oBACE","file":"text-input.css","sourcesContent":["@use \"sass:list\";\n@use \"sass:map\";\n@use \"../variables/borders\";\n@use \"../variables/colour\";\n@use \"../tools/media\";\n\n@function brand-colour($colour, $opacity: 1) {\n @return colour.brand-colour($colour, $opacity);\n}\n\n@mixin colour-css-vars($excludes...) {\n @each $name, $value in colour.$colour-palette-default {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-dark($excludes...) {\n @each $name, $value in colour.$colour-palette-dark {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-high-contrast($excludes...) {\n @each $name, $value in colour.$colour-palette-high-contrast {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-high-contrast-dark($excludes...) {\n @each $name, $value in colour.$colour-palette-high-contrast-dark {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@function colour-var($colour) {\n @return var(\n --#{$colour},\n #{map.get(colour.$colour-palette-default, $colour)}\n );\n}\n\n@mixin colour-font($colour, $important: false) {\n color: colour-var($colour) if($important, !important, null);\n}\n\n@mixin colour-background($colour, $important: false) {\n background-color: colour-var($colour) if($important, !important, null);\n}\n\n@mixin colour-background-brand($brandColour, $important: false) {\n background-color: #{brand-colour($brandColour)} if($important, !important, null);\n}\n\n@mixin colour-border(\n $colour,\n $width: \"\",\n $style: solid,\n $direction: \"\",\n $important: false\n) {\n @if $direction != \"\" {\n @if $width != \"\" {\n border-#{$direction}: $width\n colour-var($colour)\n $style\n if($important, !important, null);\n } @else {\n border-#{$direction}-color: colour-var($colour)\n if($important, !important, null);\n }\n } @else {\n @if $width != \"\" {\n border: $width\n colour-var($colour)\n $style\n if($important, !important, null);\n } @else {\n border-color: var(\n --#{$colour},\n #{map.get(colour.$colour-palette-default, $colour)}\n )\n if($important, !important, null);\n }\n }\n}\n\n@mixin colour-outline($colour, $width: \"\", $style: solid, $important: false) {\n @if $width != \"\" {\n outline: $width colour-var($colour) $style if($important, !important, null);\n } @else {\n outline-color: colour-var($colour) if($important, !important, null);\n }\n}\n\n@mixin colour-fill($colour, $important: false) {\n fill: colour-var($colour) if($important, !important, null);\n}\n\n@mixin thick-keyline($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"keyline\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"keyline\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-dark($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"keyline-dark\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"keyline-dark\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-accent($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"accent-border\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"accent-border\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-error($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"form-error-border\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\n \"form-error-border\",\n borders.$thick-border-width,\n solid\n );\n }\n}\n\n@mixin thick-keyline-brand($direction: \"\", $brandColour) {\n @if $direction != \"\" {\n border-#{$direction}: borders.$thick-border-width\n #{brand-colour($brandColour)}\n solid;\n } @else {\n border: borders.$thick-border-width #{brand-colour($brandColour)} solid;\n }\n}\n\n// Use light theme colours (except for \"form-error-border\")\n%always-light {\n @include colour-css-vars(\"form-error-border\");\n\n @media (prefers-contrast: more) {\n @include colour-css-vars-high-contrast(\"form-error-border\");\n }\n}\n\n@mixin always-light {\n @extend %always-light;\n}\n\n%contrast {\n --background: var(--contrast-background);\n --font-base: var(--contrast-font-base);\n --font-dark: var(--contrast-font-dark);\n --font-light: var(--contrast-font-light);\n --icon-light: var(--contrast-icon-light);\n --link: var(--contrast-link);\n --link-visited: var(--contrast-link-visited);\n --keyline: var(--contrast-keyline);\n --keyline-dark: var(--contrast-keyline-dark);\n --button-text: var(--contrast-button-text);\n --button-background: var(--contrast-button-background);\n --button-hover-text: var(--contrast-button-hover-text);\n --button-hover-background: var(--contrast-button-hover-background);\n --accent-list-marker: var(--accent-border);\n // --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n}\n\n@mixin contrast {\n @extend %contrast;\n}\n\n%contrast-on-mobile {\n @include media.on-mobile {\n --background: var(--contrast-background);\n --font-base: var(--contrast-font-base);\n --font-dark: var(--contrast-font-dark);\n --font-light: var(--contrast-font-light);\n --icon-light: var(--contrast-icon-light);\n --link: var(--contrast-link);\n --link-visited: var(--contrast-link-visited);\n --keyline: var(--contrast-keyline);\n --keyline-dark: var(--contrast-keyline-dark);\n --button-text: var(--contrast-button-text);\n --button-background: var(--contrast-button-background);\n --button-hover-text: var(--contrast-button-hover-text);\n --button-hover-background: var(--contrast-button-hover-background);\n --accent-list-marker: var(--accent-border);\n // --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n }\n}\n\n@mixin contrast-on-mobile {\n @extend %contrast-on-mobile;\n}\n\n%tint {\n --background: var(--background-tint);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n}\n\n@mixin tint {\n @extend %tint;\n}\n\n%accent {\n --background: var(--accent-background);\n --font-base: var(--accent-font-base);\n --font-dark: var(--accent-font-dark);\n --font-light: var(--accent-font-light);\n --icon-light: var(--accent-icon-light);\n --link: var(--accent-link);\n --link-visited: var(--accent-link);\n --keyline: var(--accent-keyline);\n --keyline-dark: var(--accent-keyline-dark);\n --accent-list-marker: var(--accent-font-base);\n --accent-border: var(--accent-font-dark);\n --button-text: var(--accent-button-text);\n --button-background: var(--accent-button-background);\n --button-hover-text: var(--accent-button-hover-text);\n --button-hover-background: var(--accent-button-hover-background);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n}\n\n@mixin accent {\n @extend %accent;\n}\n\n%accent-light {\n --background: var(--accent-background-light);\n --font-base: #{map.get(colour.$colour-palette-default, \"font-base\")};\n --font-dark: #{map.get(colour.$colour-palette-default, \"font-dark\")};\n --font-light: #{map.get(colour.$colour-palette-default, \"font-light\")};\n --icon-light: #{map.get(colour.$colour-palette-default, \"icon-light\")};\n --keyline: #{map.get(colour.$colour-palette-default, \"keyline\")};\n --keyline-dark: #{map.get(colour.$colour-palette-default, \"keyline-dark\")};\n --button-text: #{map.get(colour.$colour-palette-default, \"button-text\")};\n --button-background: #{map.get(\n colour.$colour-palette-default,\n \"button-background\"\n )};\n --button-hover-text: #{map.get(\n colour.$colour-palette-default,\n \"button-hover-text\"\n )};\n --button-hover-background: #{map.get(\n colour.$colour-palette-default,\n \"button-hover-background\"\n )};\n --accent-border: var(--font-base);\n --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n @include colour-font(\"font-base\");\n\n .tna-template--system-theme & {\n @media (prefers-color-scheme: dark) {\n --link: #{map.get(colour.$colour-palette-default, \"link\")};\n --link-visited: #{map.get(colour.$colour-palette-default, \"link-visited\")};\n }\n }\n\n .tna-template--dark-theme & {\n --link: #{map.get(colour.$colour-palette-default, \"link\")};\n --link-visited: #{map.get(colour.$colour-palette-default, \"link-visited\")};\n }\n}\n\n@mixin accent-light {\n @extend %accent-light;\n}\n\n%yellow-accent {\n --accent-background: #{colour.brand-colour(\"yellow\")} !important;\n --accent-background-light: #{colour.brand-colour(\"cream\")} !important;\n --accent-border: #{colour.brand-colour(\"yellow\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"brown\")} !important;\n --accent-font-base: #{colour.brand-colour(\"black\")} !important;\n --accent-font-dark: #{colour.brand-colour(\"black\")} !important;\n --accent-font-light: #{colour.brand-colour(\"black\", 0.7)} !important;\n --accent-icon-light: #{colour.brand-colour(\"black\", 0.45)} !important;\n --accent-link: #{colour.brand-colour(\"black\")} !important;\n --accent-link-visited: #{colour.brand-colour(\"black\")} !important;\n --accent-keyline: #{colour.brand-colour(\"black\", 0.5)} !important;\n --accent-keyline-dark: #{colour.brand-colour(\"black\", 0.8)} !important;\n --button-accented-text: #{colour.brand-colour(\"white\")} !important;\n --button-accented-background: #{colour.brand-colour(\"brown\")} !important;\n}\n\n@mixin yellow-accent {\n @extend %yellow-accent;\n}\n\n%accent-lighter-text {\n --accent-font-base: #{colour.brand-colour(\"white\")} !important;\n --accent-font-dark: #{colour.brand-colour(\"white\")} !important;\n --accent-font-light: #{colour.brand-colour(\"white\", 0.7)} !important;\n --accent-icon-light: #{colour.brand-colour(\"white\", 0.45)} !important;\n --accent-link: #{colour.brand-colour(\"white\")} !important;\n --accent-link-visited: #{colour.brand-colour(\"white\")} !important;\n --accent-keyline: #{colour.brand-colour(\"white\", 0.5)} !important;\n --accent-keyline-dark: #{colour.brand-colour(\"white\", 0.8)} !important;\n --button-accented-text: #{colour.brand-colour(\"white\")} !important;\n}\n\n%black-accent {\n --accent-background: #{colour.brand-colour(\"black\")} !important;\n --accent-background-light: #{colour.brand-colour(\"light-grey\")} !important;\n --accent-border: #{colour.brand-colour(\"black\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"grey\")} !important;\n --button-accented-text: #{colour.brand-colour(\"black\")} !important;\n --button-accented-background: #{colour.brand-colour(\"grey\")} !important;\n}\n\n@mixin black-accent {\n @extend %accent-lighter-text;\n @extend %black-accent;\n}\n\n%pink-accent {\n --accent-background: #{colour.brand-colour(\"maroon\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-pink\")} !important;\n --accent-border: #{colour.brand-colour(\"pink\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"pink\")} !important;\n --button-accented-background: #{colour.brand-colour(\"maroon\")} !important;\n}\n\n@mixin pink-accent {\n @extend %accent-lighter-text;\n @extend %pink-accent;\n}\n\n%orange-accent {\n --accent-background: #{colour.brand-colour(\"chestnut\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-orange\")} !important;\n --accent-border: #{colour.brand-colour(\"orange\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"orange\")} !important;\n --button-accented-background: #{colour.brand-colour(\"chestnut\")} !important;\n}\n\n@mixin orange-accent {\n @extend %accent-lighter-text;\n @extend %orange-accent;\n}\n\n%green-accent {\n --accent-background: #{colour.brand-colour(\"forest\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-green\")} !important;\n --accent-border: #{colour.brand-colour(\"green\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"green\")} !important;\n --button-accented-background: #{colour.brand-colour(\"forest\")} !important;\n}\n\n@mixin green-accent {\n @extend %accent-lighter-text;\n @extend %green-accent;\n}\n\n%blue-accent {\n --accent-background: #{colour.brand-colour(\"navy\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-blue\")} !important;\n --accent-border: #{colour.brand-colour(\"blue\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"blue\")} !important;\n --button-accented-background: #{colour.brand-colour(\"navy\")} !important;\n}\n\n@mixin blue-accent {\n @extend %accent-lighter-text;\n @extend %blue-accent;\n}\n\n@mixin on-high-contrast {\n @media (prefers-contrast: more) {\n @content;\n }\n}\n\n@mixin on-forced-colours {\n @media (forced-colors: active) {\n @content;\n }\n}\n\n@mixin on-high-contrast-and-forced-colours {\n @include on-forced-colours {\n @content;\n }\n\n @include on-high-contrast {\n @content;\n }\n}\n","@use \"../../variables/forms\";\n@use \"../../tools/colour\";\n@use \"../../tools/spacing\";\n\n.tna-text-input {\n width: 100%;\n padding: 0 spacing.space(0.375);\n\n display: block;\n box-sizing: border-box;\n\n @include colour.always-light;\n @include colour.colour-font(\"input-foreground\");\n line-height: 2rem;\n\n @include colour.colour-background(\"input-background\");\n\n @include colour.colour-border(\"input-border\", forms.$form-field-border-width);\n border-radius: 0.1px;\n\n .tna-form__group--error & {\n @include colour.colour-border(\"form-error-border\");\n }\n\n &--xs {\n max-width: 5rem;\n }\n\n &--s {\n max-width: 10rem;\n }\n\n &--m {\n max-width: 20rem;\n }\n\n &--l {\n max-width: 40rem;\n }\n\n &--xl {\n max-width: 80rem;\n }\n}\n"]}
1
+ {"version":3,"sourceRoot":"","sources":["../../../../src/nationalarchives/tools/_colour.scss","../../../../src/nationalarchives/components/text-input/text-input.scss"],"names":[],"mappings":"AAsLA,gBAxKM,oxDA2KJ,+BAHF,gBAxJM,8vDC1BN,gBACE,WACA,cAEA,cACA,sBD0CA,4CCtCA,iBD0CA,6DA0BI,mDC/DJ,mBAEA,wCDkEI,+CC9DJ,oBACE,eAGF,mBACE,gBAGF,mBACE,gBAGF,mBACE,gBAGF,oBACE","file":"text-input.css","sourcesContent":["@use \"sass:list\";\n@use \"sass:map\";\n@use \"../variables/borders\";\n@use \"../variables/colour\";\n@use \"../variables/features\";\n@use \"../tools/media\";\n\n@function brand-colour($colour, $opacity: 1) {\n @return colour.brand-colour($colour, $opacity);\n}\n\n@mixin colour-css-vars($excludes...) {\n @each $name, $value in colour.$colour-palette-default {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-dark($excludes...) {\n @each $name, $value in colour.$colour-palette-dark {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-high-contrast($excludes...) {\n @each $name, $value in colour.$colour-palette-high-contrast {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@mixin colour-css-vars-high-contrast-dark($excludes...) {\n @each $name, $value in colour.$colour-palette-high-contrast-dark {\n @if not list.index($excludes, $name) {\n --#{$name}: #{$value};\n }\n }\n}\n\n@function colour-var($colour) {\n @return var(\n --#{$colour},\n #{map.get(colour.$colour-palette-default, $colour)}\n );\n}\n\n@mixin colour-font($colour, $important: false) {\n color: colour-var($colour) if($important, !important, null);\n}\n\n@mixin colour-background($colour, $important: false) {\n background-color: colour-var($colour) if($important, !important, null);\n}\n\n@mixin colour-background-brand($brandColour, $important: false) {\n background-color: #{brand-colour($brandColour)} if($important, !important, null);\n}\n\n@mixin colour-border(\n $colour,\n $width: \"\",\n $style: solid,\n $direction: \"\",\n $important: false\n) {\n @if $direction != \"\" {\n @if $width != \"\" {\n border-#{$direction}: $width\n colour-var($colour)\n $style\n if($important, !important, null);\n } @else {\n border-#{$direction}-color: colour-var($colour)\n if($important, !important, null);\n }\n } @else {\n @if $width != \"\" {\n border: $width\n colour-var($colour)\n $style\n if($important, !important, null);\n } @else {\n border-color: var(\n --#{$colour},\n #{map.get(colour.$colour-palette-default, $colour)}\n )\n if($important, !important, null);\n }\n }\n}\n\n@mixin colour-outline($colour, $width: \"\", $style: solid, $important: false) {\n @if $width != \"\" {\n outline: $width colour-var($colour) $style if($important, !important, null);\n } @else {\n outline-color: colour-var($colour) if($important, !important, null);\n }\n}\n\n@mixin colour-fill($colour, $important: false) {\n fill: colour-var($colour) if($important, !important, null);\n}\n\n@mixin thick-keyline($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"keyline\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"keyline\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-dark($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"keyline-dark\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"keyline-dark\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-accent($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"accent-border\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\"accent-border\", borders.$thick-border-width, solid);\n }\n}\n\n@mixin thick-keyline-error($direction: \"\") {\n @if $direction != \"\" {\n @include colour-border(\n \"form-error-border\",\n borders.$thick-border-width,\n solid,\n $direction\n );\n } @else {\n @include colour-border(\n \"form-error-border\",\n borders.$thick-border-width,\n solid\n );\n }\n}\n\n@mixin thick-keyline-brand($direction: \"\", $brandColour) {\n @if $direction != \"\" {\n border-#{$direction}: borders.$thick-border-width\n #{brand-colour($brandColour)}\n solid;\n } @else {\n border: borders.$thick-border-width #{brand-colour($brandColour)} solid;\n }\n}\n\n@mixin thick-keyline-transparent($direction: \"\") {\n @if $direction != \"\" {\n border-#{$direction}: borders.$thick-border-width transparent solid;\n } @else {\n border: borders.$thick-border-width transparent solid;\n }\n}\n\n// Use light theme colours (except for \"form-error-border\")\n%always-light {\n @include colour-css-vars(\"form-error-border\");\n\n @media (prefers-contrast: more) {\n @include colour-css-vars-high-contrast(\"form-error-border\");\n }\n}\n\n@mixin always-light {\n @extend %always-light;\n}\n\n%contrast {\n --background: var(--contrast-background);\n --font-base: var(--contrast-font-base);\n --font-dark: var(--contrast-font-dark);\n --font-light: var(--contrast-font-light);\n --icon-light: var(--contrast-icon-light);\n --link: var(--contrast-link);\n --link-visited: var(--contrast-link-visited);\n --keyline: var(--contrast-keyline);\n --keyline-dark: var(--contrast-keyline-dark);\n --button-text: var(--contrast-button-text);\n --button-background: var(--contrast-button-background);\n --button-hover-text: var(--contrast-button-hover-text);\n --button-hover-background: var(--contrast-button-hover-background);\n --accent-list-marker: var(--accent-border);\n // --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n}\n\n@mixin contrast {\n @extend %contrast;\n}\n\n%contrast-on-mobile {\n @include media.on-mobile {\n --background: var(--contrast-background);\n --font-base: var(--contrast-font-base);\n --font-dark: var(--contrast-font-dark);\n --font-light: var(--contrast-font-light);\n --icon-light: var(--contrast-icon-light);\n --link: var(--contrast-link);\n --link-visited: var(--contrast-link-visited);\n --keyline: var(--contrast-keyline);\n --keyline-dark: var(--contrast-keyline-dark);\n --button-text: var(--contrast-button-text);\n --button-background: var(--contrast-button-background);\n --button-hover-text: var(--contrast-button-hover-text);\n --button-hover-background: var(--contrast-button-hover-background);\n --accent-list-marker: var(--accent-border);\n // --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n }\n}\n\n@mixin contrast-on-mobile {\n @extend %contrast-on-mobile;\n}\n\n%tint {\n --background: var(--background-tint);\n\n @include colour-background(\"background\");\n\n // @include colour-font(\"font-base\");\n}\n\n@mixin tint {\n @extend %tint;\n}\n\n%accent {\n --background: var(--accent-background);\n --font-base: var(--accent-font-base);\n --font-dark: var(--accent-font-dark);\n --font-light: var(--accent-font-light);\n --icon-light: var(--accent-icon-light);\n --link: var(--accent-link);\n --link-visited: var(--accent-link);\n --keyline: var(--accent-keyline);\n --keyline-dark: var(--accent-keyline-dark);\n --accent-list-marker: var(--accent-font-base);\n --accent-border: var(--accent-font-dark);\n --button-text: var(--accent-button-text);\n --button-background: var(--accent-button-background);\n --button-hover-text: var(--accent-button-hover-text);\n --button-hover-background: var(--accent-button-hover-background);\n\n @include colour-background(\"background\");\n\n @include colour-font(\"font-base\");\n}\n\n@mixin accent {\n @extend %accent;\n}\n\n%accent-light {\n --background: var(--accent-background-light);\n --font-base: #{map.get(colour.$colour-palette-default, \"font-base\")};\n --font-dark: #{map.get(colour.$colour-palette-default, \"font-dark\")};\n --font-light: #{map.get(colour.$colour-palette-default, \"font-light\")};\n --icon-light: #{map.get(colour.$colour-palette-default, \"icon-light\")};\n --keyline: #{map.get(colour.$colour-palette-default, \"keyline\")};\n --keyline-dark: #{map.get(colour.$colour-palette-default, \"keyline-dark\")};\n --button-text: #{map.get(colour.$colour-palette-default, \"button-text\")};\n --button-background: #{map.get(\n colour.$colour-palette-default,\n \"button-background\"\n )};\n --button-hover-text: #{map.get(\n colour.$colour-palette-default,\n \"button-hover-text\"\n )};\n --button-hover-background: #{map.get(\n colour.$colour-palette-default,\n \"button-hover-background\"\n )};\n --accent-border: var(--font-base);\n --accent-list-marker: var(--font-base);\n\n @include colour-background(\"background\");\n @include colour-font(\"font-base\");\n\n .tna-template--system-theme & {\n @media (prefers-color-scheme: dark) {\n --link: #{map.get(colour.$colour-palette-default, \"link\")};\n --link-visited: #{map.get(colour.$colour-palette-default, \"link-visited\")};\n }\n }\n\n .tna-template--dark-theme & {\n --link: #{map.get(colour.$colour-palette-default, \"link\")};\n --link-visited: #{map.get(colour.$colour-palette-default, \"link-visited\")};\n }\n}\n\n@mixin accent-light {\n @extend %accent-light;\n}\n\n%yellow-accent {\n --accent-background: #{colour.brand-colour(\"yellow\")} !important;\n --accent-background-light: #{colour.brand-colour(\"cream\")} !important;\n --accent-border: #{colour.brand-colour(\"yellow\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"brown\")} !important;\n --accent-font-base: #{colour.brand-colour(\"black\")} !important;\n --accent-font-dark: #{colour.brand-colour(\"black\")} !important;\n --accent-font-light: #{colour.brand-colour(\"black\", 0.7)} !important;\n --accent-icon-light: #{colour.brand-colour(\"black\", 0.45)} !important;\n --accent-link: #{colour.brand-colour(\"black\")} !important;\n --accent-link-visited: #{colour.brand-colour(\"black\")} !important;\n --accent-keyline: #{colour.brand-colour(\"black\", 0.5)} !important;\n --accent-keyline-dark: #{colour.brand-colour(\"black\", 0.8)} !important;\n --button-accented-text: #{colour.brand-colour(\"white\")} !important;\n --button-accented-background: #{colour.brand-colour(\"brown\")} !important;\n}\n\n@mixin yellow-accent {\n @extend %yellow-accent;\n}\n\n%accent-lighter-text {\n --accent-font-base: #{colour.brand-colour(\"white\")} !important;\n --accent-font-dark: #{colour.brand-colour(\"white\")} !important;\n --accent-font-light: #{colour.brand-colour(\"white\", 0.7)} !important;\n --accent-icon-light: #{colour.brand-colour(\"white\", 0.45)} !important;\n --accent-link: #{colour.brand-colour(\"white\")} !important;\n --accent-link-visited: #{colour.brand-colour(\"white\")} !important;\n --accent-keyline: #{colour.brand-colour(\"white\", 0.5)} !important;\n --accent-keyline-dark: #{colour.brand-colour(\"white\", 0.8)} !important;\n --button-accented-text: #{colour.brand-colour(\"white\")} !important;\n}\n\n%black-accent {\n --accent-background: #{colour.brand-colour(\"black\")} !important;\n --accent-background-light: #{colour.brand-colour(\"light-grey\")} !important;\n --accent-border: #{colour.brand-colour(\"black\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"grey\")} !important;\n --button-accented-text: #{colour.brand-colour(\"black\")} !important;\n --button-accented-background: #{colour.brand-colour(\"grey\")} !important;\n}\n\n@mixin black-accent {\n @extend %accent-lighter-text;\n @extend %black-accent;\n}\n\n%pink-accent {\n --accent-background: #{colour.brand-colour(\"maroon\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-pink\")} !important;\n --accent-border: #{colour.brand-colour(\"pink\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"pink\")} !important;\n --button-accented-background: #{colour.brand-colour(\"maroon\")} !important;\n}\n\n@mixin pink-accent {\n @extend %accent-lighter-text;\n @extend %pink-accent;\n}\n\n%orange-accent {\n --accent-background: #{colour.brand-colour(\"chestnut\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-orange\")} !important;\n --accent-border: #{colour.brand-colour(\"orange\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"orange\")} !important;\n --button-accented-background: #{colour.brand-colour(\"chestnut\")} !important;\n}\n\n@mixin orange-accent {\n @extend %accent-lighter-text;\n @extend %orange-accent;\n}\n\n%green-accent {\n --accent-background: #{colour.brand-colour(\"forest\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-green\")} !important;\n --accent-border: #{colour.brand-colour(\"green\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"green\")} !important;\n --button-accented-background: #{colour.brand-colour(\"forest\")} !important;\n}\n\n@mixin green-accent {\n @extend %accent-lighter-text;\n @extend %green-accent;\n}\n\n%blue-accent {\n --accent-background: #{colour.brand-colour(\"navy\")} !important;\n --accent-background-light: #{colour.brand-colour(\"pastel-blue\")} !important;\n --accent-border: #{colour.brand-colour(\"blue\")} !important;\n --accent-list-marker: #{colour.brand-colour(\"blue\")} !important;\n --button-accented-background: #{colour.brand-colour(\"navy\")} !important;\n}\n\n@mixin blue-accent {\n @extend %accent-lighter-text;\n @extend %blue-accent;\n}\n\n@mixin on-high-contrast {\n @media (prefers-contrast: more) {\n @content;\n }\n}\n\n@mixin on-forced-colours {\n @media (forced-colors: active) {\n @content;\n }\n}\n\n@mixin on-high-contrast-and-forced-colours {\n @include on-forced-colours {\n @content;\n }\n\n @include on-high-contrast {\n @content;\n }\n}\n\n@mixin image-loader-background {\n @if not features.$disable-image-loader-animations {\n background: linear-gradient(\n -45deg,\n rgba(0 0 0 / 25%),\n rgba(255 255 255 / 25%),\n rgba(0 0 0 / 25%)\n );\n background-size: 500% 500%;\n background-position: 0 50%;\n\n animation: image-loader-background ease-in-out 1.2s infinite;\n }\n}\n","@use \"../../variables/forms\";\n@use \"../../tools/colour\";\n@use \"../../tools/spacing\";\n\n.tna-text-input {\n width: 100%;\n padding: 0 spacing.space(0.375);\n\n display: block;\n box-sizing: border-box;\n\n @include colour.always-light;\n @include colour.colour-font(\"input-foreground\");\n line-height: 2rem;\n\n @include colour.colour-background(\"input-background\");\n\n @include colour.colour-border(\"input-border\", forms.$form-field-border-width);\n border-radius: 0.1px;\n\n .tna-form__group--error & {\n @include colour.colour-border(\"form-error-border\");\n }\n\n &--xs {\n max-width: 5rem;\n }\n\n &--s {\n max-width: 10rem;\n }\n\n &--m {\n max-width: 20rem;\n }\n\n &--l {\n max-width: 40rem;\n }\n\n &--xl {\n max-width: 80rem;\n }\n}\n"]}