@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.
Files changed (94) hide show
  1. package/README.md +2 -2
  2. package/nationalarchives/_features.scss +1 -0
  3. package/nationalarchives/all.css +1 -1
  4. package/nationalarchives/all.css.map +1 -1
  5. package/nationalarchives/all.js +1 -1
  6. package/nationalarchives/all.js.map +1 -1
  7. package/nationalarchives/all.mjs +53 -6
  8. package/nationalarchives/assets/images/footer/facebook.svg +11 -0
  9. package/nationalarchives/assets/images/footer/flickr.svg +11 -0
  10. package/nationalarchives/assets/images/footer/instagram.svg +17 -0
  11. package/nationalarchives/assets/images/footer/rss.svg +13 -0
  12. package/nationalarchives/assets/images/footer/twitter.svg +14 -0
  13. package/nationalarchives/assets/images/footer/youtube.svg +12 -0
  14. package/nationalarchives/assets/images/tna-square-logo.svg +24 -45
  15. package/nationalarchives/components/_all.scss +4 -0
  16. package/nationalarchives/components/breadcrumbs/_index.scss +4 -3
  17. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +2 -3
  18. package/nationalarchives/components/breadcrumbs/fixtures.json +1 -1
  19. package/nationalarchives/components/breadcrumbs/macro-options.json +2 -2
  20. package/nationalarchives/components/breadcrumbs/template.njk +9 -9
  21. package/nationalarchives/components/button/_index.scss +25 -5
  22. package/nationalarchives/components/button/button.stories.js +2 -3
  23. package/nationalarchives/components/button/fixtures.json +5 -5
  24. package/nationalarchives/components/button/template.njk +3 -3
  25. package/nationalarchives/components/card/_index.scss +7 -3
  26. package/nationalarchives/components/card/card.stories.js +2 -3
  27. package/nationalarchives/components/card/fixtures.json +11 -11
  28. package/nationalarchives/components/card/template.njk +44 -44
  29. package/nationalarchives/components/filters/_index.scss +49 -0
  30. package/nationalarchives/components/filters/filters.stories.js +75 -0
  31. package/nationalarchives/components/filters/fixtures.json +4 -0
  32. package/nationalarchives/components/filters/macro-options.json +52 -0
  33. package/nationalarchives/components/filters/macro.njk +3 -0
  34. package/nationalarchives/components/filters/template.njk +8 -0
  35. package/nationalarchives/components/footer/_index.scss +49 -4
  36. package/nationalarchives/components/footer/fixtures.json +1 -1
  37. package/nationalarchives/components/footer/footer.stories.js +23 -26
  38. package/nationalarchives/components/footer/macro-options.json +12 -6
  39. package/nationalarchives/components/footer/template.njk +61 -51
  40. package/nationalarchives/components/grid/_index.scss +3 -78
  41. package/nationalarchives/components/grid/fixtures.json +12 -12
  42. package/nationalarchives/components/grid/grid.stories.js +3 -4
  43. package/nationalarchives/components/grid/template.njk +35 -35
  44. package/nationalarchives/components/header/_index.scss +452 -0
  45. package/nationalarchives/components/header/fixtures.json +4 -0
  46. package/nationalarchives/components/header/header.js +2 -0
  47. package/nationalarchives/components/header/header.js.map +1 -0
  48. package/nationalarchives/components/header/header.mjs +108 -0
  49. package/nationalarchives/components/header/header.stories.js +68 -0
  50. package/nationalarchives/components/header/macro-options.json +104 -0
  51. package/nationalarchives/components/header/macro.njk +3 -0
  52. package/nationalarchives/components/header/template.njk +66 -0
  53. package/nationalarchives/components/hero/_index.scss +4 -1
  54. package/nationalarchives/components/hero/hero.stories.js +17 -15
  55. package/nationalarchives/components/hero/macro-options.json +3 -3
  56. package/nationalarchives/components/hero/template.njk +27 -27
  57. package/nationalarchives/components/phase-banner/_index.scss +43 -0
  58. package/nationalarchives/components/phase-banner/fixtures.json +14 -0
  59. package/nationalarchives/components/phase-banner/macro-options.json +26 -0
  60. package/nationalarchives/components/phase-banner/macro.njk +3 -0
  61. package/nationalarchives/components/phase-banner/phase-banner.stories.js +38 -0
  62. package/nationalarchives/components/phase-banner/template.njk +16 -0
  63. package/nationalarchives/components/sensitive-image/fixtures.json +3 -3
  64. package/nationalarchives/components/sensitive-image/macro-options.json +2 -2
  65. package/nationalarchives/components/sensitive-image/sensitive-image.js +1 -1
  66. package/nationalarchives/components/sensitive-image/sensitive-image.js.map +1 -1
  67. package/nationalarchives/components/sensitive-image/sensitive-image.mjs +21 -22
  68. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +2 -3
  69. package/nationalarchives/components/sensitive-image/template.njk +7 -7
  70. package/nationalarchives/lib/uuid.mjs +9 -0
  71. package/nationalarchives/stories/development/contributing.mdx +38 -0
  72. package/nationalarchives/stories/development/dependencies.mdx +2 -0
  73. package/nationalarchives/stories/development/publishing.mdx +9 -0
  74. package/nationalarchives/stories/development/technologies.mdx +65 -0
  75. package/nationalarchives/stories/utilities/lists.stories.js +2 -2
  76. package/nationalarchives/stories/utilities/typography.mdx +15 -0
  77. package/nationalarchives/templates/homepage.njk +46 -46
  78. package/nationalarchives/templates/layouts/_generic.njk +49 -52
  79. package/nationalarchives/templates/layouts/_prototype-kit.njk +5 -0
  80. package/nationalarchives/templates/search-results.njk +31 -31
  81. package/nationalarchives/templates/topics.njk +33 -33
  82. package/nationalarchives/tools/_all.scss +1 -0
  83. package/nationalarchives/tools/_assets.scss +5 -0
  84. package/nationalarchives/tools/_grid.scss +52 -27
  85. package/nationalarchives/tools/_media.scss +12 -11
  86. package/nationalarchives/utilities/_global.scss +103 -3
  87. package/nationalarchives/utilities/_typography.scss +112 -92
  88. package/nationalarchives/variables/_all.scss +1 -0
  89. package/nationalarchives/variables/_assets.scss +1 -0
  90. package/nationalarchives/variables/_colour.scss +95 -1
  91. package/nationalarchives/variables/_media.scss +39 -11
  92. package/package.json +18 -16
  93. package/nationalarchives/assets/images/tna-square-logo-inverted.svg +0 -47
  94. package/nationalarchives/stories/development/structure.mdx +0 -7
