gatsby-core-theme 17.0.7 → 17.0.9

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [17.0.9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v17.0.8...v17.0.9) (2023-01-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add show more content ([61b3f28](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/61b3f2831d1f43f010cd96ec8289a75b0bcfd24f))
7
+ * added more tests and removed unused functions ([03bea87](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/03bea87f083f3d4a4af089961fc5918616618f6f))
8
+ * content component test ([82aec7a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/82aec7ac480f8f6ba16825071617a090228a7581))
9
+ * provide atuogenerate data to pages ([49753f9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/49753f96fbdaacadbb7735d3d54c10d0dbb15547))
10
+ * update tests ([1330c9c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1330c9cde3a5d4439d7dc9f84be039e4917c9fd3))
11
+
12
+
13
+ * Merge branch 'tm-3249-autogenerated' into 'master' ([5fbdd05](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5fbdd058e7b24eecd5ef239241650fb236ec7ba6))
14
+ * Merge branch 'tm-3255-content-module-show-more' into 'master' ([4f16893](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4f1689358055cac22ecc114383050aa499e1578c))
15
+
16
+ ## [17.0.8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v17.0.7...v17.0.8) (2023-01-02)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * added animation to tracker progress bar ([6df067e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6df067e8ab6ae525621434abc94ca5e9d409b6bc))
22
+ * card filter inactive ([2de397d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2de397d09495d4affea10261997b2d79a2dc212c))
23
+
1
24
  ## [17.0.7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v17.0.6...v17.0.7) (2022-12-28)
2
25
 
3
26
 
@@ -244,11 +244,14 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
244
244
  return;
245
245
  }
246
246
 
