@nationalarchives/frontend 0.1.64 → 0.2.0

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 (270) hide show
  1. package/config/.babelrc.json +19 -0
  2. package/config/.eslintrc.js +25 -0
  3. package/config/.htmlvalidate.json +17 -0
  4. package/config/stylelint.config.js +240 -0
  5. package/nationalarchives/all.css +1 -3
  6. package/nationalarchives/all.css.map +1 -1
  7. package/nationalarchives/all.js +1 -1
  8. package/nationalarchives/all.js.map +1 -1
  9. package/nationalarchives/all.mjs +34 -18
  10. package/nationalarchives/all.scss +0 -2
  11. package/nationalarchives/components/_forms.scss +9 -0
  12. package/nationalarchives/components/_index.scss +2 -34
  13. package/nationalarchives/components/_presentation.scss +23 -0
  14. package/nationalarchives/components/accordion/accordion.css +1 -1
  15. package/nationalarchives/components/accordion/accordion.css.map +1 -1
  16. package/nationalarchives/components/accordion/accordion.js +1 -1
  17. package/nationalarchives/components/accordion/accordion.js.map +1 -1
  18. package/nationalarchives/components/accordion/accordion.mjs +92 -24
  19. package/nationalarchives/components/accordion/accordion.scss +56 -18
  20. package/nationalarchives/components/accordion/fixtures.json +34 -7
  21. package/nationalarchives/components/accordion/macro-options.json +14 -2
  22. package/nationalarchives/components/accordion/template.njk +7 -5
  23. package/nationalarchives/components/breadcrumbs/breadcrumbs.css +1 -1
  24. package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
  25. package/nationalarchives/components/breadcrumbs/breadcrumbs.scss +0 -10
  26. package/nationalarchives/components/breadcrumbs/template.njk +1 -1
  27. package/nationalarchives/components/button/button.css +1 -1
  28. package/nationalarchives/components/button/button.css.map +1 -1
  29. package/nationalarchives/components/button/button.scss +32 -10
  30. package/nationalarchives/components/button/macro-options.json +6 -0
  31. package/nationalarchives/components/button/template.njk +3 -1
  32. package/nationalarchives/components/card/card.css +1 -1
  33. package/nationalarchives/components/card/card.css.map +1 -1
  34. package/nationalarchives/components/card/template.njk +5 -5
  35. package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
  36. package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
  37. package/nationalarchives/components/checkboxes/checkboxes.njk +1 -1
  38. package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
  39. package/nationalarchives/components/checkboxes/macro-options.json +6 -0
  40. package/nationalarchives/components/checkboxes/template.njk +1 -1
  41. package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
  42. package/nationalarchives/components/compound-filters/template.njk +1 -1
  43. package/nationalarchives/components/cookie-banner/cookie-banner.css +1 -1
  44. package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
  45. package/nationalarchives/components/cookie-banner/cookie-banner.scss +0 -2
  46. package/nationalarchives/components/cookie-banner/template.njk +1 -2
  47. package/nationalarchives/components/date-input/date-input.css +1 -1
  48. package/nationalarchives/components/date-input/date-input.css.map +1 -1
  49. package/nationalarchives/components/date-input/date-input.scss +2 -2
  50. package/nationalarchives/components/date-input/fixtures.json +5 -5
  51. package/nationalarchives/components/date-input/template.njk +2 -2
  52. package/nationalarchives/components/date-search/date-search.css +1 -1
  53. package/nationalarchives/components/date-search/date-search.css.map +1 -1
  54. package/nationalarchives/components/date-search/date-search.njk +2 -2
  55. package/nationalarchives/components/date-search/date-search.scss +2 -2
  56. package/nationalarchives/components/date-search/template.njk +1 -1
  57. package/nationalarchives/components/details/details.css.map +1 -1
  58. package/nationalarchives/components/details/template.njk +1 -1
  59. package/nationalarchives/components/error-summary/error-summary.css +1 -1
  60. package/nationalarchives/components/error-summary/error-summary.css.map +1 -1
  61. package/nationalarchives/components/error-summary/error-summary.js +1 -1
  62. package/nationalarchives/components/error-summary/error-summary.js.map +1 -1
  63. package/nationalarchives/components/error-summary/error-summary.mjs +1 -1
  64. package/nationalarchives/components/error-summary/error-summary.scss +3 -4
  65. package/nationalarchives/components/error-summary/template.njk +1 -1
  66. package/nationalarchives/components/files-list/_index.scss +1 -0
  67. package/nationalarchives/components/files-list/files-list.css +1 -0
  68. package/nationalarchives/components/files-list/files-list.css.map +1 -0
  69. package/nationalarchives/components/files-list/files-list.scss +80 -0
  70. package/nationalarchives/components/files-list/fixtures.json +71 -0
  71. package/nationalarchives/components/{sensitive-image → files-list}/macro-options.json +20 -20
  72. package/nationalarchives/components/files-list/macro.njk +3 -0
  73. package/nationalarchives/components/files-list/template.njk +33 -0
  74. package/nationalarchives/components/footer/footer.css +1 -1
  75. package/nationalarchives/components/footer/footer.css.map +1 -1
  76. package/nationalarchives/components/footer/footer.scss +0 -2
  77. package/nationalarchives/components/footer/macro-options.json +0 -6
  78. package/nationalarchives/components/footer/template.njk +1 -1
  79. package/nationalarchives/components/gallery/fixtures.json +35 -1
  80. package/nationalarchives/components/gallery/gallery.css +1 -1
  81. package/nationalarchives/components/gallery/gallery.css.map +1 -1
  82. package/nationalarchives/components/gallery/gallery.js +1 -1
  83. package/nationalarchives/components/gallery/gallery.js.map +1 -1
  84. package/nationalarchives/components/gallery/gallery.mjs +192 -53
  85. package/nationalarchives/components/gallery/gallery.scss +317 -56
  86. package/nationalarchives/components/gallery/macro-options.json +34 -49
  87. package/nationalarchives/components/gallery/template.njk +74 -33
  88. package/nationalarchives/components/global-header/global-header.css +1 -1
  89. package/nationalarchives/components/global-header/global-header.css.map +1 -1
  90. package/nationalarchives/components/global-header/global-header.scss +0 -2
  91. package/nationalarchives/components/global-header/template.njk +1 -1
  92. package/nationalarchives/components/header/header.css +1 -1
  93. package/nationalarchives/components/header/header.css.map +1 -1
  94. package/nationalarchives/components/header/header.scss +3 -5
  95. package/nationalarchives/components/header/template.njk +1 -1
  96. package/nationalarchives/components/hero/hero.css +1 -1
  97. package/nationalarchives/components/hero/hero.css.map +1 -1
  98. package/nationalarchives/components/hero/hero.scss +0 -24
  99. package/nationalarchives/components/hero/template.njk +1 -1
  100. package/nationalarchives/components/index-grid/index-grid.css +1 -1
  101. package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
  102. package/nationalarchives/components/index-grid/index-grid.scss +1 -1
  103. package/nationalarchives/components/index-grid/template.njk +3 -3
  104. package/nationalarchives/components/pagination/pagination.css +1 -1
  105. package/nationalarchives/components/pagination/pagination.css.map +1 -1
  106. package/nationalarchives/components/pagination/pagination.scss +1 -1
  107. package/nationalarchives/components/pagination/template.njk +1 -1
  108. package/nationalarchives/components/phase-banner/phase-banner.css +1 -1
  109. package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
  110. package/nationalarchives/components/phase-banner/phase-banner.scss +0 -2
  111. package/nationalarchives/components/phase-banner/template.njk +1 -1
  112. package/nationalarchives/components/picture/picture.css.map +1 -1
  113. package/nationalarchives/components/picture/picture.js +1 -1
  114. package/nationalarchives/components/picture/picture.js.map +1 -1
  115. package/nationalarchives/components/picture/picture.mjs +2 -2
  116. package/nationalarchives/components/picture/template.njk +1 -1
  117. package/nationalarchives/components/quick-filters/quick-filters.css +1 -1
  118. package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -1
  119. package/nationalarchives/components/quick-filters/template.njk +1 -1
  120. package/nationalarchives/components/radios/radios.css +1 -1
  121. package/nationalarchives/components/radios/radios.css.map +1 -1
  122. package/nationalarchives/components/radios/radios.njk +1 -1
  123. package/nationalarchives/components/radios/radios.scss +1 -1
  124. package/nationalarchives/components/radios/template.njk +1 -1
  125. package/nationalarchives/components/records-list/_index.scss +1 -0
  126. package/nationalarchives/components/records-list/fixtures.json +42 -0
  127. package/nationalarchives/components/records-list/macro.njk +3 -0
  128. package/nationalarchives/components/records-list/records-list.css +1 -0
  129. package/nationalarchives/components/records-list/records-list.css.map +1 -0
  130. package/nationalarchives/components/{featured-records/featured-records.scss → records-list/records-list.scss} +2 -2
  131. package/nationalarchives/components/records-list/template.njk +21 -0
  132. package/nationalarchives/components/search-field/search-field.css +1 -1
  133. package/nationalarchives/components/search-field/search-field.css.map +1 -1
  134. package/nationalarchives/components/search-field/search-field.scss +3 -2
  135. package/nationalarchives/components/search-field/template.njk +2 -2
  136. package/nationalarchives/components/select/select.css +1 -1
  137. package/nationalarchives/components/select/select.css.map +1 -1
  138. package/nationalarchives/components/select/select.scss +2 -2
  139. package/nationalarchives/components/select/template.njk +2 -2
  140. package/nationalarchives/components/sidebar/fixtures.json +18 -8
  141. package/nationalarchives/components/sidebar/macro-options.json +9 -2
  142. package/nationalarchives/components/sidebar/sidebar.css +1 -1
  143. package/nationalarchives/components/sidebar/sidebar.css.map +1 -1
  144. package/nationalarchives/components/sidebar/template.njk +12 -3
  145. package/nationalarchives/components/skip-link/skip-link.css +1 -1
  146. package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
  147. package/nationalarchives/components/skip-link/skip-link.scss +0 -2
  148. package/nationalarchives/components/skip-link/template.njk +1 -1
  149. package/nationalarchives/components/tabs/tabs.css +1 -1
  150. package/nationalarchives/components/tabs/tabs.css.map +1 -1
  151. package/nationalarchives/components/tabs/tabs.scss +0 -12
  152. package/nationalarchives/components/tabs/template.njk +1 -1
  153. package/nationalarchives/components/text-input/template.njk +1 -1
  154. package/nationalarchives/components/text-input/text-input.css +1 -1
  155. package/nationalarchives/components/text-input/text-input.css.map +1 -1
  156. package/nationalarchives/components/text-input/text-input.njk +2 -2
  157. package/nationalarchives/components/text-input/text-input.scss +2 -2
  158. package/nationalarchives/components/textarea/template.njk +2 -2
  159. package/nationalarchives/components/textarea/textarea.css +1 -1
  160. package/nationalarchives/components/textarea/textarea.css.map +1 -1
  161. package/nationalarchives/components/textarea/textarea.scss +2 -2
  162. package/nationalarchives/components/warning/template.njk +1 -1
  163. package/nationalarchives/components/warning/warning.css +1 -1
  164. package/nationalarchives/components/warning/warning.css.map +1 -1
  165. package/nationalarchives/components/warning/warning.scss +2 -0
  166. package/nationalarchives/global-header-package.css +1 -1
  167. package/nationalarchives/global-header-package.css.map +1 -1
  168. package/nationalarchives/global-header-package.scss +1 -1
  169. package/nationalarchives/print.css +6 -0
  170. package/nationalarchives/print.css.map +1 -0
  171. package/nationalarchives/print.scss +44 -0
  172. package/nationalarchives/prototype-kit.css +1 -3
  173. package/nationalarchives/prototype-kit.css.map +1 -1
  174. package/nationalarchives/templates/layouts/_generic.njk +6 -6
  175. package/nationalarchives/tools/_a11y.scss +4 -0
  176. package/nationalarchives/tools/_colour.scss +75 -79
  177. package/nationalarchives/tools/_media.scss +0 -10
  178. package/nationalarchives/utilities/_columns.scss +1 -1
  179. package/nationalarchives/utilities/_index.scss +1 -0
  180. package/nationalarchives/utilities/_reset.scss +2 -8
  181. package/nationalarchives/utilities/{_colour.scss → colour/_index.scss} +2 -2
  182. package/nationalarchives/utilities/{_forms.scss → forms/_index.scss} +6 -6
  183. package/nationalarchives/utilities/grid/macro.njk +3 -0
  184. package/nationalarchives/{components → utilities}/grid/template.njk +1 -1
  185. package/nationalarchives/utilities/{_lists.scss → lists/_index.scss} +16 -7
  186. package/nationalarchives/utilities/{_overrides.scss → overrides/_index.scss} +8 -2
  187. package/nationalarchives/utilities/{_tables.scss → tables/_index.scss} +5 -5
  188. package/nationalarchives/utilities/{_typography.scss → typography/_index.scss} +8 -5
  189. package/nationalarchives/variables/_colour.scss +12 -5
  190. package/package.json +1 -1
  191. package/nationalarchives/components/accordion/accordion.stories.js +0 -410
  192. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +0 -128
  193. package/nationalarchives/components/button/button-group.stories.js +0 -114
  194. package/nationalarchives/components/button/button.stories.js +0 -204
  195. package/nationalarchives/components/card/card.stories.js +0 -402
  196. package/nationalarchives/components/checkboxes/checkboxes.stories.js +0 -241
  197. package/nationalarchives/components/compound-filters/compound-filters.stories.js +0 -61
  198. package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +0 -250
  199. package/nationalarchives/components/date-input/date-input.stories.js +0 -119
  200. package/nationalarchives/components/date-search/date-search.stories.js +0 -124
  201. package/nationalarchives/components/details/details.stories.js +0 -33
  202. package/nationalarchives/components/error-summary/error-summary.stories.js +0 -59
  203. package/nationalarchives/components/featured-records/_index.scss +0 -1
  204. package/nationalarchives/components/featured-records/featured-records.css +0 -1
  205. package/nationalarchives/components/featured-records/featured-records.css.map +0 -1
  206. package/nationalarchives/components/featured-records/featured-records.stories.js +0 -50
  207. package/nationalarchives/components/featured-records/fixtures.json +0 -42
  208. package/nationalarchives/components/featured-records/macro.njk +0 -3
  209. package/nationalarchives/components/featured-records/template.njk +0 -21
  210. package/nationalarchives/components/footer/footer.stories.js +0 -241
  211. package/nationalarchives/components/gallery/gallery.stories.js +0 -74
  212. package/nationalarchives/components/global-header/global-header.stories.js +0 -364
  213. package/nationalarchives/components/grid/_index.scss +0 -1
  214. package/nationalarchives/components/grid/grid.css +0 -1
  215. package/nationalarchives/components/grid/grid.css.map +0 -1
  216. package/nationalarchives/components/grid/grid.stories.js +0 -279
  217. package/nationalarchives/components/grid/macro.njk +0 -3
  218. package/nationalarchives/components/header/header.stories.js +0 -239
  219. package/nationalarchives/components/hero/hero.stories.js +0 -326
  220. package/nationalarchives/components/index-grid/index-grid.stories.js +0 -128
  221. package/nationalarchives/components/pagination/pagination.stories.js +0 -532
  222. package/nationalarchives/components/phase-banner/phase-banner.stories.js +0 -39
  223. package/nationalarchives/components/picture/picture.stories.js +0 -75
  224. package/nationalarchives/components/quick-filters/quick-filters.stories.js +0 -76
  225. package/nationalarchives/components/radios/radios.stories.js +0 -244
  226. package/nationalarchives/components/search-field/search-field.stories.js +0 -88
  227. package/nationalarchives/components/search-filters/_index.scss +0 -1
  228. package/nationalarchives/components/search-filters/fixtures.json +0 -16
  229. package/nationalarchives/components/search-filters/macro-options.json +0 -39
  230. package/nationalarchives/components/search-filters/macro.njk +0 -3
  231. package/nationalarchives/components/search-filters/search-filters.css +0 -1
  232. package/nationalarchives/components/search-filters/search-filters.css.map +0 -1
  233. package/nationalarchives/components/search-filters/search-filters.js +0 -2
  234. package/nationalarchives/components/search-filters/search-filters.js.map +0 -1
  235. package/nationalarchives/components/search-filters/search-filters.mjs +0 -67
  236. package/nationalarchives/components/search-filters/search-filters.scss +0 -198
  237. package/nationalarchives/components/search-filters/search-filters.stories.js +0 -207
  238. package/nationalarchives/components/search-filters/template.njk +0 -108
  239. package/nationalarchives/components/select/select.stories.js +0 -197
  240. package/nationalarchives/components/sensitive-image/_index.scss +0 -1
  241. package/nationalarchives/components/sensitive-image/fixtures.json +0 -51
  242. package/nationalarchives/components/sensitive-image/macro.njk +0 -3
  243. package/nationalarchives/components/sensitive-image/sensitive-image.css +0 -1
  244. package/nationalarchives/components/sensitive-image/sensitive-image.css.map +0 -1
  245. package/nationalarchives/components/sensitive-image/sensitive-image.js +0 -2
  246. package/nationalarchives/components/sensitive-image/sensitive-image.js.map +0 -1
  247. package/nationalarchives/components/sensitive-image/sensitive-image.mjs +0 -23
  248. package/nationalarchives/components/sensitive-image/sensitive-image.scss +0 -85
  249. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +0 -86
  250. package/nationalarchives/components/sensitive-image/template.njk +0 -11
  251. package/nationalarchives/components/sidebar/sidebar.stories.js +0 -224
  252. package/nationalarchives/components/skip-link/skip-link.stories.js +0 -76
  253. package/nationalarchives/components/tabs/tabs.stories.js +0 -300
  254. package/nationalarchives/components/text-input/text-input.stories.js +0 -188
  255. package/nationalarchives/components/textarea/textarea.stories.js +0 -130
  256. package/nationalarchives/components/warning/warning.stories.js +0 -39
  257. package/nationalarchives/stories/intro.mdx +0 -13
  258. package/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js +0 -293
  259. package/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +0 -1535
  260. package/nationalarchives/stories/utilities/forms/forms.mdx +0 -117
  261. package/nationalarchives/stories/utilities/lists/lists.stories.js +0 -212
  262. package/nationalarchives/stories/utilities/overrides/overrides.stories.js +0 -42
  263. package/nationalarchives/stories/utilities/tables/tables.stories.js +0 -47
  264. package/nationalarchives/stories/utilities/typography/heading-groups.stories.js +0 -94
  265. package/nationalarchives/stories/utilities/typography/headings.stories.js +0 -33
  266. package/nationalarchives/stories/utilities/typography/typography.stories.js +0 -91
  267. package/nationalarchives/components/{featured-records → records-list}/macro-options.json +0 -0
  268. package/nationalarchives/{components/grid/grid.scss → utilities/grid/_index.scss} +3 -3
  269. /package/nationalarchives/{components → utilities}/grid/fixtures.json +0 -0
  270. /package/nationalarchives/{components → utilities}/grid/macro-options.json +0 -0
