gatsby-core-theme 44.10.1 → 44.10.12-beta.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/.ci.yml +1 -0
- package/CHANGELOG.md +101 -0
- package/gatsby-browser.js +3 -145
- package/gatsby-config.js +3 -3
- package/gatsby-node.mjs +7 -1
- package/gatsby-ssr.js +142 -0
- package/package.json +2 -1
- package/src/components/app-ssr.js +16 -18
- package/src/components/atoms/admin/bar/index.js +6 -2
- package/src/components/atoms/admin/button/index.js +4 -3
- package/src/components/atoms/contact-form/index.js +2 -2
- package/src/components/atoms/market-dropdown/index.js +7 -9
- package/src/components/atoms/notifications/index.js +2 -3
- package/src/components/atoms/ratings/index.js +7 -6
- package/src/components/atoms/review-link/index.js +16 -11
- package/src/components/atoms/search/autocomplete/article/index.js +13 -9
- package/src/components/atoms/search/autocomplete/default/index.js +13 -9
- package/src/components/atoms/search/autocomplete/game/index.js +22 -12
- package/src/components/atoms/search/autocomplete/operator/index.js +26 -18
- package/src/components/molecules/bonus/template-one/index.js +15 -2
- package/src/components/molecules/bonus/template-two/index.js +7 -1
- package/src/components/molecules/cookie-modal/index.js +1 -1
- package/src/components/molecules/floating-area/index.js +6 -12
- package/src/components/molecules/footer/index.js +35 -27
- package/src/components/molecules/footer/variants/template-one/template-one.stories.js +70 -67
- package/src/components/molecules/footer/variants/template-one/template-one.test.js +92 -69
- package/src/components/molecules/footer/variants/template-three/template-three.stories.js +4 -4
- package/src/components/molecules/footer/variants/template-three/template-three.test.js +98 -73
- package/src/components/molecules/footer/variants/template-two/template-two.stories.js +3 -3
- package/src/components/molecules/footer/variants/template-two/template-two.test.js +96 -73
- package/src/components/molecules/header/variants/default/template-one/index.js +15 -13
- package/src/components/molecules/header/variants/default/template-one/template-one.test.js +37 -29
- package/src/components/molecules/header/variants/slot/template-one/templateone.test.js +32 -29
- package/src/components/molecules/leave-comment-form/index.js +90 -79
- package/src/components/molecules/main/index.js +5 -7
- package/src/components/molecules/menu/index.js +28 -30
- package/src/components/molecules/newsletter/form/index.js +2 -2
- package/src/components/molecules/newsletter/index.js +23 -19
- package/src/components/molecules/tnc/index.js +4 -2
- package/src/components/organisms/anchor/template-two/index.js +33 -18
- package/src/components/organisms/footer-navigation/index.js +10 -9
- package/src/components/organisms/navigation/navigationContext.js +28 -4
- package/src/components/organisms/search/index.js +17 -4
- package/src/constants/ratings-constant.js +7 -9
- package/src/helpers/getters.mjs +3 -3
- package/src/helpers/processImageNode.js +38 -30
- package/src/helpers/processImageNode.test.js +33 -24
- package/src/helpers/replaceMedia.js +2 -2
- package/src/resolver/games.mjs +1 -1
- package/src/resolver/operators.mjs +23 -13
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { MdClose } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import { getUrl } from
|
|
5
|
-
import Button from
|
|
6
|
-
import useTranslate from
|
|
7
|
-
import NewsletterForm from
|
|
8
|
-
import styles from
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { MdClose } from "@react-icons/all-files/md/MdClose";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { getUrl } from "~helpers/getters";
|
|
5
|
+
import Button from "./toggle-button/index";
|
|
6
|
+
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
7
|
+
import NewsletterForm from "./form/index";
|
|
8
|
+
import styles from "./newsletter.module.scss";
|
|
9
9
|
|
|
10
10
|
const Newsletter = ({
|
|
11
11
|
page,
|
|
12
|
-
openBtnText =
|
|
12
|
+
openBtnText = "Unlock Bonuses",
|
|
13
13
|
isSticky = false,
|
|
14
14
|
showLabels = true,
|
|
15
|
-
titleType =
|
|
15
|
+
titleType = "h2",
|
|
16
16
|
}) => {
|
|
17
17
|
const [toggleNewsetter, setToggleNewsletter] = useState(false);
|
|
18
18
|
const [isClicked, setIsClicked] = useState(false);
|
|
19
|
-
const country = page?.market?.split(
|
|
20
|
-
const newsletterOpenBtn = useTranslate(
|
|
19
|
+
const country = page?.market?.split("_")[0].toUpperCase();
|
|
20
|
+
const newsletterOpenBtn = useTranslate("newsletter_open_btn", openBtnText);
|
|
21
21
|
|
|
22
22
|
const redirectUrl =
|
|
23
|
-
page?.path ===
|
|
23
|
+
page?.path === "/"
|
|
24
24
|
? `${getUrl(page?.path)}?subscribed=true`
|
|
25
25
|
: `${getUrl(page?.path)}/?subscribed=true`;
|
|
26
26
|
|
|
@@ -33,12 +33,14 @@ const Newsletter = ({
|
|
|
33
33
|
<>
|
|
34
34
|
{toggleNewsetter && (
|
|
35
35
|
<div
|
|
36
|
-
className={styles?.layer ||
|
|
36
|
+
className={styles?.layer || ""}
|
|
37
37
|
onClick={() => setToggleNewsletter(false)}
|
|
38
38
|
aria-hidden="true"
|
|
39
39
|
/>
|
|
40
40
|
)}
|
|
41
|
-
<div
|
|
41
|
+
<div
|
|
42
|
+
className={!isSticky ? styles.contentPage || "" : styles.content || ""}
|
|
43
|
+
>
|
|
42
44
|
{isSticky && (
|
|
43
45
|
<Button
|
|
44
46
|
active={!toggleNewsetter}
|
|
@@ -51,8 +53,10 @@ const Newsletter = ({
|
|
|
51
53
|
<div
|
|
52
54
|
className={
|
|
53
55
|
!isSticky
|
|
54
|
-
? styles?.formPage ||
|
|
55
|
-
: `${styles?.form ||
|
|
56
|
+
? styles?.formPage || ""
|
|
57
|
+
: `${styles?.form || ""} ${
|
|
58
|
+
toggleNewsetter ? styles?.active || "" : ""
|
|
59
|
+
}`
|
|
56
60
|
}
|
|
57
61
|
>
|
|
58
62
|
<NewsletterForm
|
|
@@ -62,11 +66,11 @@ const Newsletter = ({
|
|
|
62
66
|
redirectUrl={redirectUrl}
|
|
63
67
|
showLabels={showLabels}
|
|
64
68
|
titleType={titleType}
|
|
65
|
-
customClass={styles.newsletterForm ||
|
|
69
|
+
customClass={styles.newsletterForm || ""}
|
|
66
70
|
/>
|
|
67
71
|
{isSticky && (
|
|
68
72
|
<MdClose
|
|
69
|
-
className={styles?.closeBtn ||
|
|
73
|
+
className={styles?.closeBtn || ""}
|
|
70
74
|
onClick={() => setToggleNewsletter(false)}
|
|
71
75
|
title="Close Icon"
|
|
72
76
|
/>
|
|
@@ -4,8 +4,9 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import styles from './tnc.module.scss';
|
|
5
5
|
import { getOperatorTnc } from '~helpers/getters';
|
|
6
6
|
|
|
7
|
-
const Tnc = ({ operator, isFixed = false }) => {
|
|
8
|
-
|
|
7
|
+
const Tnc = ({ operator, isFixed = false, tracker }) => {
|
|
8
|
+
|
|
9
|
+
const termsConditions = getOperatorTnc(operator, tracker);
|
|
9
10
|
return (
|
|
10
11
|
termsConditions &&
|
|
11
12
|
((!isFixed && (
|
|
@@ -35,6 +36,7 @@ Tnc.propTypes = {
|
|
|
35
36
|
main: PropTypes.string,
|
|
36
37
|
}),
|
|
37
38
|
}),
|
|
39
|
+
tracker: PropTypes.string,
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
export default Tnc;
|
|
@@ -3,49 +3,64 @@
|
|
|
3
3
|
/* eslint-disable no-unused-expressions */
|
|
4
4
|
/* eslint-disable prefer-destructuring */
|
|
5
5
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
6
|
-
import React, { useRef } from
|
|
6
|
+
import React, { useRef } from "react";
|
|
7
7
|
|
|
8
|
-
import PropTypes from
|
|
8
|
+
import PropTypes from "prop-types";
|
|
9
9
|
|
|
10
|
-
import ScollX from
|
|
11
|
-
import keygen from
|
|
12
|
-
import useTranslate from
|
|
10
|
+
import ScollX from "~hooks/scroll-x";
|
|
11
|
+
import keygen from "~helpers/keygen";
|
|
12
|
+
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
13
13
|
import { generatePlaceholderString } from "~helpers/generators";
|
|
14
14
|
|
|
15
|
-
import styles from
|
|
15
|
+
import styles from "./template-two.module.scss";
|
|
16
16
|
|
|
17
|
-
function Anchor({
|
|
17
|
+
function Anchor({
|
|
18
|
+
module: { items },
|
|
19
|
+
icon = null,
|
|
20
|
+
showTitle = true,
|
|
21
|
+
exclOperator = false,
|
|
22
|
+
page,
|
|
23
|
+
}) {
|
|
18
24
|
const itemsRef = useRef([]);
|
|
19
25
|
const anchorContainerRef = useRef(null);
|
|
20
26
|
const anchorListRef = useRef(null);
|
|
21
27
|
|
|
22
28
|
return (
|
|
23
|
-
<div className={styles.containerAnchor ||
|
|
29
|
+
<div className={styles.containerAnchor || ""} ref={anchorContainerRef}>
|
|
24
30
|
{showTitle ? (
|
|
25
|
-
<div className={`${styles.anchorTitle ||
|
|
31
|
+
<div className={`${styles.anchorTitle || ""}`}>
|
|
26
32
|
<span>
|
|
27
|
-
{useTranslate(
|
|
33
|
+
{useTranslate(
|
|
34
|
+
"anchor_title_responsible_gambling",
|
|
35
|
+
"You Might Wanna Jump To:)"
|
|
36
|
+
)}
|
|
28
37
|
</span>
|
|
29
38
|
</div>
|
|
30
39
|
) : null}
|
|
31
40
|
<div
|
|
32
|
-
className={`${styles.defaultConatiner ||
|
|
33
|
-
exclOperator ? styles.usingExclOperator ||
|
|
41
|
+
className={`${styles.defaultConatiner || ""} ${
|
|
42
|
+
exclOperator ? styles.usingExclOperator || "" : ""
|
|
34
43
|
} `}
|
|
35
44
|
>
|
|
36
45
|
<ScollX refTag={anchorListRef}>
|
|
37
|
-
<ul ref={anchorListRef} className={`${styles.anchor ||
|
|
46
|
+
<ul ref={anchorListRef} className={`${styles.anchor || ""}`}>
|
|
38
47
|
{items?.map((item, index) => (
|
|
39
|
-
<li className={styles.anchorItem ||
|
|
48
|
+
<li className={styles.anchorItem || ""}>
|
|
40
49
|
<a
|
|
41
|
-
className={`${
|
|
50
|
+
className={`${
|
|
51
|
+
styles.link || ""
|
|
52
|
+
} anchor-carousel-gtm anchor-menu-gtm`}
|
|
42
53
|
key={keygen()}
|
|
43
54
|
draggable="false"
|
|
44
55
|
// eslint-disable-next-line no-return-assign
|
|
45
56
|
ref={(el) => (itemsRef.current[index] = el)}
|
|
46
57
|
href={`#${item?.id && item.id}`}
|
|
47
58
|
>
|
|
48
|
-
{generatePlaceholderString(
|
|
59
|
+
{generatePlaceholderString(
|
|
60
|
+
useTranslate(item.slug, item.label),
|
|
61
|
+
null,
|
|
62
|
+
page?.relation
|
|
63
|
+
)}
|
|
49
64
|
{icon}
|
|
50
65
|
</a>
|
|
51
66
|
</li>
|
|
@@ -68,9 +83,9 @@ Anchor.propTypes = {
|
|
|
68
83
|
}).isRequired,
|
|
69
84
|
styles: PropTypes.shape({}),
|
|
70
85
|
icon: PropTypes.element,
|
|
71
|
-
showTitle: PropTypes.bool,
|
|
86
|
+
showTitle: PropTypes.bool,
|
|
72
87
|
page: PropTypes.shape({
|
|
73
|
-
relation: PropTypes.shape({})
|
|
88
|
+
relation: PropTypes.shape({}),
|
|
74
89
|
}),
|
|
75
90
|
};
|
|
76
91
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import React from
|
|
2
|
+
import React from "react";
|
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
-
import PropTypes from
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
import LinkList from
|
|
7
|
-
import { getFirstModuleByName } from
|
|
8
|
-
import styles from
|
|
6
|
+
import LinkList from "~molecules/link-list";
|
|
7
|
+
import { getFirstModuleByName } from "~helpers/getters";
|
|
8
|
+
import styles from "./footer-navigation.module.scss";
|
|
9
9
|
|
|
10
10
|
const FooterNavigation = ({ section, isStorybook = false }) => {
|
|
11
|
-
const menuArray = getFirstModuleByName(section,
|
|
11
|
+
const menuArray = getFirstModuleByName(section, "menu");
|
|
12
12
|
return (
|
|
13
13
|
menuArray?.children?.length > 0 && (
|
|
14
14
|
<div
|
|
15
|
-
className={`${styles?.footerLinks ||
|
|
16
|
-
${isStorybook ? styles?.isStoryBook :
|
|
17
|
-
${styles?.showFooterNav ||
|
|
15
|
+
className={`${styles?.footerLinks || ""}
|
|
16
|
+
${isStorybook ? styles?.isStoryBook : ""}
|
|
17
|
+
${styles?.showFooterNav || ""}
|
|
18
18
|
${styles[section.style]}
|
|
19
19
|
`}
|
|
20
20
|
>
|
|
@@ -38,6 +38,7 @@ FooterNavigation.propTypes = {
|
|
|
38
38
|
name: PropTypes.string,
|
|
39
39
|
})
|
|
40
40
|
),
|
|
41
|
+
style: PropTypes.string,
|
|
41
42
|
}).isRequired,
|
|
42
43
|
isStorybook: PropTypes.bool,
|
|
43
44
|
};
|
|
@@ -1,16 +1,40 @@
|
|
|
1
|
-
import React, { useState, createContext } from 'react';
|
|
1
|
+
import React, { useState, createContext, startTransition } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
|
|
3
4
|
export const NavigationContext = createContext(false);
|
|
4
5
|
|
|
5
|
-
const NavigationProvider = (
|
|
6
|
+
const NavigationProvider = ({ children }) => {
|
|
6
7
|
const [showMenu, setShowMenu] = useState(false);
|
|
7
8
|
const [showSearch, setShowSearch] = useState(false);
|
|
8
9
|
|
|
10
|
+
const setShowMenuTransition = (value) => {
|
|
11
|
+
startTransition(() => {
|
|
12
|
+
setShowMenu(value);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const setShowSearchTransition = (value) => {
|
|
17
|
+
startTransition(() => {
|
|
18
|
+
setShowSearch(value);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
9
22
|
return (
|
|
10
|
-
<NavigationContext.Provider
|
|
11
|
-
{
|
|
23
|
+
<NavigationContext.Provider
|
|
24
|
+
value={{
|
|
25
|
+
showMenu,
|
|
26
|
+
setShowMenu: setShowMenuTransition,
|
|
27
|
+
showSearch,
|
|
28
|
+
setShowSearch: setShowSearchTransition,
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
12
32
|
</NavigationContext.Provider>
|
|
13
33
|
);
|
|
14
34
|
};
|
|
15
35
|
|
|
16
36
|
export default NavigationProvider;
|
|
37
|
+
|
|
38
|
+
NavigationProvider.propTypes = {
|
|
39
|
+
children: PropTypes.node.isRequired,
|
|
40
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-unused-expressions */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
4
|
-
import React, { useRef, useState, useEffect } from "react";
|
|
4
|
+
import React, { useRef, useState, useEffect, startTransition } from "react";
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
import { BiSearchAlt } from "@react-icons/all-files/bi/BiSearchAlt";
|
|
7
7
|
import { IoIosArrowForward } from "@react-icons/all-files/io/IoIosArrowForward";
|
|
@@ -34,6 +34,7 @@ const SearchForm = ({
|
|
|
34
34
|
const topSearches =
|
|
35
35
|
pageContext?.marketSections?.top_searches?.modules?.[0]?.items;
|
|
36
36
|
const [localSearch, setLocalSearch] = useState(false);
|
|
37
|
+
const [showVariableComponent, setShowVariableComponent] = useState(false);
|
|
37
38
|
|
|
38
39
|
const loadedCounts = {
|
|
39
40
|
page: loadAutoComplete,
|
|
@@ -63,14 +64,25 @@ const SearchForm = ({
|
|
|
63
64
|
const searchFormRef = useRef();
|
|
64
65
|
|
|
65
66
|
const handleOnSearchIconClick = () => {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
setLocalSearch(!localSearch);
|
|
68
|
+
toggleScroll("search");
|
|
69
|
+
|
|
70
|
+
// Defer VariableComponent rendering to reduce processing duration on first click
|
|
71
|
+
// This allows the overlay to appear immediately, then render the heavy component
|
|
72
|
+
if (!localSearch) {
|
|
73
|
+
startTransition(() => {
|
|
74
|
+
setShowVariableComponent(true);
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
setShowVariableComponent(false);
|
|
78
|
+
}
|
|
68
79
|
};
|
|
69
80
|
|
|
70
81
|
const handleOverlayClickClose = (event) => {
|
|
71
82
|
if (event.target.classList.contains(styles.searchForm)) {
|
|
72
83
|
toggleScroll("search");
|
|
73
84
|
setLocalSearch(false);
|
|
85
|
+
setShowVariableComponent(false);
|
|
74
86
|
}
|
|
75
87
|
};
|
|
76
88
|
|
|
@@ -126,6 +138,7 @@ const SearchForm = ({
|
|
|
126
138
|
!searchFormRef.current.contains(event.target)
|
|
127
139
|
) {
|
|
128
140
|
setLocalSearch(false);
|
|
141
|
+
setShowVariableComponent(false);
|
|
129
142
|
toggleScroll("search");
|
|
130
143
|
}
|
|
131
144
|
};
|
|
@@ -275,7 +288,7 @@ const SearchForm = ({
|
|
|
275
288
|
)}
|
|
276
289
|
</div>
|
|
277
290
|
)}
|
|
278
|
-
{(showRecommendedCasinos || showTopSearches) && (!filteredData || filteredData.length === 0) && !autoCompleteLoading && (
|
|
291
|
+
{(showRecommendedCasinos || showTopSearches) && (!filteredData || filteredData.length === 0) && !autoCompleteLoading && showVariableComponent && (
|
|
279
292
|
<VariableComponent
|
|
280
293
|
recommendedCasinos={recommendedCasinos}
|
|
281
294
|
topSearches={topSearches}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react/react-in-jsx-scope */
|
|
2
2
|
/* eslint-disable import/prefer-default-export */
|
|
3
3
|
import React from "react";
|
|
4
|
-
import StarRating from "gatsby-core-theme/src/components/molecules/star-rating/one-star";
|
|
5
4
|
import { FaStar } from "@react-icons/all-files/fa/FaStar";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import StarRating from "~molecules/star-rating/one-star";
|
|
6
|
+
import CloseCircleIcon from "~images/icons/close-circle";
|
|
7
|
+
import CheckCircleIcon from "~images/icons/check-circle";
|
|
8
8
|
|
|
9
9
|
export const operatorRatings = {
|
|
10
10
|
operator: [
|
|
@@ -223,13 +223,11 @@ export const operatorRatings = {
|
|
|
223
223
|
translationKey: "min_deposit",
|
|
224
224
|
fieldValue: "min_deposit",
|
|
225
225
|
componentToUse: (numOfStars, value, currency) => {
|
|
226
|
-
if (
|
|
227
|
-
return
|
|
226
|
+
if (/N\/A|NA/i.test(value)) {
|
|
227
|
+
return "-";
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
return
|
|
231
|
-
<>{value ? `${currency}${value}` : "-"}</>
|
|
232
|
-
)
|
|
229
|
+
|
|
230
|
+
return <>{value ? `${currency}${value}` : "-"}</>;
|
|
233
231
|
},
|
|
234
232
|
},
|
|
235
233
|
{
|
package/src/helpers/getters.mjs
CHANGED
|
@@ -347,9 +347,9 @@ export function getGameIframe(relation, language = null) {
|
|
|
347
347
|
return null;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
export function getOperatorTnc(operator) {
|
|
351
|
-
return operator?.bonuses?.
|
|
352
|
-
? operator.bonuses?.
|
|
350
|
+
export function getOperatorTnc(operator, tracker = "main") {
|
|
351
|
+
return operator?.bonuses?.[tracker]?.terms_and_conditions_enabled
|
|
352
|
+
? operator.bonuses?.[tracker]?.terms_and_conditions
|
|
353
353
|
: null;
|
|
354
354
|
}
|
|
355
355
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// imageProcessor.js
|
|
2
|
-
import React from
|
|
3
|
-
import LazyImage from
|
|
4
|
-
import { parseContentImageUrl } from
|
|
5
|
-
import { parseCss } from
|
|
6
|
-
import styles from
|
|
2
|
+
import React from "react";
|
|
3
|
+
import LazyImage from "~hooks/lazy-image";
|
|
4
|
+
import { parseContentImageUrl } from "~helpers/strings";
|
|
5
|
+
import { parseCss } from "~helpers/css-parser";
|
|
6
|
+
import styles from "../components/molecules/content/content.module.scss";
|
|
7
7
|
|
|
8
8
|
const getValueFromStyle = (style, cssAttribute) => {
|
|
9
|
-
const regex = new RegExp(
|
|
9
|
+
const regex = new RegExp(
|
|
10
|
+
`${cssAttribute}:\\s*([0-9]+(?:\\.[0-9]+)?)px?`,
|
|
11
|
+
"i"
|
|
12
|
+
);
|
|
10
13
|
const match = style?.match(regex);
|
|
11
14
|
return match ? Math?.floor(parseFloat(match[1])) : null;
|
|
12
15
|
};
|
|
@@ -14,44 +17,49 @@ const getValueFromStyle = (style, cssAttribute) => {
|
|
|
14
17
|
const processImageNode = (node, moduleWidth = 960, loading) => {
|
|
15
18
|
let stylesClass = null;
|
|
16
19
|
const classes = node.attribs.class;
|
|
17
|
-
if (classes?.includes(
|
|
18
|
-
stylesClass =
|
|
19
|
-
} else if (classes?.includes(
|
|
20
|
-
stylesClass =
|
|
21
|
-
} else if (classes?.includes(
|
|
22
|
-
stylesClass =
|
|
23
|
-
} else if (classes?.includes(
|
|
24
|
-
stylesClass =
|
|
25
|
-
} else if (classes?.includes(
|
|
26
|
-
stylesClass =
|
|
20
|
+
if (classes?.includes("content-image--float-left")) {
|
|
21
|
+
stylesClass = "floatLeft";
|
|
22
|
+
} else if (classes?.includes("content-image--float-right")) {
|
|
23
|
+
stylesClass = "floatRight";
|
|
24
|
+
} else if (classes?.includes("content-image--align-center")) {
|
|
25
|
+
stylesClass = "alignCenter";
|
|
26
|
+
} else if (classes?.includes("content-image--align-left")) {
|
|
27
|
+
stylesClass = "alignLeft";
|
|
28
|
+
} else if (classes?.includes("content-image--align-right")) {
|
|
29
|
+
stylesClass = "alignRight";
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
const imgWidthData =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
||
|
|
32
|
+
const imgWidthData =
|
|
33
|
+
node?.attribs?.width ||
|
|
34
|
+
node?.attribs?.["data-width"] ||
|
|
35
|
+
getValueFromStyle(node?.attribs?.style, "width") ||
|
|
36
|
+
"";
|
|
33
37
|
|
|
34
|
-
const imgHeightData =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
||
|
|
38
|
+
const imgHeightData =
|
|
39
|
+
node?.attribs?.height ||
|
|
40
|
+
node?.attribs?.["data-height"] ||
|
|
41
|
+
getValueFromStyle(node?.attribs?.style, "height") ||
|
|
42
|
+
"";
|
|
38
43
|
|
|
39
44
|
// Parse the width and height as numbers
|
|
40
45
|
const originalWidth = parseFloat(imgWidthData);
|
|
41
|
-
const originalHeight =
|
|
46
|
+
const originalHeight =
|
|
47
|
+
imgHeightData === "auto" ? 298 : parseFloat(imgHeightData);
|
|
42
48
|
|
|
43
49
|
// If width is greater than moduleWidth, adjust the width to moduleWidth and scale height accordingly
|
|
44
|
-
const imgWidth =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const imgWidth =
|
|
51
|
+
originalWidth > moduleWidth ? moduleWidth : originalWidth || "";
|
|
52
|
+
const imgHeight =
|
|
53
|
+
originalWidth > moduleWidth
|
|
54
|
+
? Math.round((originalHeight / originalWidth) * moduleWidth)
|
|
55
|
+
: originalHeight || "";
|
|
48
56
|
|
|
49
57
|
const lazyProps = {
|
|
50
58
|
src: parseContentImageUrl(node.attribs.src, imgWidth, imgHeight),
|
|
51
59
|
width: imgWidth,
|
|
52
60
|
height: imgHeight,
|
|
53
61
|
style: node.attribs.style ? parseCss(node.attribs.style) : null,
|
|
54
|
-
alt: node.attribs.alt ? node.attribs.alt :
|
|
62
|
+
alt: node.attribs.alt ? node.attribs.alt : "",
|
|
55
63
|
className: styles[stylesClass],
|
|
56
64
|
};
|
|
57
65
|
|
|
@@ -1,41 +1,50 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
3
|
-
import processImageNode from
|
|
4
|
-
import LazyImage from
|
|
5
|
-
import { parseContentImageUrl } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import processImageNode from "./processImageNode";
|
|
4
|
+
import LazyImage from "~hooks/lazy-image";
|
|
5
|
+
import { parseContentImageUrl } from "~helpers/strings";
|
|
6
6
|
|
|
7
|
-
jest.mock(
|
|
8
|
-
jest.mock(
|
|
7
|
+
jest.mock("~hooks/lazy-image", () => jest.fn());
|
|
8
|
+
jest.mock("~helpers/strings", () => ({
|
|
9
9
|
parseContentImageUrl: jest.fn(),
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
|
-
describe(
|
|
12
|
+
describe("processImageNode", () => {
|
|
13
13
|
const node = {
|
|
14
14
|
attribs: {
|
|
15
|
-
class:
|
|
16
|
-
src:
|
|
17
|
-
width:
|
|
18
|
-
height:
|
|
19
|
-
style:
|
|
20
|
-
alt:
|
|
15
|
+
class: "content-image--align-center",
|
|
16
|
+
src: "image-src",
|
|
17
|
+
width: "500px",
|
|
18
|
+
height: "auto",
|
|
19
|
+
style: "width: 500px; height: auto;",
|
|
20
|
+
alt: "image description",
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
beforeEach(() => {
|
|
25
|
-
LazyImage.mockImplementation(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
LazyImage.mockImplementation(
|
|
26
|
+
({ src, width, height, style, alt, className }) => (
|
|
27
|
+
<img
|
|
28
|
+
src={src}
|
|
29
|
+
width={width}
|
|
30
|
+
height={height}
|
|
31
|
+
style={style}
|
|
32
|
+
alt={alt}
|
|
33
|
+
className={className}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
);
|
|
28
37
|
});
|
|
29
38
|
|
|
30
|
-
test(
|
|
31
|
-
parseContentImageUrl.mockReturnValue(
|
|
39
|
+
test("renders LazyImage with correct props", () => {
|
|
40
|
+
parseContentImageUrl.mockReturnValue("parsed-image-url");
|
|
32
41
|
|
|
33
42
|
const { getByAltText } = render(processImageNode(node));
|
|
34
|
-
const img = getByAltText(
|
|
43
|
+
const img = getByAltText("image description");
|
|
35
44
|
|
|
36
|
-
expect(img).toHaveAttribute(
|
|
37
|
-
expect(img).toHaveAttribute(
|
|
38
|
-
expect(img).toHaveAttribute(
|
|
39
|
-
expect(img).toHaveClass(
|
|
45
|
+
expect(img).toHaveAttribute("src", "parsed-image-url");
|
|
46
|
+
expect(img).toHaveAttribute("width", "500");
|
|
47
|
+
expect(img).toHaveAttribute("height", "298");
|
|
48
|
+
expect(img).toHaveClass("alignCenter");
|
|
40
49
|
});
|
|
41
50
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/destructuring-assignment */
|
|
2
2
|
import React from "react";
|
|
3
|
-
import Iframe from "
|
|
4
|
-
import { isTrackerLink } from "
|
|
3
|
+
import Iframe from "~atoms/iframe";
|
|
4
|
+
import { isTrackerLink } from "~helpers/tracker.mjs";
|
|
5
5
|
import processImageNode from "./processImageNode.js";
|
|
6
6
|
import { TrackingKeys } from "~constants/tracking-api";
|
|
7
7
|
import PrettyLink from "~atoms/pretty-link";
|
package/src/resolver/games.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import loadash from "lodash/index.js";
|
|
3
|
-
import { filterNonNullValues } from "
|
|
3
|
+
import { filterNonNullValues } from "../helpers/getters.mjs";
|
|
4
4
|
import { pickRelationKeys } from "../constants/pick-keys.mjs";
|
|
5
5
|
import { getProviderData } from "./providers.mjs";
|
|
6
6
|
|