@iamproperty/components 7.6.4--beta6 → 7.6.4--beta7

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 (137) hide show
  1. package/assets/css/components/actionbar.component.css +1 -1
  2. package/assets/css/components/actionbar.component.css.map +1 -1
  3. package/assets/css/components/address-lookup.component.css +1 -1
  4. package/assets/css/components/address-lookup.component.css.map +1 -1
  5. package/assets/css/components/barchart.component.css +1 -1
  6. package/assets/css/components/barchart.component.css.map +1 -1
  7. package/assets/css/components/calendar.component.css +1 -1
  8. package/assets/css/components/calendar.component.css.map +1 -1
  9. package/assets/css/components/card.component.css +1 -1
  10. package/assets/css/components/card.component.css.map +1 -1
  11. package/assets/css/components/carousel.component.css +1 -1
  12. package/assets/css/components/carousel.component.css.map +1 -1
  13. package/assets/css/components/collapsible-side.css +1 -1
  14. package/assets/css/components/collapsible-side.css.map +1 -1
  15. package/assets/css/components/content.component.css +1 -1
  16. package/assets/css/components/content.component.css.map +1 -1
  17. package/assets/css/components/doughnutchart.component.css +1 -1
  18. package/assets/css/components/doughnutchart.component.css.map +1 -1
  19. package/assets/css/components/fileupload.css +1 -1
  20. package/assets/css/components/fileupload.css.map +1 -1
  21. package/assets/css/components/modal.component.css +1 -1
  22. package/assets/css/components/modal.component.css.map +1 -1
  23. package/assets/css/components/multi-step-modal.component.css +1 -1
  24. package/assets/css/components/multi-step-modal.component.css.map +1 -1
  25. package/assets/css/components/multiselect.css +1 -1
  26. package/assets/css/components/multiselect.css.map +1 -1
  27. package/assets/css/components/nav.component.css +1 -1
  28. package/assets/css/components/nav.component.css.map +1 -1
  29. package/assets/css/components/nav.global.css +1 -1
  30. package/assets/css/components/nav.global.css.map +1 -1
  31. package/assets/css/components/pagination.css +1 -1
  32. package/assets/css/components/pagination.css.map +1 -1
  33. package/assets/css/components/slider.css +1 -1
  34. package/assets/css/components/slider.css.map +1 -1
  35. package/assets/css/components/split-button.component.css +1 -1
  36. package/assets/css/components/split-button.component.css.map +1 -1
  37. package/assets/css/components/table-basic.component.css +1 -1
  38. package/assets/css/components/table-basic.component.css.map +1 -1
  39. package/assets/css/components/table-basic.global.css +1 -1
  40. package/assets/css/components/table-basic.global.css.map +1 -1
  41. package/assets/css/components/table.component.css +1 -1
  42. package/assets/css/components/table.component.css.map +1 -1
  43. package/assets/css/components/table.global.css +1 -1
  44. package/assets/css/components/table.global.css.map +1 -1
  45. package/assets/css/components/tabs.component.css +1 -1
  46. package/assets/css/components/tabs.component.css.map +1 -1
  47. package/assets/css/components/tag.component.css +1 -1
  48. package/assets/css/components/tag.component.css.map +1 -1
  49. package/assets/css/components/video-modal.component.css +1 -1
  50. package/assets/css/components/video-modal.component.css.map +1 -1
  51. package/assets/css/core.min.css +1 -1
  52. package/assets/css/core.min.css.map +1 -1
  53. package/assets/css/style.min.css +1 -1
  54. package/assets/css/style.min.css.map +1 -1
  55. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  56. package/assets/js/components/actionbar/actionbar.component.min.js +2 -2
  57. package/assets/js/components/address-lookup/address-lookup.component.min.js +2 -2
  58. package/assets/js/components/advanced-select/advanced-select.component.min.js +1 -1
  59. package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
  60. package/assets/js/components/barchart/barchart.component.min.js +2 -2
  61. package/assets/js/components/bento-grid/bento-grid.component.min.js +1 -1
  62. package/assets/js/components/calendar/calendar.component.min.js +2 -2
  63. package/assets/js/components/card/card.component.min.js +2 -2
  64. package/assets/js/components/carousel/carousel.component.min.js +3 -3
  65. package/assets/js/components/collapsible-side/collapsible-side.component.min.js +2 -2
  66. package/assets/js/components/content/content.component.min.js +4 -4
  67. package/assets/js/components/darkmode/darkmode.component.min.js +1 -1
  68. package/assets/js/components/doughnutchart/doughnutchart.component.min.js +2 -2
  69. package/assets/js/components/fileupload/fileupload.component.min.js +2 -2
  70. package/assets/js/components/filter-card/filter-card.component.min.js +1 -1
  71. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  72. package/assets/js/components/form/form.component.min.js +1 -1
  73. package/assets/js/components/header/header.component.min.js +1 -1
  74. package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
  75. package/assets/js/components/input/input.component.min.js +1 -1
  76. package/assets/js/components/input-range/input-range.component.min.js +1 -1
  77. package/assets/js/components/marketing/marketing.component.min.js +1 -1
  78. package/assets/js/components/menu/menu.component.min.js +1 -1
  79. package/assets/js/components/milestone/milestone.component.min.js +1 -1
  80. package/assets/js/components/milestone-group/milestone-group.component.min.js +1 -1
  81. package/assets/js/components/modal/modal.component.min.js +4 -4
  82. package/assets/js/components/multi-step/multi-step.component.min.js +1 -1
  83. package/assets/js/components/multi-step-modal/multi-step-modal.component.min.js +4 -4
  84. package/assets/js/components/multiselect/multiselect.component.min.js +2 -2
  85. package/assets/js/components/nav/nav.component.min.js +3 -3
  86. package/assets/js/components/notification/notification.component.min.js +1 -1
  87. package/assets/js/components/pagination/pagination.component.min.js +2 -2
  88. package/assets/js/components/password/password.component.min.js +1 -1
  89. package/assets/js/components/popover/popover.component.min.js +1 -1
  90. package/assets/js/components/rank/rank.component.min.js +1 -1
  91. package/assets/js/components/rankings/rankings.component.min.js +1 -1
  92. package/assets/js/components/rating/rating.component.min.js +1 -1
  93. package/assets/js/components/record-card/record-card.component.min.js +1 -1
  94. package/assets/js/components/search/search.component.min.js +1 -1
  95. package/assets/js/components/slider/slider.component.min.js +2 -2
  96. package/assets/js/components/split-button/split-button.component.min.js +5 -5
  97. package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js +2 -2
  98. package/assets/js/components/table/table.component.min.js +8 -6
  99. package/assets/js/components/table/table.component.min.js.map +1 -1
  100. package/assets/js/components/table-ajax/table-ajax.component.min.js +8 -6
  101. package/assets/js/components/table-ajax/table-ajax.component.min.js.map +1 -1
  102. package/assets/js/components/table-basic/table-basic.component.min.js +7 -5
  103. package/assets/js/components/table-basic/table-basic.component.min.js.map +1 -1
  104. package/assets/js/components/table-no-submit/table-no-submit.component.min.js +8 -6
  105. package/assets/js/components/table-no-submit/table-no-submit.component.min.js.map +1 -1
  106. package/assets/js/components/table-submit/table-submit.component.min.js +8 -6
  107. package/assets/js/components/table-submit/table-submit.component.min.js.map +1 -1
  108. package/assets/js/components/tabs/tabs.component.min.js +3 -3
  109. package/assets/js/components/tag/tag.component.min.js +2 -2
  110. package/assets/js/components/tooltip/tooltip.component.min.js +1 -1
  111. package/assets/js/components/video-card/video-card.component.min.js +1 -1
  112. package/assets/js/components/video-modal/video-modal.component.min.js +2 -2
  113. package/assets/js/components/word-count/word-count.component.min.js +1 -1
  114. package/assets/js/modules/integration-tests.js +402 -0
  115. package/assets/js/modules/table.js +17 -1
  116. package/assets/js/scripts.bundle.js +5 -2
  117. package/assets/js/scripts.bundle.js.map +1 -1
  118. package/assets/js/scripts.bundle.min.js +2 -2
  119. package/assets/js/scripts.bundle.min.js.map +1 -1
  120. package/assets/js/scripts.js +11 -0
  121. package/assets/sass/components/modal.component.scss +1 -0
  122. package/assets/sass/components/nav.global.scss +9 -5
  123. package/assets/sass/components/table-basic.component.scss +3 -0
  124. package/assets/sass/components/table-basic.global.scss +124 -2
  125. package/assets/sass/components/table.global.scss +153 -0
  126. package/assets/sass/elements/button__group.css +57 -16
  127. package/assets/sass/elements/buttons--compact.scss +2 -2
  128. package/assets/sass/elements/buttons--special.scss +1 -1
  129. package/assets/sass/elements/label.scss +4 -0
  130. package/assets/sass/elements/progress.scss +2 -2
  131. package/assets/ts/modules/integration-tests.ts +526 -0
  132. package/assets/ts/modules/table.ts +22 -1
  133. package/assets/ts/scripts.ts +14 -0
  134. package/dist/components.es.js +29 -29
  135. package/dist/components.umd.js +226 -216
  136. package/package.json +2 -2
  137. package/src/components/Header/Header.vue +1 -1
