@nationalarchives/frontend 0.2.7 → 0.2.9

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 (123) 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/analytics.mjs +2 -4
  8. package/nationalarchives/components/accordion/accordion.css.map +1 -1
  9. package/nationalarchives/components/accordion/accordion.scss +1 -3
  10. package/nationalarchives/components/breadcrumbs/breadcrumbs.css +1 -1
  11. package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
  12. package/nationalarchives/components/breadcrumbs/breadcrumbs.scss +3 -3
  13. package/nationalarchives/components/button/button.css +1 -1
  14. package/nationalarchives/components/button/button.css.map +1 -1
  15. package/nationalarchives/components/button/button.scss +43 -8
  16. package/nationalarchives/components/card/card.css +1 -1
  17. package/nationalarchives/components/card/card.css.map +1 -1
  18. package/nationalarchives/components/card/card.scss +3 -1
  19. package/nationalarchives/components/card/fixtures.json +25 -1
  20. package/nationalarchives/components/card/macro-options.json +6 -0
  21. package/nationalarchives/components/card/template.njk +3 -3
  22. package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
  23. package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
  24. package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
  25. package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
  26. package/nationalarchives/components/cookie-banner/cookie-banner.css +1 -1
  27. package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
  28. package/nationalarchives/components/cookie-banner/cookie-banner.scss +3 -3
  29. package/nationalarchives/components/date-input/date-input.css +1 -1
  30. package/nationalarchives/components/date-input/date-input.css.map +1 -1
  31. package/nationalarchives/components/date-search/date-search.css +1 -1
  32. package/nationalarchives/components/date-search/date-search.css.map +1 -1
  33. package/nationalarchives/components/details/details.css +1 -1
  34. package/nationalarchives/components/details/details.css.map +1 -1
  35. package/nationalarchives/components/details/details.scss +5 -1
  36. package/nationalarchives/components/error-summary/error-summary.css +1 -1
  37. package/nationalarchives/components/error-summary/error-summary.css.map +1 -1
  38. package/nationalarchives/components/error-summary/error-summary.scss +3 -1
  39. package/nationalarchives/components/files-list/files-list.css +1 -1
  40. package/nationalarchives/components/files-list/files-list.css.map +1 -1
  41. package/nationalarchives/components/files-list/files-list.scss +2 -1
  42. package/nationalarchives/components/footer/fixtures.json +1 -1
  43. package/nationalarchives/components/footer/footer.css.map +1 -1
  44. package/nationalarchives/components/footer/template.njk +1 -1
  45. package/nationalarchives/components/gallery/fixtures.json +31 -1
  46. package/nationalarchives/components/gallery/gallery.css +1 -1
  47. package/nationalarchives/components/gallery/gallery.css.map +1 -1
  48. package/nationalarchives/components/gallery/gallery.js +1 -1
  49. package/nationalarchives/components/gallery/gallery.js.map +1 -1
  50. package/nationalarchives/components/gallery/gallery.mjs +12 -3
  51. package/nationalarchives/components/gallery/gallery.scss +9 -11
  52. package/nationalarchives/components/gallery/macro-options.json +3 -3
  53. package/nationalarchives/components/gallery/template.njk +4 -5
  54. package/nationalarchives/components/global-header/global-header.css.map +1 -1
  55. package/nationalarchives/components/header/header.css.map +1 -1
  56. package/nationalarchives/components/hero/fixtures.json +7 -7
  57. package/nationalarchives/components/hero/hero.css +1 -1
  58. package/nationalarchives/components/hero/hero.css.map +1 -1
  59. package/nationalarchives/components/hero/hero.scss +2 -0
  60. package/nationalarchives/components/hero/template.njk +1 -1
  61. package/nationalarchives/components/index-grid/fixtures.json +9 -9
  62. package/nationalarchives/components/index-grid/index-grid.css +1 -1
  63. package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
  64. package/nationalarchives/components/index-grid/index-grid.scss +2 -0
  65. package/nationalarchives/components/index-grid/template.njk +1 -1
  66. package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
  67. package/nationalarchives/components/picture/fixtures.json +6 -3
  68. package/nationalarchives/components/picture/macro-options.json +6 -0
  69. package/nationalarchives/components/picture/picture.css +1 -1
  70. package/nationalarchives/components/picture/picture.css.map +1 -1
  71. package/nationalarchives/components/picture/picture.js +1 -1
  72. package/nationalarchives/components/picture/picture.js.map +1 -1
  73. package/nationalarchives/components/picture/picture.mjs +27 -12
  74. package/nationalarchives/components/picture/picture.scss +19 -10
  75. package/nationalarchives/components/picture/template.njk +7 -2
  76. package/nationalarchives/components/quick-filters/quick-filters.css +1 -1
  77. package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -1
  78. package/nationalarchives/components/radios/radios.css +1 -1
  79. package/nationalarchives/components/radios/radios.css.map +1 -1
  80. package/nationalarchives/components/radios/radios.scss +1 -1
  81. package/nationalarchives/components/records-list/records-list.css.map +1 -1
  82. package/nationalarchives/components/search-field/search-field.css +1 -1
  83. package/nationalarchives/components/search-field/search-field.css.map +1 -1
  84. package/nationalarchives/components/select/select.css +1 -1
  85. package/nationalarchives/components/select/select.css.map +1 -1
  86. package/nationalarchives/components/sidebar/sidebar.css +1 -1
  87. package/nationalarchives/components/sidebar/sidebar.css.map +1 -1
  88. package/nationalarchives/components/sidebar/sidebar.scss +34 -7
  89. package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
  90. package/nationalarchives/components/tabs/fixtures.json +5 -5
  91. package/nationalarchives/components/tabs/macro-options.json +6 -6
  92. package/nationalarchives/components/tabs/tabs.css +1 -1
  93. package/nationalarchives/components/tabs/tabs.css.map +1 -1
  94. package/nationalarchives/components/tabs/tabs.js +1 -1
  95. package/nationalarchives/components/tabs/tabs.js.map +1 -1
  96. package/nationalarchives/components/tabs/tabs.mjs +51 -135
  97. package/nationalarchives/components/tabs/tabs.scss +67 -79
  98. package/nationalarchives/components/tabs/template.njk +9 -2
  99. package/nationalarchives/components/text-input/text-input.css +1 -1
  100. package/nationalarchives/components/text-input/text-input.css.map +1 -1
  101. package/nationalarchives/components/textarea/textarea.css +1 -1
  102. package/nationalarchives/components/textarea/textarea.css.map +1 -1
  103. package/nationalarchives/components/warning/warning.css +1 -1
  104. package/nationalarchives/components/warning/warning.css.map +1 -1
  105. package/nationalarchives/global-header-package.css +1 -1
  106. package/nationalarchives/global-header-package.css.map +1 -1
  107. package/nationalarchives/global-header-package.scss +1 -1
  108. package/nationalarchives/print.css.map +1 -1
  109. package/nationalarchives/prototype-kit.css +1 -1
  110. package/nationalarchives/prototype-kit.css.map +1 -1
  111. package/nationalarchives/templates/fixtures.json +1 -1
  112. package/nationalarchives/tools/_a11y.scss +9 -3
  113. package/nationalarchives/tools/_colour.scss +67 -8
  114. package/nationalarchives/utilities/_a11y.scss +17 -12
  115. package/nationalarchives/utilities/_animations.scss +10 -0
  116. package/nationalarchives/utilities/_index.scss +1 -0
  117. package/nationalarchives/utilities/grid/_index.scss +28 -24
  118. package/nationalarchives/utilities/grid/macro-options.json +1 -1
  119. package/nationalarchives/utilities/grid/template.njk +2 -2
  120. package/nationalarchives/utilities/lists/_index.scss +13 -2
  121. package/nationalarchives/utilities/typography/_index.scss +30 -4
  122. package/nationalarchives/variables/_features.scss +1 -0
  123. 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,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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","replaceState"],"sourceRoot":""}
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,ksBCLvD,IAAMC,EAAI,WAsBd,O,EArBD,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GACnBG,KAAKF,QAAUA,EACfE,KAAKC,SAAWH,GAAWA,EAAQI,cAAc,mBACjDF,KAAKG,kBACH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AFrontend/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 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 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,113 @@ 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
+ this.$tabListItemLinks.forEach(($tabListItemLink, index) => {
102
+ if (index === this.currentTabIndex) {
186
103
  $tabListItemLink.setAttribute("aria-selected", true);
187
104
  $tabListItemLink.setAttribute("tabindex", "0");
188
- $tabListItemLink.focus();
105
+ if (switchFocus) {
106
+ $tabListItemLink.focus();
107
+ }
189
108
  } else {
190
- $tabListItemLink.classList.remove("tna-tabs__list-item-link--selected");
191
109
  $tabListItemLink.setAttribute("aria-selected", false);
192
110
  $tabListItemLink.setAttribute("tabindex", "-1");
193
111
  }
194
112
  });
