@nationalarchives/frontend 0.1.8-prerelease → 0.1.10-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 +2 -2
- package/nationalarchives/_features.scss +1 -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 +53 -6
- package/nationalarchives/assets/images/footer/facebook.svg +11 -0
- package/nationalarchives/assets/images/footer/flickr.svg +11 -0
- package/nationalarchives/assets/images/footer/instagram.svg +17 -0
- package/nationalarchives/assets/images/footer/rss.svg +13 -0
- package/nationalarchives/assets/images/footer/twitter.svg +14 -0
- package/nationalarchives/assets/images/footer/youtube.svg +12 -0
- package/nationalarchives/assets/images/tna-square-logo.svg +24 -45
- package/nationalarchives/components/_all.scss +4 -0
- package/nationalarchives/components/breadcrumbs/_index.scss +4 -3
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +2 -3
- package/nationalarchives/components/breadcrumbs/fixtures.json +1 -1
- package/nationalarchives/components/breadcrumbs/macro-options.json +2 -2
- package/nationalarchives/components/breadcrumbs/template.njk +9 -9
- package/nationalarchives/components/button/_index.scss +25 -5
- package/nationalarchives/components/button/button.stories.js +2 -3
- package/nationalarchives/components/button/fixtures.json +5 -5
- package/nationalarchives/components/button/template.njk +3 -3
- package/nationalarchives/components/card/_index.scss +7 -3
- package/nationalarchives/components/card/card.stories.js +2 -3
- package/nationalarchives/components/card/fixtures.json +11 -11
- package/nationalarchives/components/card/template.njk +44 -44
- package/nationalarchives/components/filters/_index.scss +49 -0
- package/nationalarchives/components/filters/filters.stories.js +75 -0
- package/nationalarchives/components/filters/fixtures.json +4 -0
- package/nationalarchives/components/filters/macro-options.json +52 -0
- package/nationalarchives/components/filters/macro.njk +3 -0
- package/nationalarchives/components/filters/template.njk +8 -0
- package/nationalarchives/components/footer/_index.scss +49 -4
- package/nationalarchives/components/footer/fixtures.json +1 -1
- package/nationalarchives/components/footer/footer.stories.js +23 -26
- package/nationalarchives/components/footer/macro-options.json +12 -6
- package/nationalarchives/components/footer/template.njk +61 -51
- package/nationalarchives/components/grid/_index.scss +3 -78
- package/nationalarchives/components/grid/fixtures.json +12 -12
- package/nationalarchives/components/grid/grid.stories.js +3 -4
- package/nationalarchives/components/grid/template.njk +35 -35
- package/nationalarchives/components/header/_index.scss +452 -0
- package/nationalarchives/components/header/fixtures.json +4 -0
- package/nationalarchives/components/header/header.js +2 -0
- package/nationalarchives/components/header/header.js.map +1 -0
- package/nationalarchives/components/header/header.mjs +108 -0
- package/nationalarchives/components/header/header.stories.js +68 -0
- package/nationalarchives/components/header/macro-options.json +104 -0
- package/nationalarchives/components/header/macro.njk +3 -0
- package/nationalarchives/components/header/template.njk +66 -0
- package/nationalarchives/components/hero/_index.scss +4 -1
- package/nationalarchives/components/hero/hero.stories.js +17 -15
- package/nationalarchives/components/hero/macro-options.json +3 -3
- package/nationalarchives/components/hero/template.njk +27 -27
- package/nationalarchives/components/phase-banner/_index.scss +43 -0
- package/nationalarchives/components/phase-banner/fixtures.json +14 -0
- package/nationalarchives/components/phase-banner/macro-options.json +26 -0
- package/nationalarchives/components/phase-banner/macro.njk +3 -0
- package/nationalarchives/components/phase-banner/phase-banner.stories.js +38 -0
- package/nationalarchives/components/phase-banner/template.njk +16 -0
- package/nationalarchives/components/sensitive-image/fixtures.json +3 -3
- package/nationalarchives/components/sensitive-image/macro-options.json +2 -2
- package/nationalarchives/components/sensitive-image/sensitive-image.js +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.js.map +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.mjs +21 -22
- package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +2 -3
- package/nationalarchives/components/sensitive-image/template.njk +7 -7
- package/nationalarchives/lib/uuid.mjs +9 -0
- package/nationalarchives/stories/development/contributing.mdx +38 -0
- package/nationalarchives/stories/development/dependencies.mdx +2 -0
- package/nationalarchives/stories/development/publishing.mdx +9 -0
- package/nationalarchives/stories/development/technologies.mdx +65 -0
- package/nationalarchives/stories/utilities/lists.stories.js +2 -2
- package/nationalarchives/stories/utilities/typography.mdx +15 -0
- package/nationalarchives/templates/homepage.njk +46 -46
- package/nationalarchives/templates/layouts/_generic.njk +49 -52
- package/nationalarchives/templates/layouts/_prototype-kit.njk +5 -0
- package/nationalarchives/templates/search-results.njk +31 -31
- package/nationalarchives/templates/topics.njk +33 -33
- package/nationalarchives/tools/_all.scss +1 -0
- package/nationalarchives/tools/_assets.scss +5 -0
- package/nationalarchives/tools/_grid.scss +52 -27
- package/nationalarchives/tools/_media.scss +12 -11
- package/nationalarchives/utilities/_global.scss +103 -3
- package/nationalarchives/utilities/_typography.scss +112 -92
- package/nationalarchives/variables/_all.scss +1 -0
- package/nationalarchives/variables/_assets.scss +1 -0
- package/nationalarchives/variables/_colour.scss +95 -1
- package/nationalarchives/variables/_media.scss +39 -11
- package/package.json +18 -16
- package/nationalarchives/assets/images/tna-square-logo-inverted.svg +0 -47
- package/nationalarchives/stories/development/structure.mdx +0 -7
@@ -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\">\n
|
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\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</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\">\n
|
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\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</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\">\n
|
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\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</div>",
|
51
51
|
"hidden": false
|
52
52
|
}
|
53
53
|
]
|
@@ -47,12 +47,12 @@
|
|
47
47
|
"name": "classes",
|
48
48
|
"type": "string",
|
49
49
|
"required": false,
|
50
|
-
"description": "Classes to add to the
|
50
|
+
"description": "Classes to add to the sensitive image."
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"name": "attributes",
|
54
54
|
"type": "object",
|
55
55
|
"required": false,
|
56
|
-
"description": "HTML attributes (for example data attributes) to add to the
|
56
|
+
"description": "HTML attributes (for example data attributes) to add to the sensitive image."
|
57
57
|
}
|
58
58
|
]
|
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TNAFrontend",[],t):"object"==typeof exports?exports.TNAFrontend=t():(e.TNAFrontend=e.TNAFrontend||{},e.TNAFrontend["components/sensitive-image/sensitive-image"]=t())}(self,(()=>(()=>{"use strict";var e={d:(t,
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TNAFrontend",[],t):"object"==typeof exports?exports.TNAFrontend=t():(e.TNAFrontend=e.TNAFrontend||{},e.TNAFrontend["components/sensitive-image/sensitive-image"]=t())}(self,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,r=function(e,t){if("object"!==o(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,"string");if("object"!==o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key),"symbol"===o(r)?r:String(r)),n)}var r}e.r(t),e.d(t,{SensitiveImage:()=>n});var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$imageDetails=t&&t.querySelector(".tna-sensitive-image__details"),this.$image=t&&t.querySelector(".tna-sensitive-image__image"),this.imageIsVisible=!1}var t,o;return t=e,(o=[{key:"init",value:function(){var e=this;this.$module&&this.$imageDetails&&this.$image&&this.$imageDetails.addEventListener("toggle",(function(){return e.handleImageDetailsToggle()}))}},{key:"handleImageDetailsToggle",value:function(){this.$imageDetails.hasAttribute("open")&&this.$image.focus({preventScroll:!0,focusVisible:!0})}}])&&i(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();return t})()));
|
2
2
|
//# sourceMappingURL=sensitive-image.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"components/sensitive-image/sensitive-image.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,8CAAgDC,IACtH,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,
|
1
|
+
{"version":3,"file":"components/sensitive-image/sensitive-image.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,8CAAgDC,IACtH,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,6sBCLvD,IAAMC,EAAc,WACzB,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GACnBG,KAAKF,QAAUA,EACfE,KAAKC,cACHH,GAAWA,EAAQI,cAAc,iCACnCF,KAAKG,OACHL,GAAWA,EAAQI,cAAc,+BACnCF,KAAKI,gBAAiB,CACxB,C,QAeC,O,EAfAP,G,EAAA,EAAAd,IAAA,OAAAa,MAED,WAAO,IAAAS,EAAA,KACAL,KAAKF,SAAYE,KAAKC,eAAkBD,KAAKG,QAGlDH,KAAKC,cAAcK,iBAAiB,UAAU,kBAC5CD,EAAKE,0BAA0B,GAEnC,GAAC,CAAAxB,IAAA,2BAAAa,MAED,WACMI,KAAKC,cAAcO,aAAa,SAClCR,KAAKG,OAAOM,MAAM,CAAEC,eAAe,EAAMC,cAAc,GAE3D,M,oEAACd,CAAA,CAvBwB,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/sensitive-image/sensitive-image.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/sensitive-image/sensitive-image\"] = 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 SensitiveImage {\n constructor($module) {\n this.$module = $module;\n this.$imageDetails =\n $module && $module.querySelector(\".tna-sensitive-image__details\");\n this.$image =\n $module && $module.querySelector(\".tna-sensitive-image__image\");\n this.imageIsVisible = false;\n }\n\n init() {\n if (!this.$module || !this.$imageDetails || !this.$image) {\n return;\n }\n this.$imageDetails.addEventListener(\"toggle\", () =>\n this.handleImageDetailsToggle(),\n );\n }\n\n handleImageDetailsToggle() {\n if (this.$imageDetails.hasAttribute(\"open\")) {\n this.$image.focus({ preventScroll: true, focusVisible: true });\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","SensitiveImage","$module","_classCallCheck","this","$imageDetails","querySelector","$image","imageIsVisible","_this","addEventListener","handleImageDetailsToggle","hasAttribute","focus","preventScroll","focusVisible"],"sourceRoot":""}
|
@@ -1,26 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
SensitiveImage.prototype.init = function () {
|
10
|
-
console.log(this);
|
11
|
-
if (!this.$module || !this.$imageDetails || !this.$image) {
|
12
|
-
return;
|
1
|
+
export class SensitiveImage {
|
2
|
+
constructor($module) {
|
3
|
+
this.$module = $module;
|
4
|
+
this.$imageDetails =
|
5
|
+
$module && $module.querySelector(".tna-sensitive-image__details");
|
6
|
+
this.$image =
|
7
|
+
$module && $module.querySelector(".tna-sensitive-image__image");
|
8
|
+
this.imageIsVisible = false;
|
13
9
|
}
|
14
|
-
this.$imageDetails.addEventListener(
|
15
|
-
"toggle",
|
16
|
-
this.handleImageDetailsToggle.bind(this)
|
17
|
-
);
|
18
|
-
};
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
init() {
|
12
|
+
if (!this.$module || !this.$imageDetails || !this.$image) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
this.$imageDetails.addEventListener("toggle", () =>
|
16
|
+
this.handleImageDetailsToggle(),
|
17
|
+
);
|
23
18
|
}
|
24
|
-
};
|
25
19
|
|
26
|
-
|
20
|
+
handleImageDetailsToggle() {
|
21
|
+
if (this.$imageDetails.hasAttribute("open")) {
|
22
|
+
this.$image.focus({ preventScroll: true, focusVisible: true });
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import SensitiveImage from "./template.njk";
|
2
|
-
import "./_index.scss";
|
3
2
|
import macroOptions from "./macro-options.json";
|
4
3
|
import { expect } from "@storybook/jest";
|
5
4
|
import { within, userEvent } from "@storybook/testing-library";
|
@@ -15,12 +14,12 @@ const argTypes = {
|
|
15
14
|
|
16
15
|
Object.keys(argTypes).forEach((argType) => {
|
17
16
|
argTypes[argType].description = macroOptions.find(
|
18
|
-
(option) => option.name === argType
|
17
|
+
(option) => option.name === argType,
|
19
18
|
)?.description;
|
20
19
|
});
|
21
20
|
|
22
21
|
export default {
|
23
|
-
title: "Components/Sensitive image",
|
22
|
+
title: "Components/Experimental/Sensitive image",
|
24
23
|
argTypes,
|
25
24
|
};
|
26
25
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
2
2
|
<div class="tna-sensitive-image {{ containerClasses | join(' ') }}" data-module="tna-sensitive-image" style="--sensitive-image: url('{{ params.image.src }}'); --sensitive-image-width: {{ params.image.width }}; --sensitive-image-height: {{ params.image.height }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
<p class="tna-sensitive-image__warning">{{ params.warning }}</p>
|
4
|
+
<details class="tna-sensitive-image__details">
|
5
|
+
<summary class="tna-sensitive-image__show" data-action="{{ params.action }}">{{ params.action }}</summary>
|
6
|
+
<div class="tna-sensitive-image__container">
|
7
|
+
<img src="{{ params.image.src }}" alt="{{ params.image.alt }}" class="tna-sensitive-image__image" />
|
8
|
+
</div>
|
9
|
+
</details>
|
10
10
|
</div>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Contributing" />
|
4
|
+
|
5
|
+
# Contributing to the frontend styles
|
6
|
+
|
7
|
+
## Adding a new component
|
8
|
+
|
9
|
+
1. Create a new directory in `src/nationalarchives/components`
|
10
|
+
1. Create an `_index.scss`, `fixtures.json`, `macro-options.json`, `macro.njk`, `template.njk` and a `[myComponent].stories.js` in the directory using other components as a guide
|
11
|
+
1. Add the component SCSS to src/nationalarchives/components/_all.scss
|
12
|
+
1. Update `tasks/test-package.js` to check for the files as part of the CI (`...componentFiles("myComponent", true)` where `true` ignores the check for any JavaScript files)
|
13
|
+
1. Set the macro in `macro.njk` to be `tnaMyComponent` where "MyComponent" is the name of your component
|
14
|
+
|
15
|
+
### Files
|
16
|
+
|
17
|
+
- `_index.scss` - where you can add your [BEM](https://getbem.com/) SCSS styles for the component
|
18
|
+
- `fixtures.json` - these are snapshots of the rendered component's HTML in different scenarios which can be used by other implementations to test against
|
19
|
+
- `macro-options.json` - the options for the component which are rendered in the Design System as well as being copied in to the Storybook controls
|
20
|
+
- `macro.njk` - the Nunjucks macro easily allows us to include components in the prototype kit and other applications such as the Design System
|
21
|
+
- `template.njk` - this is the HTML for the component, written in [Nunjucks](https://mozilla.github.io/nunjucks/)
|
22
|
+
- `[myComponent].stories.js` - the stories that get rendered to Storybook
|
23
|
+
|
24
|
+
### If you need JavaScript
|
25
|
+
|
26
|
+
1. Create a `[myComponent].mjs` file in the component directory
|
27
|
+
1. Ensure the top level element in your component has the attribute `data-module="tna-my-component"`
|
28
|
+
1. Import and initialise your component as part of the `initAll` function in `src/nationalarchives/all.mjs`
|
29
|
+
1. Update the check in `tasks/test-package.js` to remove the `true` and enable checking of the JavaScript file (`...componentFiles("myComponent")`)
|
30
|
+
1. If your component uses JavaScript, ensure you add interaction tests using `@storybook/testing-library`
|
31
|
+
|
32
|
+
### Best practices
|
33
|
+
|
34
|
+
[TODO]
|
35
|
+
|
36
|
+
## Updating a component
|
37
|
+
|
38
|
+
[TODO]
|
@@ -15,3 +15,12 @@ import { Meta } from "@storybook/blocks";
|
|
15
15
|
1. Create a [new release on GitHub](https://github.com/nationalarchives/tna-frontend/releases/new) using the tag you just created
|
16
16
|
|
17
17
|
Once a release is created, the [publish pipeline](https://github.com/nationalarchives/tna-frontend/blob/main/.github/workflows/npm-publish.yml) will be triggered.
|
18
|
+
|
19
|
+
## Oops!
|
20
|
+
|
21
|
+
To delete a tag:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
git tag -d v0.1.0
|
25
|
+
git push --delete origin v0.1.0
|
26
|
+
```
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Technologies" />
|
4
|
+
|
5
|
+
# Technologies
|
6
|
+
|
7
|
+
## Storybook
|
8
|
+
|
9
|
+
Most widely supported open source frontend workshop for building UI components, constantly updated, also used by TDR
|
10
|
+
|
11
|
+
## ESNext JavaScript (not TypeScript)
|
12
|
+
|
13
|
+
JavaScript over TypeScript to allow in-project compilation and possible tree-shaking without extra libraries
|
14
|
+
|
15
|
+
## Babel
|
16
|
+
|
17
|
+
De facto JavaScript compiler and transpiler, allows us to use most up-to-date JavaScript for increased efficiency and cleaner source code
|
18
|
+
|
19
|
+
## SCSS
|
20
|
+
|
21
|
+
Most mature CSS preprocessor, used in other TNA projects, huge support
|
22
|
+
|
23
|
+
## BEM
|
24
|
+
|
25
|
+
Agreed CSS methodology within TNA
|
26
|
+
|
27
|
+
## Webpack
|
28
|
+
|
29
|
+
Already used in many TNA projects, most mature offering although arguably not the fastest - we could consider changing in the future
|
30
|
+
|
31
|
+
## Nunjucks
|
32
|
+
|
33
|
+
Used by GDS and made by Mozilla, Nunjucks is simple and expandable and allows us to use components in the GOV.UK prototype kit
|
34
|
+
|
35
|
+
## npm
|
36
|
+
|
37
|
+
Used by many TNA projects and provides highly available package repository, de facto standard for JavaScript packages
|
38
|
+
|
39
|
+
## GitHub actions
|
40
|
+
|
41
|
+
Free actions not relying on external services, used on some TNA projects but will allow us to have more of a CI/CD methodology
|
42
|
+
|
43
|
+
## Prettier
|
44
|
+
|
45
|
+
Opinionated code formatter for (S)CSS, JavaScript, JSON and other file types, intended to reduce bikeshedding
|
46
|
+
|
47
|
+
## ESLint
|
48
|
+
|
49
|
+
De facto linter for JavaScript to catch potential issues
|
50
|
+
|
51
|
+
## Stylelint
|
52
|
+
|
53
|
+
Most widely supported and mature (S)CSS linter
|
54
|
+
|
55
|
+
## Jest
|
56
|
+
|
57
|
+
Lightweight and fast testing library, support for Storybook, easy learning curve
|
58
|
+
|
59
|
+
## NVM
|
60
|
+
|
61
|
+
Ensures all developers can work on the same version of NodeJS, reduces differences between development environments
|
62
|
+
|
63
|
+
## Chromatic.com
|
64
|
+
|
65
|
+
Suggested by Storybook for visual regression testing
|
@@ -10,7 +10,7 @@ export default {
|
|
10
10
|
const UnorderedListTemplate = ({ items, plain }) =>
|
11
11
|
`<ul class="tna-ul${plain ? " tna-ul--plain" : ""}">${items.reduce(
|
12
12
|
(list, item) => `${list}<li>${item}</li>`,
|
13
|
-
""
|
13
|
+
"",
|
14
14
|
)}</ul>`;
|
15
15
|
export const UnorderedList = UnorderedListTemplate.bind({});
|
16
16
|
UnorderedList.args = {
|
@@ -25,7 +25,7 @@ UnorderedListPlain.args = {
|
|
25
25
|
const OrderedListTemplate = ({ items, plain }) =>
|
26
26
|
`<ol class="tna-ol${plain ? " tna-ol--plain" : ""}">${items.reduce(
|
27
27
|
(list, item) => `${list}<li>${item}</li>`,
|
28
|
-
""
|
28
|
+
"",
|
29
29
|
)}</ol>`;
|
30
30
|
export const OrderedList = OrderedListTemplate.bind({});
|
31
31
|
OrderedList.args = {
|
@@ -10,11 +10,26 @@ import * as ListStories from './lists.stories';
|
|
10
10
|
|
11
11
|
We use a set of typefaces...
|
12
12
|
|
13
|
+
## Headings
|
14
|
+
|
13
15
|
<Canvas of={HeadingStories.Heading1} />
|
14
16
|
<Canvas of={HeadingStories.Heading2} />
|
15
17
|
<Canvas of={HeadingStories.Heading3} />
|
18
|
+
|
19
|
+
## Heading groups
|
20
|
+
|
21
|
+
Although visually identical, there are two types of header groups based on whether the group should be read as a single sentence or not.
|
22
|
+
|
23
|
+
In the first example, the heading will be read by screen readers as `The story of Alice Hawkins.`
|
24
|
+
|
16
25
|
<Canvas of={HeadingGroupStories.HeadingGroup} />
|
26
|
+
|
27
|
+
In the second example, the heading will be read as two separate sentences; `Record revealed. The Monteagle Letter.`
|
28
|
+
|
17
29
|
<Canvas of={HeadingGroupStories.HeadingGroupSeparated} />
|
30
|
+
|
31
|
+
## General typography
|
32
|
+
|
18
33
|
<Canvas of={TypographyStories.Paragraph} />
|
19
34
|
<Canvas of={ListStories.UnorderedList} />
|
20
35
|
<Canvas of={ListStories.UnorderedListPlain} />
|
@@ -1,63 +1,63 @@
|
|
1
|
-
{% from "
|
1
|
+
{% from "../components/card/macro.njk" import tnaCard %}
|
2
2
|
|
3
|
-
{% extends "
|
3
|
+
{% extends "./layouts/_prototype-kit.njk" %}
|
4
4
|
|
5
5
|
{% block pageTitle %}The National Archives | Welcome{% endblock %}
|
6
6
|
|
7
7
|
{% block content %}
|
8
8
|
<div class="tna-container">
|
9
9
|
<div class="tna-column tna-column--full">
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
<h1 class="tna-heading tna-heading--xl">
|
11
|
+
Welcome
|
12
|
+
</h1>
|
13
13
|
</div>
|
14
14
|
<div class="tna-column tna-column--full">
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
{{ tnaCard({
|
16
|
+
"heading": {
|
17
|
+
"supertitle": "Card supertitle",
|
18
|
+
"title": "Card title",
|
19
|
+
"level": 2,
|
20
|
+
"size": "m"
|
21
|
+
},
|
22
|
+
"href": "#",
|
23
|
+
"image": {
|
24
|
+
"src": "https://loremflickr.com/640/360",
|
25
|
+
"alt": "A placeholder image"
|
26
|
+
},
|
27
|
+
"body": "<p>Card body</p>",
|
28
|
+
"actions": [
|
29
|
+
{
|
30
|
+
"text": "Card action",
|
22
31
|
"href": "#",
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
{
|
30
|
-
"text": "Card action",
|
31
|
-
"href": "#",
|
32
|
-
"title": "Go and do the action"
|
33
|
-
}
|
34
|
-
],
|
35
|
-
"featured": true,
|
36
|
-
"htmlElement": "article"
|
37
|
-
}) }}
|
32
|
+
"title": "Go and do the action"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"featured": true,
|
36
|
+
"htmlElement": "article"
|
37
|
+
}) }}
|
38
38
|
</div>
|
39
39
|
{% for item in range(0, 6) -%}
|
40
40
|
<div class="tna-column tna-column--width-1-3 tna-column--width-1-2-medium tna-column--full-small tna-column--full-tiny">
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
{{ tnaCard({
|
42
|
+
"heading": {
|
43
|
+
"supertitle": "Card supertitle",
|
44
|
+
"title": "Card title",
|
45
|
+
"level": 3
|
46
|
+
},
|
47
|
+
"href": "#",
|
48
|
+
"image": {
|
49
|
+
"src": "https://loremflickr.com/640/360",
|
50
|
+
"alt": "A placeholder image"
|
51
|
+
},
|
52
|
+
"body": "<p>Card body</p>",
|
53
|
+
"actions": [
|
54
|
+
{
|
55
|
+
"text": "Card action",
|
47
56
|
"href": "#",
|
48
|
-
"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
"body": "<p>Card body</p>",
|
53
|
-
"actions": [
|
54
|
-
{
|
55
|
-
"text": "Card action",
|
56
|
-
"href": "#",
|
57
|
-
"title": "Go and do the action"
|
58
|
-
}
|
59
|
-
]
|
60
|
-
}) }}
|
57
|
+
"title": "Go and do the action"
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}) }}
|
61
61
|
</div>
|
62
62
|
{%- endfor %}
|
63
63
|
</div>
|
@@ -1,60 +1,57 @@
|
|
1
1
|
{# Based on https://github.com/alphagov/govuk-frontend/blob/8b6bf304b9fc891f64459c25a08f3d623f3fea72/packages/govuk-frontend/src/govuk/template.njk #}
|
2
2
|
{#% from "./components/skip-link/macro.njk" import tnaSkipLink -%#}
|
3
3
|
<!DOCTYPE html>
|
4
|
-
<html lang="{{ htmlLang | default('en') }}" class="tna-template {{ htmlClasses }}">
|
4
|
+
<html lang="{{ htmlLang | default('en') }}" class="tna-template tna-template--js-disabled {{ htmlClasses }}">
|
5
5
|
<head>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<meta property="og:image" content="{{ opengraphImageUrl | default(assetUrl + '/images/govuk-opengraph-image.png') }}">
|
30
|
-
{% endif %}
|
6
|
+
<meta charset="utf-8">
|
7
|
+
<title{% if pageTitleLang %} lang="{{ pageTitleLang }}"{% endif %}>{% block pageTitle %}The National Archives{% endblock %}</title>
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
9
|
+
<meta name="theme-color" content="{{ themeColor | default('#000000') }}">
|
10
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
11
|
+
|
12
|
+
{% block headIcons %}
|
13
|
+
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ assetPath | default('/assets') }}/images/favicon.ico" type="image/x-icon">
|
14
|
+
<link rel="mask-icon" href="{{ assetPath | default('/assets') }}/images/govuk-mask-icon.svg" color="{{ themeColor | default('#0b0c0c') }}"> {# Hardcoded value of $govuk-black #}
|
15
|
+
<link rel="apple-touch-icon" sizes="180x180" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-180x180.png">
|
16
|
+
<link rel="apple-touch-icon" sizes="167x167" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-167x167.png">
|
17
|
+
<link rel="apple-touch-icon" sizes="152x152" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-152x152.png">
|
18
|
+
<link rel="apple-touch-icon" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon.png">
|
19
|
+
{% endblock %}
|
20
|
+
|
21
|
+
{% block head %}{% endblock %}
|
22
|
+
|
23
|
+
{% block stylesheets %}{% endblock %}
|
24
|
+
|
25
|
+
{# OpenGraph images needs to be absolute, so we need either a URL for the image or for assetUrl to be set #}
|
26
|
+
{% if opengraphImageUrl or assetUrl %}
|
27
|
+
<meta property="og:image" content="{{ opengraphImageUrl | default(assetUrl + '/images/govuk-opengraph-image.png') }}">
|
28
|
+
{% endif %}
|
31
29
|
</head>
|
32
30
|
<body class="tna-template__body {{ bodyClasses }}" {%- for attribute, value in bodyAttributes %} {{attribute}}="{{value}}"{% endfor %}>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
{% block bodyEnd %}{% endblock %}
|
31
|
+
{% block bodyStart %}{% endblock %}
|
32
|
+
|
33
|
+
{% block skipLink %}
|
34
|
+
{#{ govukSkipLink({
|
35
|
+
href: '#main-content',
|
36
|
+
text: 'Skip to main content'
|
37
|
+
}) }#}
|
38
|
+
{% endblock %}
|
39
|
+
|
40
|
+
{% block header %}
|
41
|
+
<h1>HEADER</h1>
|
42
|
+
{% endblock %}
|
43
|
+
|
44
|
+
{% block main %}
|
45
|
+
{% block beforeContent %}{% endblock %}
|
46
|
+
<main class="tna-main-wrapper {{ mainClasses }}" id="main-content" role="main"{% if mainLang %} lang="{{ mainLang }}"{% endif %}>
|
47
|
+
{% block content %}{% endblock %}
|
48
|
+
</main>
|
49
|
+
{% endblock %}
|
50
|
+
|
51
|
+
{% block footer %}
|
52
|
+
<h1>FOOTER</h1>
|
53
|
+
{% endblock %}
|
54
|
+
|
55
|
+
{% block bodyEnd %}{% endblock %}
|
59
56
|
</body>
|
60
57
|
</html>
|