gatsby-core-theme 1.3.0 → 1.4.2

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 (80) hide show
  1. package/.storybook/main.js +2 -3
  2. package/.storybook/preview.js +1 -4
  3. package/CHANGELOG.md +94 -0
  4. package/gatsby-node.esm.js +59 -19
  5. package/jest.config.js +1 -0
  6. package/package.json +1 -1
  7. package/src/components/app.js +12 -7
  8. package/src/components/atoms/archive/items/index.js +1 -1
  9. package/src/components/atoms/author/index.js +3 -2
  10. package/src/components/atoms/author-box/author-box.test.js +1 -5
  11. package/src/components/atoms/author-box/index.js +42 -13
  12. package/src/components/atoms/breadcrumbs/index.js +8 -4
  13. package/src/components/atoms/button/button.test.js +7 -0
  14. package/src/components/atoms/button/index.js +10 -3
  15. package/src/components/atoms/carousel/arrow/index.js +3 -2
  16. package/src/components/atoms/carousel/pagination-item/index.js +3 -2
  17. package/src/components/atoms/collapse/index.js +3 -1
  18. package/src/components/atoms/custom-select/index.js +2 -1
  19. package/src/components/atoms/logo/index.js +2 -2
  20. package/src/components/atoms/menu/items/index.js +6 -0
  21. package/src/components/atoms/menu/items/item/index.js +5 -4
  22. package/src/components/atoms/menu/menu-icon/index.js +4 -4
  23. package/src/components/atoms/module-title/index.js +2 -1
  24. package/src/components/atoms/not-found/index.js +14 -0
  25. package/src/components/atoms/not-found/not-found.module.scss +16 -0
  26. package/src/components/atoms/open-graph/index.js +5 -5
  27. package/src/components/atoms/operator-cta/index.js +15 -5
  28. package/src/components/atoms/operator-cta/{operator-cta.test.disabled.js → operator-cta.test.js} +12 -1
  29. package/src/components/atoms/operator-info-block/index.js +8 -1
  30. package/src/components/atoms/search/autocomplete/operator.js +1 -1
  31. package/src/components/atoms/spotlights/index.js +15 -4
  32. package/src/components/molecules/carousel/default-slide/index.js +4 -0
  33. package/src/components/molecules/counter/index.js +2 -2
  34. package/src/components/molecules/footer/index.js +6 -2
  35. package/src/components/molecules/header/header.test.js +0 -1
  36. package/src/components/molecules/link-list/index.js +9 -1
  37. package/src/components/molecules/main/index.js +3 -1
  38. package/src/components/molecules/menu/index.js +5 -1
  39. package/src/components/molecules/operator-banner/index.js +17 -7
  40. package/src/components/molecules/operator-banner/operator-banner.test.js +1 -1
  41. package/src/components/molecules/pagination/index.js +16 -5
  42. package/src/components/molecules/pagination/pagination.test.js +3 -3
  43. package/src/components/molecules/pagination/with-midpoints.js +41 -17
  44. package/src/components/molecules/pagination/with-midpoints.test.js +7 -8
  45. package/src/components/molecules/search/index.js +14 -3
  46. package/src/components/molecules/slider/index.js +27 -3
  47. package/src/components/molecules/toplist/default-row/index.js +27 -4
  48. package/src/components/organisms/accordion/accordion.test.js +3 -3
  49. package/src/components/organisms/accordion/index.js +1 -1
  50. package/src/components/organisms/anchor/index.js +2 -1
  51. package/src/components/organisms/archive/archive.test.js +8 -1
  52. package/src/components/organisms/archive/index.js +12 -12
  53. package/src/components/organisms/cards/cards.stories.js +1 -0
  54. package/src/components/organisms/cards/index.js +1 -1
  55. package/src/components/organisms/carousel/index.js +16 -17
  56. package/src/components/organisms/cookie-consent/cookie-consent.stories.js +6 -1
  57. package/src/components/organisms/cookie-consent/index.js +2 -0
  58. package/src/components/organisms/form/index.js +1 -0
  59. package/src/components/organisms/navigation/index.js +4 -4
  60. package/src/components/organisms/search/index.js +1 -1
  61. package/src/components/organisms/toplist/index.js +15 -19
  62. package/src/components/organisms/toplist/list/index.js +22 -29
  63. package/src/components/pages/body/index.js +9 -5
  64. package/src/components/pages/search/index.js +36 -1
  65. package/src/components/pages/tracker/index.js +8 -4
  66. package/src/constants/pick-keys.js +2 -0
  67. package/src/context/TranslationsProvider.js +9 -0
  68. package/src/helpers/processor/index.js +20 -3
  69. package/src/helpers/processor/processor.test.js +14 -0
  70. package/src/hooks/lazy-image/lazy-image.stories.js +1 -0
  71. package/src/hooks/link/index.js +2 -0
  72. package/src/hooks/link/link.test.js +9 -0
  73. package/src/hooks/modal/modal-content.js +7 -3
  74. package/src/hooks/modal/modal.test.js +3 -2
  75. package/src/hooks/tabs/index.js +4 -1
  76. package/src/hooks/tabs/tab/tab-list.js +4 -1
  77. package/src/hooks/tabs/tab/tab.js +11 -2
  78. package/src/pages/sitemap/index.js +77 -0
  79. package/src/pages/sitemap/sitemap.module.scss +21 -0
  80. package/tests/factories/relations/operator.factory.js +33 -0