@@ -0,0 +1,526 @@
1
+ const integrationTests = () => {
2
+
3
+ let errorTable = [];
4
+ let test = {};
5
+ const intro = "These tests run against mark-up and content meant to test how a component or element has been integrated. Making sure that guidance setout in the design system is being followed.";
6
+
7
+ window.integrationTestsIntro = intro;
8
+
9
+ console.log("%cVirgin Money Framework Tests","color: #E10A0A; font-size: 24px; font-weight: bold; margin-top: 20px; margin-bottom: 10px;");
10
+
11
+ console.log("%c"+intro,"font-size: 14px; margin-bottom: 20px;");
12
+
13
+ console.log("%cKey","font-size: 16px;font-weight:bold;");
14
+ console.log('%c %c' + 'Successfully implemented', 'background-color: green; margin-right: 10px', 'background-color: transparent');
15
+ console.log('%c %c' + 'NOT implemented correctly', 'background-color: red; margin-right: 10px', 'background-color: transparent');
16
+ console.log('%c %c' + 'N/A', 'background-color: grey; margin-right: 10px', 'background-color: transparent');
17
+ console.log('%c %c' + 'Warning - No action needed', 'background-color: orange; margin-right: 10px', 'background-color: transparent');
18
+ console.log('%c ? %c' + 'Warning - Action needed', 'background-color: orange; margin-right: 10px', 'background-color: transparent');
19
+
20
+ // #region Card deck Footer test
21
+ test = {
22
+ 'Test': 'Each card with in a card deck has a footer with some CTA text via a button link',
23
+ 'Total': 0,
24
+ 'Passes': 0,
25
+ 'Fails': 0
26
+ }
27
+
28
+ Array.from(document.querySelectorAll('.card-deck .card')).forEach((card, index) => {
29
+
30
+ if(card.closest('.navbar') == null){
31
+
32
+ let btnLink = card.querySelector('.btn-link');
33
+
34
+ if(btnLink != null && btnLink.textContent.length)
35
+ test['Passes']++;
36
+ else
37
+ test['Fails']++;
38
+ }
39
+ });
40
+
41
+ test['Total'] = test['Passes'] + test['Fails'];
42
+ errorTable.push(test);
43
+ // #endregion
44
+
45
+ // #region Article deck background colour
46
+ test = {
47
+ 'Test': 'Article Decks need to have a background colour applied',
48
+ 'Total': 0,
49
+ 'Passes': 0,
50
+ 'Fails': 0
51
+ }
52
+
53
+ Array.from(document.querySelectorAll('.article-deck')).forEach((deck, index) => {
54
+
55
+ let container = deck.closest('.container');
56
+
57
+ if (container != null && container.matches('[class*="bg-"]'))
58
+ test['Passes']++;
59
+ else
60
+ test['Fails']++;
61
+ });
62
+
63
+ test['Total'] = test['Passes'] + test['Fails'];
64
+ errorTable.push(test);
65
+ // #endregion
66
+
67
+ // #region Tabs Carousel title test
68
+ test = {
69
+ 'Test': 'Tabs Carousel has a h2 title with a display-4 class. It should always have a strapline next to it also.',
70
+ 'Total': 0,
71
+ 'Passes': 0,
72
+ 'Fails': 0,
73
+ 'Notes': 'The site nav contains cards without a footer by design.'
74
+ }
75
+
76
+ Array.from(document.querySelectorAll('.tabs__container--carousel')).forEach((tabs, index) => {
77
+
78
+ let title = tabs.querySelector('h2.display-4:first-child');
79
+ let strapline = tabs.querySelector('h2.display-4:first-child + .strapline');
80
+
81
+ if(title != null && strapline != null)
82
+ test['Passes']++;
83
+ else
84
+ test['Fails']++
85
+ });
86
+
87
+ test['Total'] = test['Passes'] + test['Fails'];
88
+ errorTable.push(test);
89
+ // #endregion
90
+
91
+ // #region Split Container tests
92
+ test = {
93
+ 'Test': 'Split Containers can only have multiple of two columns. So either 2, 4, 6 and so on.',
94
+ 'Total': 0,
95
+ 'Passes': 0,
96
+ 'Fails': 0,
97
+ 'Notes': ''
98
+ }
99
+
100
+ Array.from(document.querySelectorAll('.container.container--split')).forEach((container, index) => {
101
+
102
+ if(container.querySelectorAll(':scope > .row > [class*="col"]').length % 2 === 0)
103
+ test['Passes']++;
104
+ else
105
+ test['Fails']++;
106
+ });
107
+ test['Total'] = test['Passes'] + test['Fails'];
108
+ errorTable.push(test);
109
+ // #endregion
110
+
111
+ // #region Statement Container tests
112
+ test = {
113
+ 'Test': 'Statement Containers with only one paragraph or text element should have the class of .h6',
114
+ 'Total': 0,
115
+ 'Passes': 0,
116
+ 'Fails': 0,
117
+ 'Notes': ''
118
+ }
119
+
120
+ Array.from(document.querySelectorAll('.container.container--statement')).forEach((container, index) => {
121
+ if(container.querySelectorAll(':scope > *').length == 1 && container.querySelectorAll(':scope > .h6:first-child').length == 1)
122
+ test['Passes']++;
123
+ else if(container.querySelectorAll(':scope > *').length == 1)
124
+ test['Fails']++;
125
+ });
126
+ test['Total'] = test['Passes'] + test['Fails'];
127
+ errorTable.push(test);
128
+ // #endregion
129
+
130
+ // #region CTA Container tests
131
+ test = {
132
+ 'Test': 'CTA Containers title should always have the class of .h1',
133
+ 'Total': 0,
134
+ 'Passes': 0,
135
+ 'Fails': 0,
136
+ 'Notes': ''
137
+ }
138
+
139
+ Array.from(document.querySelectorAll('.container.container--cta')).forEach((container, index) => {
140
+
141
+ if(container.querySelectorAll('h2.h1:first-child').length == 1)
142
+ test['Passes']++;
143
+ else
144
+ test['Fails']++;
145
+ });
146
+ test['Total'] = test['Passes'] + test['Fails'];
147
+ errorTable.push(test);
148
+ // #endregion
149
+
150
+ // Print Implementation tests
151
+ console.log("%cImplementation Tests","font-size: 16px;font-weight:bold; margin-top: 20px;");
152
+ errorTable.forEach(function(entry) {
153
+ let color = 'green';
154
+
155
+ if(entry['Total'] === 0){
156
+ color = 'grey';
157
+ }
158
+ else if(entry['Fails'] != 0){
159
+ color = 'red';
160
+ }
161
+
162
+ if(entry['Type'] == 'warning'){
163
+ color = 'orange';
164
+ }
165
+
166
+ console.groupCollapsed('%c %c' + entry.Test, 'background-color: ' + color + '; margin-right: 10px', 'background-color: transparent');
167
+ console.table({
168
+ Passed: {value: entry['Passes']},
169
+ Failed: {value: entry['Fails']},
170
+ Total: {value: entry['Total']}
171
+ });
172
+
173
+ if(entry['Notes'] != ''){
174
+ console.log(entry['Notes']);
175
+ }
176
+
177
+ console.groupEnd();
178
+ });
179
+
180
+
181
+ window.integrationTests = errorTable;
182
+
183
+ // Resest table
184
+ var errorTableUtility = [];
185
+
186
+ // #region Padding classes
187
+ test = {
188
+ 'Test': 'There are XX padding classes being used on this page',
189
+ 'Type': 'warning',
190
+ 'Total': 0,
191
+ 'Passes': 0,
192
+ 'Fails': 0,
193
+ 'Notes': ''
194
+ }
195
+
196
+ Array.from(document.querySelectorAll('[class*="p-"],[class*="pt-"],[class*="pb-"],[class*="pl-"],[class*="pr-"],[class*="px-"],[class*="py-"]')).forEach((element, index) => {
197
+
198
+ test['Total']++;
199
+ });
200
+
201
+ test['Test'] = test['Test'].replace('XX',test['Total']);
202
+ errorTableUtility.push(test);
203
+ // #endregion
204
+
205
+ // #region Margin classes
206
+ test = {
207
+ 'Test': 'There are XX margin classes being used on this page',
208
+ 'Type': 'warning',
209
+ 'Total': 0,
210
+ 'Passes': 0,
211
+ 'Fails': 0,
212
+ 'Notes': ''
213
+ }
214
+
215
+ Array.from(document.querySelectorAll('[class*="m-"],[class*="mt-"],[class*="mb-"],[class*="ml-"],[class*="mr-"],[class*="mx-"],[class*="my-"]')).forEach((element, index) => {
216
+
217
+ test['Total']++;
218
+ });
219
+
220
+ test['Test'] = test['Test'].replace('XX',test['Total']);
221
+ errorTableUtility.push(test);
222
+ // #endregion
223
+
224
+ // #region Text modifier classes
225
+ test = {
226
+ 'Test': 'There are XX text modifier classes being used on this page',
227
+ 'Type': 'warning',
228
+ 'Total': 0,
229
+ 'Passes': 0,
230
+ 'Fails': 0,
231
+ 'Notes': ''
232
+ }
233
+ Array.from(document.querySelectorAll('[class*="text-"]')).forEach((element, index) => {
234
+
235
+ test['Total']++;
236
+ });
237
+
238
+ test['Test'] = test['Test'].replace('XX',test['Total']);
239
+ errorTableUtility.push(test);
240
+ // #endregion
241
+
242
+
243
+ // Print the utility classes tests
244
+ console.log("%cUtility classes","font-size: 16px;font-weight:bold;");
245
+
246
+ console.log("The use of certain utility classes is necessary at times but the over use of these classes will lead to design/layout inconsistencies.");
247
+
248
+ errorTableUtility.forEach(function(entry) {
249
+ let color = 'green';
250
+
251
+ if(entry['Total'] === 0)
252
+ color = 'grey';
253
+ else if(entry['Fails'] != 0)
254
+ color = 'red';
255
+
256
+ if(entry['Type'] == 'warning')
257
+ color = 'orange';
258
+
259
+ console.groupCollapsed('%c %c' + entry.Test, 'background-color: ' + color + '; margin-right: 10px', 'background-color: transparent');
260
+ console.table({
261
+ Total: {value: entry['Total']}
262
+ });
263
+
264
+ if(entry['Notes'] != ''){
265
+ console.log(entry['Notes']);
266
+ }
267
+
268
+ console.groupEnd();
269
+ });
270
+
271
+
272
+ // #region Headings out of context tests
273
+ console.log("%cAccessibility and Best practice Tests","font-size: 16px;font-weight:bold;");
274
+
275
+ let color = 'green';
276
+ let contextLevel = 1;
277
+ let headingTable = {};
278
+
279
+ Array.from(document.querySelectorAll('h1,h2,h3,h4,h5,h6')).forEach((heading, index) => {
280
+
281
+ let level = 1;
282
+ let text = heading.textContent;
283
+
284
+ if(heading.matches("h2"))
285
+ level = 2;
286
+ else if(heading.matches("h3"))
287
+ level = 3;
288
+ else if(heading.matches("h4"))
289
+ level = 4;
290
+ else if(heading.matches("h5"))
291
+ level = 5;
292
+ else if(heading.matches("h6"))
293
+ level = 6;
294
+
295
+
296
+ let inOrder = (level - contextLevel) <= 1;
297
+
298
+ if(index == 0 && level != 1){
299
+ inOrder = false;
300
+ }
301
+
302
+ let test = {
303
+ "Heading Level": level,
304
+ "In order": inOrder
305
+ }
306
+
307
+ if (inOrder){
308
+
309
+ contextLevel = level;
310
+ }
311
+ else {
312
+ color = 'red';
313
+ }
314
+
315
+ headingTable[text] = test;
316
+ });
317
+
318
+ console.groupCollapsed('%c %c' + 'Headings are in the correct order', 'background-color: ' + color + '; margin-right: 10px', 'background-color: transparent');
319
+ console.table(headingTable);
320
+ console.groupEnd();
321
+
322
+ console.groupCollapsed('%c ? %c' + 'Do all of the headings make sense out of context and do they introduce the content that follows?', 'background-color: ' + 'orange' + '; margin-right: 10px', 'background-color: transparent');
323
+ console.log("You should be able to read the below table and get an understanding of what the page content consists of. The titles should make sense when read in order and child titles should be relevant to the parent title.");
324
+ console.table(headingTable);
325
+ console.groupEnd();
326
+ // #endregion
327
+
328
+ // #region Links out of context tests
329
+ let linksTable = {};
330
+ Array.from(document.querySelectorAll('a')).forEach((link, index) => {
331
+
332
+ var url = link.getAttribute('href');
333
+ var text = link.textContent;
334
+ var title = link.getAttribute('title');
335
+
336
+ let test = {
337
+ "Text": text,
338
+ "Title": title
339
+ }
340
+
341
+ linksTable[url] = test;
342
+ });
343
+
344
+ console.groupCollapsed('%c ? %c' + 'Do all of the links make sense out of context and do they describe the page/section that it links to?', 'background-color: ' + 'orange' + '; margin-right: 10px', 'background-color: transparent');
345
+ console.table(linksTable);
346
+ console.groupEnd();
347
+ // #endregion
348
+
349
+
350
+ // #region Image alt tags out of context tests
351
+ let imgTable = {};
352
+ let imgNoAltTable = {};
353
+
354
+ Array.from(document.querySelectorAll('img[alt]')).forEach((image, index) => {
355
+
356
+ var url = image.getAttribute('src');
357
+ var alt = image.getAttribute('alt');
358
+
359
+ if(alt != ""){
360
+
361
+ let test = {
362
+ "Alt": alt
363
+ }
364
+
365
+ imgTable[url] = test;
366
+
367
+ }
368
+ else {
369
+
370
+ var url = image.getAttribute('src');
371
+
372
+ let test = {};
373
+
374
+ imgNoAltTable[url] = test;
375
+ }
376
+
377
+ });
378
+
379
+ console.groupCollapsed('%c ? %c' + 'Do all of the images with an alt tag make sense out of context and describes the image appropriately?', 'background-color: ' + 'orange' + '; margin-right: 10px', 'background-color: transparent');
380
+ console.table(imgTable);
381
+ console.log('%cImages with an empty alt tag:', 'font-weight: bold;');
382
+ console.table(imgNoAltTable);
383
+ console.groupEnd();
384
+ // #endregion
385
+
386
+ // #region Keyboard user messages
387
+ console.groupCollapsed('%c ? %c' + 'Can you navigation the page links by tabbing through the page?', 'background-color: ' + 'orange' + '; margin-right: 10px', 'background-color: transparent');
388
+ console.log('Are all of the links, input fields and buttons accessible through using the keyboard only?');
389
+ console.groupEnd();
390
+ // #endregion
391
+
392
+
393
+
394
+ console.log("%cLighthouse","font-size: 16px;font-weight:bold;");
395
+
396
+ // #region Lighthouse
397
+ console.groupCollapsed('%c ? %c' + 'Have you ran a lighthouse report on this page', 'background-color: ' + 'orange' + '; margin-right: 10px', 'background-color: transparent');
398
+ console.log('If you are in a modern version of chrome you can a lighthouse report by opening the lighthouse window within the devtools. This should appear as a tab link above.');
399
+ console.log('This report will give you more detail about the above the tests aswell as extra tests. ');
400
+ console.groupEnd();
401
+ // #endregion
402
+
403
+ console.log("%cImage sizes","font-size: 16px;font-weight:bold;");
404
+ console.log("The below tests work from the current screen size, so if you have your screen at a mobile viewport the scaling and sizes of images will reflect that. It is worth running the image tests in both mobile and desktop views. Simply change the screen size and refresh the page.");
405
+
406
+ Array.from(document.querySelectorAll('img')).forEach((imgElem, index) => {
407
+
408
+ if(!imgElem.matches("[src*='http']") && !imgElem.matches("[src$='.svg']")){
409
+
410
+ let src = imgElem.getAttribute('src');
411
+
412
+ var xhr = new XMLHttpRequest();
413
+ xhr.open('HEAD', src, true);
414
+ xhr.onreadystatechange = function(){
415
+ if (xhr.readyState == 4) {
416
+ if (xhr.status == 200){
417
+ var imgFSize = xhr.getResponseHeader('Content-Length');
418
+ if (imgFSize > 1024){ //ignore images under 1Kb
419
+ var imgW = imgElem.naturalWidth;
420
+ var imgH = imgElem.naturalHeight;
421
+ var imgW2 = imgElem.clientWidth;
422
+ var imgH2 = imgElem.clientHeight;
423
+ var imgScl = (imgW2/imgW).toFixed(2) == "0.00" ? "Hidden" : (imgW2/imgW).toFixed(2);
424
+ var imgFSize2 = Math.floor(imgFSize/1024);
425
+ var imgBPP = (imgFSize/(imgW*imgH)).toFixed(2);
426
+ var cssColor = "green";
427
+ var bppColor = "green";
428
+ var scaleColor = "green";
429
+
430
+ var bppError = "";
431
+ var scaleError = "";
432
+
433
+
434
+ if (imgBPP > 0.5){
435
+ cssColor = "red";
436
+ bppColor = "red";
437
+ bppError = "The image has a VERY large \'Bytes per pixel\' score, trying optimising the image using https://tinypng.com/.";
438
+ }
439
+ else if (imgBPP > 0.2){
440
+ cssColor = "orange";
441
+ bppColor = "orange";
442
+ bppError = "The image has a large \'Bytes per pixel\' score, trying optimising the image using https://tinypng.com/.";
443
+ }
444
+
445
+ if (imgScl > 1.2){
446
+ cssColor = "red";
447
+ scaleColor = "red";
448
+ scaleError = "The image size is smaller than the size shown on screen this may cause the image to appear blurry and low quality.";
449
+ }
450
+ else if (imgScl < 0.5){
451
+ cssColor = "red";
452
+ scaleColor = "red";
453
+ scaleError = "The image size is VERY large compared to the size shown on screen, this means unnecessary kb's are being downloaded. Try resizing the image in photoshop or other image editing software.";
454
+ }
455
+ else if (imgScl < 0.8){
456
+ cssColor = "orange";
457
+ scaleColor = "orange";
458
+ scaleError = "The image size is large compared to the size shown on screen, this means unnecessary kb's are being downloaded. Try resizing the image in photoshop or other image editing software.";
459
+ }
460
+
461
+ console.log("%c %c "+imgElem.src,'background: url('+imgElem.src+'); border: 3px solid '+cssColor+'; line-height: 30px; width: 30px; background-size: cover;', 'background-color: transparent');
462
+
463
+ if(bppError != ""){
464
+ console.log('%c %c'+bppError , 'background-color: ' + bppColor + '; margin-right: 10px', 'background-color: transparent');
465
+ }
466
+ if(scaleError != ""){
467
+ console.log('%c %c'+scaleError , 'background-color: ' + scaleColor + '; margin-right: 10px', 'background-color: transparent');
468
+ }
469
+
470
+ console.table({
471
+ Image: {"Dimensions": imgW + "x" + imgH, "Scaled to": imgW2 + "x" + imgH2, "Scale": imgScl, "Filesize": imgFSize2 + "Kb", "Bytes per pixel": imgBPP}
472
+ });
473
+
474
+ console.groupEnd();
475
+ }
476
+ }
477
+ else {
478
+ console.log('%c %c'+imgElem.src+' not loaded' , 'background-color: red; margin-right: 10px', 'background-color: transparent');
479
+ }
480
+ }
481
+ };
482
+ xhr.send(null);
483
+
484
+
485
+ }
486
+ });
487
+
488
+ // Add to dom here
489
+ let integrationTestsArr = [];
490
+ if(typeof window.integrationTests != "undefined"){
491
+
492
+ window.integrationTests.forEach(function(entry) {
493
+ if(entry['Total'] != 0 && entry['Type'] != "warning" ){
494
+ integrationTestsArr.push(entry['Test']);
495
+ }
496
+ });
497
+ }
498
+
499
+ if (integrationTestsArr.length != 0) {
500
+
501
+ let displayComp = document.querySelector('#vmtests-display');
502
+
503
+ if(displayComp != null){
504
+
505
+ displayComp.innerHTML = `<div class="container">
506
+ <h2>Integration notes</h2>
507
+ <ul id="integrationTests"></ul>
508
+ </div>`;
509
+
510
+ let integrationTests = document.getElementById('integrationTests');
511
+
512
+ if(integrationTests != null){
513
+
514
+ integrationTestsArr.forEach(function(test) {
515
+
516
+ integrationTests.innerHTML += '<li>'+test+'</li>';
517
+
518
+ });
519
+ }
520
+ }
521
+ }
522
+
523
+ return null
524
+ }
525
+
526
+ export default integrationTests;
@@ -171,9 +171,20 @@ export const setupBasicTable = (component, table, form, pagination): void => {
171
171
  getLargestLastColWidth(component, table);
172
172
  getRowHeight(component, table);
173
173
  }
