@nationalarchives/frontend 0.1.35 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENCE +1 -1
  2. package/README.md +0 -1
  3. package/nationalarchives/all.css +1 -13
  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 +9 -0
  8. package/nationalarchives/all.scss +0 -1
  9. package/nationalarchives/components/_index.scss +1 -0
  10. package/nationalarchives/components/breadcrumbs/breadcrumbs.css +1 -1
  11. package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
  12. package/nationalarchives/components/button/button.css +1 -1
  13. package/nationalarchives/components/button/button.css.map +1 -1
  14. package/nationalarchives/components/card/card.css +1 -1
  15. package/nationalarchives/components/card/card.css.map +1 -1
  16. package/nationalarchives/components/card/card.scss +0 -1
  17. package/nationalarchives/components/card/fixtures.json +1 -1
  18. package/nationalarchives/components/card/template.njk +3 -3
  19. package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
  20. package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
  21. package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
  22. package/nationalarchives/components/compound-filters/compound-filters.css +1 -1
  23. package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
  24. package/nationalarchives/components/cookie-banner/README.md +7 -1
  25. package/nationalarchives/components/cookie-banner/cookie-banner.css +1 -1
  26. package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
  27. package/nationalarchives/components/cookie-banner/cookie-banner.js +1 -1
  28. package/nationalarchives/components/cookie-banner/cookie-banner.js.map +1 -1
  29. package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +4 -0
  30. package/nationalarchives/components/date-input/date-input.css +1 -1
  31. package/nationalarchives/components/date-input/date-input.css.map +1 -1
  32. package/nationalarchives/components/date-search/date-search.css +1 -1
  33. package/nationalarchives/components/date-search/date-search.css.map +1 -1
  34. package/nationalarchives/components/featured-records/featured-records.css +1 -1
  35. package/nationalarchives/components/featured-records/featured-records.css.map +1 -1
  36. package/nationalarchives/components/filters/filters.css +1 -1
  37. package/nationalarchives/components/filters/filters.css.map +1 -1
  38. package/nationalarchives/components/filters/filters.scss +9 -9
  39. package/nationalarchives/components/footer/fixtures.json +2 -2
  40. package/nationalarchives/components/footer/footer.css +1 -1
  41. package/nationalarchives/components/footer/footer.css.map +1 -1
  42. package/nationalarchives/components/footer/template.njk +37 -37
  43. package/nationalarchives/components/gallery/gallery.css +1 -1
  44. package/nationalarchives/components/gallery/gallery.css.map +1 -1
  45. package/nationalarchives/components/global-header/README.md +52 -0
  46. package/nationalarchives/components/global-header/_index.scss +1 -0
  47. package/nationalarchives/components/global-header/fixtures.json +46 -0
  48. package/nationalarchives/components/global-header/global-header.css +1 -0
  49. package/nationalarchives/components/global-header/global-header.css.map +1 -0
  50. package/nationalarchives/components/global-header/global-header.js +2 -0
  51. package/nationalarchives/components/global-header/global-header.js.map +1 -0
  52. package/nationalarchives/components/global-header/global-header.mjs +146 -0
  53. package/nationalarchives/components/global-header/global-header.scss +366 -0
  54. package/nationalarchives/components/global-header/global-header.stories.js +351 -0
  55. package/nationalarchives/components/global-header/macro-options.json +104 -0
  56. package/nationalarchives/components/global-header/macro.njk +3 -0
  57. package/nationalarchives/components/global-header/template.njk +65 -0
  58. package/nationalarchives/components/grid/grid.css +1 -1
  59. package/nationalarchives/components/grid/grid.css.map +1 -1
  60. package/nationalarchives/components/header/fixtures.json +1 -1
  61. package/nationalarchives/components/header/header.css +1 -1
  62. package/nationalarchives/components/header/header.css.map +1 -1
  63. package/nationalarchives/components/header/header.scss +122 -146
  64. package/nationalarchives/components/header/header.stories.js +27 -30
  65. package/nationalarchives/components/header/template.njk +22 -19
  66. package/nationalarchives/components/hero/hero.css +1 -1
  67. package/nationalarchives/components/hero/hero.css.map +1 -1
  68. package/nationalarchives/components/hero/hero.scss +2 -12
  69. package/nationalarchives/components/index-grid/index-grid.css +1 -1
  70. package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
  71. package/nationalarchives/components/message/message.css +1 -1
  72. package/nationalarchives/components/message/message.css.map +1 -1
  73. package/nationalarchives/components/pagination/pagination.css +1 -1
  74. package/nationalarchives/components/pagination/pagination.css.map +1 -1
  75. package/nationalarchives/components/phase-banner/phase-banner.css +1 -1
  76. package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
  77. package/nationalarchives/components/phase-banner/phase-banner.scss +2 -4
  78. package/nationalarchives/components/picture/picture.css +1 -1
  79. package/nationalarchives/components/picture/picture.css.map +1 -1
  80. package/nationalarchives/components/picture/picture.scss +6 -6
  81. package/nationalarchives/components/radios/radios.css +1 -1
  82. package/nationalarchives/components/radios/radios.css.map +1 -1
  83. package/nationalarchives/components/radios/radios.scss +1 -1
  84. package/nationalarchives/components/search-field/fixtures.json +3 -3
  85. package/nationalarchives/components/search-field/search-field.css +1 -1
  86. package/nationalarchives/components/search-field/search-field.css.map +1 -1
  87. package/nationalarchives/components/search-field/search-field.scss +15 -10
  88. package/nationalarchives/components/search-field/template.njk +2 -2
  89. package/nationalarchives/components/select/select.css +1 -1
  90. package/nationalarchives/components/select/select.css.map +1 -1
  91. package/nationalarchives/components/sensitive-image/sensitive-image.css +1 -1
  92. package/nationalarchives/components/sensitive-image/sensitive-image.css.map +1 -1
  93. package/nationalarchives/components/skip-link/skip-link.css +1 -1
  94. package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
  95. package/nationalarchives/components/tabs/tabs.css +1 -1
  96. package/nationalarchives/components/tabs/tabs.css.map +1 -1
  97. package/nationalarchives/components/tabs/tabs.scss +2 -7
  98. package/nationalarchives/components/text-input/text-input.css +1 -1
  99. package/nationalarchives/components/text-input/text-input.css.map +1 -1
  100. package/nationalarchives/components/textarea/textarea.css +1 -1
  101. package/nationalarchives/components/textarea/textarea.css.map +1 -1
  102. package/nationalarchives/font-awesome.css +13 -0
  103. package/nationalarchives/font-awesome.css.map +1 -0
  104. package/nationalarchives/font-awesome.scss +6 -0
  105. package/nationalarchives/global-header-package.css +13 -0
  106. package/nationalarchives/global-header-package.css.map +1 -0
  107. package/nationalarchives/global-header-package.scss +9 -0
  108. package/nationalarchives/lib/cookies.mjs +2 -0
  109. package/nationalarchives/prototype-kit.css +1 -13
  110. package/nationalarchives/prototype-kit.css.map +1 -1
  111. package/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js +3 -3
  112. package/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +48 -23
  113. package/nationalarchives/stories/utilities/lists/lists.stories.js +5 -1
  114. package/nationalarchives/templates/layouts/_generic.njk +3 -2
  115. package/nationalarchives/tools/_colour.scss +33 -21
  116. package/nationalarchives/utilities/_colour.scss +3 -3
  117. package/nationalarchives/utilities/_forms.scss +0 -1
  118. package/nationalarchives/utilities/_lists.scss +0 -3
  119. package/nationalarchives/utilities/_typography.scss +23 -12
  120. package/nationalarchives/variables/_colour.scss +1 -2
  121. package/package.json +1 -1
  122. package/nationalarchives/lib/_font-awesome.scss +0 -6
  123. package/nationalarchives/lib/_index.scss +0 -1
