gatsby-core-theme 31.0.2 → 32.0.1
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 +29 -0
- package/package.json +1 -1
- package/src/components/atoms/footer/as-seen-on/index.js +5 -3
- package/src/components/atoms/number-rating/index.js +3 -2
- package/src/components/molecules/bonus/template-one/bonus.stories.js +10 -0
- package/src/components/molecules/bonus/template-one/index.js +7 -1
- package/src/components/molecules/bonus/template-two/bonus.stories.js +10 -0
- package/src/components/molecules/bonus/template-two/index.js +7 -1
- package/src/components/molecules/star-rating/one-star.js +7 -3
- package/src/components/molecules/star-rating/one-star.stories.js +106 -0
- package/src/helpers/rating.js +3 -3
- package/src/helpers/rating.test.js +7 -2
- package/src/helpers/tracker.mjs +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [32.0.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v32.0.0...v32.0.1) (2024-05-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tracker ([72f0022](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/72f0022e49a21ab9e6a7750a090257aac6058072))
|
|
7
|
+
|
|
8
|
+
# [32.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v31.0.2...v32.0.0) (2024-05-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* footer as seen logo ([3ae88b2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3ae88b28abf3e256afb63f628183732c2c1ed18c))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Code Refactoring
|
|
17
|
+
|
|
18
|
+
* add storybook and changes to test scripts ([3a135d6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3a135d65bf8fcecf3befe3db2d4c3b16f6a4edff))
|
|
19
|
+
* changes to bonus storybook ([9e2bb5a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9e2bb5a8fce4dcefcd57fb4f1917de637273722e))
|
|
20
|
+
* changes to ratings ([b11c595](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b11c5957e2ee520d6b0d4a5a775c084bdee35e59))
|
|
21
|
+
* correct to bonus box ratings ([0a2aa6a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0a2aa6af2bea338c4add3c8ea374228d35f2f38a))
|
|
22
|
+
* revert rating changes ([6c7a422](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6c7a4222dce826d0e06d45544aa5b48fd7f1387c))
|
|
23
|
+
* temp ([49efcf9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/49efcf9e37363ef0a30d25e70fb61dd52b199617))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
* Merge branch 'tm-4382-ratings' into 'master' ([0cd66dd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0cd66dda52540d1f272a1ffdfa79cac543af5b2b))
|
|
27
|
+
* Merge branch 'master' into tm-4382-ratings ([e359fe3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e359fe38fe209bc63aa3b5b000760fd429086f6e))
|
|
28
|
+
* Merge branch 'tm-4379-footer-as-seen-logo' into 'master' ([8a8e50c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8a8e50cd86ed2a205128b99f8a0df4380b3a2b1c))
|
|
29
|
+
|
|
1
30
|
## [31.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v31.0.1...v31.0.2) (2024-05-22)
|
|
2
31
|
|
|
3
32
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import LinkList from '../../../molecules/link-list';
|
|
4
4
|
import styles from './as-seen-on.module.scss';
|
|
5
5
|
|
|
6
|
-
const AsSeenOn = ({ asSeenOn, template }) => (
|
|
6
|
+
const AsSeenOn = ({ asSeenOn, template, width = '130', height = '36' }) => (
|
|
7
7
|
<div
|
|
8
8
|
className={`${styles?.asSeenOn || ''} ${
|
|
9
9
|
template && styles[template] ? styles[template] || '' : ''
|
|
@@ -15,8 +15,8 @@ const AsSeenOn = ({ asSeenOn, template }) => (
|
|
|
15
15
|
imageOnly
|
|
16
16
|
singleList
|
|
17
17
|
lists={asSeenOn}
|
|
18
|
-
width={
|
|
19
|
-
height={
|
|
18
|
+
width={width}
|
|
19
|
+
height={height}
|
|
20
20
|
gtmClass="mobile-menu-gtm logo-cta"
|
|
21
21
|
/>
|
|
22
22
|
</div>
|
|
@@ -27,4 +27,6 @@ export default AsSeenOn;
|
|
|
27
27
|
AsSeenOn.propTypes = {
|
|
28
28
|
asSeenOn: PropTypes.shape({}),
|
|
29
29
|
template: PropTypes.string,
|
|
30
|
+
width: PropTypes.string,
|
|
31
|
+
height: PropTypes.string,
|
|
30
32
|
};
|
|
@@ -4,14 +4,15 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import styles from './number-rating.module.scss';
|
|
5
5
|
import { getRating } from '~helpers/rating';
|
|
6
6
|
|
|
7
|
-
const NumberRating = ({ total, rating }) => {
|
|
8
|
-
const rate = getRating(rating);
|
|
7
|
+
const NumberRating = ({ total, rating, showRoundedRating = true }) => {
|
|
8
|
+
const rate = getRating(rating, showRoundedRating);
|
|
9
9
|
return <div className={styles.numberRatingContainer || ''}>{`${rate}/${total}`}</div>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
NumberRating.propTypes = {
|
|
13
13
|
total: PropTypes.oneOfType([PropTypes.oneOf([5, 10]), PropTypes.oneOf(['5', '10'])]).isRequired,
|
|
14
14
|
rating: PropTypes.oneOfType([PropTypes.array, PropTypes.number]).isRequired,
|
|
15
|
+
showRoundedRating: PropTypes.bool,
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export default NumberRating;
|
|
@@ -45,6 +45,16 @@ export default {
|
|
|
45
45
|
defaultValue: { summary: false },
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
|
+
showRoundedRating: {
|
|
49
|
+
name: 'showRoundedRating',
|
|
50
|
+
type: { name: 'boolean', required: false },
|
|
51
|
+
defaultValue: false,
|
|
52
|
+
description: 'Show rating as a rounded number or exact number',
|
|
53
|
+
table: {
|
|
54
|
+
type: { summary: 'boolean' },
|
|
55
|
+
defaultValue: { summary: false },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
48
58
|
},
|
|
49
59
|
parameters: {
|
|
50
60
|
docs: {
|
|
@@ -19,6 +19,7 @@ export default function Bonus({
|
|
|
19
19
|
},
|
|
20
20
|
tncEnable = true,
|
|
21
21
|
tncFixed = false,
|
|
22
|
+
showRoundedRating = false,
|
|
22
23
|
}) {
|
|
23
24
|
const { standardised_logo_url, logo_url, bonus, name } = operator || {};
|
|
24
25
|
const logo = standardised_logo_url || logo_url;
|
|
@@ -45,7 +46,11 @@ export default function Bonus({
|
|
|
45
46
|
<div className={styles.details}>
|
|
46
47
|
{name && <span>{name}</span>}
|
|
47
48
|
{(operator?.rating || bonus?.rating) && (
|
|
48
|
-
<Rating
|
|
49
|
+
<Rating
|
|
50
|
+
rating={operator.rating || bonus?.rating}
|
|
51
|
+
showDecimal
|
|
52
|
+
showRoundedRating={showRoundedRating}
|
|
53
|
+
/>
|
|
49
54
|
)}
|
|
50
55
|
</div>
|
|
51
56
|
</PrettyLink>
|
|
@@ -92,4 +97,5 @@ Bonus.propTypes = {
|
|
|
92
97
|
type: PropTypes.string,
|
|
93
98
|
name: PropTypes.string,
|
|
94
99
|
}),
|
|
100
|
+
showRoundedRating: PropTypes.bool,
|
|
95
101
|
};
|
|
@@ -47,6 +47,16 @@ export default {
|
|
|
47
47
|
defaultValue: { summary: false },
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
|
+
showRoundedRating: {
|
|
51
|
+
name: 'showRoundedRating',
|
|
52
|
+
type: { name: 'boolean', required: false },
|
|
53
|
+
defaultValue: false,
|
|
54
|
+
description: 'Show rating as a rounded number or exact number',
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: 'boolean' },
|
|
57
|
+
defaultValue: { summary: false },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
50
60
|
},
|
|
51
61
|
parameters: {
|
|
52
62
|
docs: {
|
|
@@ -26,6 +26,7 @@ export default function TemplateOne({
|
|
|
26
26
|
floating = false,
|
|
27
27
|
closedBanner,
|
|
28
28
|
setClosedBanner,
|
|
29
|
+
showRoundedRating = false,
|
|
29
30
|
}) {
|
|
30
31
|
const { translations } = useContext(Context) || {};
|
|
31
32
|
const { standardised_logo_url, logo_url, bonus, name } = operator || {};
|
|
@@ -71,7 +72,11 @@ export default function TemplateOne({
|
|
|
71
72
|
<div className={styles.details}>
|
|
72
73
|
{name && <span>{name}</span>}
|
|
73
74
|
{(operator?.rating || bonus?.rating) && (
|
|
74
|
-
<Rating
|
|
75
|
+
<Rating
|
|
76
|
+
rating={operator?.rating || bonus?.rating}
|
|
77
|
+
showDecimal
|
|
78
|
+
showRoundedRating={showRoundedRating}
|
|
79
|
+
/>
|
|
75
80
|
)}
|
|
76
81
|
</div>
|
|
77
82
|
</PrettyLink>
|
|
@@ -137,4 +142,5 @@ TemplateOne.propTypes = {
|
|
|
137
142
|
type: PropTypes.string,
|
|
138
143
|
name: PropTypes.string,
|
|
139
144
|
}),
|
|
145
|
+
showRoundedRating: PropTypes.bool,
|
|
140
146
|
};
|
|
@@ -11,8 +11,9 @@ const OneStar = ({
|
|
|
11
11
|
numOfStars = 5,
|
|
12
12
|
active = true,
|
|
13
13
|
showLabel = false,
|
|
14
|
-
icon =
|
|
14
|
+
icon = null,
|
|
15
15
|
showDecimal = false,
|
|
16
|
+
showRoundedRating = false,
|
|
16
17
|
}) => {
|
|
17
18
|
const { translations } = useContext(Context) || {};
|
|
18
19
|
|
|
@@ -20,7 +21,9 @@ const OneStar = ({
|
|
|
20
21
|
<div className={`${styles.starRatingContainer || ''} ${!active && (styles.inactive || '')}`}>
|
|
21
22
|
{showLabel && <span>{translate(translations, 'rating', 'Rating:')}</span>}
|
|
22
23
|
{!icon ? <span className={styles.fullStar || ''} /> : icon}
|
|
23
|
-
{showDecimal
|
|
24
|
+
{showDecimal
|
|
25
|
+
? getRating(rating, showRoundedRating).toFixed(1)
|
|
26
|
+
: getRating(rating, showRoundedRating)}
|
|
24
27
|
<span>/</span>
|
|
25
28
|
<span>{numOfStars}</span>
|
|
26
29
|
</div>
|
|
@@ -32,8 +35,9 @@ OneStar.propTypes = {
|
|
|
32
35
|
rating: PropTypes.oneOfType([PropTypes.array, PropTypes.number, PropTypes.string]).isRequired,
|
|
33
36
|
active: PropTypes.bool,
|
|
34
37
|
showLabel: PropTypes.bool,
|
|
35
|
-
icon: PropTypes.
|
|
38
|
+
icon: PropTypes.element,
|
|
36
39
|
showDecimal: PropTypes.bool,
|
|
40
|
+
showRoundedRating: PropTypes.bool,
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export default OneStar;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Title,
|
|
4
|
+
Description,
|
|
5
|
+
Primary,
|
|
6
|
+
PRIMARY_STORY,
|
|
7
|
+
ArgsTable,
|
|
8
|
+
} from '@storybook/addon-docs/blocks';
|
|
9
|
+
|
|
10
|
+
import OneStar from './one-star';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Theme/Molecules/Star Rating/One Star',
|
|
14
|
+
component: OneStar,
|
|
15
|
+
argTypes: {
|
|
16
|
+
numOfStars: {
|
|
17
|
+
name: 'numOfStars',
|
|
18
|
+
type: { name: 'number', required: true },
|
|
19
|
+
defaultValue: '',
|
|
20
|
+
description: 'Total number.',
|
|
21
|
+
table: {
|
|
22
|
+
type: { summary: 'one of 5 and 10' },
|
|
23
|
+
defaultValue: { summary: '' },
|
|
24
|
+
},
|
|
25
|
+
control: {
|
|
26
|
+
type: 'inline-radio',
|
|
27
|
+
options: [5, 10],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
rating: {
|
|
31
|
+
name: 'rating',
|
|
32
|
+
type: { name: 'number', required: true },
|
|
33
|
+
defaultValue: '',
|
|
34
|
+
description: 'Rate number/s.',
|
|
35
|
+
table: {
|
|
36
|
+
type: { summary: 'number | array of numbers' },
|
|
37
|
+
defaultValue: { summary: '' },
|
|
38
|
+
},
|
|
39
|
+
control: { type: 'range', min: 0, max: 10, step: 0.2 },
|
|
40
|
+
},
|
|
41
|
+
active: {
|
|
42
|
+
name: 'active',
|
|
43
|
+
type: { name: 'boolean', required: false },
|
|
44
|
+
defaultValue: true,
|
|
45
|
+
description: 'Show as active star or not',
|
|
46
|
+
table: {
|
|
47
|
+
type: { summary: 'boolean' },
|
|
48
|
+
defaultValue: { summary: true },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
showLabel: {
|
|
52
|
+
name: 'showLabel',
|
|
53
|
+
type: { name: 'boolean', required: false },
|
|
54
|
+
defaultValue: false,
|
|
55
|
+
description: "Show a translatable lable 'Rating'",
|
|
56
|
+
table: {
|
|
57
|
+
type: { summary: 'boolean' },
|
|
58
|
+
defaultValue: { summary: false },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
showDecimal: {
|
|
62
|
+
name: 'showDecimal',
|
|
63
|
+
type: { name: 'boolean', required: false },
|
|
64
|
+
defaultValue: false,
|
|
65
|
+
description: 'Show decimal if a whole number',
|
|
66
|
+
table: {
|
|
67
|
+
type: { summary: 'boolean' },
|
|
68
|
+
defaultValue: { summary: false },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
showRoundedRating: {
|
|
72
|
+
name: 'showRoundedRating',
|
|
73
|
+
type: { name: 'boolean', required: false },
|
|
74
|
+
defaultValue: false,
|
|
75
|
+
description: 'Show rating as a rounded number or exact number',
|
|
76
|
+
table: {
|
|
77
|
+
type: { summary: 'boolean' },
|
|
78
|
+
defaultValue: { summary: false },
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
parameters: {
|
|
83
|
+
docs: {
|
|
84
|
+
description: {
|
|
85
|
+
component:
|
|
86
|
+
'A component that accepts the rate numbers and the total number and generates a rating div.',
|
|
87
|
+
},
|
|
88
|
+
page: () => (
|
|
89
|
+
<>
|
|
90
|
+
<Title />
|
|
91
|
+
<Description />
|
|
92
|
+
<Primary />
|
|
93
|
+
<ArgsTable story={PRIMARY_STORY} />
|
|
94
|
+
</>
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const Template = (args) => <OneStar {...args} />;
|
|
101
|
+
|
|
102
|
+
export const Default = Template.bind({});
|
|
103
|
+
Default.args = {
|
|
104
|
+
numOfStars: 10,
|
|
105
|
+
rating: 6.2,
|
|
106
|
+
};
|
package/src/helpers/rating.js
CHANGED
|
@@ -4,15 +4,15 @@ export const roundHalf = (num) => {
|
|
|
4
4
|
return Math.round(num * 2) / 2;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export const getRating = (rating) => {
|
|
7
|
+
export const getRating = (rating, showRoundedRating = false) => {
|
|
8
8
|
// check if rating is an array or a number
|
|
9
9
|
let rate = 0;
|
|
10
10
|
if (Array.isArray(rating)) {
|
|
11
11
|
const sum = rating.reduce((a, b) => parseInt(a) + parseInt(b));
|
|
12
12
|
const avg = sum / rating.length;
|
|
13
|
-
rate = roundHalf(avg);
|
|
13
|
+
rate = showRoundedRating ? roundHalf(avg) : +avg;
|
|
14
14
|
} else {
|
|
15
|
-
rate = roundHalf(rating);
|
|
15
|
+
rate = showRoundedRating ? roundHalf(rating) : +rating;
|
|
16
16
|
}
|
|
17
17
|
return rate;
|
|
18
18
|
};
|
|
@@ -8,8 +8,13 @@ describe('Rating Helper', () => {
|
|
|
8
8
|
expect(roundHalf(3.75)).toEqual(4);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
test('getRating()', () => {
|
|
11
|
+
test('getRating() with rounded', () => {
|
|
12
12
|
expect(getRating([5, 6, 7, 6.3])).toEqual(6);
|
|
13
|
-
expect(getRating(3.75)).toEqual(4);
|
|
13
|
+
expect(getRating(3.75, true)).toEqual(4);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('getRating() without rounded', () => {
|
|
17
|
+
expect(getRating([5, 6, 7, 6.3])).toEqual(6);
|
|
18
|
+
expect(getRating(3.75, false)).toEqual(3.75);
|
|
14
19
|
});
|
|
15
20
|
});
|
package/src/helpers/tracker.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
1
2
|
/* eslint-disable no-underscore-dangle */
|
|
2
3
|
import { generateTrackerLink } from '~helpers/generators';
|
|
3
4
|
|
|
@@ -90,6 +91,7 @@ export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
|
90
91
|
facebook_browser_id: cookie ? cookie._fbp || null : null,
|
|
91
92
|
facebook_click_id: cookie ? cookie._fbc || null : null,
|
|
92
93
|
split_test_name: cookie ? cookie.split_test_name || null : null,
|
|
94
|
+
google_client_id: cookie ? cookie._ga || null : null,
|
|
93
95
|
split_test_variant: cookie ? cookie.split_test_variant || null : null,
|
|
94
96
|
facebook_pixel_id: process.env.PIXEL_ID || null,
|
|
95
97
|
...(isJsonString(cookie.affObject) ? JSON.parse(cookie.affObject) : {}),
|
|
@@ -102,7 +104,7 @@ export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
|
102
104
|
: {}),
|
|
103
105
|
...(extraURLParams || {}),
|
|
104
106
|
};
|
|
105
|
-
|
|
107
|
+
|
|
106
108
|
const res = await fetch(
|
|
107
109
|
`${process.env.GATSBY_TRACKING_API_URL}?${new URLSearchParams(clean(urlParam)).toString()}`
|
|
108
110
|
).catch((err) => null);
|
|
@@ -115,6 +117,7 @@ export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
|
115
117
|
|
|
116
118
|
export function getTrackingAPIParams(pageTemplate, module, tracker, clickedElement, url, referer) {
|
|
117
119
|
const urlParams = {};
|
|
120
|
+
let extraData = {}
|
|
118
121
|
|
|
119
122
|
if (pageTemplate) {
|
|
120
123
|
urlParams.page_type = pageTemplate;
|
|
@@ -137,22 +140,20 @@ export function getTrackingAPIParams(pageTemplate, module, tracker, clickedEleme
|
|
|
137
140
|
if (url && url.split('?').length === 2) {
|
|
138
141
|
// eslint-disable-next-line prefer-destructuring
|
|
139
142
|
urlParams.request_url = url.split('?')[0];
|
|
140
|
-
|
|
143
|
+
extraData = deparam(url.split('?')[1]);
|
|
141
144
|
|
|
142
145
|
if (extraData.msclkid) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (extraData.brevo_customer_id) {
|
|
147
|
-
urlParams.brevo_customer_id = extraData.brevo_customer_id;
|
|
146
|
+
extraData.microsoft_click_id = extraData.msclkid;
|
|
147
|
+
delete extraData.msclkid;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if (extraData.gclid) {
|
|
151
|
-
|
|
151
|
+
extraData.google_click_id = extraData.gclid;
|
|
152
|
+
delete extraData.gclid;
|
|
152
153
|
}
|
|
153
154
|
} else if (url) {
|
|
154
155
|
urlParams.request_url = url;
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
-
return urlParams;
|
|
157
|
+
|
|
158
|
+
return {...urlParams, ...extraData};
|
|
158
159
|
}
|