174
+
175
+ highlightRows(component);
174
176
  };
175
177
 
176
178
  // #region Basic table fnctions
179
+ export const highlightRows = (component): void => {
180
+
181
+ Array.from(component.querySelectorAll('tr[data-highlight]')).forEach((row) => {
182
+ row.insertAdjacentHTML('afterend',`<tr role="presentation" class="tr--highlight">
183
+ <td colspan="100%"><i class="fa-solid fa-star"></i> ${row.getAttribute('data-highlight')}</td>
184
+ </tr>`);
185
+ });
186
+ }
187
+
177
188
  export const transferAttributes = (component, pagination): void => {
178
189
  if (component.hasAttribute('data-total')) pagination.setAttribute('data-total', component.getAttribute('data-total'));
179
190
  if (component.hasAttribute('data-page')) pagination.setAttribute('data-page', component.getAttribute('data-page'));
@@ -289,7 +300,7 @@ export const createMobileButton = (component, table): void => {
289
300
  const preExpanded = row.getAttribute('data-view') === 'full' ? 'aria-expanded' : '';
290
301
  row.insertAdjacentHTML(
291
302
  'afterbegin',
292
- `<td class="${component.hasAttribute('data-expandable') ? 'td--fixed ' : ''}td--expand"><button class="btn btn-compact btn-secondary btn-sm" data-expand-button ${preExpanded} data-index="${index}">Expand</button></td>`
303
+ `<td class="${component.hasAttribute('data-expandable') ? 'td--fixed ' : ''}td--expand"><button class="btn btn-compact btn-secondary btn-sm fa-circle-plus" data-expand-button ${preExpanded} data-index="${index}">Expand</button></td>`
293
304
  );
294
305
  });