@@ -0,0 +1,108 @@
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
+ this.$toggleButton.classList.add(
76
+ "tna-header__navigation-toggle-button--opened",
77
+ );
78
+
79
+ for (let i = 0; i < this.$links.length; i++) {
80
+ this.$links[i].setAttribute("tabindex", "0");
81
+ }
82
+ } else {
83
+ this.$navigation.classList.remove("tna-header__navigation--open");
84
+ this.$navigation.hidden = true;
85
+ this.$navigation.setAttribute("aria-hidden", "true");
86
+ this.$toggleButton.setAttribute("aria-expanded", "false");
87
+ this.$toggleButton.setAttribute("title", "Open menu");
88
+ this.$toggleButton.classList.remove(
89
+ "tna-header__navigation-toggle-button--opened",
90
+ );
91
+
92
+ for (let i = 0; i < this.$links.length; i++) {
93
+ this.$links[i].setAttribute("tabindex", "-1");
94
+ }
95
+ }
96
+ } else {
97
+ this.$navigation.classList.add("tna-header__navigation--open");
98
+ this.$navigation.hidden = false;
99
+ this.$navigation.setAttribute("aria-hidden", "false");
100
+ this.$toggleButton.setAttribute("aria-expanded", "true");
101
+ this.$toggleButton.setAttribute("title", "Close menu");
102
+
103
+ for (let i = 0; i < this.$links.length; i++) {
104
+ this.$links[i].setAttribute("tabindex", "0");
105
+ }
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,68 @@
1
+ import Header from "./template.njk";
2
+ import macroOptions from "./macro-options.json";
3
+
4
+ const argTypes = {
5
+ logo: { control: "object" },
6
+ navigation: { control: "object" },
7
+ colour: {
8
+ control: "radio",
9
+ options: ["black", "yellow", "pink", "orange", "green", "blue"],
10
+ },
11
+ exit: { control: "object" },
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 = ({ logo, navigation, colour, exit, classes, attributes }) => {
28
+ return Header({
29
+ params: {
30
+ logo,
31
+ navigation,
32
+ colour,
33
+ exit,
34
+ classes,
35
+ attributes,
36
+ },
37
+ });
38
+ };
39
+
40
+ export const Standard = Template.bind({});
41
+ Standard.args = {
42
+ logo: {
43
+ strapline: "Beta",
44
+ href: "#/",
45
+ },
46
+ navigation: [
47
+ {
48
+ text: "Alpha",
49
+ href: "#/alpha",
50
+ selected: true,
51
+ },
52
+ {
53
+ text: "Beta",
54
+ href: "#/beta",
55
+ },
56
+ {
57
+ text: "Gamma",
58
+ href: "#/gamma",
59
+ },
60
+ ],
61
+ colour: "yellow",
62
+ exit: {
63
+ text: "Go to the current National Archives website",
64
+ href: "#",
65
+ target: "_blank",
66
+ },
67
+ classes: "tna-header--demo",
68
+ };
@@ -0,0 +1,104 @@
1
+ [
2
+ {
3
+ "name": "logo",
4
+ "type": "object",
5
+ "required": false,
6
+ "description": "",
7
+ "params": [
8
+ {
9
+ "name": "href",
10
+ "type": "string",
11
+ "required": false,
12
+ "description": ""
13
+ },
14
+ {
15
+ "name": "title",
16
+ "type": "string",
17
+ "required": false,
18
+ "description": ""
19
+ },
20
+ {
21
+ "name": "strapline",
22
+ "type": "string",
23
+ "required": false,
24
+ "description": ""
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "name": "navigation",
30
+ "type": "array",
31
+ "required": false,
32
+ "description": "",
33
+ "params": [
34
+ {
35
+ "name": "text",
36
+ "type": "string",
37
+ "required": true,
38
+ "description": ""
39
+ },
40
+ {
41
+ "name": "href",
42
+ "type": "string",
43
+ "required": true,
44
+ "description": ""
45
+ },
46
+ {
47
+ "name": "title",
48
+ "type": "string",
49
+ "required": false,
50
+ "description": ""
51
+ },
52
+ {
53
+ "name": "selected",
54
+ "type": "boolean",
55
+ "required": false,
56
+ "description": ""
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "name": "colour",
62
+ "type": "string",
63
+ "required": false,
64
+ "description": ""
65
+ },
66
+ {
67
+ "name": "exit",
68
+ "type": "object",
69
+ "required": false,
70
+ "description": "",
71
+ "params": [
72
+ {
73
+ "name": "text",
74
+ "type": "string",
75
+ "required": true,
76
+ "description": ""
77
+ },
78
+ {
79
+ "name": "href",
80
+ "type": "string",
81
+ "required": true,
82
+ "description": ""
83
+ },
84
+ {
85
+ "name": "target",
86
+ "type": "string",
87
+ "required": false,
88
+ "description": ""
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "name": "classes",
94
+ "type": "string",
95
+ "required": false,
96
+ "description": "Classes to add to the header."
97
+ },
98
+ {
99
+ "name": "attributes",
100
+ "type": "object",
101
+ "required": false,
102
+ "description": "HTML attributes (for example data attributes) to add to the header."
103
+ }
104
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro tnaHeader(params) %}
2
+ {%- include "./template.njk" -%}
3
+ {% endmacro %}
@@ -0,0 +1,66 @@
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
+ {%- if params.exit -%}
7
+ <div class="tna-header__exit">
8
+ <div class="tna-container">
9
+ <div class="tna-column tna-column--full">
10
+ <a href="{{ params.exit.href }}" class="tna-header__exit-link"{%- if params.exit.target -%} target="{{ params.exit.target }}"{%- endif -%}>
11
+ {{ params.exit.text }}
12
+ {%- if params.exit.target == "_blank" -%}
13
+ <span class="tna-header__exit-link-icon"></span>
14
+ {%- endif -%}
15
+ </a>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ {%- endif -%}
20
+ <div class="tna-container tna-header__contents">
21
+ <div class="tna-column tna-header__logo">
22
+ <{%- if params.logo.href -%}a href="{{ params.logo.href }}" class="tna-header__logo-link tna-header__logo-link--href"{%- else -%}span class="tna-header__logo-link"{%- endif -%}>
23
+ <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" width="100" height="100">
24
+ <rect class="tna-logo__background" fill="none" width="160" height="160"/>
25
+ <g class="tna-logo__foreground" fill="#000">
26
+ <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"/>
27
+ <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 "/>
28
+ <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 "/>
29
+ <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 "/>
30
+ <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"/>
31
+ <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"/>
32
+ <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 "/>
33
+ <rect x="67.8" y="69.2" width="3.5" height="21.4"/>
34
+ <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"/>
35
+ <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"/>
36
+ <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"/>
37
+ <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 "/>
38
+ <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"/>
39
+ <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"/>
40
+ <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"/>
41
+ <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 "/>
42
+ <rect x="87.9" y="121.8" width="3.5" height="21.4"/>
43
+ <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"/>
44
+ <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 "/>
45
+ <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"/>
46
+ </g>
47
+ </svg>
48
+ {%- if params.logo.strapline -%}
49
+ <span class="tna-header__logo-strapline">{{ params.logo.strapline }}</span>
50
+ {%- endif -%}
51
+ </{%- if params.logo.href -%}a{%- else -%}span{%- endif -%}>
52
+ </div>
53
+ {%- if params.navigation -%}
54
+ <div class="tna-column tna-column--flex-1- tna-header__navigation-toggle"><!-- POPULATED BY JAVASCRIPT IF ENABLED --></div>
55
+ <nav class="tna-column tna-column--flex-1 tna-column--full-small tna-column--full-tiny tna-header__navigation" aria-label="Main site navigation">
56
+ <ul class="tna-header__navigation-items">
57
+ {%- for item in params.navigation -%}
58
+ <li class="tna-header__navigation-item">
59
+ <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>
60
+ </li>
61
+ {%- endfor -%}
62
+ </ul>
63
+ </nav>
64
+ {%- endif -%}
65
+ </div>
66
+ </header>
@@ -7,7 +7,7 @@
7
7
 
8
8
  display: -ms-flexbox;
9
9
  display: flex;
10
- align-items: end;
10
+ align-items: flex-end;
11
11
 
12
12
  position: relative;
13
13
 
@@ -96,6 +96,7 @@
96
96
  }
97
97
 
98
98
  &__body {
99
+ margin-top: 1.5rem;
99
100
  }
100
101
 
101
102
  @include media.on-mobile {
@@ -138,9 +139,11 @@
138
139
  }
139
140
 
140
141
  &__heading {
142
+ color: inherit;
141
143
  }
142
144
 
143
145
  &__body {
146
+ color: inherit;
144
147
  }
145
148
  }
146
149
 
@@ -1,5 +1,4 @@
1
1
  import Hero 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,7 +14,7 @@ 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
 
@@ -49,26 +48,29 @@ Standard.args = {
49
48
  classes: "tna-hero--demo",
50
49
  };
51
50
 
52
- Standard.play = async ({ args, canvasElement }) => {
51
+ Standard.play = async ({ args, canvasElement, step }) => {
53
52
  const canvas = within(canvasElement);
54
53
  const image = canvas.getByAltText(args.image.alt);
55
54
  const title = canvas.getByText(args.heading);
56
55
  const summary = canvasElement.querySelector(
57
- ".tna-hero__image-details-summary"
56
+ ".tna-hero__image-details-summary",
58
57
  );
59
58
  const information = canvas.getByText(args.image.information);
60
59
 
61
- await expect(image).toBeVisible();
62
- await expect(title).toBeVisible();
63
- await expect(summary).toBeVisible();
64
- await expect(information).not.toBeVisible();
60
+ await step("Initial load", async () => {
61
+ await expect(image).toBeVisible();
62
+ await expect(title).toBeVisible();
63
+ await expect(summary).toBeVisible();
64
+ await expect(information).not.toBeVisible();
65
+ });
65
66
 
66
- await userEvent.click(summary);
67
- await expect(image).toBeVisible();
68
- await expect(title).toBeVisible();
69
- await expect(summary).toBeVisible();
70
- await expect(information).toBeVisible();
67
+ await step("Open information", async () => {
68
+ await userEvent.click(summary);
69
+ await expect(information).toBeVisible();
70
+ });
71
71
 
72
- await userEvent.click(summary);
73
- await expect(information).not.toBeVisible();
72
+ await step("Close information", async () => {
73
+ await userEvent.click(summary);
74
+ await expect(information).not.toBeVisible();
75
+ });
74
76
  };
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "name": "heading",
4
4
  "type": "string",
5
- "required": false,
5
+ "required": true,
6
6
  "description": ""
7
7
  },
8
8
  {
@@ -47,12 +47,12 @@
47
47
  "name": "classes",
48
48
  "type": "string",
49
49
  "required": false,
50
- "description": "Classes to add to the card."
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 card."
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
- <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 -%}
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>
@@ -0,0 +1,43 @@
1
+ @use "../../tools/media";
2
+ @use "../../tools/typography";
3
+
4
+ .tna-phase-banner {
5
+ padding-top: 0.375rem;
6
+ padding-bottom: 0.375rem;
7
+
8
+ .tna-container {
9
+ align-items: center;
10
+ flex-wrap: nowrap;
11
+
12
+ // @include media.on-tiny {
13
+ // flex-wrap: wrap;
14
+ // }
15
+ }
16
+
17
+ &__phase {
18
+ margin: 0.25rem 0;
19
+ padding: 0 0.5rem;
20
+
21
+ display: block;
22
+
23
+ font-weight: 700;
24
+ text-transform: uppercase;
25
+ line-height: 1.5;
26
+
27
+ background-color: #fff;
28
+ }
29
+
30
+ &__message {
31
+ margin: 0.25rem 0;
32
+
33
+ // @include typography.relative-font-size(14);
34
+
35
+ a {
36
+ color: inherit;
37
+ }
38
+ }
39
+
40
+ &--beta {
41
+ background-color: #f9f7e2;
42
+ }
43
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "component": "phase-banner",
3
+ "fixtures": [
4
+ {
5
+ "name": "beta",
6
+ "options": {
7
+ "phase": "Beta",
8
+ "message": "This is a new service – <a href='#'>give us your feedback</a> to help improve it."
9
+ },
10
+ "html": "<div class=\"tna-phase-banner tna-phase-banner--beta\">\n <div class=\"tna-container\">\n <div class=\"tna-column\">\n <span class=\"tna-phase-banner__phase\">\n Beta\n </span>\n </div>\n <div class=\"tna-column\">\n <p class=\"tna-phase-banner__message\">\n This is a new service – <a href='#'>give us your feedback</a> to help improve it.\n </p>\n </div>\n </div>\n</div>",
11
+ "hidden": false
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "name": "phase",
4
+ "type": "string",
5
+ "required": true,
6
+ "description": ""
7
+ },
8
+ {
9
+ "name": "message",
10
+ "type": "string",
11
+ "required": true,
12
+ "description": ""
13
+ },
14
+ {
15
+ "name": "classes",
16
+ "type": "string",
17
+ "required": false,
18
+ "description": "Classes to add to the phase banner."
19
+ },
20
+ {
21
+ "name": "attributes",
22
+ "type": "object",
23
+ "required": false,
24
+ "description": "HTML attributes (for example data attributes) to add to the phase banner."
25
+ }
26
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro tnaPhaseBanner(params) %}
2
+ {%- include "./template.njk" -%}
3
+ {% endmacro %}
@@ -0,0 +1,38 @@
1
+ import PhaseBanner from "./template.njk";
2
+ import macroOptions from "./macro-options.json";
3
+
4
+ const argTypes = {
5
+ phase: { control: "text" },
6
+ message: { control: "text" },
7
+ classes: { control: "text" },
8
+ attributes: { control: "object" },
9
+ };
10
+
11
+ Object.keys(argTypes).forEach((argType) => {
12
+ argTypes[argType].description = macroOptions.find(
13
+ (option) => option.name === argType,
14
+ )?.description;
15
+ });
16
+
17
+ export default {
18
+ title: "Components/Phase banner",
19
+ argTypes,
20
+ };
21
+
22
+ const Template = ({ phase, message, classes, attributes }) => {
23
+ return PhaseBanner({
24
+ params: {
25
+ phase,
26
+ message,
27
+ classes,
28
+ attributes,
29
+ },
30
+ });
31
+ };
32
+
33
+ export const Standard = Template.bind({});
34
+ Standard.args = {
35
+ phase: "Beta",
36
+ message: `This is a new service – <a href="#">give us your feedback</a> to help improve it.`,
37
+ classes: "tna-phase-banner--demo",
38
+ };
@@ -0,0 +1,16 @@
1
+ {%- set classes = [params.classes] if params.classes else [] -%}
2
+ {%- set classes = classes.concat('tna-phase-banner--' + params.phase | lower) -%}
3
+ <div class="tna-phase-banner {{ classes | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
4
+ <div class="tna-container">
5
+ <div class="tna-column">
6
+ <span class="tna-phase-banner__phase">
7
+ {{ params.phase }}
8
+ </span>
9
+ </div>
10
+ <div class="tna-column">
11
+ <p class="tna-phase-banner__message">
12
+ {{ params.message | safe }}
13
+ </p>
14
+ </div>
15
+ </div>
16
+ </div>