@@ -1,300 +0,0 @@
1
- import Tabs from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
- import { within, userEvent, expect } from "@storybook/test";
4
-
5
- const argTypes = {
6
- items: { control: "object" },
7
- sticky: { control: "boolean" },
8
- classes: { control: "text" },
9
- attributes: { control: "object" },
10
- };
11
-
12
- Object.keys(argTypes).forEach((argType) => {
13
- argTypes[argType].description = macroOptions.find(
14
- (option) => option.name === argType,
15
- )?.description;
16
- });
17
-
18
- export default {
19
- title: "Components/Tabs",
20
- argTypes,
21
- };
22
-
23
- const Template = ({ items, sticky, classes, attributes }) =>
24
- Tabs({
25
- params: {
26
- items,
27
- sticky,
28
- classes,
29
- attributes,
30
- },
31
- });
32
-
33
- export const Standard = Template.bind({});
34
- Standard.args = {
35
- items: [
36
- {
37
- id: "unique-id-a",
38
- title: "Alpha section",
39
- body: '<h2 class="tna-heading-l">Alpha title</h2><p>Lorem ipsum</p>',
40
- },
41
- {
42
- id: "unique-id-b",
43
- title: "Beta section",
44
- body: '<h2 class="tna-heading-l">Beta title</h2><p>Lorem ipsum</p>',
45
- },
46
- {
47
- id: "unique-id-c",
48
- title: "Gamma section",
49
- body: '<h2 class="tna-heading-l">Gamma title</h2><p>Lorem ipsum</p>',
50
- },
51
- ],
52
- classes: "tna-tabs--demo",
53
- };
54
-
55
- export const Test = Template.bind({});
56
- Test.parameters = {
57
- chromatic: { disableSnapshot: true },
58
- };
59
- Test.args = {
60
- items: [
61
- {
62
- id: "unique-id-a",
63
- title: "Alpha section",
64
- body: '<h2 class="tna-heading-l">Alpha title</h2><p>Lorem ipsum</p>',
65
- },
66
- {
67
- id: "unique-id-b",
68
- title: "Beta section",
69
- body: '<h2 class="tna-heading-l">Beta title</h2><p>Lorem ipsum</p>',
70
- },
71
- {
72
- id: "unique-id-c",
73
- title: "Gamma section",
74
- body: '<h2 class="tna-heading-l">Gamma title</h2><p>Lorem ipsum</p>',
75
- },
76
- ],
77
- classes: "tna-tabs--demo",
78
- };
79
- Test.play = async ({ args, canvasElement, step }) => {
80
- await new Promise((r) => setTimeout(r, 100));
81
-
82
- const canvas = within(canvasElement);
83
-
84
- const tablist = canvas.getByRole("tablist");
85
- const [buttonA, buttonB, buttonC] = args.items.map((item) =>
86
- canvas.getByText(item.title),
87
- );
88
- const [sectionA, sectionB, sectionC] = args.items.map((item) =>
89
- canvasElement.querySelector(`#${item.id}`),
90
- );
91
-
92
- const expectButtonToBeCurrent = async (button) => {
93
- await expect(button).toHaveAttribute("tabindex", "0");
94
- await expect(button).toHaveAttribute("aria-selected", "true");
95
- await expect(button).toHaveFocus();
96
- };
97
-
98
- const expectButtonNotToBeCurrent = async (button) => {
99
- await expect(button).toHaveAttribute("tabindex", "-1");
100
- await expect(button).toHaveAttribute("aria-selected", "false");
101
- };
102
-
103
- const expectSectionToBeCurrent = async (section) => {
104
- await expect(section).toBeVisible();
105
- await expect(section).toHaveAttribute("tabindex", "0");
106
- };
107
-
108
- const expectSectionNotToBeCurrent = async (section) => {
109
- await expect(section).not.toBeVisible();
110
- await expect(section).toHaveAttribute("tabindex", "-1");
111
- };
112
-
113
- const expectButtonAndSectionAToBeCurrent = async () => {
114
- await step("Test tab buttons", async () => {
115
- await expectButtonToBeCurrent(buttonA);
116
- await expectButtonNotToBeCurrent(buttonB);
117
- await expectButtonNotToBeCurrent(buttonC);
118
- });
119
-
120
- await step("Test tab sections", async () => {
121
- await expectSectionToBeCurrent(sectionA);
122
- await expectSectionNotToBeCurrent(sectionB);
123
- await expectSectionNotToBeCurrent(sectionC);
124
- });
125
- };
126
-
127
- const expectButtonAndSectionBToBeCurrent = async () => {
128
- await step("Test tab buttons", async () => {
129
- await expectButtonNotToBeCurrent(buttonA);
130
- await expectButtonToBeCurrent(buttonB);
131
- await expectButtonNotToBeCurrent(buttonC);
132
- });
133
-
134
- await step("Test tab sections", async () => {
135
- await expectSectionNotToBeCurrent(sectionA);
136
- await expectSectionToBeCurrent(sectionB);
137
- await expectSectionNotToBeCurrent(sectionC);
138
- });
139
- };
140
-
141
- const expectButtonAndSectionCToBeCurrent = async () => {
142
- await step("Test tab buttons", async () => {
143
- await expectButtonNotToBeCurrent(buttonA);
144
- await expectButtonNotToBeCurrent(buttonB);
145
- await expectButtonToBeCurrent(buttonC);
146
- });
147
-
148
- await step("Test tab sections", async () => {
149
- await expectSectionNotToBeCurrent(sectionA);
150
- await expectSectionNotToBeCurrent(sectionB);
151
- await expectSectionToBeCurrent(sectionC);
152
- });
153
- };
154
-
155
- await step("Initial load", async () => {
156
- await step("Test tablist", async () => {
157
- await expect(tablist).toBeDefined();
158
- await expect(tablist).toBeVisible();
159
- });
160
-
161
- await step("Test tab buttons", async () => {
162
- await step("First tab button", async () => {
163
- await expect(buttonA).toBeVisible();
164
- await expect(buttonA).toHaveAttribute("id", `${args.items[0].id}-tab`);
165
- await expect(buttonA).toHaveAttribute("role", "tab");
166
- await expect(buttonA).toHaveAttribute("tabindex", "0");
167
- await expect(buttonA).toHaveAttribute("aria-selected", "true");
168
- await expect(buttonA).toHaveAttribute(
169
- "aria-controls",
170
- args.items[0].id,
171
- );
172
- });
173
-
174
- await step("Second tab button", async () => {
175
- await expect(buttonB).toBeVisible();
176
- await expect(buttonB).toHaveAttribute("id", `${args.items[1].id}-tab`);
177
- await expect(buttonB).toHaveAttribute("role", "tab");
178
- await expect(buttonB).toHaveAttribute("tabindex", "-1");
179
- await expect(buttonB).toHaveAttribute("aria-selected", "false");
180
- await expect(buttonB).toHaveAttribute(
181
- "aria-controls",
182
- args.items[1].id,
183
- );
184
- });
185
-
186
- await step("Third tab button", async () => {
187
- await expect(buttonC).toBeVisible();
188
- await expect(buttonC).toHaveAttribute("id", `${args.items[2].id}-tab`);
189
- await expect(buttonC).toHaveAttribute("role", "tab");
190
- await expect(buttonC).toHaveAttribute("tabindex", "-1");
191
- await expect(buttonC).toHaveAttribute("aria-selected", "false");
192
- await expect(buttonC).toHaveAttribute(
193
- "aria-controls",
194
- args.items[2].id,
195
- );
196
- });
197
- });
198
-
199
- await step("Test tab sections", async () => {
200
- await expect(sectionA).toBeVisible();
201
- await expect(sectionA).toHaveAttribute("id", args.items[0].id);
202
- await expect(sectionA).toHaveAttribute("role", "tabpanel");
203
- await expect(sectionA).toHaveAttribute(
204
- "aria-labelledby",
205
- `${args.items[0].id}-tab`,
206
- );
207
- await expect(sectionA).toHaveAttribute("tabindex", "0");
208
-
209
- await expect(sectionB).not.toBeVisible();
210
- await expect(sectionB).toHaveAttribute("id", args.items[1].id);
211
- await expect(sectionB).toHaveAttribute("role", "tabpanel");
212
- await expect(sectionB).toHaveAttribute(
213
- "aria-labelledby",
214
- `${args.items[1].id}-tab`,
215
- );
216
- await expect(sectionB).toHaveAttribute("tabindex", "0");
217
-
218
- await expect(sectionC).not.toBeVisible();
219
- await expect(sectionC).toHaveAttribute("id", args.items[2].id);
220
- await expect(sectionC).toHaveAttribute("role", "tabpanel");
221
- await expect(sectionC).toHaveAttribute(
222
- "aria-labelledby",
223
- `${args.items[2].id}-tab`,
224
- );
225
- await expect(sectionC).toHaveAttribute("tabindex", "0");
226
- });
227
- });
228
-
229
- await userEvent.click(buttonA);
230
-
231
- await step("First tab (already selected)", async () => {
232
- await userEvent.click(buttonA);
233
- await expectButtonAndSectionAToBeCurrent();
234
- });
235
-
236
- await step("Second tab", async () => {
237
- await userEvent.click(buttonB);
238
- await expectButtonAndSectionBToBeCurrent();
239
- });
240
-
241
- await step("Third tab", async () => {
242
- await userEvent.click(buttonC);
243
- await expectButtonAndSectionCToBeCurrent();
244
- });
245
-
246
- await step("First tab", async () => {
247
- await userEvent.click(buttonA);
248
- await expectButtonAndSectionAToBeCurrent();
249
- });
250
-
251
- await step("Keyboard interaciton", async () => {
252
- await step("Left/right", async () => {
253
- await userEvent.click(buttonA);
254
- await expectButtonAndSectionAToBeCurrent();
255
-
256
- await userEvent.keyboard("[ArrowRight]");
257
- await expectButtonAndSectionBToBeCurrent();
258
-
259
- await userEvent.keyboard("[ArrowRight]");
260
- await expectButtonAndSectionCToBeCurrent();
261
-
262
- await userEvent.keyboard("[ArrowRight]");
263
- await expectButtonAndSectionAToBeCurrent();
264
-
265
- await userEvent.keyboard("[ArrowRight]");
266
- await expectButtonAndSectionBToBeCurrent();
267
-
268
- await userEvent.keyboard("[ArrowLeft]");
269
- await expectButtonAndSectionAToBeCurrent();
270
-
271
- await userEvent.keyboard("[ArrowLeft]");
272
- await expectButtonAndSectionCToBeCurrent();
273
-
274
- await userEvent.keyboard("[ArrowLeft]");
275
- await expectButtonAndSectionBToBeCurrent();
276
-
277
- await userEvent.keyboard("[ArrowLeft]");
278
- await expectButtonAndSectionAToBeCurrent();
279
- });
280
-
281
- await step("Home/end", async () => {
282
- await userEvent.click(buttonA);
283
- await expectButtonAndSectionAToBeCurrent();
284
-
285
- await userEvent.keyboard("[Home]");
286
- await expectButtonAndSectionAToBeCurrent();
287
-
288
- await userEvent.keyboard("[End]");
289
- await expectButtonAndSectionCToBeCurrent();
290
-
291
- await userEvent.keyboard("[End]");
292
- await expectButtonAndSectionCToBeCurrent();
293
-
294
- await userEvent.keyboard("[Home]");
295
- await expectButtonAndSectionAToBeCurrent();
296
- });
297
-
298
- buttonA.blur();
299
- });
300
- };
@@ -1,188 +0,0 @@
1
- import TextInput from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
-
4
- const argTypes = {
5
- label: { control: "text" },
6
- headingLevel: { control: { type: "number", min: 1, max: 6 } },
7
- headingSize: {
8
- control: "inline-radio",
9
- options: ["xs", "s", "m", "l", "xl"],
10
- },
11
- id: { control: "text" },
12
- name: { control: "text" },
13
- hint: { control: "text" },
14
- value: { control: "text" },
15
- error: { control: "object" },
16
- spellcheck: { control: "boolean" },
17
- inputmode: {
18
- control: "select",
19
- options: ["text", "decimal", "numeric", "tel", "search", "email", "url"],
20
- },
21
- autofill: {
22
- control: "select",
23
- options: [
24
- "name",
25
- "honorific-prefix",
26
- "given-name",
27
- "additional-name",
28
- "family-name",
29
- "honorific-suffix",
30
- "nickname",
31
- "username",
32
- "new-password",
33
- "current-password",
34
- "one-time-code",
35
- "organization-title",
36
- "organization",
37
- "street-address",
38
- "address-line1",
39
- "address-line2",
40
- "address-line3",
41
- "address-level4",
42
- "address-level3",
43
- "address-level2",
44
- "address-level1",
45
- "country",
46
- "country-name",
47
- "postal-code",
48
- "cc-name",
49
- "cc-given-name",
50
- "cc-additional-name",
51
- "cc-family-name",
52
- "cc-number",
53
- "cc-exp",
54
- "cc-exp-month",
55
- "cc-exp-year",
56
- "cc-csc",
57
- "cc-type",
58
- "transaction-currency",
59
- "transaction-amount",
60
- "language",
61
- "bday",
62
- "bday-day",
63
- "bday-month",
64
- "bday-year",
65
- "sex",
66
- "url",
67
- "photo",
68
- "email",
69
- ],
70
- },
71
- size: { control: "inline-radio", options: ["xs", "s", "m", "l", "xl"] },
72
- maxLength: { control: "number" },
73
- inline: { control: "boolean" },
74
- formGroupClasses: { control: "text" },
75
- formGroupAttributes: { control: "object" },
76
- classes: { control: "text" },
77
- attributes: { control: "object" },
78
- };
79
-
80
- Object.keys(argTypes).forEach((argType) => {
81
- argTypes[argType].description = macroOptions.find(
82
- (option) => option.name === argType,
83
- )?.description;
84
- });
85
-
86
- export default {
87
- title: "Components/Text input",
88
- argTypes,
89
- };
90
-
91
- const Template = ({
92
- label,
93
- headingLevel,
94
- headingSize,
95
- id,
96
- name,
97
- hint,
98
- value,
99
- error,
100
- spellcheck,
101
- inputmode,
102
- autofill,
103
- size,
104
- maxLength,
105
- inline,
106
- formGroupClasses,
107
- formGroupAttributes,
108
- classes,
109
- attributes,
110
- }) =>
111
- TextInput({
112
- params: {
113
- label,
114
- headingLevel,
115
- headingSize,
116
- id,
117
- name,
118
- hint,
119
- value,
120
- error,
121
- spellcheck,
122
- inputmode,
123
- autofill,
124
- size,
125
- maxLength,
126
- inline,
127
- formGroupClasses,
128
- formGroupAttributes,
129
- classes,
130
- attributes,
131
- },
132
- });
133
-
134
- export const Standard = Template.bind({});
135
- Standard.args = {
136
- label: "Enter your first name",
137
- headingLevel: 4,
138
- headingSize: "m",
139
- id: "firstname1",
140
- name: "firstname1",
141
- classes: "tna-text-input--demo",
142
- };
143
-
144
- export const Predefined = Template.bind({});
145
- Predefined.args = {
146
- label: "Edit your first name",
147
- headingLevel: 4,
148
- headingSize: "m",
149
- id: "firstname2",
150
- name: "firstname2",
151
- value: "John",
152
- classes: "tna-text-input--demo",
153
- };
154
-
155
- export const WithHint = Template.bind({});
156
- WithHint.args = {
157
- label: "Enter your first name",
158
- headingLevel: 4,
159
- headingSize: "m",
160
- id: "firstname3",
161
- name: "firstname3",
162
- hint: "What people call you by",
163
- classes: "tna-text-input--demo",
164
- };
165
-
166
- export const Error = Template.bind({});
167
- Error.args = {
168
- label: "Enter your first name",
169
- headingLevel: 4,
170
- headingSize: "m",
171
- id: "firstname4",
172
- name: "firstname4",
173
- error: {
174
- text: "Enter a name",
175
- },
176
- classes: "tna-text-input--demo",
177
- };
178
-
179
- export const Inline = Template.bind({});
180
- Inline.args = {
181
- label: "Enter your first name",
182
- headingLevel: 4,
183
- headingSize: "xs",
184
- id: "firstname5",
185
- name: "firstname5",
186
- inline: true,
187
- classes: "tna-text-input--demo",
188
- };
@@ -1,130 +0,0 @@
1
- import Textarea from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
-
4
- const argTypes = {
5
- label: { control: "text" },
6
- headingLevel: { control: { type: "number", min: 1, max: 6 } },
7
- headingSize: {
8
- control: "inline-radio",
9
- options: ["xs", "s", "m", "l", "xl"],
10
- },
11
- id: { control: "text" },
12
- name: { control: "text" },
13
- hint: { control: "text" },
14
- value: { control: "text" },
15
- error: { control: "object" },
16
- spellcheck: { control: "boolean" },
17
- size: { control: "inline-radio", options: ["m", "l", "xl"] },
18
- rows: { control: "number" },
19
- inline: { control: "boolean" },
20
- formGroupClasses: { control: "text" },
21
- formGroupAttributes: { control: "object" },
22
- classes: { control: "text" },
23
- attributes: { control: "object" },
24
- };
25
-
26
- Object.keys(argTypes).forEach((argType) => {
27
- argTypes[argType].description = macroOptions.find(
28
- (option) => option.name === argType,
29
- )?.description;
30
- });
31
-
32
- export default {
33
- title: "Components/Textarea",
34
- argTypes,
35
- };
36
-
37
- const Template = ({
38
- label,
39
- headingLevel,
40
- headingSize,
41
- id,
42
- name,
43
- hint,
44
- value,
45
- error,
46
- spellcheck,
47
- size,
48
- rows,
49
- inline,
50
- formGroupClasses,
51
- formGroupAttributes,
52
- classes,
53
- attributes,
54
- }) =>
55
- Textarea({
56
- params: {
57
- label,
58
- headingLevel,
59
- headingSize,
60
- id,
61
- name,
62
- hint,
63
- value,
64
- error,
65
- spellcheck,
66
- size,
67
- rows,
68
- inline,
69
- formGroupClasses,
70
- formGroupAttributes,
71
- classes,
72
- attributes,
73
- },
74
- });
75
-
76
- export const Standard = Template.bind({});
77
- Standard.args = {
78
- label: "Enter your feedback",
79
- headingLevel: 4,
80
- headingSize: "m",
81
- id: "feedback1",
82
- name: "feedback1",
83
- classes: "tna-textarea--demo",
84
- };
85
-
86
- export const Predefined = Template.bind({});
87
- Predefined.args = {
88
- label: "Edit your feedback",
89
- headingLevel: 4,
90
- headingSize: "m",
91
- id: "feedback2",
92
- name: "feedback2",
93
- value: "I like this 👍🏼",
94
- classes: "tna-textarea--demo",
95
- };
96
-
97
- export const WithHint = Template.bind({});
98
- WithHint.args = {
99
- label: "Enter your feedback",
100
- headingLevel: 4,
101
- headingSize: "m",
102
- id: "feedback3",
103
- name: "feedback3",
104
- hint: "What did you think?",
105
- classes: "tna-textarea--demo",
106
- };
107
-
108
- export const Error = Template.bind({});
109
- Error.args = {
110
- label: "Enter your feedback",
111
- headingLevel: 4,
112
- headingSize: "m",
113
- id: "feedback4",
114
- name: "feedback4",
115
- error: {
116
- text: "Enter some feedback",
117
- },
118
- classes: "tna-textarea--demo",
119
- };
120
-
121
- export const Inline = Template.bind({});
122
- Inline.args = {
123
- label: "Enter your feedback",
124
- headingLevel: 4,
125
- headingSize: "xs",
126
- id: "feedback5",
127
- name: "feedback5",
128
- inline: true,
129
- classes: "tna-textarea--demo",
130
- };
@@ -1,39 +0,0 @@
1
- import Warning from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
-
4
- const argTypes = {
5
- heading: { control: "text" },
6
- headingLevel: { control: { type: "number", min: 1, max: 6 } },
7
- body: { control: "text" },
8
- classes: { control: "text" },
9
- attributes: { control: "object" },
10
- };
11
-
12
- Object.keys(argTypes).forEach((argType) => {
13
- argTypes[argType].description = macroOptions.find(
14
- (option) => option.name === argType,
15
- )?.description;
16
- });
17
-
18
- export default {
19
- title: "Components/Warning",
20
- argTypes,
21
- };
22
-
23
- const Template = ({ heading, headingLevel, body, classes, attributes }) =>
24
- Warning({
25
- params: {
26
- heading,
27
- headingLevel,
28
- body,
29
- classes,
30
- attributes,
31
- },
32
- });
33
-
34
- export const Standard = Template.bind({});
35
- Standard.args = {
36
- headingLevel: 2,
37
- body: "Please note this page references hunger strikes and force feeding, which some people may find upsetting.",
38
- classes: "tna-warning--demo",
39
- };
@@ -1,13 +0,0 @@
1
- import { Meta } from "@storybook/blocks";
2
-
3
- <Meta title="Introduction" />
4
-
5
- # Welcome
6
-
7
- [TNA Frontend](https://github.com/nationalarchives/tna-frontend) contains the code you need to start building user interfaces for National Archives platforms and services.
8
-
9
- This Storybook instance represents the working branch (`main`) of TNA Frontend. This may contain unreleased styles and code.
10
-
11
- To see how the styles and components in TNA Frontend should be used, see the [National Archives Design System](https://nationalarchives.github.io/design-system/).
12
-
13
- To get the latest release, see the [GitHub releases page](https://github.com/nationalarchives/tna-frontend/releases).