@nationalarchives/frontend 0.1.65 → 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 (205) hide show
  1. package/config/.eslintrc.js +1 -1
  2. package/config/.htmlvalidate.json +12 -5
  3. package/config/stylelint.config.js +1 -0
  4. package/nationalarchives/all.css +1 -1
  5. package/nationalarchives/all.css.map +1 -1
  6. package/nationalarchives/all.js +1 -1
  7. package/nationalarchives/all.js.map +1 -1
  8. package/nationalarchives/all.mjs +0 -18
  9. package/nationalarchives/components/_forms.scss +9 -0
  10. package/nationalarchives/components/_index.scss +2 -35
  11. package/nationalarchives/components/_presentation.scss +23 -0
  12. package/nationalarchives/components/accordion/accordion.css.map +1 -1
  13. package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
  14. package/nationalarchives/components/button/button.css +1 -1
  15. package/nationalarchives/components/button/button.css.map +1 -1
  16. package/nationalarchives/components/button/button.scss +9 -9
  17. package/nationalarchives/components/card/card.css +1 -1
  18. package/nationalarchives/components/card/card.css.map +1 -1
  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.njk +1 -1
  22. package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
  23. package/nationalarchives/components/checkboxes/macro-options.json +6 -0
  24. package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
  25. package/nationalarchives/components/date-input/date-input.css +1 -1
  26. package/nationalarchives/components/date-input/date-input.css.map +1 -1
  27. package/nationalarchives/components/date-input/date-input.scss +2 -2
  28. package/nationalarchives/components/date-input/fixtures.json +5 -5
  29. package/nationalarchives/components/date-input/template.njk +1 -1
  30. package/nationalarchives/components/date-search/date-search.css +1 -1
  31. package/nationalarchives/components/date-search/date-search.css.map +1 -1
  32. package/nationalarchives/components/date-search/date-search.scss +2 -2
  33. package/nationalarchives/components/details/details.css.map +1 -1
  34. package/nationalarchives/components/error-summary/error-summary.css +1 -1
  35. package/nationalarchives/components/error-summary/error-summary.css.map +1 -1
  36. package/nationalarchives/components/error-summary/error-summary.js +1 -1
  37. package/nationalarchives/components/error-summary/error-summary.js.map +1 -1
  38. package/nationalarchives/components/error-summary/error-summary.mjs +1 -1
  39. package/nationalarchives/components/error-summary/error-summary.scss +3 -4
  40. package/nationalarchives/components/files-list/_index.scss +1 -0
  41. package/nationalarchives/components/files-list/files-list.css +1 -0
  42. package/nationalarchives/components/files-list/files-list.css.map +1 -0
  43. package/nationalarchives/components/{files/files.scss → files-list/files-list.scss} +2 -1
  44. package/nationalarchives/components/files-list/fixtures.json +71 -0
  45. package/nationalarchives/components/files-list/macro.njk +3 -0
  46. package/nationalarchives/components/files-list/template.njk +33 -0
  47. package/nationalarchives/components/footer/footer.css.map +1 -1
  48. package/nationalarchives/components/gallery/fixtures.json +1 -1
  49. package/nationalarchives/components/gallery/gallery.css +1 -1
  50. package/nationalarchives/components/gallery/gallery.css.map +1 -1
  51. package/nationalarchives/components/gallery/gallery.scss +5 -6
  52. package/nationalarchives/components/gallery/template.njk +11 -7
  53. package/nationalarchives/components/global-header/global-header.css.map +1 -1
  54. package/nationalarchives/components/header/header.css.map +1 -1
  55. package/nationalarchives/components/hero/hero.css +1 -1
  56. package/nationalarchives/components/hero/hero.css.map +1 -1
  57. package/nationalarchives/components/hero/hero.scss +0 -24
  58. package/nationalarchives/components/index-grid/index-grid.css +1 -1
  59. package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
  60. package/nationalarchives/components/index-grid/index-grid.scss +1 -1
  61. package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
  62. package/nationalarchives/components/picture/picture.css.map +1 -1
  63. package/nationalarchives/components/quick-filters/quick-filters.css +1 -1
  64. package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -1
  65. package/nationalarchives/components/radios/radios.css +1 -1
  66. package/nationalarchives/components/radios/radios.css.map +1 -1
  67. package/nationalarchives/components/radios/radios.scss +1 -1
  68. package/nationalarchives/components/records-list/_index.scss +1 -0
  69. package/nationalarchives/components/records-list/fixtures.json +42 -0
  70. package/nationalarchives/components/records-list/macro.njk +3 -0
  71. package/nationalarchives/components/records-list/records-list.css +1 -0
  72. package/nationalarchives/components/records-list/records-list.css.map +1 -0
  73. package/nationalarchives/components/{featured-records/featured-records.scss → records-list/records-list.scss} +1 -1
  74. package/nationalarchives/components/records-list/template.njk +21 -0
  75. package/nationalarchives/components/search-field/search-field.css +1 -1
  76. package/nationalarchives/components/search-field/search-field.css.map +1 -1
  77. package/nationalarchives/components/search-field/search-field.scss +1 -1
  78. package/nationalarchives/components/select/select.css +1 -1
  79. package/nationalarchives/components/select/select.css.map +1 -1
  80. package/nationalarchives/components/select/select.scss +2 -2
  81. package/nationalarchives/components/sidebar/fixtures.json +12 -2
  82. package/nationalarchives/components/sidebar/sidebar.css +1 -1
  83. package/nationalarchives/components/sidebar/sidebar.css.map +1 -1
  84. package/nationalarchives/components/sidebar/template.njk +9 -0
  85. package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
  86. package/nationalarchives/components/tabs/tabs.css.map +1 -1
  87. package/nationalarchives/components/text-input/text-input.css +1 -1
  88. package/nationalarchives/components/text-input/text-input.css.map +1 -1
  89. package/nationalarchives/components/text-input/text-input.scss +2 -2
  90. package/nationalarchives/components/textarea/textarea.css +1 -1
  91. package/nationalarchives/components/textarea/textarea.css.map +1 -1
  92. package/nationalarchives/components/textarea/textarea.scss +2 -2
  93. package/nationalarchives/components/warning/warning.css +1 -1
  94. package/nationalarchives/components/warning/warning.css.map +1 -1
  95. package/nationalarchives/components/warning/warning.scss +1 -0
  96. package/nationalarchives/global-header-package.css +1 -1
  97. package/nationalarchives/global-header-package.css.map +1 -1
  98. package/nationalarchives/global-header-package.scss +1 -1
  99. package/nationalarchives/print.css +1 -1
  100. package/nationalarchives/print.css.map +1 -1
  101. package/nationalarchives/prototype-kit.css +1 -1
  102. package/nationalarchives/prototype-kit.css.map +1 -1
  103. package/nationalarchives/tools/_colour.scss +25 -50
  104. package/nationalarchives/utilities/_columns.scss +1 -1
  105. package/nationalarchives/utilities/_index.scss +1 -0
  106. package/nationalarchives/utilities/_reset.scss +2 -8
  107. package/nationalarchives/utilities/{_colour.scss → colour/_index.scss} +2 -2
  108. package/nationalarchives/utilities/{_forms.scss → forms/_index.scss} +6 -6
  109. package/nationalarchives/utilities/grid/macro.njk +3 -0
  110. package/nationalarchives/utilities/{_lists.scss → lists/_index.scss} +16 -7
  111. package/nationalarchives/utilities/{_overrides.scss → overrides/_index.scss} +2 -2
  112. package/nationalarchives/utilities/{_tables.scss → tables/_index.scss} +5 -5
  113. package/nationalarchives/utilities/{_typography.scss → typography/_index.scss} +5 -5
  114. package/nationalarchives/variables/_colour.scss +12 -5
  115. package/package.json +1 -1
  116. package/nationalarchives/components/accordion/accordion.stories.js +0 -432
  117. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +0 -128
  118. package/nationalarchives/components/button/button-group.stories.js +0 -114
  119. package/nationalarchives/components/button/button.stories.js +0 -207
  120. package/nationalarchives/components/card/card.stories.js +0 -402
  121. package/nationalarchives/components/checkboxes/checkboxes.stories.js +0 -241
  122. package/nationalarchives/components/compound-filters/compound-filters.stories.js +0 -61
  123. package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +0 -250
  124. package/nationalarchives/components/date-input/date-input.stories.js +0 -119
  125. package/nationalarchives/components/date-search/date-search.stories.js +0 -124
  126. package/nationalarchives/components/details/details.stories.js +0 -33
  127. package/nationalarchives/components/error-summary/error-summary.stories.js +0 -59
  128. package/nationalarchives/components/featured-records/_index.scss +0 -1
  129. package/nationalarchives/components/featured-records/featured-records.css +0 -1
  130. package/nationalarchives/components/featured-records/featured-records.css.map +0 -1
  131. package/nationalarchives/components/featured-records/featured-records.stories.js +0 -50
  132. package/nationalarchives/components/featured-records/fixtures.json +0 -42
  133. package/nationalarchives/components/featured-records/macro.njk +0 -3
  134. package/nationalarchives/components/featured-records/template.njk +0 -21
  135. package/nationalarchives/components/files/_index.scss +0 -1
  136. package/nationalarchives/components/files/files.css +0 -1
  137. package/nationalarchives/components/files/files.css.map +0 -1
  138. package/nationalarchives/components/files/files.stories.js +0 -59
  139. package/nationalarchives/components/files/fixtures.json +0 -71
  140. package/nationalarchives/components/files/macro.njk +0 -3
  141. package/nationalarchives/components/files/template.njk +0 -33
  142. package/nationalarchives/components/footer/footer.stories.js +0 -241
  143. package/nationalarchives/components/gallery/gallery.stories.js +0 -87
  144. package/nationalarchives/components/global-header/global-header.stories.js +0 -364
  145. package/nationalarchives/components/grid/_index.scss +0 -1
  146. package/nationalarchives/components/grid/grid.css +0 -1
  147. package/nationalarchives/components/grid/grid.css.map +0 -1
  148. package/nationalarchives/components/grid/grid.stories.js +0 -279
  149. package/nationalarchives/components/grid/macro.njk +0 -3
  150. package/nationalarchives/components/header/header.stories.js +0 -239
  151. package/nationalarchives/components/hero/hero.stories.js +0 -326
  152. package/nationalarchives/components/index-grid/index-grid.stories.js +0 -128
  153. package/nationalarchives/components/pagination/pagination.stories.js +0 -532
  154. package/nationalarchives/components/phase-banner/phase-banner.stories.js +0 -39
  155. package/nationalarchives/components/picture/picture.stories.js +0 -75
  156. package/nationalarchives/components/quick-filters/quick-filters.stories.js +0 -76
  157. package/nationalarchives/components/radios/radios.stories.js +0 -244
  158. package/nationalarchives/components/search-field/search-field.stories.js +0 -88
  159. package/nationalarchives/components/search-filters/_index.scss +0 -1
  160. package/nationalarchives/components/search-filters/fixtures.json +0 -16
  161. package/nationalarchives/components/search-filters/macro-options.json +0 -39
  162. package/nationalarchives/components/search-filters/macro.njk +0 -3
  163. package/nationalarchives/components/search-filters/search-filters.css +0 -1
  164. package/nationalarchives/components/search-filters/search-filters.css.map +0 -1
  165. package/nationalarchives/components/search-filters/search-filters.js +0 -2
  166. package/nationalarchives/components/search-filters/search-filters.js.map +0 -1
  167. package/nationalarchives/components/search-filters/search-filters.mjs +0 -67
  168. package/nationalarchives/components/search-filters/search-filters.scss +0 -198
  169. package/nationalarchives/components/search-filters/search-filters.stories.js +0 -207
  170. package/nationalarchives/components/search-filters/template.njk +0 -108
  171. package/nationalarchives/components/select/select.stories.js +0 -197
  172. package/nationalarchives/components/sensitive-image/_index.scss +0 -1
  173. package/nationalarchives/components/sensitive-image/fixtures.json +0 -51
  174. package/nationalarchives/components/sensitive-image/macro-options.json +0 -58
  175. package/nationalarchives/components/sensitive-image/macro.njk +0 -3
  176. package/nationalarchives/components/sensitive-image/sensitive-image.css +0 -1
  177. package/nationalarchives/components/sensitive-image/sensitive-image.css.map +0 -1
  178. package/nationalarchives/components/sensitive-image/sensitive-image.js +0 -2
  179. package/nationalarchives/components/sensitive-image/sensitive-image.js.map +0 -1
  180. package/nationalarchives/components/sensitive-image/sensitive-image.mjs +0 -23
  181. package/nationalarchives/components/sensitive-image/sensitive-image.scss +0 -85
  182. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +0 -86
  183. package/nationalarchives/components/sensitive-image/template.njk +0 -11
  184. package/nationalarchives/components/sidebar/sidebar.stories.js +0 -227
  185. package/nationalarchives/components/skip-link/skip-link.stories.js +0 -76
  186. package/nationalarchives/components/tabs/tabs.stories.js +0 -300
  187. package/nationalarchives/components/text-input/text-input.stories.js +0 -188
  188. package/nationalarchives/components/textarea/textarea.stories.js +0 -130
  189. package/nationalarchives/components/warning/warning.stories.js +0 -39
  190. package/nationalarchives/stories/intro.mdx +0 -13
  191. package/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js +0 -293
  192. package/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +0 -1513
  193. package/nationalarchives/stories/utilities/forms/forms.mdx +0 -117
  194. package/nationalarchives/stories/utilities/lists/lists.stories.js +0 -212
  195. package/nationalarchives/stories/utilities/overrides/overrides.stories.js +0 -42
  196. package/nationalarchives/stories/utilities/tables/tables.stories.js +0 -47
  197. package/nationalarchives/stories/utilities/typography/heading-groups.stories.js +0 -94
  198. package/nationalarchives/stories/utilities/typography/headings.stories.js +0 -33
  199. package/nationalarchives/stories/utilities/typography/typography.stories.js +0 -91
  200. package/nationalarchives/components/{files → files-list}/macro-options.json +0 -0
  201. package/nationalarchives/components/{featured-records → records-list}/macro-options.json +0 -0
  202. package/nationalarchives/{components/grid/grid.scss → utilities/grid/_index.scss} +1 -1
  203. /package/nationalarchives/{components → utilities}/grid/fixtures.json +0 -0
  204. /package/nationalarchives/{components → utilities}/grid/macro-options.json +0 -0
  205. /package/nationalarchives/{components → utilities}/grid/template.njk +0 -0