@@ -0,0 +1,366 @@
1
+ @use "sass:math";
2
+ @use "../../variables/grid" as gridVars;
3
+ @use "../../tools/colour";
4
+ @use "../../tools/typography";
5
+ @use "../../tools/media";
6
+ @use "../../utilities";
7
+ @use "../grid";
8
+
9
+ .tna-global-header {
10
+ padding-top: 1rem;
11
+
12
+ @include colour.contrast;
13
+
14
+ .tna-template--light-theme & {
15
+ background: linear-gradient(
16
+ 0deg,
17
+ rgb(34 34 34 / 100%) 0%,
18
+ rgb(0 0 0 / 100%) 100%
19
+ );
20
+ }
21
+
22
+ .tna-template--system-theme {
23
+ @media (prefers-color-scheme: light) {
24
+ background: linear-gradient(
25
+ 0deg,
26
+ rgb(34 34 34 / 100%) 0%,
27
+ rgb(0 0 0 / 100%) 100%
28
+ );
29
+ }
30
+ }
31
+
32
+ &__main {
33
+ padding-bottom: 1.5rem;
34
+ }
35
+
36
+ &__logo-wrapper {
37
+ margin-top: 0.5rem;
38
+
39
+ display: flex;
40
+ }
41
+
42
+ &__logo {
43
+ display: flex;
44
+ gap: 1rem;
45
+ align-items: flex-end;
46
+
47
+ text-decoration: none;
48
+
49
+ &:hover {
50
+ text-decoration: none;
51
+
52
+ @include colour.colour-outline("font-dark", 0.3125rem, solid);
53
+ outline-offset: 1px;
54
+ }
55
+ }
56
+
57
+ .tna-logo {
58
+ width: 6.75rem;
59
+ height: 6.75rem;
60
+ }
61
+
62
+ &__logo-strapline {
63
+ padding-right: 0.625rem;
64
+
65
+ @include typography.heading-font;
66
+ @include typography.relative-font-size(20);
67
+ text-transform: uppercase;
68
+ line-height: math.div(6.75rem, 3);
69
+ }
70
+
71
+ &__navigation-button-wrapper {
72
+ display: none;
73
+ }
74
+
75
+ &__hamburger {
76
+ width: 2rem;
77
+ height: 0.25rem;
78
+
79
+ display: block;
80
+
81
+ @include colour.colour-background("font-dark");
82
+
83
+ &::before,
84
+ &::after {
85
+ height: 0.25rem;
86
+
87
+ display: block;
88
+
89
+ position: absolute;
90
+ right: 0;
91
+ left: 0;
92
+
93
+ background-color: inherit;
94
+
95
+ content: "";
96
+ }
97
+
98
+ &::before {
99
+ top: 0;
100
+ }
101
+
102
+ &::after {
103
+ bottom: 0;
104
+ }
105
+ }
106
+
107
+ &__navigation-button {
108
+ height: 2rem;
109
+ padding: 0;
110
+
111
+ display: block;
112
+
113
+ position: relative;
114
+
115
+ appearance: none;
116
+
117
+ font-size: 0;
118
+
119
+ background: none;
120
+
121
+ border: 0 transparent solid;
122
+ border-width: 0.25rem 0;
123
+
124
+ cursor: pointer;
125
+
126
+ &--opened {
127
+ .tna-global-header__hamburger {
128
+ height: 0;
129
+
130
+ &::before {
131
+ top: 0.625rem;
132
+
133
+ transform: rotate(-135deg);
134
+ }
135
+
136
+ &::after {
137
+ bottom: 0.625rem;
138
+
139
+ transform: rotate(135deg);
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ &__navigation {
146
+ margin: 0.5rem 0 0;
147
+ height: 100%;
148
+
149
+ position: relative;
150
+
151
+ columns: 2;
152
+ column-gap: 2rem;
153
+ list-style: none;
154
+ }
155
+
156
+ &__navigation-item {
157
+ break-inside: avoid;
158
+ }
159
+
160
+ &__navigation-item-link {
161
+ min-width: 15rem;
162
+ height: math.div(6.75rem, 3);
163
+
164
+ display: block;
165
+ box-sizing: border-box;
166
+
167
+ @include typography.relative-font-size(17);
168
+ text-decoration: none;
169
+ line-height: math.div(6.75rem, 3);
170
+
171
+ @include colour.colour-border("keyline", 0.5px, solid, bottom);
172
+
173
+ &:hover {
174
+ @include typography.interacted-text-decoration;
175
+ }
176
+ }
177
+
178
+ &__top-navigation {
179
+ padding: 0 0 0.5rem;
180
+
181
+ display: flex;
182
+ justify-content: flex-end;
183
+ gap: 1.5rem;
184
+
185
+ @include typography.relative-font-size(15);
186
+ list-style: none;
187
+ }
188
+
189
+ &__top-navigation-item {
190
+ }
191
+
192
+ &__top-navigation-link {
193
+ display: flex;
194
+ gap: 0.5rem;
195
+ align-items: center;
196
+
197
+ text-decoration: none;
198
+
199
+ &,
200
+ &:link,
201
+ &:visited {
202
+ @include colour.colour-font("font-light");
203
+ }
204
+
205
+ &:hover {
206
+ @include colour.colour-font("font-base");
207
+ @include typography.interacted-text-decoration;
208
+ }
209
+ }
210
+
211
+ @include media.on-medium {
212
+ &__navigation-item-link {
213
+ @include typography.relative-font-size(16);
214
+ }
215
+
216
+ &--collapse-on-medium &__navigation-wrapper {
217
+ width: 100%;
218
+ }
219
+
220
+ &--collapse-on-medium &__top-navigation-wrapper {
221
+ flex: 1;
222
+ order: 2;
223
+ }
224
+
225
+ &--collapse-on-medium &__main {
226
+ padding-bottom: 1rem;
227
+ }
228
+
229
+ &--collapse-on-medium &__logo {
230
+ gap: 0.75rem;
231
+ }
232
+
233
+ &--collapse-on-medium &__logo-wrapper {
234
+ margin-top: 0.5rem;
235
+ margin-bottom: 0.5rem;
236
+ }
237
+
238
+ &--collapse-on-medium .tna-logo {
239
+ width: 5rem;
240
+ height: 5rem;
241
+ }
242
+
243
+ &--collapse-on-medium &__logo-strapline {
244
+ line-height: math.div(5rem, 3);
245
+ }
246
+
247
+ &--collapse-on-medium &__navigation {
248
+ margin-bottom: 0.5rem;
249
+ }
250
+
251
+ &--collapse-on-medium &__navigation,
252
+ &--collapse-on-medium &__navigation-item,
253
+ &--collapse-on-medium &__navigation-item-link {
254
+ height: auto;
255
+ }
256
+ }
257
+
258
+ @include media.on-mobile {
259
+ &__main {
260
+ padding-bottom: 0;
261
+ }
262
+
263
+ &__logo-wrapper,
264
+ &__navigation-button-wrapper {
265
+ margin-top: 0;
266
+ margin-bottom: 1rem;
267
+ }
268
+
269
+ &__logo {
270
+ gap: 0.75rem;
271
+ }
272
+
273
+ &__navigation-button-wrapper {
274
+ display: flex;
275
+ align-items: center;
276
+ }
277
+
278
+ &__navigation,
279
+ &__navigation-item,
280
+ &__navigation-item-link {
281
+ height: auto;
282
+ }
283
+
284
+ &__navigation {
285
+ margin-top: 0;
286
+
287
+ columns: 1;
288
+
289
+ background-color: rgb(255 255 255 / 10%);
290
+
291
+ @include colour.colour-border("keyline-dark", 3px, solid, top);
292
+ @include colour.colour-border("keyline-dark", 3px, solid, bottom);
293
+ }
294
+
295
+ &__navigation-item {
296
+ flex-direction: column;
297
+ align-items: flex-start;
298
+ }
299
+
300
+ &__navigation-item-link {
301
+ line-height: 1.75rem;
302
+ }
303
+
304
+ &__navigation-item:last-child &__navigation-item-link {
305
+ border-bottom: none;
306
+ }
307
+
308
+ &__navigation-item-contents {
309
+ display: block;
310
+ }
311
+
312
+ &__navigation-item-children {
313
+ margin-bottom: 1rem;
314
+ margin-left: 1.5rem;
315
+ }
316
+
317
+ &__top-navigation {
318
+ padding-top: 1rem;
319
+ padding-bottom: 1rem;
320
+
321
+ justify-content: flex-start;
322
+ }
323
+ }
324
+
325
+ @include media.on-small {
326
+ .tna-logo {
327
+ width: 4rem;
328
+ height: 4rem;
329
+ }
330
+
331
+ &__logo-strapline {
332
+ line-height: 1.25rem;
333
+ }
334
+
335
+ &__navigation {
336
+ width: calc(100% + #{gridVars.$gutter-width * 2});
337
+
338
+ left: -#{gridVars.$gutter-width};
339
+ }
340
+
341
+ &__navigation-item-link {
342
+ padding: 0.5rem gridVars.$gutter-width;
343
+ }
344
+ }
345
+
346
+ @include media.on-tiny {
347
+ .tna-logo {
348
+ width: 3.5rem;
349
+ height: 3.5rem;
350
+ }
351
+
352
+ &__logo-strapline {
353
+ line-height: 1;
354
+ }
355
+
356
+ &__navigation {
357
+ width: calc(100% + #{gridVars.$gutter-width-tiny * 2});
358
+
359
+ left: -#{gridVars.$gutter-width-tiny};
360
+ }
361
+
362
+ &__navigation-item-link {
363
+ padding: 0.5rem gridVars.$gutter-width-tiny;
364
+ }
365
+ }
366
+ }
@@ -0,0 +1,351 @@
1
+ import Header from "./template.njk";
2
+ import macroOptions from "./macro-options.json";
3
+ import { within, userEvent, expect } from "@storybook/test";
4
+ import { customViewports } from "../../../../.storybook/viewports";
5
+
6
+ const argTypes = {
7
+ logo: { control: "object" },
8
+ topNavigation: { control: "object" },
9
+ navigation: { control: "object" },
10
+ collapseOnMedium: { control: "boolean" },
11
+ classes: { control: "text" },
12
+ attributes: { control: "object" },
13
+ };
14
+
15
+ Object.keys(argTypes).forEach((argType) => {
16
+ argTypes[argType].description = macroOptions.find(
17
+ (option) => option.name === argType,
18
+ )?.description;
19
+ });
20
+
21
+ export default {
22
+ title: "Components/Global header",
23
+ argTypes,
24
+ parameters: {
25
+ chromatic: { delay: 1000 },
26
+ },
27
+ };
28
+
29
+ const Template = ({
30
+ logo,
31
+ topNavigation,
32
+ navigation,
33
+ collapseOnMedium,
34
+ classes,
35
+ attributes,
36
+ }) =>
37
+ Header({
38
+ params: {
39
+ logo,
40
+ topNavigation,
41
+ navigation,
42
+ collapseOnMedium,
43
+ classes,
44
+ attributes,
45
+ },
46
+ });
47
+
48
+ export const Standard = Template.bind({});
49
+ Standard.args = {
50
+ logo: {
51
+ // strapline: "Design System",
52
+ href: "#/",
53
+ },
54
+ topNavigation: [
55
+ {
56
+ text: "Search",
57
+ href: "#/search",
58
+ icon: "search",
59
+ },
60
+ {
61
+ text: "Shop",
62
+ href: "#/shop",
63
+ icon: "bag-shopping",
64
+ },
65
+ {
66
+ text: "Sign in",
67
+ href: "#/sign-in",
68
+ icon: "user",
69
+ },
70
+ ],
71
+ navigation: [
72
+ {
73
+ text: "Visit",
74
+ href: "#/visit",
75
+ },
76
+ {
77
+ text: "What's on",
78
+ href: "#/whats-on",
79
+ },
80
+ {
81
+ text: "Explore the collection",
82
+ href: "#/explore-the-collection",
83
+ },
84
+ {
85
+ text: "Using the archives",
86
+ href: "#/using-the-archives",
87
+ },
88
+ {
89
+ text: "Learn",
90
+ href: "#/learn",
91
+ },
92
+ {
93
+ text: "Professional guidance & services",
94
+ href: "#/professional-guidance-and-services",
95
+ },
96
+ ],
97
+ classes: "tna-global-header--demo",
98
+ };
99
+ Standard.play = async ({ canvasElement }) => {
100
+ await new Promise((r) => setTimeout(r, 100));
101
+
102
+ const $navigationItems = canvasElement.querySelector(
103
+ `.tna-global-header__navigation`,
104
+ );
105
+ const $navigationToggle = canvasElement.querySelector(
106
+ `.tna-global-header__navigation-button`,
107
+ );
108
+
109
+ await expect($navigationItems).toBeVisible();
110
+ await expect($navigationToggle).not.toBeVisible();
111
+ };
112
+
113
+ export const Medium = Template.bind({});
114
+ Medium.parameters = {
115
+ viewport: {
116
+ defaultViewport: "medium",
117
+ },
118
+ chromatic: {
119
+ viewports: [customViewports["medium"].styles.width.replace(/px$/, "")],
120
+ },
121
+ };
122
+ Medium.args = {
123
+ logo: {
124
+ strapline: "Design System",
125
+ href: "#/",
126
+ },
127
+ topNavigation: [
128
+ {
129
+ text: "Search",
130
+ href: "#/search",
131
+ icon: "search",
132
+ },
133
+ {
134
+ text: "Shop",
135
+ href: "#/shop",
136
+ icon: "bag-shopping",
137
+ },
138
+ {
139
+ text: "Sign in",
140
+ href: "#/sign-in",
141
+ icon: "user",
142
+ },
143
+ ],
144
+ navigation: [
145
+ {
146
+ text: "Visit",
147
+ href: "#/visit",
148
+ },
149
+ {
150
+ text: "What's on",
151
+ href: "#/whats-on",
152
+ },
153
+ {
154
+ text: "Explore the collection",
155
+ href: "#/explore-the-collection",
156
+ },
157
+ {
158
+ text: "Using the archives",
159
+ href: "#/using-the-archives",
160
+ },
161
+ {
162
+ text: "Learn",
163
+ href: "#/learn",
164
+ },
165
+ {
166
+ text: "Professional guidance & services",
167
+ href: "#/professional-guidance-and-services",
168
+ },
169
+ ],
170
+ classes: "tna-global-header--demo",
171
+ };
172
+ Medium.play = async ({ canvasElement }) => {
173
+ await new Promise((r) => setTimeout(r, 100));
174
+
175
+ const $navigationItems = canvasElement.querySelector(
176
+ `.tna-global-header__navigation`,
177
+ );
178
+ const $navigationToggle = canvasElement.querySelector(
179
+ `.tna-global-header__navigation-button`,
180
+ );
181
+
182
+ await expect($navigationItems).toBeVisible();
183
+ await expect($navigationToggle).not.toBeVisible();
184
+ };
185
+
186
+ export const MediumCollapsed = Template.bind({});
187
+ MediumCollapsed.parameters = {
188
+ viewport: {
189
+ defaultViewport: "medium",
190
+ },
191
+ chromatic: {
192
+ viewports: [customViewports["medium"].styles.width.replace(/px$/, "")],
193
+ },
194
+ };
195
+ MediumCollapsed.args = {
196
+ logo: {
197
+ strapline: "Design System",
198
+ href: "#/",
199
+ },
200
+ topNavigation: [
201
+ {
202
+ text: "Search",
203
+ href: "#/search",
204
+ icon: "search",
205
+ },
206
+ {
207
+ text: "Shop",
208
+ href: "#/shop",
209
+ icon: "bag-shopping",
210
+ },
211
+ {
212
+ text: "Sign in",
213
+ href: "#/sign-in",
214
+ icon: "user",
215
+ },
216
+ ],
217
+ navigation: [
218
+ {
219
+ text: "Visit",
220
+ href: "#/visit",
221
+ },
222
+ {
223
+ text: "What's on",
224
+ href: "#/whats-on",
225
+ },
226
+ {
227
+ text: "Explore the collection",
228
+ href: "#/explore-the-collection",
229
+ },
230
+ {
231
+ text: "Using the archives",
232
+ href: "#/using-the-archives",
233
+ },
234
+ {
235
+ text: "Learn",
236
+ href: "#/learn",
237
+ },
238
+ {
239
+ text: "Professional guidance & services",
240
+ href: "#/professional-guidance-and-services",
241
+ },
242
+ ],
243
+ collapseOnMedium: true,
244
+ classes: "tna-global-header--demo",
245
+ };
246
+
247
+ export const Mobile = Template.bind({});
248
+ Mobile.parameters = {
249
+ viewport: {
250
+ defaultViewport: "small",
251
+ },
252
+ chromatic: {
253
+ viewports: [customViewports["small"].styles.width.replace(/px$/, "")],
254
+ },
255
+ };
256
+ Mobile.args = {
257
+ logo: {
258
+ strapline: "Design System",
259
+ href: "#/",
260
+ },
261
+ topNavigation: [
262
+ {
263
+ text: "Search",
264
+ href: "#/search",
265
+ icon: "search",
266
+ },
267
+ {
268
+ text: "Shop",
269
+ href: "#/shop",
270
+ icon: "bag-shopping",
271
+ },
272
+ {
273
+ text: "Sign in",
274
+ href: "#/sign-in",
275
+ icon: "user",
276
+ },
277
+ ],
278
+ navigation: [
279
+ {
280
+ text: "Visit",
281
+ href: "#/visit",
282
+ },
283
+ {
284
+ text: "What's on",
285
+ href: "#/whats-on",
286
+ },
287
+ {
288
+ text: "Explore the collection",
289
+ href: "#/explore-the-collection",
290
+ },
291
+ {
292
+ text: "Using the archives",
293
+ href: "#/using-the-archives",
294
+ },
295
+ {
296
+ text: "Learn",
297
+ href: "#/learn",
298
+ },
299
+ {
300
+ text: "Professional guidance & services",
301
+ href: "#/professional-guidance-and-services",
302
+ },
303
+ ],
304
+ classes: "tna-global-header--demo",
305
+ };
306
+ Mobile.play = async ({ args, canvasElement, step }) => {
307
+ await new Promise((r) => setTimeout(r, 100));
308
+
309
+ const canvas = within(canvasElement);
310
+
311
+ const $navigationItems = canvasElement.querySelector(
312
+ `.tna-global-header__navigation`,
313
+ );
314
+ const [$linkA, $linkB, $linkC] = args.navigation.map((navigationItem) =>
315
+ canvas.getByText(navigationItem.text),
316
+ );
317
+ const $navigationToggle = canvasElement.querySelector(
318
+ `.tna-global-header__navigation-button`,
319
+ );
320
+
321
+ await step("Initial load", async () => {
322
+ await expect($navigationItems).not.toBeVisible();
323
+ await expect($navigationToggle).toBeVisible();
324
+ await expect($navigationToggle).toHaveAttribute("aria-expanded", "false");
325
+ await expect($linkA).not.toBeVisible();
326
+ await expect($linkB).not.toBeVisible();
327
+ await expect($linkC).not.toBeVisible();
328
+ });
329
+
330
+ await step("Open the menu", async () => {
331
+ await userEvent.click($navigationToggle);
332
+ await expect($navigationItems).toBeVisible();
333
+ await expect($navigationToggle).toBeVisible();
334
+ await expect($navigationToggle).toHaveAttribute("aria-expanded", "true");
335
+ await expect($linkA).toBeVisible();
336
+ await expect($linkB).toBeVisible();
337
+ await expect($linkC).toBeVisible();
338
+ });
339
+
340
+ await step("Close the menu", async () => {
341
+ await userEvent.click($navigationToggle);
342
+ await expect($navigationItems).not.toBeVisible();
343
+ await expect($navigationToggle).toBeVisible();
344
+ await expect($navigationToggle).toHaveAttribute("aria-expanded", "false");
345
+ await expect($linkA).not.toBeVisible();
346
+ await expect($linkB).not.toBeVisible();
347
+ await expect($linkC).not.toBeVisible();
348
+ });
349
+
350
+ $navigationToggle.blur();
351
+ };