@nationalarchives/frontend 0.1.8-prerelease → 0.1.9-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/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 +18 -6
- package/nationalarchives/assets/images/tna-square-logo.svg +24 -45
- package/nationalarchives/components/_all.scss +1 -0
- package/nationalarchives/components/breadcrumbs/_index.scss +2 -2
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +76 -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 +3 -1
- package/nationalarchives/components/footer/fixtures.json +1 -1
- package/nationalarchives/components/footer/footer.stories.js +2 -2
- package/nationalarchives/components/footer/template.njk +51 -51
- package/nationalarchives/components/grid/_index.scss +3 -78
- package/nationalarchives/components/grid/fixtures.json +12 -12
- package/nationalarchives/components/grid/grid.stories.js +1 -1
- package/nationalarchives/components/grid/template.njk +35 -35
- package/nationalarchives/components/header/_index.scss +308 -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 +102 -0
- package/nationalarchives/components/header/header.stories.js +59 -0
- package/nationalarchives/components/header/macro-options.json +52 -0
- package/nationalarchives/components/header/macro.njk +3 -0
- package/nationalarchives/components/header/template.njk +54 -0
- package/nationalarchives/components/hero/_index.scss +1 -1
- package/nationalarchives/components/hero/hero.stories.js +2 -2
- package/nationalarchives/components/hero/macro-options.json +2 -2
- package/nationalarchives/components/hero/template.njk +27 -27
- 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 -2
- package/nationalarchives/components/sensitive-image/template.njk +7 -7
- package/nationalarchives/lib/uuid.mjs +9 -0
- package/nationalarchives/stories/development/publishing.mdx +9 -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/_grid.scss +52 -27
- package/nationalarchives/utilities/_global.scss +9 -2
- package/nationalarchives/utilities/_typography.scss +8 -0
- package/nationalarchives/variables/_colour.scss +11 -1
- package/package.json +4 -4
- package/nationalarchives/assets/images/tna-square-logo-inverted.svg +0 -47
@@ -0,0 +1,102 @@
|
|
1
|
+
import uuidv4 from "../../lib/uuid.mjs";
|
2
|
+
|
3
|
+
export class Header {
|
4
|
+
constructor($module) {
|
5
|
+
this.$module = $module;
|
6
|
+
this.$toggleButtonWrapper =
|
7
|
+
$module && $module.querySelector(".tna-header__navigation-toggle");
|
8
|
+
this.$navigation =
|
9
|
+
$module && $module.querySelector(".tna-header__navigation");
|
10
|
+
this.$links =
|
11
|
+
$module &&
|
12
|
+
this.$navigation &&
|
13
|
+
this.$navigation.querySelectorAll("[tabindex='0']");
|
14
|
+
this.menuOpened = false;
|
15
|
+
this.mql = window.matchMedia("(max-width: 768px)");
|
16
|
+
}
|
17
|
+
|
18
|
+
init() {
|
19
|
+
if (!this.$module || !this.$toggleButtonWrapper || !this.$navigation) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
|
23
|
+
// const uniqueLinkIds = []
|
24
|
+
|
25
|
+
// for (let i = 0; i < this.$links.length; i++) {
|
26
|
+
// const uniqueLinkId = uuidv4()
|
27
|
+
// this.$links[i].setAttribute("id", uniqueLinkId);
|
28
|
+
// uniqueLinkIds.push(uniqueLinkId)
|
29
|
+
// }
|
30
|
+
|
31
|
+
const uniqueId = `menu-content-${uuidv4()}`;
|
32
|
+
this.$navigation.setAttribute("id", uniqueId);
|
33
|
+
// this.$navigation.setAttribute("aria-owns", uniqueLinkIds.join(","));
|
34
|
+
|
35
|
+
this.$toggleButton = document.createElement("button");
|
36
|
+
this.$toggleButton.innerText = "Menu";
|
37
|
+
this.$toggleButton.setAttribute("aria-controls", uniqueId);
|
38
|
+
this.$toggleButton.setAttribute("aria-haspopup", "true");
|
39
|
+
this.$toggleButton.classList.add("tna-header__navigation-toggle-button");
|
40
|
+
|
41
|
+
this.$hamburger = document.createElement("div");
|
42
|
+
this.$hamburger.classList.add("tna-header__hamburger");
|
43
|
+
|
44
|
+
this.$toggleButton.appendChild(this.$hamburger);
|
45
|
+
this.$toggleButtonWrapper.appendChild(this.$toggleButton);
|
46
|
+
|
47
|
+
this.syncState();
|
48
|
+
|
49
|
+
this.$toggleButton.addEventListener("click", () =>
|
50
|
+
this.handleToggleNavigation(),
|
51
|
+
);
|
52
|
+
|
53
|
+
if ("addEventListener" in this.mql) {
|
54
|
+
this.mql.addEventListener("change", () => this.syncState());
|
55
|
+
// this.mql.addEventListener("change", this.syncState.bind(this));
|
56
|
+
} else {
|
57
|
+
this.mql.addListener(() => this.syncState());
|
58
|
+
// this.mql.addListener(this.syncState.bind(this));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
handleToggleNavigation() {
|
63
|
+
this.menuOpened = !this.menuOpened;
|
64
|
+
this.syncState();
|
65
|
+
}
|
66
|
+
|
67
|
+
syncState() {
|
68
|
+
if (this.mql.matches) {
|
69
|
+
if (this.menuOpened) {
|
70
|
+
this.$navigation.classList.add("tna-header__navigation--open");
|
71
|
+
this.$navigation.hidden = false;
|
72
|
+
this.$navigation.setAttribute("aria-hidden", "false");
|
73
|
+
this.$toggleButton.setAttribute("aria-expanded", "true");
|
74
|
+
this.$toggleButton.setAttribute("title", "Close menu");
|
75
|
+
|
76
|
+
for (let i = 0; i < this.$links.length; i++) {
|
77
|
+
this.$links[i].setAttribute("tabindex", "0");
|
78
|
+
}
|
79
|
+
} else {
|
80
|
+
this.$navigation.classList.remove("tna-header__navigation--open");
|
81
|
+
this.$navigation.hidden = true;
|
82
|
+
this.$navigation.setAttribute("aria-hidden", "true");
|
83
|
+
this.$toggleButton.setAttribute("aria-expanded", "false");
|
84
|
+
this.$toggleButton.setAttribute("title", "Open menu");
|
85
|
+
|
86
|
+
for (let i = 0; i < this.$links.length; i++) {
|
87
|
+
this.$links[i].setAttribute("tabindex", "-1");
|
88
|
+
}
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
this.$navigation.classList.add("tna-header__navigation--open");
|
92
|
+
this.$navigation.hidden = false;
|
93
|
+
this.$navigation.setAttribute("aria-hidden", "false");
|
94
|
+
this.$toggleButton.setAttribute("aria-expanded", "true");
|
95
|
+
this.$toggleButton.setAttribute("title", "Close menu");
|
96
|
+
|
97
|
+
for (let i = 0; i < this.$links.length; i++) {
|
98
|
+
this.$links[i].setAttribute("tabindex", "0");
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import Header from "./template.njk";
|
2
|
+
import "./_index.scss";
|
3
|
+
import macroOptions from "./macro-options.json";
|
4
|
+
|
5
|
+
const argTypes = {
|
6
|
+
strapline: { control: "text" },
|
7
|
+
navigation: { control: "object" },
|
8
|
+
colour: {
|
9
|
+
control: "radio",
|
10
|
+
options: ["black", "yellow", "pink", "orange", "green", "blue"],
|
11
|
+
},
|
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: "Components/Header",
|
24
|
+
argTypes,
|
25
|
+
};
|
26
|
+
|
27
|
+
const Template = ({ strapline, navigation, colour, classes, attributes }) => {
|
28
|
+
return Header({
|
29
|
+
params: {
|
30
|
+
strapline,
|
31
|
+
navigation,
|
32
|
+
colour,
|
33
|
+
classes,
|
34
|
+
attributes,
|
35
|
+
},
|
36
|
+
});
|
37
|
+
};
|
38
|
+
|
39
|
+
export const Standard = Template.bind({});
|
40
|
+
Standard.args = {
|
41
|
+
strapline: "Beta",
|
42
|
+
navigation: [
|
43
|
+
{
|
44
|
+
text: "Alpha",
|
45
|
+
href: "#/alpha",
|
46
|
+
selected: true,
|
47
|
+
},
|
48
|
+
{
|
49
|
+
text: "Beta",
|
50
|
+
href: "#/beta",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
text: "Gamma",
|
54
|
+
href: "#/gamma",
|
55
|
+
},
|
56
|
+
],
|
57
|
+
colour: "yellow",
|
58
|
+
classes: "tna-header--demo",
|
59
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "strapline",
|
4
|
+
"type": "string",
|
5
|
+
"required": false,
|
6
|
+
"description": ""
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "navigation",
|
10
|
+
"type": "array",
|
11
|
+
"required": false,
|
12
|
+
"description": "",
|
13
|
+
"params": [
|
14
|
+
{
|
15
|
+
"name": "text",
|
16
|
+
"type": "string",
|
17
|
+
"required": true,
|
18
|
+
"description": ""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "href",
|
22
|
+
"type": "string",
|
23
|
+
"required": true,
|
24
|
+
"description": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "title",
|
28
|
+
"type": "string",
|
29
|
+
"required": false,
|
30
|
+
"description": ""
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"name": "selected",
|
34
|
+
"type": "boolean",
|
35
|
+
"required": false,
|
36
|
+
"description": ""
|
37
|
+
}
|
38
|
+
]
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"name": "classes",
|
42
|
+
"type": "string",
|
43
|
+
"required": false,
|
44
|
+
"description": "Classes to add to the hero."
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"name": "attributes",
|
48
|
+
"type": "object",
|
49
|
+
"required": false,
|
50
|
+
"description": "HTML attributes (for example data attributes) to add to the hero."
|
51
|
+
}
|
52
|
+
]
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{%- set classes = [params.classes] if params.classes else [] -%}
|
2
|
+
{%- if params.colour -%}
|
3
|
+
{%- set classes = classes.concat('tna-header--' + params.colour) -%}
|
4
|
+
{%- endif -%}
|
5
|
+
<header class="tna-header {{ classes | join(' ') }}" data-module="tna-header" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
6
|
+
<div class="tna-container tna-header__contents">
|
7
|
+
<div class="tna-column tna-header__logo">
|
8
|
+
<a href="#" class="tna-header__logo-link">
|
9
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="0 0 160 160" style="enable-background:new 0 0 160 160;" xml:space="preserve" class="tna-logo">
|
10
|
+
<rect class="tna-logo__background" fill="none" width="160" height="160"/>
|
11
|
+
<g class="tna-logo__foreground" fill="#000">
|
12
|
+
<path d="M1.9,107.2h156.3V158H1.9V107.2z M1.9,54.5h79.1h77.2v50.8H1.9V54.5z M1.9,1.9h77.2v50.8H1.9V1.9z M80.9,1.9 h77.2v50.8H80.9C80.9,52.7,80.9,1.9,80.9,1.9z M80.9,0H0v52.7v1.9v50.8v1.9v52.7h160v-52.7v-1.9V52.7V0H80.9z"/>
|
13
|
+
<polygon points="21.3,19.5 15.9,19.5 15.9,16.5 30.2,16.5 30.2,19.5 24.8,19.5 24.8,37.9 21.3,37.9 "/>
|
14
|
+
<polygon points="31.6,16.5 35,16.5 35,25.5 43.4,25.5 43.4,16.5 46.8,16.5 46.8,37.9 43.4,37.9 43.4,28.6 35,28.6 35,37.9 31.6,37.9 "/>
|
15
|
+
<polygon points="50.9,16.5 63.1,16.5 63.1,19.5 54.3,19.5 54.3,25.6 61.7,25.6 61.7,28.6 54.3,28.6 54.3,34.9 63.1,34.9 63.1,37.9 50.9,37.9 "/>
|
16
|
+
<path d="M19.7,69.2h3.8l6.4,12.5c0.6,1.1,1.1,2.7,1.6,4h0.2c-0.2-1.7-0.3-3.6-0.3-4.8V69.2h3.5v21.4h-3.7l-6.3-12.3c-0.7-1.4-1.2-2.7-1.7-4.2h-0.2c0.2,1.4,0.3,3.3,0.3,5v11.5h-3.5C19.7,90.6,19.7,69.2,19.7,69.2z"/>
|
17
|
+
<path d="M47.8,82.6l-1.7-6.3c-0.3-1.1-0.6-2.2-0.9-3.8H45c-0.3,1.6-0.5,2.6-0.8,3.8l-1.7,6.3H47.8z M43,69.2h4.2l6.2,21.4h-3.5l-1.5-5.2h-6.6l-1.4,5.2h-3.6L43,69.2z"/>
|
18
|
+
<polygon points="57.2,72.3 51.8,72.3 51.8,69.2 66,69.2 66,72.3 60.6,72.3 60.6,90.7 57.2,90.7 "/>
|
19
|
+
<rect x="67.8" y="69.2" width="3.5" height="21.4"/>
|
20
|
+
<path d="M87.5,80c0-5.3-1.7-8-4.8-8c-3.2,0-4.8,2.7-4.8,8c0,5.2,1.6,7.9,4.8,7.9C85.9,87.9,87.5,85.2,87.5,80 M74.2,80c0-7,3-11.1,8.5-11.1c5.4,0,8.4,4.1,8.4,11.1c0,6.9-3,11-8.4,11C77.3,91,74.2,86.9,74.2,80"/>
|
21
|
+
<path d="M94.3,69.2H98l6.4,12.5c0.6,1.1,1.2,2.7,1.7,4h0.2c-0.2-1.7-0.3-3.6-0.3-4.8V69.2h3.4v21.4h-3.7l-6.3-12.3c-0.7-1.4-1.2-2.7-1.7-4.2h-0.2c0.2,1.4,0.3,3.3,0.3,5v11.5h-3.5V69.2z"/>
|
22
|
+
<path d="M122.4,82.6l-1.7-6.3c-0.3-1.1-0.6-2.2-0.9-3.8h-0.2c-0.3,1.6-0.5,2.6-0.8,3.8l-1.7,6.3H122.4z M117.6,69.2h4.2l6.2,21.4h-3.5l-1.5-5.2h-6.6l-1.4,5.2h-3.6L117.6,69.2z"/>
|
23
|
+
<polygon points="129.9,69.2 133.4,69.2 133.4,87.6 141.8,87.6 141.8,90.7 129.9,90.7 "/>
|
24
|
+
<path d="M26.9,135.2l-1.7-6.3c-0.3-1.1-0.6-2.2-0.9-3.8h-0.2c-0.3,1.6-0.5,2.6-0.8,3.8l-1.7,6.3H26.9z M22.1,121.8h4.2l6.2,21.4H29l-1.5-5.2h-6.6l-1.4,5.2h-3.6L22.1,121.8z"/>
|
25
|
+
<path d="M39.9,132.5c2.5,0,3.4-1.6,3.4-3.9c0-2.2-1-3.8-3.4-3.8h-2.7v7.7H39.9z M33.8,121.8h6.4c4.5,0,6.7,2.4,6.7,6.6c0,3.1-1.5,5.6-3.7,6.3v0.2c1,1.1,4,7.5,4.8,7.9v0.5h-3.8c-1-0.6-3.6-7.2-4.4-7.8h-2.5v7.8h-3.5L33.8,121.8L33.8,121.8z"/>
|
26
|
+
<path d="M52.9,132.5c0,5.3,1.9,8,4.8,8c2.9,0,4-2,4-5.2l3.5,0.1c0,0.2,0.1,0.4,0.1,0.6c0,4.4-2.1,7.5-7.5,7.5c-5.2,0-8.5-3.9-8.5-11.1c0-7.1,3.3-11,8.5-11c6.4,0,7.5,4.6,7.5,7.2c0,0.3,0,0.7-0.1,0.9l-3.5,0.1c0-3.3-1.2-5.2-4-5.2C54.8,124.6,52.9,127.3,52.9,132.5"/>
|
27
|
+
<polygon points="68,121.8 71.5,121.8 71.5,130.9 79.8,130.9 79.8,121.8 83.3,121.8 83.3,143.3 79.8,143.3 79.8,133.9 71.5,133.9 71.5,143.3 68,143.3 "/>
|
28
|
+
<rect x="87.9" y="121.8" width="3.5" height="21.4"/>
|
29
|
+
<path d="M94.2,121.8h3.6l3.2,12.3c0.5,1.9,0.8,3.6,1.1,5.6h0.2c0.3-2,0.6-3.7,1.1-5.6l3.2-12.3h3.6l-6.1,21.4h-4.1L94.2,121.8z"/>
|
30
|
+
<polygon points="112.7,121.8 125,121.8 125,124.9 116.2,124.9 116.2,130.9 123.6,130.9 123.6,133.9 116.2,133.9 116.2,140.2 125,140.2 125,143.3 112.7,143.3 "/>
|
31
|
+
<path d="M130.4,136c0,0.2-0.1,0.5-0.1,0.8c0,1.9,0.8,3.7,3.4,3.7c2.1,0,3.3-1.2,3.3-2.9c0-1.6-0.7-2.4-2.2-3l-3.4-1.3c-2.4-0.9-4.2-2.4-4.2-5.7c0-3.5,2.3-6.1,6.6-6.1c5.5,0,6.4,3.6,6.4,5.9c0,0.3,0,0.7-0.1,1.1l-3.4,0.1c0-0.2,0.1-0.5,0.1-0.7c0-1.7-0.6-3.2-3-3.2c-2.1,0-3,1.2-3,2.8c0,1.7,0.9,2.5,2.2,2.9l3.5,1.3c2.6,1,4.3,2.6,4.3,5.8c0,3.6-2.4,6.1-7,6.1c-5.9,0-6.8-3.9-6.8-6.5c0-0.3,0-0.6,0.1-1L130.4,136z"/>
|
32
|
+
</g>
|
33
|
+
</svg>
|
34
|
+
{%- if params.strapline -%}
|
35
|
+
<span class="tna-header__logo-strapline">{{ params.strapline }}</span>
|
36
|
+
{%- endif -%}
|
37
|
+
</a>
|
38
|
+
</div>
|
39
|
+
{%- if params.navigation -%}
|
40
|
+
<div class="tna-column tna-column--flex-1- tna-header__navigation-toggle">
|
41
|
+
<!-- POPULATED BY JAVASCRIPT IF ENABLED -->
|
42
|
+
</div>
|
43
|
+
<nav class="tna-column tna-column--flex-1 tna-column--full-small tna-column--full-tiny tna-header__navigation" aria-label="Main site navigation">
|
44
|
+
<ul class="tna-header__navigation-items">
|
45
|
+
{%- for item in params.navigation -%}
|
46
|
+
<li class="tna-header__navigation-item">
|
47
|
+
<a href="{{ item.href }}" class="tna-header__navigation-item-link{%- if item.selected %} tna-header__navigation-item-link--selected{% endif %}" tabindex="0" {%- if item.selected %} aria-current="true"{% endif %} {%- if item.title %} title="{{ item.title }}"{% endif %}>{{ item.text }}</a>
|
48
|
+
</li>
|
49
|
+
{%- endfor -%}
|
50
|
+
</ul>
|
51
|
+
</nav>
|
52
|
+
{%- endif -%}
|
53
|
+
</div>
|
54
|
+
</header>
|
@@ -15,7 +15,7 @@ const argTypes = {
|
|
15
15
|
|
16
16
|
Object.keys(argTypes).forEach((argType) => {
|
17
17
|
argTypes[argType].description = macroOptions.find(
|
18
|
-
(option) => option.name === argType
|
18
|
+
(option) => option.name === argType,
|
19
19
|
)?.description;
|
20
20
|
});
|
21
21
|
|
@@ -54,7 +54,7 @@ Standard.play = async ({ args, canvasElement }) => {
|
|
54
54
|
const image = canvas.getByAltText(args.image.alt);
|
55
55
|
const title = canvas.getByText(args.heading);
|
56
56
|
const summary = canvasElement.querySelector(
|
57
|
-
".tna-hero__image-details-summary"
|
57
|
+
".tna-hero__image-details-summary",
|
58
58
|
);
|
59
59
|
const information = canvas.getByText(args.image.information);
|
60
60
|
|
@@ -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 hero."
|
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 hero."
|
57
57
|
}
|
58
58
|
]
|
@@ -1,32 +1,32 @@
|
|
1
1
|
{%- set classes = [params.classes] if params.classes else [] -%}
|
2
2
|
<header class="tna-hero {{ classes | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
</div>
|
29
|
-
</div>
|
3
|
+
<img src="{{ params.image.src }}" alt="{{ params.image.alt }}" class="tna-hero__image">
|
4
|
+
{%- if params.image.information -%}
|
5
|
+
<details class="tna-hero__image-details">
|
6
|
+
<summary class="tna-hero__image-details-summary">
|
7
|
+
<span class="tna-hero__image-details-summary-icon">I</span>nformation about this image
|
8
|
+
</summary>
|
9
|
+
<div class="tna-hero__image-information">
|
10
|
+
<p>{{ params.image.information }}</p>
|
11
|
+
</div>
|
12
|
+
</details>
|
13
|
+
{%- endif -%}
|
14
|
+
<div class="tna-container tna-hero__inner">
|
15
|
+
<div class="tna-column tna-column--width-2-3 tna-column--full-small tna-column--full-tiny tna-hero__content">
|
16
|
+
<div class="tna-hero__content-inner">
|
17
|
+
{%- if params.heading -%}
|
18
|
+
<h1 class="tna-heading tna-heading--xl tna-hero__heading">
|
19
|
+
{{ params.heading }}
|
20
|
+
</h1>
|
21
|
+
{%- endif -%}
|
22
|
+
<div class="tna-hero__body">
|
23
|
+
{%- if params.text -%}
|
24
|
+
<p>{{ params.text }}</p>
|
25
|
+
{%- elseif params.body -%}
|
26
|
+
{{ params.body | safe }}
|
27
|
+
{%- endif -%}
|
30
28
|
</div>
|
29
|
+
</div>
|
31
30
|
</div>
|
31
|
+
</div>
|
32
32
|
</header>
|
@@ -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
|
+
}
|
@@ -15,12 +15,12 @@ const argTypes = {
|
|
15
15
|
|
16
16
|
Object.keys(argTypes).forEach((argType) => {
|
17
17
|
argTypes[argType].description = macroOptions.find(
|
18
|
-
(option) => option.name === argType
|
18
|
+
(option) => option.name === argType,
|
19
19
|
)?.description;
|
20
20
|
});
|
21
21
|
|
22
22
|
export default {
|
23
|
-
title: "
|
23
|
+
title: "Experimental/Sensitive image",
|
24
24
|
argTypes,
|
25
25
|
};
|
26
26
|
|
@@ -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>
|
@@ -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
|
+
```
|
@@ -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} />
|