gatsby-core-theme 18.0.2 → 18.0.3

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,23 @@
1
+ ## [18.0.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v18.0.2...v18.0.3) (2023-01-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add new review component and tests ([5740902](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5740902d6efff14e537980fa534f1124b578f8a4))
7
+ * default value ([f6cc6bc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f6cc6bcf584c9e82a9a90d5c17967f7a9a6a67e6))
8
+ * getters test ([080bfbf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/080bfbf6942b1f54674101832e7e86bda5d7e77a))
9
+ * one-star ([f65156f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f65156f6891687a8ce401bee6e7a885dd4cea5c7))
10
+ * one-star ([ae348f2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ae348f2886054f1708275b83b0b0c92fc6432b40))
11
+ * operator header core ([020ab5d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/020ab5d850a40eb46899676ceff85ed18607282b))
12
+ * remove one-star css ([01beecf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/01beecfd20df4842065efc26fdb76203afe66a61))
13
+ * review link in toplist ([5d76d5e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5d76d5ee80c5664b5942b96d4e26d89d1710a8e2))
14
+ * typo ([e4e4dae](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e4e4dae91590a90b3af93d86fdbce6f15c3383ec))
15
+ * update name of reviewLink component and update the if with include ([31af320](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/31af3202d2f7f04c068601c81a2c69e683f1ee78))
16
+
17
+
18
+ * Merge branch 'tm-3138-changing-operator-review-text-on-modules' into 'master' ([423c965](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/423c96599ff4834fc26cfef1969decacf8eb8eb0))
19
+ * Merge branch 'tm-3253-operator-header' into 'master' ([5f3da13](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5f3da135c36b4e39e08f4856730111fa5aaa990b))
20
+
1
21
  ## [18.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v18.0.1...v18.0.2) (2023-01-17)
2
22
 
3
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "18.0.2",
3
+ "version": "18.0.3",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -17,6 +17,7 @@ export default function OperatorCta({
17
17
  gtmClass = '',
18
18
  tertiary = false,
19
19
  pageTemplate,
20
+ icon,
20
21
  }) {
21
22
  const { translations } = useContext(Context) || {};
22
23
  const status = operator?.status;
@@ -51,6 +52,7 @@ export default function OperatorCta({
51
52
  isInternalLink={false}
52
53
  gtmClass={`${gtmClass} operator-cta-gtm btn-cta`}
53
54
  tertiary={tertiary}
55
+ icon={icon}
54
56
  />
55
57
  );
56
58
  };
@@ -67,4 +69,5 @@ OperatorCta.propTypes = {
67
69
  playText: PropTypes.string,
68
70
  closedCasinoText: PropTypes.string,
69
71
  gtmClass: PropTypes.string,
72
+ icon: PropTypes.func,
70
73
  };
@@ -0,0 +1,36 @@
1
+ import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Context } from 'gatsby-core-theme/src/context/MainProvider';
4
+ import { translate } from 'gatsby-core-theme/src/helpers/getters';
5
+ import Link from 'gatsby-core-theme/src/hooks/link';
6
+
7
+ const ReviewLink = ({ template, itemName, reviewPath }) => {
8
+ let isBonusTemplate = false;
9
+ const { translations } = useContext(Context) || {};
10
+
11
+ if (['free_bonuses', 'bonus_pages', 'casino_bonus'].includes(template)) {
12
+ isBonusTemplate = true;
13
+ }
14
+
15
+ return (
16
+ <Link to={reviewPath}>{`${
17
+ isBonusTemplate
18
+ ? translate(translations, 'bonus', '[operator_name] Bonus').replace(
19
+ '[operator_name]',
20
+ itemName
21
+ )
22
+ : translate(translations, 'read_review', '[operator_name] Review').replace(
23
+ '[operator_name]',
24
+ itemName
25
+ )
26
+ }`}</Link>
27
+ );
28
+ };
29
+
30
+ ReviewLink.propTypes = {
31
+ template: PropTypes.string,
32
+ itemName: PropTypes.string,
33
+ reviewPath: PropTypes.string,
34
+ };
35
+
36
+ export default ReviewLink;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { render, cleanup } from '@testing-library/react';
3
+ import '@testing-library/jest-dom/extend-expect';
4
+ import ReviewLink from '.';
5
+
6
+ describe('ReviewLink', () => {
7
+ it('renders the correct text for the "bonus" template', () => {
8
+ const { getByText } = render(
9
+ <ReviewLink template="bonus_pages" itemName="Super Slot" reviewPath="/review" />
10
+ );
11
+
12
+ expect(getByText('Super Slot Bonus')).toBeInTheDocument();
13
+ });
14
+
15
+ it('renders the correct text for the "review" template', () => {
16
+ const { getByText } = render(
17
+ <ReviewLink template="review_pages" itemName="Super Slot" reviewPath="/review" />
18
+ );
19
+
20
+ expect(getByText('Super Slot Review')).toBeInTheDocument();
21
+ });
22
+
23
+ it('renders the correct link path', () => {
24
+ const { container } = render(
25
+ <ReviewLink template="review_pages" itemName="Super Slot" reviewPath="/review" />
26
+ );
27
+
28
+ expect(container.querySelector('a').getAttribute('href')).toBe('/review');
29
+ });
30
+ });
31
+
32
+ afterEach(() => {
33
+ cleanup();
34
+ });
@@ -6,14 +6,15 @@ import { translate } from '~helpers/getters';
6
6
 