195
-
196
- this.$tabItems.forEach(($tabItem) => {
197
- if ($tabItem.getAttribute("id") === targetId) {
113
+ this.$tabItems.forEach(($tabItem, index) => {
114
+ if (index === this.currentTabIndex) {
198
115
  $tabItem.removeAttribute("hidden");
199
116
  $tabItem.setAttribute("tabindex", "0");
200
117
  } else {
201
- $tabItem.setAttribute("hidden", true);
118
+ $tabItem.setAttribute("hidden", "until-found");
202
119
  $tabItem.setAttribute("tabindex", "-1");
203
120
  }
204
121
  });
122
+ }
205
123
 
206
- if (this.sticky) {
207
- if (history.replaceState) {
208
- history.replaceState(null, null, `#${targetId}`);
209
- } else {
210
- location.hash = `#${targetId}`;
211
- }
212
- }
124
+ switchTabByID(targetId) {
125
+ const index = Array.from(this.$tabItems).findIndex(
126
+ ($tabItem) => $tabItem.getAttribute("id") === targetId,
127
+ );
128
+ this.switchTabByIndex(index);
213
129
  }
214
130
  }
@@ -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,120 @@
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
- cursor: pointer;
45
+ border: 1px transparent solid;
46
+ border-bottom: none;
41
47
 
42
- @include typography.font-size(20);
43
- @include typography.heading-font;
48
+ cursor: pointer;
44
49
 
45
- &,
46
- &:link,
47
- &:visited {
48
- @include colour.colour-font("font-dark");
50
+ &:active {
51
+ @include a11y.focus-outline-without-offset;
52
+ @include a11y.active-outline;
49
53
  }
54
+ }
55
+
56
+ &__button[aria-selected="true"] {
57
+ padding-top: 0;
58
+
59
+ @include colour.colour-border("keyline");
50
60
 
51
61
  &::after {
52
62
  content: "";
53
63
 
64
+ height: 1px;
65
+
54
66
  position: absolute;
67
+ top: 100%;
55
68
  right: 0;
56
- bottom: 0;
57
69
  left: 0;
58
- }
59
-
60
- &:hover,
61
- &--selected,
62
- &--selected:hover {
63
- text-decoration: none;
64
70
 
65
- &::after {
66
- @include colour.thick-keyline-dark(top);
67
- }
71
+ @include colour.colour-background("background");
68
72
  }
73
+ }
69
74
 
70
- .tna-template--js-enabled & {
71
- @include colour.colour-font("font-light");
75
+ &__button-inner {
76
+ padding: spacing.space(0.5) spacing.space(0.75);
72
77
 
73
- &:hover {
74
- &::after {
75
- @include colour.thick-keyline(top);
76
- }
77
- }
78
+ display: block;
78
79
 
79
- &--selected {
80
- @include colour.colour-font("font-dark");
80
+ text-decoration: underline;
81
81
 
82
- &::after,
83
- &:hover::after {
84
- @include colour.thick-keyline-dark(top);
85
- }
86
- }
87
- }
82
+ @include colour.colour-font("font-dark");
88
83
  }
89
84
 
90
- &__items {
91
- // &:not(:target-within) {
92
- // .tna-tabs__item:first-child {
93
- // display: block;
94
- // }
95
- // }
85
+ &--small &__button-inner {
86
+ padding: spacing.space(0.25) spacing.space(0.5) spacing.space(0.125);
87
+
88
+ @include typography.font-size(16);
96
89
  }
97
90
 
98
- &__item {
99
- display: none;
91
+ &__button:hover &__button-inner {
92
+ @include typography.interacted-text-decoration;
93
+ }
100
94
 
101
- &:first-child {
102
- display: block;
103
- }
95
+ &__button[aria-selected="true"] &__button-inner {
96
+ text-decoration: none;
104
97
 
105
- &:has(~ :target) {
106
- display: none;
107
- }
98
+ @include colour.thick-keyline-accent(top);
99
+ }
108
100
 
109
- &:target {
110
- display: block;
111
- }
101
+ &__items {
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: spacing.space(2);
112
105
 
113
- .tna-template--js-enabled & {
114
- display: block;
106
+ position: relative;
107
+ z-index: 1;
108
+ }
115
109
 
116
- &[hidden] {
117
- display: none;
118
- }
119
- }
110
+ &__item {
111
+ border-radius: 0.1px;
112
+ // @include a11y.no-focus-outline-on-click;
120
113
 
121
- .tna-template--clicked &:focus {
122
- outline: none;
114
+ &:focus {
115
+ outline-offset: -#{a11yVariables.$focus-outline-width};
123
116
  }
124
117
  }
125
118
 
126
- @include colour.on-high-contrast-and-forced-colours {
127
- &__list {
128
- @include colour.colour-border("keyline-dark", 1px, solid, bottom);
129
- }
119
+ &--interactive &__item {
120
+ padding: spacing.space(1);
121
+ @include colour.colour-border("keyline", 1px, solid);
130
122
  }
131
123
 
132
- // @include colour.on-forced-colours {
133
- // &__list-item-link {
134
- // &--selected {
135
- // padding-bottom: spacing.space(0.125);
136
-
137
- // border-bottom-width: 0.375rem;
138
- // }
139
- // }
140
- // }
124
+ &--tint#{&}--interactive &__button[aria-selected="true"],
125
+ &--tint#{&}--interactive &__button:hover &__button-inner,
126
+ &--tint#{&}--interactive &__items {
127
+ @include colour.tint;
128
+ }
141
129
  }
@@ -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
- .tna-text-input{--background: #f4f4f4;--background-tint: rgb(217, 217, 214);--font-base: #343338;--font-dark: rgb(1, 1, 1);--font-light: rgb(1 1 1/0.58);--icon-light: rgb(52 51 56/0.45);--link: #005fa3;--link-visited: #4c2c92;--focus-outline: rgb(0, 176, 255);--keyline: rgb(38 38 42/0.25);--keyline-dark: #26262a;--input-foreground: rgb(1, 1, 1);--input-background: rgb(255, 255, 255);--input-border: rgb(1, 1, 1);--form-error-text: #c20000;--button-text: rgb(255, 255, 255);--button-background: rgb(1, 1, 1);--button-hover-text: rgb(1, 1, 1);--button-hover-background: rgb(255, 255, 255);--contrast-background: #1e1e1e;--contrast-font-base: rgb(255, 255, 255);--contrast-font-dark: rgb(255, 255, 255);--contrast-font-light: rgb(255 255 255/0.7);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: rgb(255, 255, 255);--contrast-link-visited: rgb(255, 255, 255);--contrast-keyline: rgb(255 255 255/0.5);--contrast-keyline-dark: rgb(255 255 255/0.8);--contrast-button-text: rgb(1, 1, 1);--contrast-button-background: rgb(255, 255, 255);--contrast-button-hover-text: rgb(255, 255, 255);--contrast-button-hover-background: rgb(1, 1, 1);--accent-background: #afb6b5;--accent-background-light: rgb(217, 217, 214);--accent-border: rgb(140, 150, 148);--accent-list-marker: rgb(1 1 1/0.58);--accent-font-base: rgb(1, 1, 1);--accent-font-dark: rgb(1, 1, 1);--accent-font-light: rgb(1 1 1/0.7);--accent-icon-light: rgb(1 1 1/0.45);--accent-link: rgb(1, 1, 1);--accent-link-visited: rgb(1, 1, 1);--accent-keyline: rgb(1 1 1/0.5);--accent-keyline-dark: rgb(1 1 1/0.8);--accent-button-text: rgb(255, 255, 255);--accent-button-background: rgb(1, 1, 1);--accent-button-hover-text: rgb(1, 1, 1);--accent-button-hover-background: rgb(255, 255, 255);--button-accented-text: rgb(1, 1, 1);--button-accented-background: rgb(140, 150, 148)}@media(prefers-contrast: more){.tna-text-input{--background: rgb(255, 255, 255);--background-tint: #ddd;--font-base: rgb(1, 1, 1);--font-dark: rgb(1, 1, 1);--font-light: rgb(1, 1, 1);--icon-light: rgb(1 1 1/0.75);--link: #34d;--link-visited: #848;--focus-outline: rgb(253, 63, 3);--keyline: rgb(1, 1, 1);--keyline-dark: rgb(1, 1, 1);--input-foreground: rgb(1, 1, 1);--input-background: rgb(255, 255, 255);--input-border: rgb(1, 1, 1);--form-error-text: #c20000;--button-text: rgb(255, 255, 255);--button-background: rgb(1, 1, 1);--button-hover-text: rgb(1, 1, 1);--button-hover-background: rgb(255, 255, 255);--contrast-background: rgb(1, 1, 1);--contrast-font-base: rgb(255, 255, 255);--contrast-font-dark: rgb(255, 255, 255);--contrast-font-light: rgb(255 255 255/0.7);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: rgb(0, 176, 255);--contrast-link-visited: #a8f;--contrast-keyline: rgb(255 255 255/0.5);--contrast-keyline-dark: rgb(255 255 255/0.8);--contrast-button-text: rgb(1, 1, 1);--contrast-button-background: rgb(255, 255, 255);--contrast-button-hover-text: rgb(255, 255, 255);--contrast-button-hover-background: rgb(1, 1, 1);--accent-background: #afb6b5;--accent-background-light: rgb(217, 217, 214);--accent-border: rgb(140, 150, 148);--accent-list-marker: rgb(1 1 1/0.58);--accent-font-base: rgb(1, 1, 1);--accent-font-dark: rgb(1, 1, 1);--accent-font-light: rgb(1 1 1/0.7);--accent-icon-light: rgb(1 1 1/0.45);--accent-link: rgb(1, 1, 1);--accent-link-visited: rgb(1, 1, 1);--accent-keyline: rgb(1 1 1/0.5);--accent-keyline-dark: rgb(1 1 1/0.8);--accent-button-text: rgb(255, 255, 255);--accent-button-background: rgb(1, 1, 1);--accent-button-hover-text: rgb(1, 1, 1);--accent-button-hover-background: rgb(255, 255, 255);--button-accented-text: rgb(1, 1, 1);--button-accented-background: rgb(140, 150, 148)}}.tna-text-input{width:100%;padding:0 6px;display:block;box-sizing:border-box;color:var(--input-foreground, rgb(1, 1, 1));line-height:2rem;background-color:var(--input-background, rgb(255, 255, 255));border:2px var(--input-border, rgb(1, 1, 1)) solid;border-radius:.1px}.tna-form__group--error .tna-text-input{border-color:var(--form-error-border, #c20000)}.tna-text-input--xs{max-width:5rem}.tna-text-input--s{max-width:10rem}.tna-text-input--m{max-width:20rem}.tna-text-input--l{max-width:40rem}.tna-text-input--xl{max-width:80rem}/*# sourceMappingURL=text-input.css.map */
1
+ .tna-text-input{--background: #f4f4f4;--background-tint: rgb(217, 217, 214);--font-base: #343338;--font-dark: rgb(1, 1, 1);--font-light: rgb(1 1 1/0.58);--icon-light: rgb(52 51 56/0.45);--link: #005fa3;--link-visited: #4c2c92;--keyline: rgb(38 38 42/0.25);--keyline-dark: #26262a;--input-foreground: rgb(1, 1, 1);--input-background: rgb(255, 255, 255);--input-border: rgb(1, 1, 1);--form-error-text: #c20000;--button-text: rgb(255, 255, 255);--button-background: rgb(1, 1, 1);--button-hover-text: rgb(1, 1, 1);--button-hover-background: rgb(255, 255, 255);--contrast-background: #1e1e1e;--contrast-font-base: rgb(255, 255, 255);--contrast-font-dark: rgb(255, 255, 255);--contrast-font-light: rgb(255 255 255/0.7);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: rgb(255, 255, 255);--contrast-link-visited: rgb(255, 255, 255);--contrast-keyline: rgb(255 255 255/0.5);--contrast-keyline-dark: rgb(255 255 255/0.8);--contrast-button-text: rgb(1, 1, 1);--contrast-button-background: rgb(255, 255, 255);--contrast-button-hover-text: rgb(255, 255, 255);--contrast-button-hover-background: rgb(1, 1, 1);--accent-background: #afb6b5;--accent-background-light: rgb(217, 217, 214);--accent-border: rgb(140, 150, 148);--accent-list-marker: rgb(1 1 1/0.58);--accent-font-base: rgb(1, 1, 1);--accent-font-dark: rgb(1, 1, 1);--accent-font-light: rgb(1 1 1/0.7);--accent-icon-light: rgb(1 1 1/0.45);--accent-link: rgb(1, 1, 1);--accent-link-visited: rgb(1, 1, 1);--accent-keyline: rgb(1 1 1/0.5);--accent-keyline-dark: rgb(1 1 1/0.8);--accent-button-text: rgb(255, 255, 255);--accent-button-background: rgb(1, 1, 1);--accent-button-hover-text: rgb(1, 1, 1);--accent-button-hover-background: rgb(255, 255, 255);--button-accented-text: rgb(1, 1, 1);--button-accented-background: rgb(140, 150, 148)}@media(prefers-contrast: more){.tna-text-input{--background: rgb(255, 255, 255);--background-tint: #ddd;--font-base: rgb(1, 1, 1);--font-dark: rgb(1, 1, 1);--font-light: rgb(1, 1, 1);--icon-light: rgb(1 1 1/0.75);--link: #34d;--link-visited: #848;--keyline: rgb(1, 1, 1);--keyline-dark: rgb(1, 1, 1);--input-foreground: rgb(1, 1, 1);--input-background: rgb(255, 255, 255);--input-border: rgb(1, 1, 1);--form-error-text: #c20000;--button-text: rgb(255, 255, 255);--button-background: rgb(1, 1, 1);--button-hover-text: rgb(1, 1, 1);--button-hover-background: rgb(255, 255, 255);--contrast-background: rgb(1, 1, 1);--contrast-font-base: rgb(255, 255, 255);--contrast-font-dark: rgb(255, 255, 255);--contrast-font-light: rgb(255 255 255/0.7);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: rgb(0, 176, 255);--contrast-link-visited: #a8f;--contrast-keyline: rgb(255 255 255/0.5);--contrast-keyline-dark: rgb(255 255 255/0.8);--contrast-button-text: rgb(1, 1, 1);--contrast-button-background: rgb(255, 255, 255);--contrast-button-hover-text: rgb(255, 255, 255);--contrast-button-hover-background: rgb(1, 1, 1);--accent-background: #afb6b5;--accent-background-light: rgb(217, 217, 214);--accent-border: rgb(140, 150, 148);--accent-list-marker: rgb(1 1 1/0.58);--accent-font-base: rgb(1, 1, 1);--accent-font-dark: rgb(1, 1, 1);--accent-font-light: rgb(1 1 1/0.7);--accent-icon-light: rgb(1 1 1/0.45);--accent-link: rgb(1, 1, 1);--accent-link-visited: rgb(1, 1, 1);--accent-keyline: rgb(1 1 1/0.5);--accent-keyline-dark: rgb(1 1 1/0.8);--accent-button-text: rgb(255, 255, 255);--accent-button-background: rgb(1, 1, 1);--accent-button-hover-text: rgb(1, 1, 1);--accent-button-hover-background: rgb(255, 255, 255);--button-accented-text: rgb(1, 1, 1);--button-accented-background: rgb(140, 150, 148)}}.tna-text-input{width:100%;padding:0 6px;display:block;box-sizing:border-box;color:var(--input-foreground, rgb(1, 1, 1));line-height:2rem;background-color:var(--input-background, rgb(255, 255, 255));border:2px var(--input-border, rgb(1, 1, 1)) solid;border-radius:.1px}.tna-form__group--error .tna-text-input{border-color:var(--form-error-border, #c20000)}.tna-text-input--xs{max-width:5rem}.tna-text-input--s{max-width:10rem}.tna-text-input--m{max-width:20rem}.tna-text-input--l{max-width:40rem}.tna-text-input--xl{max-width:80rem}/*# sourceMappingURL=text-input.css.map */