@@ -1,241 +0,0 @@
1
- import Checkboxes 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
- error: { control: "object" },
15
- items: { control: "object" },
16
- small: { control: "boolean" },
17
- inline: { control: "boolean" },
18
- classes: { control: "text" },
19
- attributes: { control: "object" },
20
- };
21
-
22
- Object.keys(argTypes).forEach((argType) => {
23
- argTypes[argType].description = macroOptions.find(
24
- (option) => option.name === argType,
25
- )?.description;
26
- });
27
-
28
- export default {
29
- title: "Components/Checkboxes",
30
- argTypes,
31
- };
32
-
33
- const Template = ({
34
- label,
35
- headingLevel,
36
- headingSize,
37
- id,
38
- name,
39
- hint,
40
- error,
41
- items,
42
- small,
43
- inline,
44
- classes,
45
- attributes,
46
- }) =>
47
- Checkboxes({
48
- params: {
49
- label,
50
- headingLevel,
51
- headingSize,
52
- id,
53
- name,
54
- hint,
55
- error,
56
- items,
57
- small,
58
- inline,
59
- classes,
60
- attributes,
61
- },
62
- });
63
-
64
- export const Standard = Template.bind({});
65
- Standard.args = {
66
- label: "Categories",
67
- headingLevel: 4,
68
- headingSize: "m",
69
- id: "categories1",
70
- name: "categories1",
71
- items: [
72
- {
73
- text: "Alpha",
74
- value: "alpha",
75
- },
76
- {
77
- text: "Beta",
78
- value: "beta",
79
- },
80
- {
81
- text: "Gamma",
82
- value: "gamma",
83
- },
84
- ],
85
- classes: "tna-checkboxes--demo",
86
- };
87
-
88
- export const Small = Template.bind({});
89
- Small.args = {
90
- label: "Categories",
91
- headingLevel: 4,
92
- headingSize: "m",
93
- id: "categories2",
94
- name: "categories2",
95
- items: [
96
- {
97
- text: "Admiralty, Navy, Royal Marines, and Coastguard",
98
- value: "ADM",
99
- },
100
- {
101
- text: "Air Ministry and Royal Air Force records",
102
- value: "AIR",
103
- },
104
- {
105
- text: "Board of Trade and successors",
106
- value: "BT",
107
- },
108
- {
109
- text: "Chancery, the Wardrobe, Royal Household, Exchequer and various commissions",
110
- value: "C",
111
- },
112
- {
113
- text: "Colonial Office, Commonwealth and Foreign and Commonwealth Offices",
114
- value: "CO",
115
- },
116
- {
117
- text: "Exchequer, Office of First Fruits and Tenths, and the Court of Augmentations",
118
- value: "E",
119
- },
120
- {
121
- text: "Foreign Office",
122
- value: "FO",
123
- },
124
- {
125
- text: "Home Office",
126
- value: "HO",
127
- },
128
- {
129
- text: "Prerogative Court of Canterbury",
130
- value: "PROB",
131
- },
132
- {
133
- text: "War Office, Armed Forces, Judge Advocate General, and related bodies",
134
- value: "WO",
135
- },
136
- ],
137
- small: true,
138
- classes: "tna-checkboxes--demo",
139
- };
140
-
141
- export const Preselected = Template.bind({});
142
- Preselected.args = {
143
- label: "Categories",
144
- headingLevel: 4,
145
- headingSize: "m",
146
- id: "categories3",
147
- name: "categories3",
148
- items: [
149
- {
150
- text: "Alpha",
151
- value: "alpha",
152
- },
153
- {
154
- text: "Beta",
155
- value: "beta",
156
- checked: true,
157
- },
158
- {
159
- text: "Gamma",
160
- value: "gamma",
161
- },
162
- ],
163
- classes: "tna-checkboxes--demo",
164
- };
165
-
166
- export const WithHint = Template.bind({});
167
- WithHint.args = {
168
- label: "Categories",
169
- headingLevel: 4,
170
- headingSize: "m",
171
- id: "categories4",
172
- name: "categories4",
173
- hint: "Select all that apply.",
174
- items: [
175
- {
176
- text: "Alpha",
177
- value: "alpha",
178
- },
179
- {
180
- text: "Beta",
181
- value: "beta",
182
- },
183
- {
184
- text: "Gamma",
185
- value: "gamma",
186
- },
187
- ],
188
- classes: "tna-checkboxes--demo",
189
- };
190
-
191
- export const Error = Template.bind({});
192
- Error.args = {
193
- label: "Categories",
194
- headingLevel: 4,
195
- headingSize: "m",
196
- id: "categories5",
197
- name: "categories5",
198
- error: {
199
- text: "You must select a category",
200
- },
201
- items: [
202
- {
203
- text: "Alpha",
204
- value: "alpha",
205
- },
206
- {
207
- text: "Beta",
208
- value: "beta",
209
- },
210
- {
211
- text: "Gamma",
212
- value: "gamma",
213
- },
214
- ],
215
- classes: "tna-checkboxes--demo",
216
- };
217
-
218
- export const Inline = Template.bind({});
219
- Inline.args = {
220
- label: "Categories",
221
- headingLevel: 4,
222
- headingSize: "xs",
223
- id: "categories6",
224
- name: "categories6",
225
- items: [
226
- {
227
- text: "Alpha",
228
- value: "alpha",
229
- },
230
- {
231
- text: "Beta",
232
- value: "beta",
233
- },
234
- {
235
- text: "Gamma",
236
- value: "gamma",
237
- },
238
- ],
239
- inline: true,
240
- classes: "tna-checkboxes--demo",
241
- };
@@ -1,61 +0,0 @@
1
- import Filters from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
-
4
- const argTypes = {
5
- items: { control: "object" },
6
- removeAllText: { control: "text" },
7
- removeAllHref: { 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/Compound filters",
20
- argTypes,
21
- };
22
-
23
- const Template = ({
24
- items,
25
- removeAllText,
26
- removeAllHref,
27
- classes,
28
- attributes,
29
- }) =>
30
- Filters({
31
- params: {
32
- items,
33
- removeAllText,
34
- removeAllHref,
35
- classes,
36
- attributes,
37
- },
38
- });
39
-
40
- export const Standard = Template.bind({});
41
- Standard.args = {
42
- items: [
43
- {
44
- label: "AIR - Air Ministry and Royal Air Force records",
45
- href: "#",
46
- title: "Remove Air Ministry and Royal Air Force records filter",
47
- },
48
- {
49
- label: "Item",
50
- href: "#",
51
- title: "Remove item filter",
52
- },
53
- {
54
- label: "Closed Or Retained Document, Open Description",
55
- href: "#",
56
- title: "Remove filter for Closed Or Retained Document, Open Description",
57
- },
58
- ],
59
- removeAllHref: "#",
60
- classes: "tna-filters--demo",
61
- };
@@ -1,250 +0,0 @@
1
- import CookieBanner from "./template.njk";
2
- import macroOptions from "./macro-options.json";
3
- import { within, userEvent, expect } from "@storybook/test";
4
- import Cookies from "../../lib/cookies.mjs";
5
-
6
- const argTypes = {
7
- serviceName: { control: "text" },
8
- cookiesUrl: { control: "text" },
9
- policies: { control: "text" },
10
- policiesKey: { control: "text" },
11
- preferencesSetKey: { control: "text" },
12
- cookiesDomain: { control: "text" },
13
- cookiesPath: { control: "text" },
14
- allowInsecure: { control: "boolean" },
15
- style: {
16
- control: "inline-radio",
17
- options: ["none", "contrast", "accent", "tint"],
18
- },
19
- classes: { control: "text" },
20
- attributes: { control: "object" },
21
- };
22
-
23
- Object.keys(argTypes).forEach((argType) => {
24
- argTypes[argType].description = macroOptions.find(
25
- (option) => option.name === argType,
26
- )?.description;
27
- });
28
-
29
- export default {
30
- title: "Components/Cookie banner",
31
- argTypes,
32
- };
33
-
34
- const Template = ({
35
- serviceName,
36
- cookiesUrl,
37
- policies,
38
- policiesKey,
39
- preferencesSetKey,
40
- cookiesDomain,
41
- cookiesPath,
42
- allowInsecure,
43
- style,
44
- classes,
45
- attributes,
46
- }) =>
47
- CookieBanner({
48
- params: {
49
- serviceName,
50
- cookiesUrl,
51
- policies,
52
- policiesKey,
53
- preferencesSetKey,
54
- cookiesDomain,
55
- cookiesPath,
56
- allowInsecure,
57
- style,
58
- classes,
59
- attributes,
60
- },
61
- });
62
-
63
- export const Standard = Template.bind({});
64
- Standard.args = {
65
- cookiesUrl: "#",
66
- cookiesPath: "/tna-frontend/",
67
- classes: "tna-cookie-banner--demo",
68
- };
69
-
70
- export const Accept = Template.bind({});
71
- Accept.args = {
72
- serviceName: "My service",
73
- cookiesUrl: "#",
74
- allowInsecure: true,
75
- classes: "tna-cookie-banner--demo",
76
- };
77
- Accept.play = async ({ canvasElement }) => {
78
- const cookies = new Cookies({ newInstance: true });
79
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
80
- await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
81
- await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
82
- await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
83
- await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
84
-
85
- const canvas = within(canvasElement);
86
- const acceptButton = canvas.getByText("Accept cookies");
87
- const rejectButton = canvas.getByText("Reject cookies");
88
- await expect(acceptButton).toBeVisible();
89
- await expect(rejectButton).toBeVisible();
90
- await userEvent.click(acceptButton);
91
-
92
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
93
- await expect(cookies.isPolicyAccepted("usage")).toEqual(true);
94
- await expect(cookies.isPolicyAccepted("settings")).toEqual(true);
95
- await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
96
- await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
97
- await expect(cookies.get("cookie_preferences_set")).toEqual("true");
98
- await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
99
- true,
100
- );
101
- await expect(acceptButton).not.toBeVisible();
102
- await expect(rejectButton).not.toBeVisible();
103
-
104
- // const closeButton = canvas.getByText("Close this message");
105
- // await expect(closeButton).toBeVisible();
106
- // await userEvent.click(closeButton);
107
-
108
- // await expect(closeButton).not.toBeVisible();
109
-
110
- await cookies.deleteAll();
111
- };
112
-
113
- export const Reject = Template.bind({});
114
- Reject.args = {
115
- serviceName: "My service",
116
- cookiesUrl: "#",
117
- classes: "tna-cookie-banner--demo",
118
- };
119
- Reject.play = async ({ canvasElement }) => {
120
- const cookies = new Cookies({ newInstance: true });
121
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
122
- await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
123
- await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
124
- await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
125
- await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
126
-
127
- const canvas = within(canvasElement);
128
- const acceptButton = canvas.getByText("Accept cookies");
129
- const rejectButton = canvas.getByText("Reject cookies");
130
- await expect(acceptButton).toBeVisible();
131
- await expect(rejectButton).toBeVisible();
132
- await userEvent.click(rejectButton);
133
-
134
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
135
- await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
136
- await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
137
- await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
138
- await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
139
- await expect(cookies.get("cookie_preferences_set")).toEqual("true");
140
- await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
141
- true,
142
- );
143
- await expect(acceptButton).not.toBeVisible();
144
- await expect(rejectButton).not.toBeVisible();
145
-
146
- await cookies.deleteAll();
147
- };
148
-
149
- export const CustomPolicies = Template.bind({});
150
- CustomPolicies.args = {
151
- serviceName: "My service",
152
- cookiesUrl: "#",
153
- policies: "custom",
154
- classes: "tna-cookie-banner--demo",
155
- };
156
- CustomPolicies.parameters = {
157
- chromatic: { disableSnapshot: true },
158
- };
159
- CustomPolicies.play = async ({ args, canvasElement }) => {
160
- const cookies = new Cookies({
161
- extraPolicies: args.policies.split(","),
162
- newInstance: true,
163
- });
164
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
165
- await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
166
- await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
167
- await expect(cookies.isPolicyAccepted("custom")).toEqual(false);
168
- await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
169
-
170
- const canvas = within(canvasElement);
171
- const acceptButton = canvas.getByText("Accept cookies");
172
- await userEvent.click(acceptButton);
173
-
174
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
175
- await expect(cookies.isPolicyAccepted("usage")).toEqual(true);
176
- await expect(cookies.isPolicyAccepted("settings")).toEqual(true);
177
- await expect(cookies.isPolicyAccepted("custom")).toEqual(true);
178
- await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
179
- await expect(cookies.get("cookie_preferences_set")).toEqual("true");
180
- await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
181
- true,
182
- );
183
-
184
- await cookies.deleteAll();
185
- };
186
-
187
- export const Existing = Template.bind({});
188
- Existing.args = {
189
- serviceName: "My service",
190
- cookiesUrl: "#",
191
- allowInsecure: true,
192
- classes: "tna-cookie-banner--demo",
193
- };
194
- Existing.decorators = [
195
- (Story) => {
196
- const cookies = new Cookies({ newInstance: true });
197
- cookies.set("cookie_preferences_set", true);
198
- return Story();
199
- },
200
- ];
201
- Existing.play = async ({ canvasElement }) => {
202
- const cookies = new Cookies();
203
- await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
204
- await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
205
- await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
206
- await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
207
- await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
208
- await expect(cookies.get("cookie_preferences_set")).toEqual("true");
209
- await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
210
- true,
211
- );
212
-
213
- const canvas = within(canvasElement);
214
- const acceptButton = canvas.getByText("Accept cookies");
215
- const rejectButton = canvas.getByText("Reject cookies");
216
- await expect(acceptButton).not.toBeVisible();
217
- await expect(rejectButton).not.toBeVisible();
218
-
219
- await cookies.deleteAll();
220
- };
221
-
222
- // export const EventHandling = Template.bind({});
223
- // EventHandling.args = {
224
- // serviceName: "My service",
225
- // cookiesUrl: "#",
226
- // cookiesPath: "/tna-frontend/",
227
- // policies: "custom",
228
- // classes: "tna-cookie-banner--demo",
229
- // };
230
- // EventHandling.play = async ({ args, canvasElement }) => {
231
- // deleteAllCookies();
232
-
233
- // const cookies = new Cookies();
234
-
235
- // const onChangePolicy = jest.fn(data => {
236
- // console.log(data)
237
- // })
238
- // cookies.on("changePolicy", onChangePolicy)
239
-
240
- // const canvas = within(canvasElement);
241
- // const acceptButton = canvas.getByText("Accept cookies");
242
- // await userEvent.click(acceptButton);
243
-
244
- // await expect(onChangePolicy.mock).toHaveBeenCalledTimes(1);
245
- // await expect(onChangePolicy.mock.calls).toHaveLength(1);
246
- // await expect(onChangePolicy.mock.results[0].value).toHaveProperty("custom");
247
- // await expect(onChangePolicy.mock.results[0].value.custom).toEqual(true);
248
-
249
- // deleteAllCookies();
250
- // };
@@ -1,119 +0,0 @@
1
- import DateInput 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: "object" },
15
- error: { control: "object" },
16
- inline: { control: "boolean" },
17
- classes: { control: "text" },
18
- attributes: { control: "object" },
19
- };
20
-
21
- Object.keys(argTypes).forEach((argType) => {
22
- argTypes[argType].description = macroOptions.find(
23
- (option) => option.name === argType,
24
- )?.description;
25
- });
26
-
27
- export default {
28
- title: "Components/Date input",
29
- argTypes,
30
- };
31
-
32
- const Template = ({
33
- label,
34
- headingLevel,
35
- headingSize,
36
- id,
37
- name,
38
- hint,
39
- value,
40
- error,
41
- inline,
42
- classes,
43
- attributes,
44
- }) =>
45
- DateInput({
46
- params: {
47
- label,
48
- headingLevel,
49
- headingSize,
50
- id,
51
- name,
52
- hint,
53
- value,
54
- error,
55
- inline,
56
- classes,
57
- attributes,
58
- },
59
- });
60
-
61
- export const Standard = Template.bind({});
62
- Standard.args = {
63
- label: "Enter a start date",
64
- headingLevel: 4,
65
- headingSize: "m",
66
- id: "date11",
67
- name: "date11",
68
- classes: "tna-date-search--demo",
69
- };
70
-
71
- export const Predefined = Template.bind({});
72
- Predefined.args = {
73
- label: "Enter a start date",
74
- headingLevel: 4,
75
- headingSize: "m",
76
- id: "date12",
77
- name: "date12",
78
- value: {
79
- day: "24",
80
- month: "09",
81
- year: "1986",
82
- },
83
- classes: "tna-date-search--demo",
84
- };
85
-
86
- export const WithHint = Template.bind({});
87
- WithHint.args = {
88
- label: "Enter a start date",
89
- headingLevel: 4,
90
- headingSize: "m",
91
- id: "date13",
92
- name: "date13",
93
- hint: "The earliest date of the record",
94
- classes: "tna-date-search--demo",
95
- };
96
-
97
- export const Error = Template.bind({});
98
- Error.args = {
99
- label: "Enter a start date",
100
- headingLevel: 4,
101
- headingSize: "m",
102
- id: "date14",
103
- name: "date14",
104
- error: {
105
- text: "Date is not valid",
106
- },
107
- classes: "tna-date-search--demo",
108
- };
109
-
110
- export const Inline = Template.bind({});
111
- Inline.args = {
112
- label: "Enter a start date",
113
- headingLevel: 4,
114
- headingSize: "xs",
115
- id: "date15",
116
- name: "date15",
117
- inline: true,
118
- classes: "tna-date-search--demo",
119
- };