@@ -21,9 +21,7 @@ module.exports = {
21
21
  {
22
22
  loader: require.resolve('sass-resources-loader'),
23
23
  options: {
24
- resources: [
25
- path.resolve(__dirname, '../src/styles/globals.scss'),
26
- ],
24
+ resources: [path.resolve(__dirname, '../src/styles/globals.scss')],
27
25
  },
28
26
  },
29
27
  ],
@@ -46,6 +44,7 @@ module.exports = {
46
44
  '~helpers': path.resolve(__dirname, '../src/helpers'),
47
45
  '~hooks': path.resolve(__dirname, '../src/hooks'),
48
46
  '~tests': path.resolve(__dirname, '../tests'),
47
+ '~context': path.resolve(__dirname, '../src/context'),
49
48
  };
50
49
 
51
50
  config.resolve.alias['$virtual/lazy-client-sync-requires'] = path.resolve(
@@ -19,10 +19,7 @@ export const parameters = {
19
19
  options: {
20
20
  storySort: {
21
21
  method: 'alphabetical',
22
- order: [
23
- 'Gatsby-Theme',
24
- ['Atoms', 'Molecules', 'Organisms', 'Pages', 'Hooks']
25
- ],
22
+ order: ['Gatsby-Theme', ['Atoms', 'Molecules', 'Organisms', 'Pages', 'Hooks']],
26
23
  },
27
24
  },
28
25
  };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,97 @@
1
+ ## [1.4.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.4.1...v1.4.2) (2021-11-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * removed commented code in tracker ([0071494](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/00714945fc9737ffb90f79a2b068ac74ef450d34))
7
+
8
+ ## [1.4.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.4.0...v1.4.1) (2021-11-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * authors added on contact us page ([39ab905](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/39ab9058ca760444ae9ed9fdab8ca9be431e3627))
14
+ * fix demo search data ([48e4464](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/48e4464ed1f5ed5587a04ea4fe120daaed50c1e3))
15
+ * fix loadmore on search ([92e9ed1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/92e9ed1e5e6b315c513f215926bce003bebdf836))
16
+ * fixed an object on context page ([762d1b7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/762d1b7690d758871ed30fb98a713578fd27b1b2))
17
+ * slider fixed bug ([7ac3faf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7ac3faf26b5cb8fd0e098bb53a4f8962b747dbbd))
18
+ * throttle silder ([c8d8c52](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c8d8c527e482adb6d70b44a40e715c5d188fdad9))
19
+
20
+
21
+ ### Code Refactoring
22
+
23
+ * add gtm classes ([65cc36a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/65cc36a5e821e1a5bab75dafcf28daca04a189a3))
24
+ * changes to classnames ([e90ae2e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e90ae2e71735ba56106e269ed12eef8cd5ad460e))
25
+ * more gtm classes ([6cbfb8e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6cbfb8efb1007fbb461768c02b6d6e1610d60afd))
26
+
27
+
28
+ ### Config
29
+
30
+ * merge master ([459dea5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/459dea54398ebaf72d9ec832f60caa7ddc6518a2))
31
+ * merge master ([bc1c508](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/bc1c50856d7007c13dd98480524f3a6945fe00aa))
32
+
33
+
34
+ * Merge branch 'tm-2478-search' into 'master' ([05280e0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/05280e01f40e1c8e853e578aedde5a35e94cf4df))
35
+ * Merge branch 'tm-2565-authors' into 'master' ([a18e732](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a18e7327e918ee4b096419df99b35f48163182a6))
36
+ * Merge branch 'tm-2462-gtm-classes' into 'master' ([5886be6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5886be6b0751abe09705b3bf12a8447192ba314a))
37
+ * Merge branch 'tm-2538-slider-fixed-bug' into 'master' ([269a1a6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/269a1a6631ec390902fe77c8ad59208d08c5d015))
38
+
39
+
40
+ ### Tests
41
+
42
+ * changes to test script ([ea920df](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ea920dfa509210968b0348de365ec405b3432e88))
43
+ * changes to test script ([e0a0adc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e0a0adcf062a8601b89eca75c72f25633a97120f))
44
+ * changes to test script ([9c14c64](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9c14c64c0eeefde4890edb2c5cb1a67af5d48c67))
45
+
46
+ # [1.4.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.3.1...v1.4.0) (2021-10-29)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * added a check for profile page link ([cb687c3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cb687c3cf6a7aef0a232090cd42296d74eaafad4))
52
+ * added operator name placeholder in tracker main text ([fc03455](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fc034552bcb32b6d9ea199646fb0b6ea59de9ce5))
53
+ * added scroll to slider ([6e369b9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6e369b9543db4e69ff77778ad0c12a8883f52604))
54
+ * merged master branch ([c54d5ee](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c54d5ee8456c9aad92df30025177e7467cea1a7e))
55
+ * site schema to context ([61b6567](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/61b6567e8305036509a021855b0626f670717771))
56
+
57
+
58
+ ### Code Refactoring
59
+
60
+ * fix tests ([6c11800](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6c1180048827fd5da419868040e2dafd0f27c4db))
61
+ * merge master into branch ([4d93726](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4d93726d4e15492ecbe5acdfad34d99f2d40dd86))
62
+ * merge master into branch ([34b8232](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/34b8232419d43edba2a2e4f6dc3b45d36fe56c88))
63
+ * moved translations to global context ([53b4208](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/53b42087a3283a797ad4ae7e113fce4b350d0703))
64
+ * replace translationsporvider at test with empty object check ([8bdcd5f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8bdcd5f6457ce02cb6e915439b86f2248431156a))
65
+ * return sports variable after merging branches ([f3669b9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f3669b91b58ac6388f005bb227a883e5e414b7f9))
66
+ * update components to remove build errors ([9b18785](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9b187858f04a9cbbde6579a89a98b0fec3841de8))
67
+ * update components to remove build errors ([088a42a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/088a42ad9a7b9dc6d50577a362ccef43dca68374))
68
+
69
+
70
+ * Merge branch 'tm-2565-site-schema-to-context' into 'master' ([7ea2653](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7ea26534ab12d47b7fb3940fb8092d130daf611c))
71
+ * Merge branch 'master' into my branch ([2c55d4a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2c55d4a2fec98a3049f361eebe4d134fe6aa2811))
72
+ * Merge branch 'tm-2564-404page' into 'master' ([41c010b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/41c010b7612b90c9a4f7a9e831080225e7fc4671))
73
+ * Merge branch 'master' into 404 MR ([1336ef7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1336ef79ddf93c091116b6516965270a21d428f9))
74
+ * Merge branch 'tm-2539-html-sitemap' into 'master' ([4a98f89](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4a98f895b9efb54c76a35649a217c7d98d6c7ed1))
75
+ * Merge branch 'tm-2543-fix-translation-refactor' into 'master' ([f0d67a3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f0d67a30134c2db528e1c6c0c02e5fe4672a2b59))
76
+ * Merge branch 'tm-2543-translations-refactoring' into 'master' ([4eb1f7d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4eb1f7d05cf6e5404968746218c0d90552b5feaf))
77
+ * Merge branch 'tm-2517-tracker-page' into 'master' ([0329e5e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0329e5ef286cdd192c741639f0df841a89f60c28))
78
+ * Merge branch 'master' into 'tm-2543-translations-refactoring' ([fe32751](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fe3275166f21d1136716fb8303d8abee96aab302))
79
+ * Merge branch 'tm-2538-slides-change-onscroll' into 'master' ([12a5d4e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/12a5d4e7a6273e9ae0445446fd00dbc47ce33b75))
80
+ * Merge branch 'tm-2551-update-theme-to-fix-build-errors' into 'master' ([00f7c27](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/00f7c27422f3575f3161b42d2ef16c27d64c6a4c))
81
+
82
+
83
+ ### Features
84
+
85
+ * added html sitemap page ([cc30b06](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cc30b06d39400a8464e65ba08d272cffff0fe72b))
86
+ * replaced static 404 with data from hercules ([37c2172](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/37c21725e427357e84bef00e7a0c4cb9d1bdcdde))
87
+
88
+ ## [1.3.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.3.0...v1.3.1) (2021-10-19)
89
+
90
+
91
+ ### Bug Fixes
92
+
93
+ * author component ([7d64a02](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7d64a02746c64a87fd56b15cfe3040184ef69207))
94
+
1
95
  # [1.3.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.2.6...v1.3.0) (2021-10-18)
2
96
 
3
97
 
@@ -5,7 +5,7 @@ import { cloneDeep, chunk } from 'lodash';
5
5
  import chalk from 'chalk';
6
6
  import { getData, getLocalData } from './src/helpers/api';
7
7
  import { generateTrackerLink } from './src/helpers/generators';
8
- import processor from './src/helpers/processor';
8
+ import processor, { processSitemapPages } from './src/helpers/processor';
9
9
 
10
10
  const fs = require('fs');
11
11
 
@@ -15,13 +15,18 @@ const path = require('path');
15
15
 
16
16
  let preconnectLinks = null;
17
17
  let pages = null;
18
+ let htmlSitemapPages = null;
18
19
  let marketSections = [];
19
20
  let prefilledModules = [];
20
21
  let siteInfo = null;
21
22
  let operators = null;
22
23
  let translations = null;
23
24
  let languageKey = null;
25
+ let context404 = null;
24
26
  let sports = null;
27
+ let siteSchema = null;
28
+ let templates = null;
29
+ let authors = null;
25
30
 
26
31
  function createArchivePage(pageObject, marketSections, prefilledModules, createPage) {
27
32
  const archiveModuleIndex = pageObject.sections.main.modules.findIndex(
@@ -143,8 +148,10 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
143
148
  // add data to modules
144
149
  const processed = processor.run(response, themeOptions, fs);
145
150
  pages = processed.pages;
151
+ htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
146
152
  siteInfo = processed.general;
147
153
  operators = processed.relations.operator;
154
+ templates = processed.templates;
148
155
  // eslint-disable-next-line prefer-destructuring
149
156
  languageKey = Object.keys(processed.relations.translations)[0];
150
157
  translations = processed.relations.translations[languageKey];
@@ -185,7 +192,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
185
192
  const processedPage = page;
186
193
  processedPage.preconnect_links = preconnectLinks;
187
194
 
188
- page.translations = translations;
195
+ page.translations = {};
189
196
 
190
197
  if (hasArchiveModule(page)) {
191
198
  createArchivePage(page, marketSections, prefilledModules, createPage);
@@ -195,20 +202,44 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
195
202
  if (page.type === 'event' && !page.relation.event) {
196
203
  return;
197
204
  }
205
+ siteSchema = response.schema[page['market_id']];
206
+ authors = response.authors;
198
207
 
199
- createPage({
200
- path: page.path.charAt(0) === '/' ? page.path : `/${page.path}`,
201
- component: require.resolve(
202
- page.path === 'preview' ? './src/components/app-preview.js' : './src/components/app.js'
203
- ),
204
- context: {
205
- page,
206
- marketSections,
207
- prefilledModules,
208
- siteInfo,
209
- ...themeOptions,
210
- },
211
- });
208
+ const contextData = {
209
+ page,
210
+ marketSections,
211
+ prefilledModules,
212
+ siteInfo,
213
+ ...themeOptions,
214
+ };
215
+
216
+ if (page.path === 'contact-us') {
217
+ createPage({
218
+ path: `/${page.path}`,
219
+ component: require.resolve('./src/components/app.js'),
220
+ context: {
221
+ ...contextData,
222
+ siteSchema,
223
+ authors,
224
+ },
225
+ });
226
+ } else if (page.path === '404') {
227
+ context404 = contextData;
228
+ } else {
229
+ createPage({
230
+ path: page.path.charAt(0) === '/' ? page.path : `/${page.path}`,
231
+ component: require.resolve(
232
+ page.path === 'preview'
233
+ ? './src/components/app-preview.js'
234
+ : './src/components/app.js'
235
+ ),
236
+ context: {
237
+ ...contextData,
238
+ siteSchema,
239
+ translations,
240
+ },
241
+ });
242
+ }
212
243
 
213
244
  // Operator tracker pages
214
245
  if (page.type === 'operator') {
@@ -257,10 +288,12 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
257
288
 
258
289
  exports.onCreatePage = ({ page, actions }) => {
259
290
  const { createPage } = actions;
260
- if (page.path.includes('404')) {
291
+
292
+ if (page.path.includes('sitemap')) {
261
293
  const pageNotFoundData = {
262
- meta_title: 'Page not found',
263
- template: '404',
294
+ meta_title: 'Sitemap',
295
+ template: 'sitemap',
296
+ title: 'Site Map',
264
297
  type: 'page',
265
298
  sections: {
266
299
  main: null,
@@ -275,10 +308,16 @@ exports.onCreatePage = ({ page, actions }) => {
275
308
  },
276
309
  };
277
310
  page = Object.assign(pageNotFoundData, page); // eslint-disable-line no-param-reassign
311
+ createPage({
312
+ path: page.path,
313
+ component: require.resolve('./src/pages/sitemap/'),
314
+ context: { page, siteInfo, marketSections, sitemapData: { ...htmlSitemapPages }, templates },
315
+ });
316
+ } else if (page.path.includes('404')) {
278
317
  createPage({
279
318
  path: page.path,
280
319
  component: require.resolve('./src/pages/404/'),
281
- context: { page, marketSections, prefilledModules, siteInfo },
320
+ context: context404,
282
321
  });
283
322
  } else {
284
323
  createPage({
@@ -300,6 +339,7 @@ exports.onCreateWebpackConfig = ({ actions }) => {
300
339
  '~helpers': path.resolve(__dirname, 'src/helpers'),
301
340
  '~hooks': path.resolve(__dirname, 'src/hooks'),
302
341
  '~tests': path.resolve(__dirname, 'tests'),
342
+ '~context': path.resolve(__dirname, 'src/context'),
303
343
  },
304
344
  },
305
345
  });
package/jest.config.js CHANGED
@@ -14,6 +14,7 @@ module.exports = {
14
14
  '^~helpers(.*)$': '<rootDir>/src/helpers$1',
15
15
  '^~hooks(.*)$': '<rootDir>/src/hooks$1',
16
16
  '^~tests(.*)$': '<rootDir>/tests$1',
17
+ '^~context(.*)$': '<rootDir>/src/context$1',
17
18
  // JSON Data
18
19
  'data.json': '<rootDir>/__mocks__/search-data.json',
19
20
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.3.0",
3
+ "version": "1.4.2",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,21 +1,26 @@
1
+ /* eslint-disable react/forbid-prop-types */
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
-
4
+ import TranslationsProvider from '~context/TranslationsProvider';
4
5
  import Body from '~pages/body';
5
6
  import Head from '~organisms/head';
6
7
 
7
- const App = ({ pageContext }) => (
8
- <>
9
- <Head page={pageContext.page} siteInfo={pageContext.siteInfo} />
10
- <Body pageContext={pageContext} />
11
- </>
12
- );
8
+ const App = ({ pageContext }) => {
9
+ const { translations } = pageContext;
10
+ return (
11
+ <TranslationsProvider value={{ translations }}>
12
+ <Head page={pageContext.page} siteInfo={pageContext.siteInfo} />
13
+ <Body pageContext={pageContext} />
14
+ </TranslationsProvider>
15
+ );
16
+ };
13
17
 
14
18
  App.propTypes = {
15
19
  pageContext: PropTypes.shape({
16
20
  page: PropTypes.shape({
17
21
  id: PropTypes.number,
18
22
  }),
23
+ translations: PropTypes.object,
19
24
  siteInfo: PropTypes.shape({
20
25
  robots_txt: PropTypes.string,
21
26
  site_logo: PropTypes.string,
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import Cards from '~organisms/cards';
5
5
 
6
6
  // Test included with archive & cards test
7
- const Items = ({ module , page }) => <Cards module={module} page={page} />;
7
+ const Items = ({ module, page }) => <Cards module={module} page={page} />;
8
8
 
9
9
  Items.propTypes = {
10
10
  module: PropTypes.shape({
@@ -1,3 +1,4 @@
1
+ /* eslint-disable arrow-body-style */
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
 
@@ -19,7 +20,7 @@ const Author = ({
19
20
  <>
20
21
  {link && icon && (
21
22
  <div className={styles.authorIcon}>
22
- <a href={link} target="_blank" rel="noreferrer">
23
+ <a href={link} target="_blank" rel="noreferrer" className="author-gtm">
23
24
  {icon}
24
25
  </a>
25
26
  </div>
@@ -31,7 +32,7 @@ const Author = ({
31
32
  (authorProfile ? (
32
33
  <>
33
34
  {`${prefix} `}
34
- <Link to={authorProfile} title={name}>
35
+ <Link to={authorProfile} className="author-gtm" title={name}>
35
36
  {name}
36
37
  </Link>
37
38
  </>
@@ -2,17 +2,13 @@ import React from 'react';
2
2
  import { render, cleanup } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
5
- import getPageData from '~tests/factories/pages/default.factory';
6
5
  import { authorObject } from '~tests/factories/modules/author-box.factory';
7
6
  import AuthorBox from '.';
8
7
 
9
8
  describe('author box component', () => {
10
9
  test('render', () => {
11
- const page = getPageData;
12
10
  const author = authorObject;
13
- const { container, getByText } = render(
14
- <AuthorBox author={author} translations={page.translations} />
15
- );
11
+ const { container, getByText } = render(<AuthorBox author={author} />);
16
12
  expect(container).toBeTruthy();
17
13
  // Logo
18
14
  expect(container.querySelector('img')).toBeFalsy();
@@ -1,17 +1,19 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { FaInstagram, FaFacebookSquare, FaTwitter, FaLinkedin } from 'react-icons/fa';
3
3
  import PropTypes from 'prop-types';
4
4
  import { translate } from '~helpers/getters';
5
5
  import styles from './author-box.module.scss';
6
6
  import LazyImage from '~hooks/lazy-image';
7
7
  import Link from '~hooks/link';
8
+ import { Context } from '~context/TranslationsProvider';
8
9
 
9
- export default function AuthorBox({ author, translations }) {
10
+ export default function AuthorBox({ author }) {
11
+ const { translations } = useContext(Context) || {};
10
12
  const socialLinks = [
11
- { link: author.facebook_profile, icon: <FaFacebookSquare /> },
12
- { link: author.instagram_profile, icon: <FaInstagram /> },
13
- { link: author.linkedin_profile, icon: <FaLinkedin /> },
14
- { link: author.twitter_profile, icon: <FaTwitter /> },
13
+ { id: 'fb', link: author.facebook_profile, icon: <FaFacebookSquare /> },
14
+ { id: 'ig', link: author.instagram_profile, icon: <FaInstagram /> },
15
+ { id: 'li', link: author.linkedin_profile, icon: <FaLinkedin /> },
16
+ { id: 'tw', link: author.twitter_profile, icon: <FaTwitter /> },
15
17
  ];
16
18
  return (
17
19
  <div className={styles.container}>
@@ -30,17 +32,32 @@ export default function AuthorBox({ author, translations }) {
30
32
  <div className={styles.links}>
31
33
  <p className={styles.contactLinks}>
32
34
  {author.email_address && (
33
- <a href={`mailto:${author.email_address}`} target="_blank" rel="noreferrer">
35
+ <a
36
+ href={`mailto:${author.email_address}`}
37
+ className="author-gtm"
38
+ target="_blank"
39
+ rel="noreferrer"
40
+ >
34
41
  Email
35
42
  </a>
36
43
  )}
37
44
  {author.personal_website && (
38
- <a href={author.personal_website} target="_blank" rel="noreferrer">
45
+ <a
46
+ href={author.personal_website}
47
+ className="author-gtm"
48
+ target="_blank"
49
+ rel="noreferrer"
50
+ >
39
51
  Website
40
52
  </a>
41
53
  )}
42
54
  {author.additional_url && (
43
- <a href={author.additional_url} target="_blank" rel="noreferrer">
55
+ <a
56
+ href={author.additional_url}
57
+ className="author-gtm"
58
+ target="_blank"
59
+ rel="noreferrer"
60
+ >
44
61
  Contact
45
62
  </a>
46
63
  )}
@@ -50,16 +67,28 @@ export default function AuthorBox({ author, translations }) {
50
67
  .filter((socialLink) => socialLink.link)
51
68
  .map((filteredLinks) => (
52
69
  // eslint-disable-next-line jsx-a11y/control-has-associated-label
53
- <a href={filteredLinks.link} target="_blank" rel="noreferrer">
70
+ <a
71
+ href={filteredLinks.link}
72
+ className="author-gtm"
73
+ target="_blank"
74
+ rel="noreferrer"
75
+ key={`author-box-link-${filteredLinks.id}`}
76
+ >
54
77
  {filteredLinks.icon}
55
78
  </a>
56
79
  ))}
57
80
  </p>
58
81
  <p className={styles.biography}>{author.biography}</p>
59
82
  </div>
60
- <Link to={author.profile_page_path} title="Read More" className={styles.button}>
61
- {translate(translations, 'read_more', 'Read More')}
62
- </Link>
83
+ {author.profile_page_path && (
84
+ <Link
85
+ to={author.profile_page_path}
86
+ title="Read More"
87
+ className={`${styles.button} author-gtm`}
88
+ >
89
+ {translate(translations, 'read_more', 'Read More')}
90
+ </Link>
91
+ )}
63
92
  </div>
64
93
  </div>
65
94
  </div>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
 
3
3
  import PropTypes from 'prop-types';
4
4
  import Link from '~hooks/link';
@@ -6,8 +6,11 @@ import Link from '~hooks/link';
6
6
  import styles from './breadcrumbs.module.scss';
7
7
  import keygen from '~helpers/keygen';
8
8
  import { translate } from '~helpers/getters';
9
+ import { Context } from '~context/TranslationsProvider';
9
10
 
10
11
  function Breadcrumbs({ page, separator = <span> / </span> }) {
12
+ const { translations } = useContext(Context) || {};
13
+
11
14
  if (page.path === '/') {
12
15
  return <></>;
13
16
  }
@@ -15,8 +18,8 @@ function Breadcrumbs({ page, separator = <span> / </span> }) {
15
18
  return (
16
19
  <ol className={styles.breadcrumbs}>
17
20
  <li className={styles.item}>
18
- <Link to="/" title="Home">
19
- {translate(page.translations, 'Home', 'Home')}
21
+ <Link to="/" title="Home" className="breadcrumbs-gtm">
22
+ {translate(translations, 'Home', 'Home')}
20
23
  </Link>
21
24
  {separator}
22
25
  </li>
@@ -24,7 +27,7 @@ function Breadcrumbs({ page, separator = <span> / </span> }) {
24
27
  page.breadcrumbs.map((breadcrumb) => (
25
28
  <li key={keygen()} className={styles.item}>
26
29
  {breadcrumb.path ? (
27
- <Link to={breadcrumb.path} title={breadcrumb.label}>
30
+ <Link to={breadcrumb.path} title={breadcrumb.label} className="breadcrumbs-gtm">
28
31
  {breadcrumb.label}
29
32
  </Link>
30
33
  ) : (
@@ -44,6 +47,7 @@ Breadcrumbs.propTypes = {
44
47
  path: PropTypes.string,
45
48
  breadcrumbs: PropTypes.arrayOf(PropTypes.object),
46
49
  vanity_label: PropTypes.string,
50
+ translations: PropTypes.shape({}),
47
51
  }).isRequired,
48
52
  separator: PropTypes.element,
49
53
  };
@@ -32,6 +32,13 @@ describe('Button Component', () => {
32
32
  expect(container.querySelectorAll('a.primary')).toHaveLength(0);
33
33
  expect(getByText('sample text').closest('a')).toHaveAttribute('href', '/example');
34
34
  });
35
+
36
+ test('check for GTM class', () => {
37
+ const { getByText } = render(
38
+ <Button to="/example" btnText="sample text" gtmClass="sample-gtm" primaryColor={false} />
39
+ );
40
+ expect(getByText('sample text').closest('a').classList.contains('sample-gtm')).toBe(true);
41
+ });
35
42
  });
36
43
  afterEach(() => {
37
44
  cleanup();
@@ -18,6 +18,7 @@ function Button({
18
18
  disabled = false,
19
19
  tertiary = false,
20
20
  noStyle = false,
21
+ gtmClass = '',
21
22
  }) {
22
23
  const classes = `${styles.ctaBtn} ${primaryColor ? styles.primary : styles.secondary} ${
23
24
  invertColors && styles.invertColors
@@ -29,7 +30,12 @@ function Button({
29
30
 
30
31
  if (isButton) {
31
32
  return (
32
- <button type="submit" onClick={onClick} className={classes} disabled={disabled}>
33
+ <button
34
+ type="submit"
35
+ onClick={onClick}
36
+ className={`${classes} ${gtmClass} btn-cta`}
37
+ disabled={disabled}
38
+ >
33
39
  {btnText}
34
40
  </button>
35
41
  );
@@ -37,7 +43,7 @@ function Button({
37
43
 
38
44
  if (isInternalLink) {
39
45
  return (
40
- <Link className={classes} to={to} title={btnTitle} aria-label={btnTitle}>
46
+ <Link className={`${classes} ${gtmClass}`} to={to} title={btnTitle} aria-label={btnTitle}>
41
47
  {btnText}
42
48
  </Link>
43
49
  );
@@ -50,7 +56,7 @@ function Button({
50
56
  aria-label={btnTitle}
51
57
  onClick={onClick}
52
58
  target={!isAnchorLink && targetBlank ? '_blank' : ''}
53
- className={classes}
59
+ className={`${classes} ${gtmClass}`}
54
60
  rel="nofollow noreferrer"
55
61
  >
56
62
  {btnText}
@@ -72,6 +78,7 @@ Button.propTypes = {
72
78
  disabled: PropTypes.bool,
73
79
  tertiary: PropTypes.bool,
74
80
  noStyle: PropTypes.bool,
81
+ gtmClass: PropTypes.string,
75
82
  };
76
83
 
77
84
  export default Button;
@@ -3,10 +3,10 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import styles from './arrow.module.scss';
5
5
 
6
- const Arrow = ({ direction, content = '', onClick, onKeyDown, disabled }) => (
6
+ const Arrow = ({ direction, content = '', onClick, onKeyDown, disabled, gtmClass = '' }) => (
7
7
  <button
8
8
  type="button"
9
- className={`${styles.arrow} ${styles[direction]}`}
9
+ className={`${styles.arrow} ${styles[direction]} ${gtmClass} carousel-arrow-gtm btn-cta`}
10
10
  onClick={onClick}
11
11
  onKeyDown={onKeyDown}
12
12
  disabled={disabled}
@@ -21,6 +21,7 @@ Arrow.propTypes = {
21
21
  onClick: PropTypes.func,
22
22
  onKeyDown: PropTypes.func,
23
23
  disabled: PropTypes.bool,
24
+ gtmClass: PropTypes.string,
24
25
  };
25
26
 
26
27
  export default Arrow;
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import styles from './pagination-item.module.scss';
5
5
  import keygen from '~helpers/keygen';
6
6
 
7
- const PaginationItem = ({ type, paginationHandler, slideIndex, totalSlides }) => {
7
+ const PaginationItem = ({ type, paginationHandler, slideIndex, totalSlides, gtmClass = '' }) => {
8
8
  const pages = [];
9
9
 
10
10
  for (let i = 0; i < totalSlides; i += 1) {
@@ -19,7 +19,7 @@ const PaginationItem = ({ type, paginationHandler, slideIndex, totalSlides }) =>
19
19
  type="button"
20
20
  tabIndex="0"
21
21
  aria-label={`Slide ${i + 1}`}
22
- className={classes}
22
+ className={`${classes} ${gtmClass} carousel-pagination-gtm btn-cta`}
23
23
  />
24
24
  );
25
25
  }
@@ -32,6 +32,7 @@ PaginationItem.propTypes = {
32
32
  paginationHandler: PropTypes.func,
33
33
  slideIndex: PropTypes.number,
34
34
  totalSlides: PropTypes.number,
35
+ gtmClass: PropTypes.string,
35
36
  };
36
37
 
37
38
  export default PaginationItem;
@@ -43,7 +43,9 @@ const Collapse = ({
43
43
  <button
44
44
  type="button"
45
45
  onClick={clickHandler}
46
- className={`${styles.button} ${maxHeightStyle !== 0 ? styles.invertArrow : ''}`}
46
+ className={`${styles.button} ${
47
+ maxHeightStyle !== 0 ? styles.invertArrow : ''
48
+ } collapse-gtm btn-cta`}
47
49
  >
48
50
  {buttonText}
49
51
  </button>