gatsby-core-theme 35.0.3 → 35.0.4
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/.storybook/main.js +28 -24
- package/CHANGELOG.md +30 -0
- package/package.json +2 -2
- package/package.old.json +1 -1
- package/src/components/atoms/button/button.js +1 -1
- package/src/components/atoms/button/operator-cta.js +1 -1
- package/src/components/atoms/market-dropdown/index.js +149 -0
- package/src/components/atoms/market-dropdown/market-dropdown.module.scss +169 -0
- package/src/components/atoms/market-dropdown/market-dropdown.stories.js +105 -0
- package/src/components/atoms/market-dropdown/market-dropdown.test.js +85 -0
- package/src/components/atoms/menu/mega-items/index.js +90 -0
- package/src/components/atoms/menu/mega-items/items.test.js +56 -0
- package/src/components/atoms/menu/mega-items/mega-item.module.scss +198 -0
- package/src/components/atoms/menu/variables/index.js +0 -1
- package/src/components/atoms/pretty-link/index.js +1 -1
- package/src/components/molecules/bonus/template-one/index.js +30 -23
- package/src/components/molecules/bonus/template-two/index.js +38 -34
- package/src/components/molecules/footer/variants/template-three/template-three.stories.js +71 -69
- package/src/components/molecules/footer/variants/template-two/template-two.stories.js +71 -69
- package/src/components/molecules/header/variants/operator/template-one-two/template-one-two.stories.js +20 -20
- package/src/components/molecules/menu/index.js +39 -26
- package/src/components/molecules/menu/menu.module.scss +7 -3
- package/src/components/molecules/toplist/header/header-toplist.module.scss +37 -0
- package/src/components/molecules/toplist/header/header-toplist.test.js +31 -0
- package/src/components/molecules/toplist/header/index.js +52 -0
- package/src/components/organisms/navigation/index.js +21 -14
- package/src/components/organisms/navigation/navigation.module.scss +12 -10
- package/src/components/organisms/search/index.js +2 -2
- package/src/components/pages/body/index.js +2 -0
- package/src/components/pages/tracker/index.js +54 -32
- package/src/components/pages/tracker/tracker.stories.js +73 -76
- package/src/constants/site-settings/navigation.js +2 -1
- package/src/styles/utils/variables/_main.scss +4 -4
- package/static/images/markets/ar_es.svg +13 -0
- package/static/images/markets/arab_en.svg +14 -0
- package/static/images/markets/marketdefault.svg +14 -0
package/.storybook/main.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
const path = require(
|
|
1
|
+
const path = require("path");
|
|
2
2
|
module.exports = {
|
|
3
3
|
stories: [
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
"../src/**/*.stories.@(js|jsx|ts|tsx)",
|
|
5
|
+
"../../**/**/src/**/*.stories.@(js|jsx|ts|tsx)",
|
|
6
6
|
],
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
staticDirs: ["../static"],
|
|
8
|
+
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
|
|
9
|
+
framework: "@storybook/react",
|
|
9
10
|
core: {
|
|
10
|
-
builder:
|
|
11
|
+
builder: "webpack5",
|
|
11
12
|
},
|
|
12
13
|
webpackFinal: async (config) => {
|
|
13
14
|
config.module.rules.push({
|
|
14
15
|
test: /\.scss$/,
|
|
15
16
|
use: [
|
|
16
|
-
require.resolve(
|
|
17
|
+
require.resolve("style-loader"),
|
|
17
18
|
{
|
|
18
|
-
loader: require.resolve(
|
|
19
|
+
loader: require.resolve("css-loader"),
|
|
19
20
|
options: {
|
|
20
21
|
importLoaders: 1,
|
|
21
22
|
modules: true,
|
|
22
23
|
},
|
|
23
24
|
},
|
|
24
|
-
require.resolve(
|
|
25
|
+
require.resolve("sass-loader"),
|
|
25
26
|
{
|
|
26
|
-
loader: require.resolve(
|
|
27
|
+
loader: require.resolve("sass-resources-loader"),
|
|
27
28
|
options: {
|
|
28
|
-
resources: [path.resolve(__dirname,
|
|
29
|
+
resources: [path.resolve(__dirname, "../src/styles/globals.scss")],
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
],
|
|
@@ -33,26 +34,29 @@ module.exports = {
|
|
|
33
34
|
config.module.rules[0].exclude = [/node_modules\/(?!(gatsby)\/)/];
|
|
34
35
|
// Use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
|
|
35
36
|
config.module.rules[0].use[0].options.plugins.push(
|
|
36
|
-
require.resolve(
|
|
37
|
+
require.resolve("babel-plugin-remove-graphql-queries")
|
|
37
38
|
);
|
|
38
39
|
config.resolve.alias = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
"~atoms": path.resolve(__dirname, "../src/components/atoms/"),
|
|
41
|
+
"~molecules": path.resolve(__dirname, "../src/components/molecules"),
|
|
42
|
+
"~organisms": path.resolve(__dirname, "../src/components/organisms"),
|
|
43
|
+
"~pages": path.resolve(__dirname, "../src/components/pages"),
|
|
44
|
+
"~helpers": path.resolve(__dirname, "../src/helpers"),
|
|
45
|
+
"~hooks": path.resolve(__dirname, "../src/hooks"),
|
|
46
|
+
"~tests": path.resolve(__dirname, "../tests"),
|
|
47
|
+
"~context": path.resolve(__dirname, "../src/context"),
|
|
48
|
+
"~constants": path.resolve(__dirname, "../src/constants"),
|
|
49
|
+
"gatsby-page-utils": path.resolve(
|
|
50
|
+
__dirname,
|
|
51
|
+
"../../node_modules/gatsby-page-utils/dist"
|
|
52
|
+
),
|
|
49
53
|
};
|
|
50
54
|
|
|
51
|
-
config.resolve.alias[
|
|
55
|
+
config.resolve.alias["$virtual/lazy-client-sync-requires"] = path.resolve(
|
|
52
56
|
`./__mocks__/virtual-lazy-client-sync-requires.js`
|
|
53
57
|
);
|
|
54
58
|
|
|
55
|
-
config.resolve.mainFields = [
|
|
59
|
+
config.resolve.mainFields = ["browser", "module", "main"];
|
|
56
60
|
return config;
|
|
57
61
|
},
|
|
58
62
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## [35.0.4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v35.0.3...v35.0.4) (2024-07-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added market dropdown + tests + storybook ([11a66e9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/11a66e91b1a9a52ea4120bdf331f3a9b7fc0557e))
|
|
7
|
+
* added mega menu ([6a5dfd9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6a5dfd9d48aa8d9cf3cd3126b78c183c1fbc379a))
|
|
8
|
+
* added mega menu ([db4622b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/db4622b69a6ca01d85989d2869e63c4b7f9ca261))
|
|
9
|
+
* conflict ([8840bf9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8840bf96bca6cdedcc75c04c853e65b9b795e7a2))
|
|
10
|
+
* icons and default svg name ([6ebd98c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6ebd98c482f3537103c9ec787865f021f296bdeb))
|
|
11
|
+
* icons and default svg name ([6f66265](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6f66265ed344b8dc85cc363e257f702ee6c4d9bd))
|
|
12
|
+
* lighthouse pipeline ([a112a48](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a112a48ff5d15644f315648445fb06e25f05af26))
|
|
13
|
+
* lint ([d282f74](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d282f741e85634984caaa37ffc8e19f2081e2b7e))
|
|
14
|
+
* lint ([113351b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/113351b995bdaac2424eef7c32fd80030bcc7663))
|
|
15
|
+
* lint ([c68f342](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c68f342128b690de1be99b67a939eb779ebec823))
|
|
16
|
+
* lint and storybook images ([45846e8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/45846e85c70cfc6183db3913343049ee74e6473f))
|
|
17
|
+
* lint fixes ([07941f2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/07941f24875c877f37b47dfb927cf462b8fab408))
|
|
18
|
+
* mega menu on tablet ([957728f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/957728f32903c33eff7e259c51a91e76985c54d0))
|
|
19
|
+
* mega menu on tablet ([2ad76b9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2ad76b9c129adbe594293e5b0fe2b99722a287e5))
|
|
20
|
+
* remove noreferrer from cta links ([6e6b4e6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6e6b4e63afd2eec161d2f002c22d0486d610e695))
|
|
21
|
+
* remove noreferrer from cta links ([c4e0270](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c4e0270322fae6f99e38051f62651446848ae1a9))
|
|
22
|
+
* storybook and lint ([507c93c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/507c93c375607c19ad3a8153fa5ceee71d4d5141))
|
|
23
|
+
* storybook and lint ([072948b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/072948b57fee5ad4d359760c1ff0728ae13169c6))
|
|
24
|
+
* update stylesheet ([159e102](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/159e102252c3192c469efdeed103ebf48269fd55))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
* Merge branch 'tm-4071-market-dropdown' into 'master' ([fe55f5e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fe55f5ec4ca94be811f6521cc4eaadddc105c6e4))
|
|
28
|
+
* Merge branch 'tm-4598-mega-menu' into 'master' ([ae141ba](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ae141baa429717f4f65910b12067bd744ae51b30))
|
|
29
|
+
* Merge branch 'tm-4578-remove-noreferre' into 'master' ([63987fd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/63987fd39fd6afb655d6d4959d7e9e3c15bbd421))
|
|
30
|
+
|
|
1
31
|
## [35.0.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v35.0.2...v35.0.3) (2024-07-19)
|
|
2
32
|
|
|
3
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-core-theme",
|
|
3
|
-
"version": "35.0.
|
|
3
|
+
"version": "35.0.4",
|
|
4
4
|
"description": "Gatsby Theme NPM Package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "jest --coverage",
|
|
17
|
-
"storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name start-storybook -
|
|
17
|
+
"storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name start-storybook -p 6006",
|
|
18
18
|
"build-storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name build-storybook"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
package/package.old.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "jest --coverage",
|
|
16
|
-
"storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name start-storybook -
|
|
16
|
+
"storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name start-storybook -p 6006",
|
|
17
17
|
"build-storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name build-storybook"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
@@ -27,7 +27,7 @@ const OperatorCtaButton = ({
|
|
|
27
27
|
inactive: { translationKey: 'inactive', defaultValue: 'Not Accepting New Players' },
|
|
28
28
|
blacklisted: { translationKey: 'blacklisted', defaultValue: 'Blacklisted' },
|
|
29
29
|
},
|
|
30
|
-
rel = 'nofollow
|
|
30
|
+
rel = 'nofollow sponsored',
|
|
31
31
|
}) => {
|
|
32
32
|
const status = operator?.status || '';
|
|
33
33
|
const trackerType = tracker?.toLowerCase()?.replace(' ', '_');
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { IoMdClose } from "@react-icons/all-files/io/IoMdClose";
|
|
5
|
+
import Link from "gatsby-core-theme/src/hooks/link";
|
|
6
|
+
import LazyImage from "gatsby-core-theme/src/hooks/lazy-image";
|
|
7
|
+
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
8
|
+
import styles from "./market-dropdown.module.scss";
|
|
9
|
+
|
|
10
|
+
const MarketDropdown = ({ pageContext, defaultMarket = "US (English)" }) => {
|
|
11
|
+
const { allMarkets, page } = pageContext;
|
|
12
|
+
const containerRef = useRef(null);
|
|
13
|
+
const dropdownRef = useRef(null);
|
|
14
|
+
const [isActive, setIsActive] = useState(false);
|
|
15
|
+
const selectMarketText = useTranslate("select_market", "Select Market");
|
|
16
|
+
const activeMarket = allMarkets[page.market] || "gb_en";
|
|
17
|
+
const marketOptions = Object.keys(allMarkets).map((key) => [
|
|
18
|
+
key,
|
|
19
|
+
allMarkets[key],
|
|
20
|
+
]);
|
|
21
|
+
const onClick = () => {
|
|
22
|
+
setIsActive(!isActive);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
activeMarket.market = page.market;
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
function handleClickOutside(event) {
|
|
29
|
+
if (
|
|
30
|
+
containerRef.current &&
|
|
31
|
+
!containerRef.current.contains(event.target)
|
|
32
|
+
) {
|
|
33
|
+
setIsActive(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Bind the event listener
|
|
38
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
// Unbind the event listener on clean up
|
|
42
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
43
|
+
};
|
|
44
|
+
}, [containerRef]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
marketOptions.length > 1 && (
|
|
48
|
+
<div
|
|
49
|
+
className={`${styles.dropdownContainer} ${
|
|
50
|
+
isActive && styles.RemoveBorder
|
|
51
|
+
}`}
|
|
52
|
+
ref={containerRef}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className={`${styles.dropdown}`}
|
|
56
|
+
onKeyDown={() => onClick()}
|
|
57
|
+
onClick={() => onClick()}
|
|
58
|
+
>
|
|
59
|
+
<div
|
|
60
|
+
className={`${isActive && styles.dropdownActive} ${
|
|
61
|
+
styles.dropdownInner
|
|
62
|
+
}`}
|
|
63
|
+
>
|
|
64
|
+
<LazyImage
|
|
65
|
+
width={18}
|
|
66
|
+
height={18}
|
|
67
|
+
src={`/images/markets/${
|
|
68
|
+
activeMarket.path_prefix === null
|
|
69
|
+
? "marketdefault"
|
|
70
|
+
: activeMarket.market
|
|
71
|
+
}.svg`}
|
|
72
|
+
loading="eager"
|
|
73
|
+
alt={activeMarket.market}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div
|
|
78
|
+
ref={dropdownRef}
|
|
79
|
+
className={`${styles.dropdownOptions} ${
|
|
80
|
+
isActive && styles.RemoveBorderOptions
|
|
81
|
+
} ${isActive ? styles.active : ""}`}
|
|
82
|
+
>
|
|
83
|
+
<span className={styles.marketText}>
|
|
84
|
+
{selectMarketText}
|
|
85
|
+
<IoMdClose onClick={() => onClick()} />
|
|
86
|
+
</span>
|
|
87
|
+
|
|
88
|
+
<div className={styles.triangle} />
|
|
89
|
+
{marketOptions.map((item) => {
|
|
90
|
+
if (item[0] !== activeMarket.market) {
|
|
91
|
+
const langPage = page.hreflangs
|
|
92
|
+
? page.hreflangs.filter((lang) => {
|
|
93
|
+
const nonActiveMarket = item[0].split("_");
|
|
94
|
+
return (
|
|
95
|
+
lang.language === nonActiveMarket[1] &&
|
|
96
|
+
lang.country === nonActiveMarket[0]
|
|
97
|
+
);
|
|
98
|
+
})
|
|
99
|
+
: [];
|
|
100
|
+
|
|
101
|
+
const path =
|
|
102
|
+
langPage.length > 0
|
|
103
|
+
? langPage[0].path
|
|
104
|
+
: item[1].path_prefix || "/";
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Link
|
|
108
|
+
aria-label={item[0]}
|
|
109
|
+
to={path}
|
|
110
|
+
className={styles.marketLink}
|
|
111
|
+
>
|
|
112
|
+
<LazyImage
|
|
113
|
+
width={24}
|
|
114
|
+
height={24}
|
|
115
|
+
src={`/images/markets/${
|
|
116
|
+
item[1].path_prefix === null ? "marketdefault" : item[0]
|
|
117
|
+
}.svg`}
|
|
118
|
+
loading="eager"
|
|
119
|
+
alt={item[1].path_prefix}
|
|
120
|
+
/>
|
|
121
|
+
<span>
|
|
122
|
+
{item[1].path_prefix === null
|
|
123
|
+
? defaultMarket
|
|
124
|
+
: item[1].path_prefix}
|
|
125
|
+
</span>
|
|
126
|
+
</Link>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return <></>;
|
|
130
|
+
})}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
MarketDropdown.propTypes = {
|
|
138
|
+
pageContext: PropTypes.shape({
|
|
139
|
+
allMarkets: PropTypes.shape({}),
|
|
140
|
+
page: PropTypes.shape({
|
|
141
|
+
market: PropTypes.string,
|
|
142
|
+
hreflangs: PropTypes.arrayOf(PropTypes.shape({})),
|
|
143
|
+
}),
|
|
144
|
+
}),
|
|
145
|
+
section: PropTypes.shape({}),
|
|
146
|
+
defaultMarket: PropTypes.string,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default MarketDropdown;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
.dropdownContainer {
|
|
2
|
+
@include min(tablet){ position: relative;}
|
|
3
|
+
|
|
4
|
+
z-index: 3;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dropdown {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
background-color: #fff;
|
|
10
|
+
padding: .45rem;
|
|
11
|
+
border-radius:.8rem;
|
|
12
|
+
box-shadow: 0 20px 24px -4px rgb(27 27 28 / 5%);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dropdownInner{
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
background-color: #F4F4F4;
|
|
18
|
+
padding: .4rem;
|
|
19
|
+
|
|
20
|
+
@include flex-direction(row);
|
|
21
|
+
@include flex-align(center, center);
|
|
22
|
+
|
|
23
|
+
gap: .4rem;
|
|
24
|
+
border-radius:.8rem;
|
|
25
|
+
|
|
26
|
+
&::after{
|
|
27
|
+
@include arrow(rgba(27, 27, 28, 1), 0.8rem, down, false, translateY(-50%));
|
|
28
|
+
|
|
29
|
+
margin: .8rem .4rem .4rem;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dropdownActive::after{
|
|
34
|
+
@include arrow(rgba(27, 27, 28, 1), 0.8rem, up, false, translateY(50%));
|
|
35
|
+
|
|
36
|
+
margin: .4rem .4rem .8rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.dropdownOptions {
|
|
40
|
+
position: absolute;
|
|
41
|
+
background-color: #fff;
|
|
42
|
+
top: 100%;
|
|
43
|
+
padding: 1.6rem;
|
|
44
|
+
border-radius: 0.4rem;
|
|
45
|
+
gap: 0.6rem;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
height: 100dvh;
|
|
48
|
+
width: 100%;
|
|
49
|
+
right: 0;
|
|
50
|
+
display: none !important;
|
|
51
|
+
box-shadow: 0 20px 24px -4px rgb(27 27 28 / 5%);
|
|
52
|
+
|
|
53
|
+
@include flex-align(start, start);
|
|
54
|
+
|
|
55
|
+
@include min(tablet) {
|
|
56
|
+
min-width: 18.2rem;
|
|
57
|
+
margin-top: 2.6rem;
|
|
58
|
+
|
|
59
|
+
@include flex-align(start, center);
|
|
60
|
+
|
|
61
|
+
height: unset;
|
|
62
|
+
padding: .4rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@include min(desktop) {
|
|
66
|
+
margin-right: 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.marketText{
|
|
71
|
+
@include min(tablet){display: none;}
|
|
72
|
+
|
|
73
|
+
color: rgb(27 27 28 / 100%);
|
|
74
|
+
font-size: 1.8rem;
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
width: 100%;
|
|
77
|
+
line-height: 2.9rem;
|
|
78
|
+
|
|
79
|
+
@include flex-direction(row);
|
|
80
|
+
@include flex-align(center, center);
|
|
81
|
+
|
|
82
|
+
svg{
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
margin-left: auto
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.marketLink {
|
|
89
|
+
@include flex-align(center, flex-start);
|
|
90
|
+
|
|
91
|
+
width: 100%;
|
|
92
|
+
background-color: rgb(244 244 244 / 100%);
|
|
93
|
+
padding: .9rem .4rem;
|
|
94
|
+
border-radius: .8rem;
|
|
95
|
+
color: #0f172a;
|
|
96
|
+
text-transform: capitalize;
|
|
97
|
+
gap: .4rem;
|
|
98
|
+
|
|
99
|
+
&:hover{
|
|
100
|
+
background-color: #fff;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
> img {
|
|
104
|
+
width: 1.8rem;
|
|
105
|
+
height: 1.8rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
> span {
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
font-style: normal;
|
|
111
|
+
font-weight: 400;
|
|
112
|
+
line-height: 22px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&::after{
|
|
116
|
+
@include arrow(rgba(27, 27, 28, 1), 0.8rem, right, false, translateY(-50%));
|
|
117
|
+
|
|
118
|
+
margin-top: .8rem;
|
|
119
|
+
margin-right: 1.287rem;
|
|
120
|
+
margin-left: auto;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
.active {
|
|
126
|
+
display: flex !important;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.RemoveBorder {
|
|
130
|
+
> div::after {
|
|
131
|
+
transform: rotate(0deg);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.triangle {
|
|
136
|
+
@include min(tablet) {
|
|
137
|
+
display: block;
|
|
138
|
+
position: absolute;
|
|
139
|
+
bottom: 99%;
|
|
140
|
+
right: 1.5rem;
|
|
141
|
+
margin-top: -9px;
|
|
142
|
+
background-color: #fff;
|
|
143
|
+
width: 20px;
|
|
144
|
+
height: 20px;
|
|
145
|
+
border-top-right-radius: 5px;
|
|
146
|
+
transform: rotate(300deg) skewX(-30deg) scale(1, 0.866);
|
|
147
|
+
z-index: -1;
|
|
148
|
+
box-shadow: 0 20px 24px -4px rgb(27 27 28 / 5%);
|
|
149
|
+
|
|
150
|
+
&::before,
|
|
151
|
+
&::after {
|
|
152
|
+
content: '';
|
|
153
|
+
position: absolute;
|
|
154
|
+
background-color: inherit;
|
|
155
|
+
width: 20px;
|
|
156
|
+
height: 20px;
|
|
157
|
+
border-top-right-radius: 5px;
|
|
158
|
+
box-shadow: 0 20px 24px -4px rgb(27 27 28 / 5%);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&::before {
|
|
162
|
+
transform: rotate(-135deg) skewX(-45deg) scale(1.414, 0.707) translate(0, -50%);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&::after {
|
|
166
|
+
transform: rotate(135deg) skewY(-45deg) scale(0.707, 1.414) translate(50%);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 MarketDropdown from ".";
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: "Theme/Layout/Navigation/Market Dropdown",
|
|
14
|
+
component: MarketDropdown,
|
|
15
|
+
argTypes: {
|
|
16
|
+
pageContext: {
|
|
17
|
+
name: "pageContext",
|
|
18
|
+
type: { name: "object", required: true },
|
|
19
|
+
defaultValue: "",
|
|
20
|
+
description: "The Context object for the current page.",
|
|
21
|
+
table: {
|
|
22
|
+
type: { summary: "string" },
|
|
23
|
+
defaultValue: { summary: "" },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
showIcons: {
|
|
27
|
+
name: "showIcons",
|
|
28
|
+
type: { name: "boolean", required: false },
|
|
29
|
+
defaultValue: true,
|
|
30
|
+
description: "Choose whether SVG icons are shown.",
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: "boolean" },
|
|
33
|
+
defaultValue: { summary: "true" },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultMarket: {
|
|
37
|
+
name: "defaultMarket",
|
|
38
|
+
type: { name: "string", required: false },
|
|
39
|
+
defaultValue: true,
|
|
40
|
+
description: "Choose what is the default market text.",
|
|
41
|
+
table: {
|
|
42
|
+
type: { summary: "string" },
|
|
43
|
+
defaultValue: { summary: "US (English)" },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
parameters: {
|
|
48
|
+
docs: {
|
|
49
|
+
description: {
|
|
50
|
+
component:
|
|
51
|
+
"A component that renders a market dropdown for multimarket sites",
|
|
52
|
+
},
|
|
53
|
+
page: () => (
|
|
54
|
+
<>
|
|
55
|
+
<Title />
|
|
56
|
+
<Description />
|
|
57
|
+
<Primary />
|
|
58
|
+
<ArgsTable story={PRIMARY_STORY} />
|
|
59
|
+
</>
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const Template = (args) => (
|
|
66
|
+
<div style={{ width: "62px", margin: "0 auto" }}>
|
|
67
|
+
<MarketDropdown {...args} />
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export const Default = Template.bind({});
|
|
72
|
+
Default.args = {
|
|
73
|
+
pageContext: {
|
|
74
|
+
allMarkets: {
|
|
75
|
+
latam_es: {
|
|
76
|
+
path_prefix: null,
|
|
77
|
+
timezone: "UTC",
|
|
78
|
+
market: "latam_es",
|
|
79
|
+
},
|
|
80
|
+
ar_es: {
|
|
81
|
+
path_prefix: "argentina",
|
|
82
|
+
timezone: "UTC",
|
|
83
|
+
},
|
|
84
|
+
bo_es: {
|
|
85
|
+
path_prefix: "bolivia",
|
|
86
|
+
timezone: "UTC",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
page: {
|
|
90
|
+
market: "latam_es",
|
|
91
|
+
hreflangs: [
|
|
92
|
+
{
|
|
93
|
+
language: "latam",
|
|
94
|
+
country: "latam",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
language: "test",
|
|
98
|
+
country: "test",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
showIcons: true,
|
|
104
|
+
defaultMarket: "US (English)",
|
|
105
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
|
|
5
|
+
import MarketDropdown from '.';
|
|
6
|
+
|
|
7
|
+
const pageContext = {
|
|
8
|
+
allMarkets: {
|
|
9
|
+
latam_es: {
|
|
10
|
+
path_prefix: null,
|
|
11
|
+
timezone: 'UTC',
|
|
12
|
+
market: 'latam_es',
|
|
13
|
+
},
|
|
14
|
+
ar_es: {
|
|
15
|
+
path_prefix: 'argentina',
|
|
16
|
+
timezone: 'UTC',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
page: {
|
|
20
|
+
market: 'latam_es',
|
|
21
|
+
hreflangs: [
|
|
22
|
+
{
|
|
23
|
+
language: 'latam',
|
|
24
|
+
country: 'latam',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
language: 'test',
|
|
28
|
+
country: 'test',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const emptyPageContext = {
|
|
34
|
+
allMarkets: {
|
|
35
|
+
gb_en: {
|
|
36
|
+
path_prefix: 'english',
|
|
37
|
+
timezone: 'UTC',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
page: { market: 'gb_en' },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('Label Component', () => {
|
|
44
|
+
test('render market dropdown with markets', () => {
|
|
45
|
+
const { container } = render(<MarketDropdown pageContext={pageContext} />);
|
|
46
|
+
expect(container.querySelector('div.dropdownContainer')).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
test('render market dropdown without markets', () => {
|
|
49
|
+
const { container } = render(<MarketDropdown pageContext={emptyPageContext} />);
|
|
50
|
+
expect(container.querySelector('div.dropdownContainer')).toBeFalsy();
|
|
51
|
+
});
|
|
52
|
+
test('render market dropdown without icons', () => {
|
|
53
|
+
const { container } = render(<MarketDropdown pageContext={pageContext} showIcons={false} />);
|
|
54
|
+
expect(container.querySelector('div.dropdown svg')).toBeFalsy();
|
|
55
|
+
});
|
|
56
|
+
test('click market dropdown element', () => {
|
|
57
|
+
const { container } = render(<MarketDropdown pageContext={pageContext} />);
|
|
58
|
+
const marketDropdown = container.querySelector('div.dropdownContainer > div');
|
|
59
|
+
const body = document.querySelector('body');
|
|
60
|
+
fireEvent.click(marketDropdown);
|
|
61
|
+
fireEvent.keyDown(marketDropdown);
|
|
62
|
+
expect(container.querySelector('div.dropdownOptions')).toBeVisible();
|
|
63
|
+
fireEvent.click(body);
|
|
64
|
+
expect(container.querySelector('div.dropdownOptions')).not.toHaveClass('active');
|
|
65
|
+
});
|
|
66
|
+
test('render market dropdown on mobile', () => {
|
|
67
|
+
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 450 });
|
|
68
|
+
Object.defineProperty(window, 'innerHeight', {
|
|
69
|
+
writable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
value: 700,
|
|
72
|
+
});
|
|
73
|
+
window.dispatchEvent(new Event('resize'));
|
|
74
|
+
const { container } = render(<MarketDropdown pageContext={pageContext} />);
|
|
75
|
+
const marketDropdown = container.querySelector('div.dropdownContainer > div');
|
|
76
|
+
const closeIcon = container.querySelector('div.dropdownOptions .marketText svg');
|
|
77
|
+
fireEvent.click(marketDropdown);
|
|
78
|
+
expect(container.querySelector('div.dropdownOptions')).toBeVisible();
|
|
79
|
+
fireEvent.click(closeIcon);
|
|
80
|
+
expect(container.querySelector('div.dropdownOptions')).not.toHaveClass('active');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
cleanup();
|
|
85
|
+
});
|