247
+ const template = templates[page.template_id];
248
+ const autogenerated = template && template.autogenerated_content;
247
249
  const contextData = {
248
250
  page,
249
251
  marketSections,
250
252
  prefilledModules,
251
253
  siteInfo,
254
+ autogenerated,
252
255
  siteSchema,
253
256
  translations,
254
257
  authors,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "17.0.7",
3
+ "version": "17.0.9",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { render, cleanup } from '@testing-library/react';
2
+ import { render, cleanup, fireEvent } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
-
5
4
  import { getSingleContentData } from '~tests/factories/modules/content.factory';
6
5
  import Content from '.';
7
6
 
@@ -10,7 +9,7 @@ describe('Content Component', () => {
10
9
  const correctData = getSingleContentData('h4');
11
10
  const { container } = render(<Content module={correctData} />);
12
11
  expect(container).toBeTruthy();
13
- expect(container.querySelectorAll('div.grid')).toHaveLength(1);
12
+ expect(container.querySelectorAll('div.content')).toHaveLength(1);
14
13
 
15
14
  // HTML parse
16
15
  expect(container.querySelectorAll('p')).toHaveLength(1);
@@ -147,6 +146,60 @@ describe('Content Component', () => {
147
146
  expect(container.querySelectorAll('iframe')).toBeTruthy();
148
147
  expect(container.querySelectorAll('noscript').length).toEqual(5);
149
148
  });
149
+
150
+ test('test Show more content', () => {
151
+ const iframeModule = {
152
+ anchor_label: 'Slot tips',
153
+ anchor_slug: 'slot-tips',
154
+ anchored: 1,
155
+ background_color: null,
156
+ extra_anchors: null,
157
+ module_title: 'Tips when Choosing Slot Machines',
158
+ module_title_tag: 'h2',
159
+ module_value_id: 208480,
160
+ name: 'content',
161
+ see_more_link: null,
162
+ show_more_content: `
163
+ <p>More COntent test</p>
164
+ `,
165
+ show_more_enabled: '1',
166
+ show_more_label: 'show more test',
167
+ style: 'content_frame_style',
168
+ style_id: 41,
169
+ tag: 'h2',
170
+ title: 'Tips when Choosing Slot Machines',
171
+ value: `
172
+ <p>
173
+ <p>
174
+ <strong>
175
+ 5. Reviews on Payment Methods:
176
+ </strong> Payment methods form the backbone for the secure transfer of funds into and from your
177
+ <a data-page-id="99253" href="/zar-online-casinos-south-africa">
178
+ &nbsp;ZAR-friendly casino accounts
179
+ </a> which is why we only recommend trusted and proven banking methods that are safe, easy and convenient for South Africans to use.
180
+ </p>
181
+ </p>
182
+ <p>
183
+ <strong>
184
+ 6. Guides:&nbsp;
185
+ </strong>
186
+ From
187
+ <a data-page-id="99185" href="/online-casino-gambling">
188
+ beginner guides and how-to-play guides
189
+ </a>
190
+ to more intermediate and advanced strategies and tips, we cover everything players need to know whether they are new or experienced.
191
+ </p>
192
+
193
+ `,
194
+ };
195
+ const { container, getByText } = render(<Content module={iframeModule} />);
196
+ expect(getByText('show more test')).toBeTruthy();
197
+
198
+ const showMorebutton = container.querySelector('button');
199
+ fireEvent.click(showMorebutton);
200
+
201
+ expect(getByText('More COntent test')).toBeTruthy();
202
+ });
150
203
  });
151
204
  afterEach(() => {
152
205
  cleanup();
@@ -1,16 +1,18 @@
1
- /* eslint-disable react/forbid-prop-types */
2
- /* eslint-disable react/no-danger */
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
1
+ /* eslint-disable camelcase */
2
+ /* eslint-disable import/no-extraneous-dependencies */
3
+ import React, { useState } from 'react';
5
4
  import parse from 'html-react-parser';
6
-
5
+ import PropTypes from 'prop-types';
6
+ import LazyImage from 'gatsby-core-theme/src/hooks/lazy-image';
7
+ import { parseCss } from 'gatsby-core-theme/src/helpers/css-parser';
7
8
  import loadable from '@loadable/component';
8
- import LazyImage from '~hooks/lazy-image';
9
- import { parseCss } from '~helpers/css-parser';
10
- import { parseContentImageUrl } from '~helpers/strings';
9
+ import { parseContentImageUrl } from 'gatsby-core-theme/src/helpers/strings';
11
10
  import styles from './content.module.scss';
12
11
 
13
- const Content = ({ module, pageContext = null }) => {
12
+ const Content = ({ module, isHomepageFirstModule = false, isModuleIntroduction = '' }) => {
13
+ const { show_more_label, show_more_enabled } = module || {};
14
+ const [showMore, setShowMore] = useState(show_more_enabled === '1');
15
+
14
16
  const replaceMedia = (node) => {
15
17
  if (node.name === 'iframe') {
16
18
  const Iframe = loadable(() => import('gatsby-core-theme/src/components/atoms/iframe'));
@@ -31,7 +33,6 @@ const Content = ({ module, pageContext = null }) => {
31
33
  } else if (classes?.includes('content-image--align-right')) {
32
34
  stylesClass = 'alignRight';
33
35
  }
34
-
35
36
  const lazyProps = {
36
37
  src: parseContentImageUrl(node.attribs.src),
37
38
  width: node.attribs.width && node.attribs.width.replace('px', ''),
@@ -40,32 +41,80 @@ const Content = ({ module, pageContext = null }) => {
40
41
  alt: node.attribs.alt ? node.attribs.alt : 'missing alt',
41
42
  className: styles[stylesClass],
42
43
  };
44
+
43
45
  return <LazyImage {...lazyProps} />;
44
46
  }
47
+
48
+ if (node.name === 'p' && module.style === 'horizontal_image_scroll_mobile') {
49
+ const hasChildImg = node?.children.find((child) => child?.name === 'img');
50
+
51
+ if (hasChildImg && node.nodeType === 1) {
52
+ node.attribs.style = 'overflow-x: scroll';
53
+ return node;
54
+ }
55
+ }
56
+
45
57
  return null;
46
58
  };
47
- const template = pageContext?.page?.template;
48
- const type = pageContext?.page?.type;
59
+ const switchStyle = (style) => {
60
+ switch (style) {
61
+ case 'table_1':
62
+ return `${styles.tableResponsive} ${styles.firstTable}`;
63
+ case 'table_2':
64
+ return `${styles.tableResponsive} ${styles.secondTable}`;
65
+ case 'stack_table':
66
+ return `${styles.stackTable}`;
67
+ case 'default_table':
68
+ return `${styles.tableResponsive}`;
69
+ case 'content_frame_style':
70
+ return `${styles.tableResponsive} ${styles.contentFrame}`;
71
+ case 'horizontal_image_scroll_mobile':
72
+ return `${styles.horizontalScrollImage}`;
73
+ default:
74
+ return null;
75
+ }
76
+ };
77
+
78
+ const handleChange = () => {
79
+ setShowMore(!showMore);
80
+ };
81
+
82
+ const conditionalContent = showMore ? module.value : module.value + module.show_more_content;
49
83
 
50
84
  return (
51
85
  <>
52
- <div className={`${styles.grid} ${styles[type]} ${styles[template]}`}>
86
+ <div
87
+ className={`${styles.content} ${showMore && styles.showMore} ${switchStyle(module.style)} ${
88
+ isHomepageFirstModule && styles.homepageFirstModuleContent
89
+ } ${isModuleIntroduction && styles.moduleIntroMargin}`}
90
+ >
53
91
  {module.value &&
54
- parse(module.value, {
92
+ parse(conditionalContent, {
55
93
  replace: replaceMedia,
56
94
  })}
57
95
  </div>
96
+ {showMore && (
97
+ <button type="button" className={styles.showMoreButton} onClick={handleChange}>
98
+ {show_more_label}
99
+ </button>
100
+ )}
58
101
  </>
59
102
  );
60
103
  };
61
104
 
62
105
  Content.propTypes = {
63
- pageContext: PropTypes.object,
64
106
  module: PropTypes.shape({
65
107
  anchor_label: PropTypes.string,
66
108
  name: PropTypes.string,
109
+ module_title: PropTypes.string,
67
110
  value: PropTypes.string,
111
+ style: PropTypes.string,
112
+ show_more_content: PropTypes.string,
68
113
  }),
114
+ isHomepageFirstModule: PropTypes.bool,
115
+ isModuleIntroduction: PropTypes.string,
116
+ // eslint-disable-next-line react/forbid-prop-types
117
+ styles: PropTypes.object,
69
118
  };
70
119
 
71
120
  export default Content;
@@ -11,6 +11,11 @@
11
11
  object-fit: cover;
12
12
  }
13
13
 
14
+ @keyframes load {
15
+ 0% { width: 0; }
16
+ 100% { width: 100%; }
17
+ }
18
+
14
19
  .content {
15
20
  width: 90%;
16
21
  background: var(--color-16);
@@ -70,10 +75,11 @@
70
75
  &:before {
71
76
  content: ' ';
72
77
  height: 0.8rem;
73
- width: 70%;
78
+ width: 0;
74
79
  background: linear-gradient(270deg, #17d6cc 0.34%, #17d68a 86.37%);
75
80
  border-radius: 10rem;
76
81
  display: block;
82
+ animation: load 5s normal forwards;
77
83
  }
78
84
  }
79
85
 
@@ -7,12 +7,6 @@ export function getURLParam(param) {
7
7
  return urlParams.get(param);
8
8
  }
9
9
 
10
- export function getSiteName() {
11
- const siteName =
12
- parseInt(process.env.GATSBY_SITE_ID) === 1 ? 'Irishluck' : 'Norske Spilleautomater';
13
- return siteName;
14
- }
15
-
16
10
  export function getPageTitle(page) {
17
11
  const searchquery = typeof window !== 'undefined' ? getURLParam('s') : '';
18
12
  if (page.path === 's') {
@@ -354,10 +348,6 @@ export function translate(translations, key, defaultValue = '') {
354
348
  return defaultValue;
355
349
  }
356
350
 
357
- export function getAws(imageName) {
358
- return `https://assets-srv.s3.eu-west-1.amazonaws.com/${imageName}`;
359
- }
360
-
361
351
  // This part of the code, help us to add operator related to the page as the first item in the comparison table automatically
362
352
  // example: if we are on the operator review page(Rizk) that should be first in the comparison table
363
353
  // First, we check if we have that item in the array, if that item is in the array, we check its position
@@ -24,7 +24,18 @@ describe('Getters Helper', () => {
24
24
  expect(Getters.getPageTitle({ path: 's' })).toEqual('You searched for hello - irishluck.ie');
25
25
  });
26
26
 
27
+ test('getPageTitle() non search page', () => {
28
+ window.location.search = 's=hello';
29
+ expect(Getters.getPageTitle({ meta_title: 'test meta title', path: '/' })).toEqual(
30
+ 'test meta title'
31
+ );
32
+ });
33
+
27
34
  test('getExtraField()', () => {
35
+ expect(Getters.getExtraField({}, 'k')).toEqual(null);
36
+ });
37
+
38
+ test('getExtraField() non existent', () => {
28
39
  expect(Getters.getExtraField({}, 'k', 'def')).toEqual('def');
29
40
  expect(Getters.getExtraField({ name: 'foo' }, 'name', 'def')).toEqual('foo');
30
41
  });
@@ -58,6 +69,7 @@ describe('Getters Helper', () => {
58
69
  const text = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`;
59
70
  expect(Getters.textWordsLimit(text, 5)).toEqual('Lorem Ipsum is simply dummy...');
60
71
  expect(Getters.textWordsLimit(text, 2)).toEqual('Lorem Ipsum...');
72
+ expect(Getters.textWordsLimit(1, 2)).toEqual(null);
61
73
  });
62
74
 
63
75
  test('filterImgSrc()', () => {
@@ -87,12 +87,15 @@ export function filterGames(pages, selectedCategories, selectedProviders) {
87
87
  }
88
88
 
89
89
  export function filterInactiveOperators(items) {
90
- return items.filter(
91
- (page) =>
92
- !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(
93
- page.relation && page.relation.status
94
- )
95
- );
90
+ return items.filter((page) => {
91
+ if (!settings.filter_cards_modules[process.env.GATSBY_SITE_NAME]) {
92
+ return false;
93
+ }
94
+
95
+ return !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(
96
+ page.relation && page.relation.status
97
+ );
98
+ });
96
99
  }
97
100
 
98
101
  export function filterOperators(pages, selectedProviders, selectedTypes) {