@nationalarchives/frontend 0.1.10-prerelease → 0.1.11-prerelease
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/govuk-prototype-kit.config.json +0 -3
- package/nationalarchives/_features.scss +3 -0
- package/nationalarchives/all.css +1 -1
- package/nationalarchives/all.css.map +1 -1
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +24 -8
- package/nationalarchives/all.scss +8 -4
- package/nationalarchives/assets/images/tna-square-logo.svg +5 -24
- package/nationalarchives/components/_index.scss +13 -0
- package/nationalarchives/components/breadcrumbs/_index.scss +28 -7
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +1 -1
- package/nationalarchives/components/breadcrumbs/fixtures.json +1 -1
- package/nationalarchives/components/breadcrumbs/macro.njk +1 -1
- package/nationalarchives/components/breadcrumbs/template.njk +14 -13
- package/nationalarchives/components/button/_index.scss +23 -11
- package/nationalarchives/components/button/button.stories.js +1 -1
- package/nationalarchives/components/button/fixtures.json +5 -5
- package/nationalarchives/components/button/macro.njk +1 -1
- package/nationalarchives/components/card/_index.scss +51 -7
- package/nationalarchives/components/card/card.js +2 -0
- package/nationalarchives/components/card/card.js.map +1 -0
- package/nationalarchives/components/card/card.mjs +45 -0
- package/nationalarchives/components/card/card.stories.js +18 -14
- package/nationalarchives/components/card/fixtures.json +14 -12
- package/nationalarchives/components/card/macro-options.json +18 -0
- package/nationalarchives/components/card/macro.njk +1 -1
- package/nationalarchives/components/card/template.njk +9 -4
- package/nationalarchives/components/filters/filters.stories.js +1 -1
- package/nationalarchives/components/filters/macro.njk +1 -1
- package/nationalarchives/components/filters/template.njk +2 -2
- package/nationalarchives/components/footer/_index.scss +24 -12
- package/nationalarchives/components/footer/fixtures.json +1 -1
- package/nationalarchives/components/footer/footer.stories.js +7 -7
- package/nationalarchives/components/footer/macro.njk +1 -1
- package/nationalarchives/components/footer/template.njk +4 -4
- package/nationalarchives/components/grid/_index.scss +10 -12
- package/nationalarchives/components/grid/fixtures.json +12 -12
- package/nationalarchives/components/grid/grid.stories.js +55 -1
- package/nationalarchives/components/grid/macro-options.json +30 -0
- package/nationalarchives/components/grid/macro.njk +1 -1
- package/nationalarchives/components/grid/template.njk +17 -1
- package/nationalarchives/components/header/_index.scss +103 -38
- package/nationalarchives/components/header/header.js +1 -1
- package/nationalarchives/components/header/header.js.map +1 -1
- package/nationalarchives/components/header/header.mjs +1 -12
- package/nationalarchives/components/header/header.stories.js +143 -2
- package/nationalarchives/components/header/macro-options.json +26 -0
- package/nationalarchives/components/header/macro.njk +1 -1
- package/nationalarchives/components/header/template.njk +27 -30
- package/nationalarchives/components/hero/_index.scss +33 -6
- package/nationalarchives/components/hero/fixtures.json +16 -1
- package/nationalarchives/components/hero/hero.stories.js +17 -3
- package/nationalarchives/components/hero/macro-options.json +13 -1
- package/nationalarchives/components/hero/macro.njk +1 -1
- package/nationalarchives/components/hero/template.njk +7 -5
- package/nationalarchives/components/phase-banner/_index.scss +17 -0
- package/nationalarchives/components/phase-banner/fixtures.json +69 -2
- package/nationalarchives/components/phase-banner/macro.njk +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.stories.js +32 -6
- package/nationalarchives/components/phase-banner/template.njk +4 -4
- package/nationalarchives/components/picture/_index.scss +77 -0
- package/nationalarchives/components/picture/fixtures.json +4 -0
- package/nationalarchives/components/picture/macro-options.json +88 -0
- package/nationalarchives/components/picture/macro.njk +3 -0
- package/nationalarchives/components/picture/picture.js +2 -0
- package/nationalarchives/components/picture/picture.js.map +1 -0
- package/nationalarchives/components/picture/picture.mjs +57 -0
- package/nationalarchives/components/picture/picture.stories.js +63 -0
- package/nationalarchives/components/picture/template.njk +42 -0
- package/nationalarchives/components/profile/_index.scss +2 -0
- package/nationalarchives/components/profile/fixtures.json +4 -0
- package/nationalarchives/components/profile/macro-options.json +14 -0
- package/nationalarchives/components/profile/macro.njk +3 -0
- package/nationalarchives/components/profile/profile.stories.js +32 -0
- package/nationalarchives/components/profile/template.njk +15 -0
- package/nationalarchives/components/sensitive-image/fixtures.json +3 -3
- package/nationalarchives/components/sensitive-image/macro.njk +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +1 -1
- package/nationalarchives/components/tabs/_index.scss +148 -0
- package/nationalarchives/components/tabs/fixtures.json +4 -0
- package/nationalarchives/components/tabs/macro-options.json +52 -0
- package/nationalarchives/components/tabs/macro.njk +3 -0
- package/nationalarchives/components/tabs/tabs.js +2 -0
- package/nationalarchives/components/tabs/tabs.js.map +1 -0
- package/nationalarchives/components/tabs/tabs.mjs +214 -0
- package/nationalarchives/components/tabs/tabs.stories.js +302 -0
- package/nationalarchives/components/tabs/template.njk +20 -0
- package/nationalarchives/patterns/_index.scss +1 -0
- package/nationalarchives/patterns/featured-collection/_index.scss +13 -0
- package/nationalarchives/patterns/featured-collection/featured-collection.stories.js +35 -0
- package/nationalarchives/patterns/featured-collection/macro-options.json +20 -0
- package/nationalarchives/patterns/featured-collection/macro.njk +3 -0
- package/nationalarchives/patterns/featured-collection/template.njk +96 -0
- package/nationalarchives/stories/development/contributing.mdx +2 -1
- package/nationalarchives/stories/utilities/colour.stories.js +189 -0
- package/nationalarchives/stories/utilities/typography.mdx +1 -0
- package/nationalarchives/stories/utilities/typography.stories.js +15 -0
- package/nationalarchives/templates/layouts/_generic.njk +1 -1
- package/nationalarchives/tools/_colour.scss +129 -0
- package/nationalarchives/tools/_grid.scss +2 -2
- package/nationalarchives/tools/_index.scss +5 -0
- package/nationalarchives/tools/_typography.scss +15 -0
- package/nationalarchives/utilities/_debug.scss +11 -0
- package/nationalarchives/utilities/_global.scss +65 -41
- package/nationalarchives/utilities/_index.scss +3 -0
- package/nationalarchives/utilities/_typography.scss +92 -60
- package/nationalarchives/variables/_colour.scss +96 -71
- package/nationalarchives/variables/_typography.scss +1 -1
- package/package.json +15 -14
- package/nationalarchives/components/_all.scss +0 -10
- package/nationalarchives/tools/_all.scss +0 -4
- package/nationalarchives/utilities/_all.scss +0 -2
- /package/nationalarchives/variables/{_all.scss → _index.scss} +0 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "src",
|
4
|
+
"type": "string",
|
5
|
+
"required": true,
|
6
|
+
"description": ""
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "alt",
|
10
|
+
"type": "string",
|
11
|
+
"required": true,
|
12
|
+
"description": ""
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "width",
|
16
|
+
"type": "number",
|
17
|
+
"required": true,
|
18
|
+
"description": ""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "height",
|
22
|
+
"type": "number",
|
23
|
+
"required": true,
|
24
|
+
"description": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "sources",
|
28
|
+
"type": "array",
|
29
|
+
"required": false,
|
30
|
+
"description": "",
|
31
|
+
"params": [
|
32
|
+
{
|
33
|
+
"name": "media",
|
34
|
+
"type": "text",
|
35
|
+
"required": true,
|
36
|
+
"description": ""
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "src",
|
40
|
+
"type": "text",
|
41
|
+
"required": true,
|
42
|
+
"description": ""
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "width",
|
46
|
+
"type": "number",
|
47
|
+
"required": false,
|
48
|
+
"description": ""
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "height",
|
52
|
+
"type": "number",
|
53
|
+
"required": false,
|
54
|
+
"description": ""
|
55
|
+
}
|
56
|
+
]
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"name": "caption",
|
60
|
+
"type": "string",
|
61
|
+
"required": false,
|
62
|
+
"description": ""
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "transcript",
|
66
|
+
"type": "string",
|
67
|
+
"required": false,
|
68
|
+
"description": ""
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "translation",
|
72
|
+
"type": "string",
|
73
|
+
"required": false,
|
74
|
+
"description": ""
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"name": "classes",
|
78
|
+
"type": "string",
|
79
|
+
"required": false,
|
80
|
+
"description": "Classes to add to the phase banner."
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "attributes",
|
84
|
+
"type": "object",
|
85
|
+
"required": false,
|
86
|
+
"description": "HTML attributes (for example data attributes) to add to the phase banner."
|
87
|
+
}
|
88
|
+
]
|
@@ -0,0 +1,2 @@
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("TNAFrontend",[],e):"object"==typeof exports?exports.TNAFrontend=e():(t.TNAFrontend=t.TNAFrontend||{},t.TNAFrontend["components/picture/picture"]=e())}(self,(()=>(()=>{"use strict";var t={948:(t,e,r)=>{r.d(e,{Z:()=>n});const n=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(t){return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{Picture:()=>o});var t=r(948);function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function i(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,o=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===e(o)?o:String(o)),i)}var o}var o=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$imageWrapper=t&&t.querySelector(".tna-picture__image-wrapper"),this.$transcript=t&&t.querySelector(".tna-picture__transcript"),this.transcriptOpened=!1}var r,n;return r=e,(n=[{key:"init",value:function(){var e=this;if(this.$module&&this.$imageWrapper&&this.$transcript){var r="tna-picture-".concat((0,t.Z)());this.$transcriptToggle=document.createElement("button"),this.$transcriptToggle.classList.add("tna-picture__toggle-transcript","tna-button"),this.$transcriptToggle.setAttribute("aria-controls",r),this.$transcriptToggle.setAttribute("aria-expanded",!1),this.$transcriptToggle.innerText="Open transcript",this.$transcriptToggle.addEventListener("click",(function(){return e.handleToggleTranscript()})),this.$imageWrapper.appendChild(this.$transcriptToggle),this.$transcript.setAttribute("id",r),this.$transcript.setAttribute("hidden",!0)}}},{key:"handleToggleTranscript",value:function(){var t="tna-picture__toggle-transcript--opened";this.transcriptOpened=!this.transcriptOpened,this.transcriptOpened?(this.$transcriptToggle.classList.add(t),this.$transcriptToggle.setAttribute("aria-expanded",!0),this.$transcriptToggle.innerText="Close transcript",this.$transcript.removeAttribute("hidden")):(this.$transcriptToggle.classList.remove(t),this.$transcriptToggle.setAttribute("aria-expanded",!1),this.$transcriptToggle.innerText="Open transcript",this.$transcript.setAttribute("hidden",!0))}}])&&i(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),e}()})(),n})()));
|
2
|
+
//# sourceMappingURL=picture.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"components/picture/picture.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,KAEzBD,EAAkB,YAAIA,EAAkB,aAAK,CAAC,EAAGA,EAAkB,YAAE,8BAAgCC,IACtG,CATD,CASGK,MAAM,I,yDCDT,QARe,WAAH,OACT,CAAC,MAAQ,KAAO,KAAO,KAAO,MAAMC,QAAQ,UAAU,SAACC,GAAC,OAErDA,EACCC,OAAOC,gBAAgB,IAAIC,WAAW,IAAI,GAAM,IAAOH,EAAI,GAC5DI,SAAS,GAAG,GACf,C,GCLCC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAad,QAGrB,IAAIC,EAASU,EAAyBE,GAAY,CAGjDb,QAAS,CAAC,GAOX,OAHAgB,EAAoBH,GAAUZ,EAAQA,EAAOD,QAASY,GAG/CX,EAAOD,OACf,CCrBAY,EAAoBK,EAAI,CAACjB,EAASkB,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEpB,EAASmB,IAC5EE,OAAOC,eAAetB,EAASmB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAK9B,IACH,oBAAX+B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAetB,EAAS+B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAetB,EAAS,aAAc,CAAEiC,OAAO,GAAO,E,muBCHvD,IAAMC,EAAO,WAClB,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GACnBG,KAAKF,QAAUA,EACfE,KAAKC,cACHH,GAAWA,EAAQI,cAAc,+BACnCF,KAAKG,YACHL,GAAWA,EAAQI,cAAc,4BACnCF,KAAKI,kBAAmB,CAC1B,C,QA6CC,O,EA7CAP,G,EAAA,EAAAf,IAAA,OAAAc,MAED,WAAO,IAAAS,EAAA,KACL,GAAKL,KAAKF,SAAYE,KAAKC,eAAkBD,KAAKG,YAAlD,CAIA,IAAMG,EAAW,eAAHC,QAAkBC,EAAAA,EAAAA,MAEhCR,KAAKS,kBAAoBC,SAASC,cAAc,UAChDX,KAAKS,kBAAkBG,UAAUC,IAC/B,iCACA,cAEFb,KAAKS,kBAAkBK,aAAa,gBAAiBR,GACrDN,KAAKS,kBAAkBK,aAAa,iBAAiB,GACrDd,KAAKS,kBAAkBM,UAAY,kBACnCf,KAAKS,kBAAkBO,iBAAiB,SAAS,kBAC/CX,EAAKY,wBAAwB,IAE/BjB,KAAKC,cAAciB,YAAYlB,KAAKS,mBAEpCT,KAAKG,YAAYW,aAAa,KAAMR,GACpCN,KAAKG,YAAYW,aAAa,UAAU,EAlBxC,CAoBF,GAAC,CAAAhC,IAAA,yBAAAc,MAED,WACE,IAAMuB,EACJ,yCACFnB,KAAKI,kBAAoBJ,KAAKI,iBAC1BJ,KAAKI,kBACPJ,KAAKS,kBAAkBG,UAAUC,IAAIM,GACrCnB,KAAKS,kBAAkBK,aAAa,iBAAiB,GACrDd,KAAKS,kBAAkBM,UAAY,mBACnCf,KAAKG,YAAYiB,gBAAgB,YAIjCpB,KAAKS,kBAAkBG,UAAUS,OAAOF,GACxCnB,KAAKS,kBAAkBK,aAAa,iBAAiB,GACrDd,KAAKS,kBAAkBM,UAAY,kBACnCf,KAAKG,YAAYW,aAAa,UAAU,GAG5C,M,oEAACjB,CAAA,CArDiB,E","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/./src/nationalarchives/lib/uuid.mjs","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/picture/picture.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = root[\"TNAFrontend\"] || {}, root[\"TNAFrontend\"][\"components/picture/picture\"] = factory();\n})(self, () => {\nreturn ","const uuidv4 = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16),\n );\n\nexport default uuidv4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import uuidv4 from \"../../lib/uuid.mjs\";\n\nexport class Picture {\n constructor($module) {\n this.$module = $module;\n this.$imageWrapper =\n $module && $module.querySelector(\".tna-picture__image-wrapper\");\n this.$transcript =\n $module && $module.querySelector(\".tna-picture__transcript\");\n this.transcriptOpened = false;\n }\n\n init() {\n if (!this.$module || !this.$imageWrapper || !this.$transcript) {\n return;\n }\n\n const uniqueId = `tna-picture-${uuidv4()}`;\n\n this.$transcriptToggle = document.createElement(\"button\");\n this.$transcriptToggle.classList.add(\n \"tna-picture__toggle-transcript\",\n \"tna-button\",\n );\n this.$transcriptToggle.setAttribute(\"aria-controls\", uniqueId);\n this.$transcriptToggle.setAttribute(\"aria-expanded\", false);\n this.$transcriptToggle.innerText = \"Open transcript\";\n this.$transcriptToggle.addEventListener(\"click\", () =>\n this.handleToggleTranscript(),\n );\n this.$imageWrapper.appendChild(this.$transcriptToggle);\n\n this.$transcript.setAttribute(\"id\", uniqueId);\n this.$transcript.setAttribute(\"hidden\", true);\n // this.$transcript.setAttribute(\"tabindex\", \"-1\");\n }\n\n handleToggleTranscript() {\n const transcriptToggleOpenedClass =\n \"tna-picture__toggle-transcript--opened\";\n this.transcriptOpened = !this.transcriptOpened;\n if (this.transcriptOpened) {\n this.$transcriptToggle.classList.add(transcriptToggleOpenedClass);\n this.$transcriptToggle.setAttribute(\"aria-expanded\", true);\n this.$transcriptToggle.innerText = \"Close transcript\";\n this.$transcript.removeAttribute(\"hidden\");\n // this.$transcript.setAttribute(\"tabindex\", \"0\");\n // this.$transcript.focus();\n } else {\n this.$transcriptToggle.classList.remove(transcriptToggleOpenedClass);\n this.$transcriptToggle.setAttribute(\"aria-expanded\", false);\n this.$transcriptToggle.innerText = \"Open transcript\";\n this.$transcript.setAttribute(\"hidden\", true);\n // this.$transcript.setAttribute(\"tabindex\", \"-1\");\n }\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","replace","c","crypto","getRandomValues","Uint8Array","toString","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","Picture","$module","_classCallCheck","this","$imageWrapper","querySelector","$transcript","transcriptOpened","_this","uniqueId","concat","uuidv4","$transcriptToggle","document","createElement","classList","add","setAttribute","innerText","addEventListener","handleToggleTranscript","appendChild","transcriptToggleOpenedClass","removeAttribute","remove"],"sourceRoot":""}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import uuidv4 from "../../lib/uuid.mjs";
|
2
|
+
|
3
|
+
export class Picture {
|
4
|
+
constructor($module) {
|
5
|
+
this.$module = $module;
|
6
|
+
this.$imageWrapper =
|
7
|
+
$module && $module.querySelector(".tna-picture__image-wrapper");
|
8
|
+
this.$transcript =
|
9
|
+
$module && $module.querySelector(".tna-picture__transcript");
|
10
|
+
this.transcriptOpened = false;
|
11
|
+
}
|
12
|
+
|
13
|
+
init() {
|
14
|
+
if (!this.$module || !this.$imageWrapper || !this.$transcript) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
|
18
|
+
const uniqueId = `tna-picture-${uuidv4()}`;
|
19
|
+
|
20
|
+
this.$transcriptToggle = document.createElement("button");
|
21
|
+
this.$transcriptToggle.classList.add(
|
22
|
+
"tna-picture__toggle-transcript",
|
23
|
+
"tna-button",
|
24
|
+
);
|
25
|
+
this.$transcriptToggle.setAttribute("aria-controls", uniqueId);
|
26
|
+
this.$transcriptToggle.setAttribute("aria-expanded", false);
|
27
|
+
this.$transcriptToggle.innerText = "Open transcript";
|
28
|
+
this.$transcriptToggle.addEventListener("click", () =>
|
29
|
+
this.handleToggleTranscript(),
|
30
|
+
);
|
31
|
+
this.$imageWrapper.appendChild(this.$transcriptToggle);
|
32
|
+
|
33
|
+
this.$transcript.setAttribute("id", uniqueId);
|
34
|
+
this.$transcript.setAttribute("hidden", true);
|
35
|
+
// this.$transcript.setAttribute("tabindex", "-1");
|
36
|
+
}
|
37
|
+
|
38
|
+
handleToggleTranscript() {
|
39
|
+
const transcriptToggleOpenedClass =
|
40
|
+
"tna-picture__toggle-transcript--opened";
|
41
|
+
this.transcriptOpened = !this.transcriptOpened;
|
42
|
+
if (this.transcriptOpened) {
|
43
|
+
this.$transcriptToggle.classList.add(transcriptToggleOpenedClass);
|
44
|
+
this.$transcriptToggle.setAttribute("aria-expanded", true);
|
45
|
+
this.$transcriptToggle.innerText = "Close transcript";
|
46
|
+
this.$transcript.removeAttribute("hidden");
|
47
|
+
// this.$transcript.setAttribute("tabindex", "0");
|
48
|
+
// this.$transcript.focus();
|
49
|
+
} else {
|
50
|
+
this.$transcriptToggle.classList.remove(transcriptToggleOpenedClass);
|
51
|
+
this.$transcriptToggle.setAttribute("aria-expanded", false);
|
52
|
+
this.$transcriptToggle.innerText = "Open transcript";
|
53
|
+
this.$transcript.setAttribute("hidden", true);
|
54
|
+
// this.$transcript.setAttribute("tabindex", "-1");
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import Picture from "./template.njk";
|
2
|
+
import macroOptions from "./macro-options.json";
|
3
|
+
|
4
|
+
const argTypes = {
|
5
|
+
src: { control: "text" },
|
6
|
+
width: { control: "number" },
|
7
|
+
height: { control: "number" },
|
8
|
+
sources: { control: "object" },
|
9
|
+
caption: { control: "text" },
|
10
|
+
transcript: { control: "text" },
|
11
|
+
translation: { control: "text" },
|
12
|
+
classes: { control: "text" },
|
13
|
+
attributes: { control: "object" },
|
14
|
+
};
|
15
|
+
|
16
|
+
Object.keys(argTypes).forEach((argType) => {
|
17
|
+
argTypes[argType].description = macroOptions.find(
|
18
|
+
(option) => option.name === argType,
|
19
|
+
)?.description;
|
20
|
+
});
|
21
|
+
|
22
|
+
export default {
|
23
|
+
title: "Work in progress/Components/Picture",
|
24
|
+
argTypes,
|
25
|
+
};
|
26
|
+
|
27
|
+
const Template = ({
|
28
|
+
src,
|
29
|
+
width,
|
30
|
+
height,
|
31
|
+
sources,
|
32
|
+
caption,
|
33
|
+
transcript,
|
34
|
+
translation,
|
35
|
+
classes,
|
36
|
+
attributes,
|
37
|
+
}) => {
|
38
|
+
return Picture({
|
39
|
+
params: {
|
40
|
+
src,
|
41
|
+
width,
|
42
|
+
height,
|
43
|
+
sources,
|
44
|
+
caption,
|
45
|
+
transcript,
|
46
|
+
translation,
|
47
|
+
classes,
|
48
|
+
attributes,
|
49
|
+
},
|
50
|
+
});
|
51
|
+
};
|
52
|
+
|
53
|
+
export const Standard = Template.bind({});
|
54
|
+
Standard.args = {
|
55
|
+
src: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg",
|
56
|
+
alt: "The National Archives office",
|
57
|
+
width: 1996,
|
58
|
+
height: 1331,
|
59
|
+
caption: "<p>This is a pretty image</p>",
|
60
|
+
transcript: "<p>Lorem ipsum transcript</p>",
|
61
|
+
translation: "<p>Lorem ipsum translation</p>",
|
62
|
+
classes: "tna-picture--demo",
|
63
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{% from "nationalarchives/components/tabs/macro.njk" import tnaTabs %}
|
2
|
+
|
3
|
+
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
4
|
+
<figure class="tna-picture {{ containerClasses | join(' ') }}" data-module="tna-picture" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
5
|
+
<div class="tna-picture__image-wrapper">
|
6
|
+
<picture>
|
7
|
+
{%- for source in params.sources -%}
|
8
|
+
<source class="tna-picture__image" media="{{ source.media }}" srcset="{{ source.src }}" width="{{ source.width }}" height="{{ source.height }}">
|
9
|
+
{%- endfor -%}
|
10
|
+
<img class="tna-picture__image" width="{{ params.width }}" height="{{ params.height }}" src="{{ params.src }}" alt="{{ params.alt }}">
|
11
|
+
</picture>
|
12
|
+
</div>
|
13
|
+
{%- if params.transcript or params.translation -%}
|
14
|
+
<div class="tna-picture__transcript">
|
15
|
+
{%- if params.transcript and params.translation -%}
|
16
|
+
{{ tnaTabs({
|
17
|
+
items: [
|
18
|
+
{
|
19
|
+
id: "test1",
|
20
|
+
title: "Transcript",
|
21
|
+
body: params.transcript
|
22
|
+
},
|
23
|
+
{
|
24
|
+
id: "test2",
|
25
|
+
title: "English translation",
|
26
|
+
body: params.translation
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}) }}
|
30
|
+
{%- elseif params.transcript -%}
|
31
|
+
{{ params.transcript | safe }}
|
32
|
+
{%- else -%}
|
33
|
+
{{ params.translation | safe }}
|
34
|
+
{%- endif -%}
|
35
|
+
</div>
|
36
|
+
{%- endif -%}
|
37
|
+
{%- if params.caption -%}
|
38
|
+
<figcaption class="tna-picture__caption">
|
39
|
+
{{ params.caption | safe }}
|
40
|
+
</figcaption>
|
41
|
+
{%- endif -%}
|
42
|
+
</figure>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "classes",
|
4
|
+
"type": "string",
|
5
|
+
"required": false,
|
6
|
+
"description": "Classes to add to the profile."
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "attributes",
|
10
|
+
"type": "object",
|
11
|
+
"required": false,
|
12
|
+
"description": "HTML attributes (for example data attributes) to add to the profile."
|
13
|
+
}
|
14
|
+
]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import Profile from "./template.njk";
|
2
|
+
import macroOptions from "./macro-options.json";
|
3
|
+
|
4
|
+
const argTypes = {
|
5
|
+
classes: { control: "text" },
|
6
|
+
attributes: { control: "object" },
|
7
|
+
};
|
8
|
+
|
9
|
+
Object.keys(argTypes).forEach((argType) => {
|
10
|
+
argTypes[argType].description = macroOptions.find(
|
11
|
+
(option) => option.name === argType,
|
12
|
+
)?.description;
|
13
|
+
});
|
14
|
+
|
15
|
+
export default {
|
16
|
+
title: "Work in progress/Components/Profile",
|
17
|
+
argTypes,
|
18
|
+
};
|
19
|
+
|
20
|
+
const Template = ({ classes, attributes }) => {
|
21
|
+
return Profile({
|
22
|
+
params: {
|
23
|
+
classes,
|
24
|
+
attributes,
|
25
|
+
},
|
26
|
+
});
|
27
|
+
};
|
28
|
+
|
29
|
+
export const Standard = Template.bind({});
|
30
|
+
Standard.args = {
|
31
|
+
classes: "tna-profile--demo",
|
32
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
2
|
+
<div class="tna-profile tna-container {{ containerClasses | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
3
|
+
<div class="tna-column tna-column--order-2">
|
4
|
+
<img src="https://avatar.iran.liara.run/public" width="200" height="200" />
|
5
|
+
</div>
|
6
|
+
<div class="tna-column tna-column--flex-1 tna-column--full-small tna-column--full-tiny tna-column--order-1 tna-column--order-3-small tna-column--order-3-tiny">
|
7
|
+
<hgroup class="tna-hgroup tna-hgroup--xl">
|
8
|
+
<p class="tna-hgroup__supertitle">Profile</p>
|
9
|
+
<h1 class="tna-hgroup__title tna-heading">Max Smith</h1>
|
10
|
+
</hgroup>
|
11
|
+
<p>
|
12
|
+
Master of Documents
|
13
|
+
</p>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"warning": "This is a gory photo",
|
14
14
|
"action": "Show me the gory photo"
|
15
15
|
},
|
16
|
-
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\"
|
16
|
+
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\"><p class=\"tna-sensitive-image__warning\">This is a gory photo</p><details class=\"tna-sensitive-image__details\"><summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary><div class=\"tna-sensitive-image__container\"><img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" /></div></details></div>",
|
17
17
|
"hidden": false
|
18
18
|
},
|
19
19
|
{
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"action": "Show me the gory photo",
|
30
30
|
"classes": "sensitive-image__test-class"
|
31
31
|
},
|
32
|
-
"html": "<div class=\"tna-sensitive-image sensitive-image__test-class\" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\"
|
32
|
+
"html": "<div class=\"tna-sensitive-image sensitive-image__test-class\" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\"><p class=\"tna-sensitive-image__warning\">This is a gory photo</p><details class=\"tna-sensitive-image__details\"><summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary><div class=\"tna-sensitive-image__container\"><img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" /></div></details></div>",
|
33
33
|
"hidden": false
|
34
34
|
},
|
35
35
|
{
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"data-testattribute": "foobar"
|
48
48
|
}
|
49
49
|
},
|
50
|
-
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\" data-testattribute=\"foobar\"
|
50
|
+
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\" data-testattribute=\"foobar\"><p class=\"tna-sensitive-image__warning\">This is a gory photo</p><details class=\"tna-sensitive-image__details\"><summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary><div class=\"tna-sensitive-image__container\"><img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" /></div></details></div>",
|
51
51
|
"hidden": false
|
52
52
|
}
|
53
53
|
]
|
@@ -0,0 +1,148 @@
|
|
1
|
+
@use "../../tools/colour";
|
2
|
+
|
3
|
+
.tna-tabs {
|
4
|
+
margin-bottom: 1rem;
|
5
|
+
|
6
|
+
&__list {
|
7
|
+
margin: 0 0 1rem;
|
8
|
+
padding: 0;
|
9
|
+
|
10
|
+
display: flex;
|
11
|
+
align-items: stretch;
|
12
|
+
|
13
|
+
list-style: none;
|
14
|
+
}
|
15
|
+
|
16
|
+
&__list-item {
|
17
|
+
display: inline-flex;
|
18
|
+
|
19
|
+
& + & {
|
20
|
+
margin-left: 1rem;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
&__list-item-link {
|
25
|
+
padding: 0.5rem 0;
|
26
|
+
|
27
|
+
display: flex;
|
28
|
+
|
29
|
+
align-items: center;
|
30
|
+
position: relative;
|
31
|
+
|
32
|
+
@include colour.colour-font("font-dark");
|
33
|
+
font-size: inherit;
|
34
|
+
font-family: inherit;
|
35
|
+
font-weight: 700;
|
36
|
+
text-decoration: none;
|
37
|
+
line-height: 1.5;
|
38
|
+
text-align: center;
|
39
|
+
|
40
|
+
background: transparent;
|
41
|
+
|
42
|
+
border: none;
|
43
|
+
|
44
|
+
cursor: pointer;
|
45
|
+
|
46
|
+
& + & {
|
47
|
+
margin-left: 1.5rem;
|
48
|
+
}
|
49
|
+
|
50
|
+
&::after {
|
51
|
+
height: 0;
|
52
|
+
|
53
|
+
position: absolute;
|
54
|
+
right: 0;
|
55
|
+
bottom: 0;
|
56
|
+
left: 0;
|
57
|
+
|
58
|
+
@include colour.colour-background("keyline-dark");
|
59
|
+
|
60
|
+
content: "";
|
61
|
+
}
|
62
|
+
|
63
|
+
&:hover,
|
64
|
+
&--selected,
|
65
|
+
&--selected:hover {
|
66
|
+
&::after {
|
67
|
+
height: 0.25rem;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
.tna-template--js-enabled & {
|
72
|
+
@include colour.colour-font("font-light");
|
73
|
+
|
74
|
+
&:hover {
|
75
|
+
&::after {
|
76
|
+
height: 0.125rem;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
&--selected {
|
81
|
+
@include colour.colour-font("font-dark");
|
82
|
+
|
83
|
+
&::after,
|
84
|
+
&:hover::after {
|
85
|
+
height: 0.25rem;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
&__items {
|
92
|
+
// &:not(:target-within) {
|
93
|
+
// .tna-tabs__item:first-child {
|
94
|
+
// display: block;
|
95
|
+
// }
|
96
|
+
// }
|
97
|
+
}
|
98
|
+
|
99
|
+
&__item {
|
100
|
+
display: none;
|
101
|
+
|
102
|
+
&:first-child {
|
103
|
+
display: block;
|
104
|
+
}
|
105
|
+
|
106
|
+
&:has(~ :target) {
|
107
|
+
display: none;
|
108
|
+
}
|
109
|
+
|
110
|
+
&:target {
|
111
|
+
display: block;
|
112
|
+
}
|
113
|
+
|
114
|
+
.tna-template--js-enabled & {
|
115
|
+
display: block;
|
116
|
+
|
117
|
+
&[hidden] {
|
118
|
+
display: none;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
.tna-template--clicked &:focus {
|
123
|
+
outline: none;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
@mixin high-contrast {
|
128
|
+
&__list-item-link {
|
129
|
+
padding-right: 1rem;
|
130
|
+
padding-left: 1rem;
|
131
|
+
|
132
|
+
overflow: hidden;
|
133
|
+
|
134
|
+
border: 1px transparent solid;
|
135
|
+
@include colour.colour-border("keyline-dark");
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
.tna-template--high-contrast-theme & {
|
140
|
+
@include high-contrast;
|
141
|
+
}
|
142
|
+
|
143
|
+
@media (prefers-contrast: more) {
|
144
|
+
.tna-template--system-theme & {
|
145
|
+
@include high-contrast;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "title",
|
4
|
+
"type": "string",
|
5
|
+
"required": true,
|
6
|
+
"description": ""
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "items",
|
10
|
+
"type": "array",
|
11
|
+
"required": true,
|
12
|
+
"description": "",
|
13
|
+
"params": [
|
14
|
+
{
|
15
|
+
"name": "id",
|
16
|
+
"type": "string",
|
17
|
+
"required": true,
|
18
|
+
"description": ""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "title",
|
22
|
+
"type": "string",
|
23
|
+
"required": true,
|
24
|
+
"description": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "body",
|
28
|
+
"type": "string",
|
29
|
+
"required": true,
|
30
|
+
"description": ""
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "sticky",
|
36
|
+
"type": "boolean",
|
37
|
+
"required": false,
|
38
|
+
"description": ""
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"name": "classes",
|
42
|
+
"type": "string",
|
43
|
+
"required": false,
|
44
|
+
"description": "Classes to add to the tabs."
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"name": "attributes",
|
48
|
+
"type": "object",
|
49
|
+
"required": false,
|
50
|
+
"description": "HTML attributes (for example data attributes) to add to the tabs."
|
51
|
+
}
|
52
|
+
]
|
@@ -0,0 +1,2 @@
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("TNAFrontend",[],e):"object"==typeof exports?exports.TNAFrontend=e():(t.TNAFrontend=t.TNAFrontend||{},t.TNAFrontend["components/tabs/tabs"]=e())}(self,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,s=function(t,e){if("object"!==i(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===i(s)?s:String(s)),r)}var s}t.r(e),t.d(e,{Tabs:()=>a});var a=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.$module=e,this.$tabList=e&&e.querySelector(".tna-tabs__list"),this.$tabListItemLinks=e&&this.$tabList&&e.querySelectorAll(".tna-tabs__list-item-link"),this.$tabItems=e&&e.querySelectorAll(".tna-tabs__item")}var e,i;return e=t,(i=[{key:"init",value:function(){var t=this;if(this.$module&&this.$tabList&&this.$tabListItemLinks&&this.$tabItems&&this.$tabListItemLinks.length===this.$tabItems.length){this.sticky=this.$module.classList.contains("tna-tabs--sticky");var e=window.location.hash.replace(/^#/,"");this.$newTabList=document.createElement("div"),this.$newTabList.setAttribute("role","tablist"),this.$newTabList.setAttribute("class",this.$tabList.getAttribute("class")),this.$tabItems.forEach((function(t,i){t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby","".concat(t.getAttribute("id"),"-tab")),t.setAttribute("tabindex","0"),(e&&t.getAttribute("id")!==e||!e&&i>0)&&t.setAttribute("hidden",!0)})),this.$tabListItemLinks.forEach((function(e){var i=document.createElement("button");i.innerText=e.innerText,i.setAttribute("class",e.getAttribute("class")),i.setAttribute("role","tab"),i.setAttribute("id",e.getAttribute("id")),i.setAttribute("aria-controls",e.getAttribute("href").replace(/^#/,"")),i.setAttribute("tabindex","-1"),t.$newTabList.appendChild(i)})),this.$tabList.replaceWith(this.$newTabList),this.$tabListItemLinks=this.$module.querySelectorAll(".tna-tabs__list-item-link"),this.$tabListItemLinks.forEach((function(i,n){e&&i.getAttribute("aria-controls")==="".concat(e)||!e&&0===n?(i.classList.add("tna-tabs__list-item-link--selected"),i.setAttribute("aria-selected",!0),i.setAttribute("tabindex","0")):i.setAttribute("aria-selected",!1),i.addEventListener("keydown",(function(e){return t.handleItemLinkKeyDown(e)}),!0),i.addEventListener("click",(function(e){return t.handleItemLinkClick(e)}),!0)}))}}},{key:"handleItemLinkClick",value:function(t){t.preventDefault();var e=t.currentTarget.getAttribute("aria-controls");this.switchTab(e)}},{key:"handleItemLinkKeyDown",value:function(t){var e=t.currentTarget,i=!1;switch(t.key){case"ArrowLeft":this.setSelectedToPreviousTab(e),i=!0;break;case"ArrowRight":this.setSelectedToNextTab(e),i=!0;break;case"Home":this.switchTab(this.$tabListItemLinks[0].getAttribute("aria-controls")),i=!0;break;case"End":this.switchTab(this.$tabListItemLinks[this.$tabListItemLinks.length-1].getAttribute("aria-controls")),i=!0}i&&(t.stopPropagation(),t.preventDefault())}},{key:"setSelectedToNextTab",value:function(t){console.log("setSelectedToNextTab",t);var e,i=n(this.$tabListItemLinks).findIndex((function(e){return e.getAttribute("id")===t.getAttribute("id")}));e=i<this.$tabListItemLinks.length-1?i+1:0,console.log(i,e),this.switchTab(this.$tabListItemLinks[e].getAttribute("aria-controls"))}},{key:"setSelectedToPreviousTab",value:function(t){console.log("setSelectedToPreviousTab",t);var e,i=n(this.$tabListItemLinks).findIndex((function(e){return e.getAttribute("id")===t.getAttribute("id")}));e=i>=1?i-1:this.$tabListItemLinks.length-1,console.log(i,e),this.switchTab(this.$tabListItemLinks[e].getAttribute("aria-controls"))}},{key:"switchTab",value:function(t){this.$tabListItemLinks.forEach((function(e){e.getAttribute("aria-controls")===t?(e.classList.add("tna-tabs__list-item-link--selected"),e.setAttribute("aria-selected",!0),e.setAttribute("tabindex","0"),e.focus()):(e.classList.remove("tna-tabs__list-item-link--selected"),e.setAttribute("aria-selected",!1),e.setAttribute("tabindex","-1"))})),this.$tabItems.forEach((function(e){e.getAttribute("id")===t?(e.removeAttribute("hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("hidden",!0),e.setAttribute("tabindex","-1"))})),this.sticky&&(history.replaceState?history.replaceState(null,null,"#".concat(t)):location.hash="#".concat(t))}}])&&s(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();return e})()));
|
2
|
+
//# sourceMappingURL=tabs.js.map
|