295
306
 
@@ -300,6 +311,16 @@ export const createMobileButton = (component, table): void => {
300
311
 
301
312
  button.toggleAttribute('aria-expanded');
302
313
 
314
+ if(button.classList.contains('fa-circle-plus')){
315
+ button.classList.remove('fa-circle-plus');
316
+ button.classList.add('fa-circle-minus');
317
+ }
318
+ else {
319
+
320
+ button.classList.remove('fa-circle-minus');
321
+ button.classList.add('fa-circle-plus');
322
+ }
323
+
303
324
  if (tableRow.getAttribute('data-view') == 'full') tableRow.setAttribute('data-view', 'default');
304
325
  else tableRow.setAttribute('data-view', 'full');
305
326
 
@@ -5,6 +5,7 @@ import createDataLayer from './modules/data-layer';
5
5
 
6
6
  import createDynamicEvents from './modules/dynamicEvents';
7
7
  import videoSupport from './modules/videos';
8
+ import integrationTests from './modules/integration-tests';
8
9
 
9
10
  const components = [
10
11
  'accordion',
@@ -46,6 +47,19 @@ const components = [
46
47
 
47
48
  ];
48
49
 
50
+ const testDomains = ["localhost"];
51
+
52
+ if (testDomains.includes(window.location.hostname)) {
53
+
54
+ import(`../js/modules/integration-tests.js`)
55
+ .then((module) => {
56
+ window.iamTest = ():void => { integrationTests() };
57
+ })
58
+ .catch((err) => {
59
+ console.log(err.message);
60
+ });
61
+ }
62
+
49
63
  // Attach classes to dom elements
50
64
  document.addEventListener('DOMContentLoaded', async (): void => {
51
65
  createDataLayer();