7
7
  import styles from './one-star.module.scss';
8
8
 
9
- const OneStar = ({ numOfStars, rating, active = true, showLabel = false }) => {
9
+ const OneStar = ({ rating, numOfStars = 5, active = true, showLabel = false }) => {
10
10
  const { translations } = useContext(Context) || {};
11
11
 
12
12
  return (
13
13
  <div className={`${styles.starRatingContainer} ${!active && styles.inactive}`}>
14
14
  {showLabel && translate(translations, 'rating', 'Rating')}
15
15
  <span className={styles.fullStar} />
16
- {`${getRating(rating)}/${numOfStars}`}
16
+ {`${getRating(rating)}/`}
17
+ <span>{numOfStars}</span>
17
18
  </div>
18
19
  );
19
20
  };
@@ -12,7 +12,7 @@
12
12
  font-size: 1.3rem;
13
13
  margin: 0 0.33rem;
14
14
  line-height: 2.1rem;
15
-
15
+
16
16
  &.inactive {
17
17
  .fullStar {
18
18
  @include star(var(--empty-star-border-color), var(--empty-star-border-color), unset, 2.1rem);
@@ -9,7 +9,8 @@ describe('OneStar Component', () => {
9
9
  const { getByText } = render(<OneStar showLabel numOfStars={5} rating={3} />);
10
10
 
11
11
  expect(getByText('Rating', { exact: false })).toBeTruthy();
12
- expect(getByText('3/5', { exact: false })).toBeTruthy();
12
+ expect(getByText('3/', { exact: false })).toBeTruthy();
13
+ expect(getByText('5', { exact: false })).toBeTruthy();
13
14
  });
14
15
  });
15
16
 
@@ -7,6 +7,7 @@ import { Context } from '~context/MainProvider';
7
7
  import SellingPoints from '~atoms/selling-points';
8
8
  import StarRating from '~molecules/star-rating/one-star';
9
9
  import Link from '~hooks/link';
10
+ import ReviewLink from '../../../atoms/review-link';
10
11
  import OperatorCta from '~atoms/operator-cta';
11
12
  import { prettyTracker, imagePrettyUrl, translate, getAltText } from '~helpers/getters';
12
13
  import LazyImage from '~hooks/lazy-image';
@@ -25,6 +26,7 @@ const Row = ({
25
26
  }) => {
26
27
  const prettyLink = prettyTracker(item, 'main', false, pageTemplate);
27
28
  const itemRating = item.rating;
29
+ const reviewPath = item.review_link ? `/${item.review_link}` : item.path || '/';
28
30
  const { translations } = useContext(Context) || {};
29
31
 
30
32
  const imageObject = item?.standardised_logo_url_object || item?.logo_url_object;
@@ -57,7 +59,6 @@ const Row = ({
57
59
  width={100}
58
60
  height={100}
59
61
  />
60
- {item.name}
61
62
  </a>
62
63
  <a
63
64
  href={prettyLink}
@@ -69,11 +70,7 @@ const Row = ({
69
70
  </a>
70
71
  <StarRating numOfStars={5} rating={itemRating} showLabel />
71
72
  <SellingPoints sellingPoints={item.selling_points} />
72
- <div>
73
- <Link className={`${styles.reviewLink} toplist-variant-one-gtm`} to={item.review_link}>
74
- {`${translate(translations, 'read_review', 'Review')}`}
75
- </Link>
76
- </div>
73
+ <ReviewLink template={pageTemplate} itemName={item.name} reviewPath={reviewPath} />
77
74
  <div>
78
75
  <OperatorCta
79
76
  operator={item}
@@ -391,3 +391,9 @@ export const getRoundMinutes = (time) => {
391
391
  export function getAltText(imageObject, defaultAlt = 'missing alt') {
392
392
  return imageObject && imageObject.alt ? imageObject.alt : defaultAlt;
393
393
  }
394
+
395
+ export function getObjectValue(obj, path) {
396
+ if (!path) return obj;
397
+ const properties = path.split('.');
398
+ return getObjectValue(obj[properties.shift()], properties.join('.'));
399
+ }
@@ -302,4 +302,19 @@ describe('Getters Helper', () => {
302
302
  const altText = Getters.getAltText(null, 'default');
303
303
  expect(altText).toEqual('default');
304
304
  });
305
+
306
+ test('getObjectvalue recursive function to get value', () => {
307
+ const getObjValue = Getters.getObjectValue({ name: 'test' }, 'name');
308
+ expect(getObjValue).toEqual('test');
309
+ });
310
+
311
+ test('getObjectvalue recursive function to get 2 times nested value', () => {
312
+ const getObjValue = Getters.getObjectValue({ test: { test2: 'test3' } }, 'test.test2');
313
+ expect(getObjValue).toEqual('test3');
314
+ });
315
+
316
+ test('getObjectvalue recursive function no path it will return the object', () => {
317
+ const getObjValue = Getters.getObjectValue({ name: 'test' });
318
+ expect(getObjValue).toEqual({ name: 'test' });
319
+ });
305
320
  });