gatsby-core-theme 22.0.15 → 23.0.0
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/preview.js +3 -2
- package/.storybook/storybook-styles/global.module.scss +4 -0
- package/.storybook/storybook-styles/navigation.module.scss +36 -0
- package/.storybook/storybook-styles.module.scss +5 -0
- package/CHANGELOG.md +48 -0
- package/package.json +1 -1
- package/src/components/atoms/author/author.stories.js +1 -1
- package/src/components/atoms/author-box/author-box.stories.js +1 -1
- package/src/components/atoms/bonus/bonus.stories.js +1 -1
- package/src/components/atoms/breadcrumbs/breadcrumbs.stories.js +1 -1
- package/src/components/atoms/button/button.stories.js +1 -1
- package/src/components/atoms/collapse/collpase.stories.js +1 -1
- package/src/components/atoms/content-box/content-box.stories.js +1 -1
- package/src/components/atoms/custom-select/custom-select.stories.js +1 -1
- package/src/components/atoms/faq/faq.stories.js +1 -1
- package/src/components/atoms/iframe/iframe.stories.js +1 -1
- package/src/components/atoms/image/image.stories.js +1 -1
- package/src/components/atoms/info-grid/info-grid.stories.js +1 -1
- package/src/components/atoms/label/label.stories.js +1 -1
- package/src/components/atoms/menu/items/index.js +76 -82
- package/src/components/atoms/menu/items/item/index.js +11 -92
- package/src/components/atoms/menu/items/item/item.module.scss +18 -57
- package/src/components/atoms/menu/items/item/item.moduleOriginal.scss +67 -0
- package/src/components/atoms/menu/items/items.module.scss +204 -58
- package/src/components/atoms/menu/items/items.test.js +33 -0
- package/src/components/atoms/menu/menu-icon/index.js +2 -2
- package/src/components/atoms/menu/menu-icon/menu-icon.module.scss +5 -4
- package/src/components/atoms/menu/menu-icon/menu-icon.test.js +44 -0
- package/src/components/atoms/menu/variables/index.js +26 -0
- package/src/components/atoms/menu/variables/variable.module.scss +0 -0
- package/src/components/atoms/module-title/module-title.stories.js +1 -1
- package/src/components/atoms/number-rating/number-rating.stories.js +1 -1
- package/src/components/atoms/open-graph/open-graph.stories.js +1 -1
- package/src/components/atoms/operator-cta/operator-cta.stories.js +1 -1
- package/src/components/atoms/operator-cta-button/operator-cta-button.stories.js +1 -1
- package/src/components/atoms/operator-info-block/operator-info-block.stories.js +1 -1
- package/src/components/atoms/scroll-to-top/stroll-to-top.stories.js +1 -1
- package/src/components/atoms/selling-points/selling-points.stories.js +1 -1
- package/src/components/atoms/sitemap/sitemap.stories.js +1 -1
- package/src/components/atoms/spotlights/spotlights.stories.js +1 -1
- package/src/components/atoms/timeline/timeline.stories.js +1 -1
- package/src/components/molecules/content/content.stories.js +1 -1
- package/src/components/molecules/content-and-custom-module/content-and-custom-module.stories.js +1 -1
- package/src/components/molecules/counter/counter-item/count-date/count-date.stories.js +1 -1
- package/src/components/molecules/counter/counter-item/count-number/count-number.stories.js +1 -1
- package/src/components/molecules/counter/counter.stories.js +1 -1
- package/src/components/molecules/footer/footer.stories.js +1 -1
- package/src/components/molecules/header/header.module.scss +1 -0
- package/src/components/molecules/header/{header.storiesssss.js → header.stories.js} +1 -1
- package/src/components/molecules/link-list/link-list.stories.js +1 -1
- package/src/components/molecules/menu/index.js +23 -43
- package/src/components/molecules/menu/menu.module.scss +76 -97
- package/src/components/molecules/menu/menu.test.js +111 -83
- package/src/components/molecules/operator-banner/operator-banner.stories.js +1 -1
- package/src/components/molecules/pagination/pagination.stories.js +1 -1
- package/src/components/molecules/pagination/with-midpoint.stories.js +1 -1
- package/src/components/molecules/pros-cons/pros-cons.stories.js +1 -1
- package/src/components/molecules/slider/slider.stories.js +1 -1
- package/src/components/molecules/star-rating/star-rating.stories.js +1 -1
- package/src/components/molecules/sticky/sticky.stories.js +1 -1
- package/src/components/molecules/tnc/tnc.stories.js +1 -1
- package/src/components/organisms/accordion/accordion.stories.js +1 -1
- package/src/components/organisms/anchor/anchor.module.scss +21 -16
- package/src/components/organisms/anchor/anchor.stories.js +3 -3
- package/src/components/organisms/archive/archive.stories.js +1 -1
- package/src/components/organisms/cards/cards.stories.js +1 -1
- package/src/components/organisms/cookie-consent/cookie-consent.stories.js +1 -1
- package/src/components/organisms/form/form.stories.js +1 -1
- package/src/components/organisms/navigation/index.js +26 -34
- package/src/components/organisms/navigation/navigation.module.scss +35 -39
- package/src/components/organisms/navigation/navigation.stories.js +163 -119
- package/src/components/organisms/navigation/navigation.test.js +28 -3
- package/src/components/organisms/search/search.stories.js +1 -1
- package/src/components/organisms/toplist/toplist.stories.js +1 -1
- package/src/components/pages/body/index.js +4 -12
- package/src/components/pages/tracker/tracker.stories.js +1 -1
- package/src/helpers/menu.js +24 -0
- package/src/helpers/menu.test.js +30 -0
- package/src/hooks/lazy-image/lazy-image.stories.js +1 -1
- package/src/hooks/lazy-picture/lazy-picture.stories.js +1 -1
- package/src/hooks/modal/modal.stories.js +1 -1
- package/src/hooks/tabs/tabs.stories.js +1 -1
- package/src/styles/utils/_animations.scss +4 -3
- package/src/styles/utils/_media-queries.scss +0 -10
- package/src/styles/utils/variables/_colors.scss +2 -0
- package/src/styles/utils/variables/_main.scss +29 -1
- package/static/images/bell.svg +3 -0
- package/static/images/notification-bubble.svg +4 -0
- package/tests/factories/sections/navigationStatic.factory.js +229 -0
- package/src/components/molecules/menu/menu.stories.js +0 -155
package/.storybook/preview.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '../gatsby-browser';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import styles from './storybook-styles.module.scss';
|
|
3
4
|
|
|
4
5
|
global.___loader = {
|
|
5
6
|
enqueue: () => {},
|
|
@@ -19,7 +20,7 @@ export const parameters = {
|
|
|
19
20
|
options: {
|
|
20
21
|
storySort: {
|
|
21
22
|
method: 'alphabetical',
|
|
22
|
-
order: ['
|
|
23
|
+
order: ['Theme', ['Layout', 'Modules', 'Atoms', 'Molecules', 'Organisms', 'Pages', 'Hooks']],
|
|
23
24
|
},
|
|
24
25
|
},
|
|
25
26
|
};
|
|
@@ -27,7 +28,7 @@ export const parameters = {
|
|
|
27
28
|
// Global decorators for stories
|
|
28
29
|
export const decorators = [
|
|
29
30
|
(Story) => (
|
|
30
|
-
<div
|
|
31
|
+
<div className={styles.storyMainContainer}>
|
|
31
32
|
<Story />
|
|
32
33
|
</div>
|
|
33
34
|
),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.navStoryContainer {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: calc(100vh - 5rem);
|
|
5
|
+
|
|
6
|
+
// added so that nav is visible on storybook without stretched beyond the viewport due to position:fixed
|
|
7
|
+
> div {
|
|
8
|
+
max-width: 96rem;
|
|
9
|
+
width: calc(100vw - 20px);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
nav {
|
|
13
|
+
padding: 0 10px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// dummy content styles
|
|
17
|
+
main {
|
|
18
|
+
padding-top: var(--nav-height);
|
|
19
|
+
background-color: var(--color-4);
|
|
20
|
+
|
|
21
|
+
pre {
|
|
22
|
+
display: inline;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.dummyContent {
|
|
26
|
+
letter-spacing: 0.2rem;
|
|
27
|
+
margin: 5rem auto;
|
|
28
|
+
width: 80vw;
|
|
29
|
+
|
|
30
|
+
@include min(laptop) {
|
|
31
|
+
margin: 10rem auto;
|
|
32
|
+
width: 60vw;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
# [23.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.15...v23.0.0) (2023-06-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix for tests ([77425fc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/77425fc2037aeb3606db730df4e304a3a3697a90))
|
|
7
|
+
* fix for tests ([d2871a2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d2871a26364aff6b39273c62c144eb83760ad082))
|
|
8
|
+
* storybook paths ([c7c5087](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c7c50872e52adfa4d88d995a81f2ea0e81847dc1))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* add changes to custom component ([929f141](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/929f14142d9611cd0847dda2be7a09faf927afa3))
|
|
14
|
+
* add logo width to align with sitelevel ([38cf693](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/38cf69332560717397dc51292b192eac3ac00097))
|
|
15
|
+
* added page context back and new custom component ([4663159](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4663159caff6ab8c57fa75b485a48a4b68173d37))
|
|
16
|
+
* changes to code review ([59e3bc9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/59e3bc9113591615ce30ff52ecd9415708bca39b))
|
|
17
|
+
* changes to mobile menu open/close ([8dcba1e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8dcba1e6d8e72319b314893a65a5e10903781fd2))
|
|
18
|
+
* changes to nav click even when clicking on child nav links ([d9cfc69](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d9cfc692929362cc7e5adac148812a46e36a6c3b))
|
|
19
|
+
* changes to storybook ([1f9978a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1f9978af14422e351cd82f6f14f59e61ec91c2b0))
|
|
20
|
+
* changes to storybook styles ([0687026](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0687026192912092a789d67178bcab9279862795))
|
|
21
|
+
* changes to styles ([eed0288](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/eed028825fe4e766d5051116c1a215f1b9262f49))
|
|
22
|
+
* clean up css files ([afeed74](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/afeed747071d3b970fbf03416f52e37f6bd6cd49))
|
|
23
|
+
* close all menus if when opening one if its enabled ([4ac8878](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4ac88788e64b6a45461612ab0cb47999c9547fe4))
|
|
24
|
+
* code review changes ([131a303](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/131a303feb0775d4511716b2aea7f9a3d1f7b321))
|
|
25
|
+
* code review changes, file rename to fix typo ([4ac8e2a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4ac8e2af06504f9107b4acd8c29d260baedfd4d4))
|
|
26
|
+
* correction to li style ([588167b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/588167b33767c34972cb77fbaffbdd2df2ee1a43))
|
|
27
|
+
* correction to menu item labeling long words ([542bc16](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/542bc16a6c4aad77948880bf17a44442051880d8))
|
|
28
|
+
* correction to storybook, fix unwanted props ([e63c438](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e63c43870446ffad2723e7b10dda49604c4bf14c))
|
|
29
|
+
* initial commit ([a23307c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a23307c61f7a8e905e3c3f8ee63800636faa7ae9))
|
|
30
|
+
* initial storybook changes ([c358380](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c358380002f110c26b513567bd1566600667f4b8))
|
|
31
|
+
* minor css changes ([2253833](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/225383340ebcc3fc49545fc1c1f208a8475723e6))
|
|
32
|
+
* remove temp variable ([f2fb5f7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f2fb5f788a42680a828a595217c9cf4d2856034a))
|
|
33
|
+
* remove unused vars ([746bb19](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/746bb19dc9ffd2790609ee4d2e78a217d30fd850))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
* Merge branch 'tm-3475-main-menu' into 'master' ([1029e54](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1029e54fecebabdf76647e759c9a763cd24edea4))
|
|
37
|
+
* Merge branch 'master' into tm-3475-main-menu ([7771485](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/77714850e6c86a4ba7670db47d6843239a4e2183))
|
|
38
|
+
* Merge branch 'master' into tm-3475-main-menu ([3805342](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/380534213add828157336133a33eab5bd9064cfb))
|
|
39
|
+
* Merge branch 'master' into tm-3475-main-menu ([531e98e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/531e98e0be3128b829fec83eb6b9719af6c5465f))
|
|
40
|
+
* Merge branch 'master' into tm-3475-main-menu ([1074e24](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1074e24d608f4ef4b74ca338e3f7e9ff2f27a725))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Tests
|
|
44
|
+
|
|
45
|
+
* add test ([1926693](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/19266937454c7926c48d652f22d0f20120a5f52e))
|
|
46
|
+
* fix for tests ([054dca9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/054dca90f302772ef4c8b3bc171b80cee87eea35))
|
|
47
|
+
* temp changes to test ([f760d93](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f760d9383f80f1bd0c98766380adecc59cc6ffd8))
|
|
48
|
+
|
|
1
49
|
## [22.0.15](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.14...v22.0.15) (2023-06-19)
|
|
2
50
|
|
|
3
51
|
|
package/package.json
CHANGED
|
@@ -1,110 +1,107 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
2
|
-
/* eslint-disable react/jsx-no-bind */
|
|
3
|
-
/* eslint-disable no-restricted-syntax */
|
|
4
1
|
/* eslint-disable no-unused-expressions */
|
|
5
|
-
/* eslint-disable
|
|
2
|
+
/* eslint-disable no-restricted-syntax */
|
|
6
3
|
import React, { useRef } from 'react';
|
|
7
4
|
import PropTypes from 'prop-types';
|
|
8
5
|
import keygen from '~helpers/keygen';
|
|
9
6
|
import Item from './item';
|
|
10
7
|
import styles from './items.module.scss';
|
|
11
|
-
|
|
12
|
-
const addPositionClass = ({ target }) => {
|
|
13
|
-
const children = target?.parentNode?.parentNode?.children || [];
|
|
14
|
-
for (const element of children) {
|
|
15
|
-
if (element?.tagName === 'UL' && element?.className === styles.subMenuList) {
|
|
16
|
-
const { left, width } = element.getBoundingClientRect();
|
|
17
|
-
left + width > document.body.clientWidth &&
|
|
18
|
-
element.classList.add(styles.staticLeft, styles.hoverLeft);
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
8
|
+
import { getPositionClass, itemHasChildren } from '~helpers/menu';
|
|
23
9
|
|
|
24
10
|
// Test included with menu molecule test
|
|
25
11
|
const Items = ({
|
|
26
12
|
item,
|
|
27
13
|
menuListRef,
|
|
28
|
-
options = {
|
|
29
|
-
mobile: {
|
|
30
|
-
canOpenAllSubMenus: false,
|
|
31
|
-
subMenuDropDownButton: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
14
|
gtmClass = '',
|
|
15
|
+
level = 1,
|
|
16
|
+
dropdownButtonWidth = 64,
|
|
17
|
+
canOpenAllSubMenus = true,
|
|
35
18
|
}) => {
|
|
36
19
|
let link;
|
|
37
20
|
let menu;
|
|
38
21
|
|
|
39
|
-
const
|
|
22
|
+
const parentMenuRef = useRef(null);
|
|
23
|
+
const subMenuListRef = useRef(null);
|
|
40
24
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
const closeOtherMenus = (target) => {
|
|
26
|
+
const parentsWithOpenSubMenu = target.parentNode.getElementsByClassName(styles.showSubMenu)[0];
|
|
27
|
+
const openSubmenus = parentsWithOpenSubMenu?.getElementsByClassName(styles.show)[0];
|
|
44
28
|
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
if (parentsWithOpenSubMenu && parentsWithOpenSubMenu !== target) {
|
|
30
|
+
// close other opened levels except the target
|
|
31
|
+
parentsWithOpenSubMenu && parentsWithOpenSubMenu.classList.remove(styles.showSubMenu);
|
|
32
|
+
openSubmenus && openSubmenus.classList.remove(styles.show);
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
34
|
+
// if other levels have open submenus, close them too
|
|
35
|
+
openSubmenus
|
|
36
|
+
.getElementsByClassName(styles.showSubMenu)[0]
|
|
37
|
+
?.classList.remove(styles.showSubMenu);
|
|
38
|
+
openSubmenus.getElementsByClassName(styles.show)[0]?.classList.remove(styles.show);
|
|
54
39
|
}
|
|
40
|
+
};
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
const onClick = (e) => {
|
|
43
|
+
const { target } = e;
|
|
44
|
+
const { width } = target.getBoundingClientRect();
|
|
45
|
+
|
|
46
|
+
// check if clicked within the arrow area which has a padding of 4.8rem on the li tag
|
|
47
|
+
if (e.nativeEvent.layerX > width - dropdownButtonWidth) {
|
|
48
|
+
// check if multiple submenus can be opened at same time, if not close them
|
|
49
|
+
if (!canOpenAllSubMenus) {
|
|
50
|
+
closeOtherMenus(target);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// toggle the clicked menu item
|
|
54
|
+
target.classList.toggle(styles.showSubMenu);
|
|
55
|
+
target.getElementsByTagName('UL')[0]?.classList.toggle(styles.show);
|
|
58
56
|
}
|
|
59
|
-
}
|
|
57
|
+
};
|
|
60
58
|
|
|
61
59
|
if (item.children) {
|
|
62
|
-
link =
|
|
63
|
-
<Item
|
|
64
|
-
hasChildren
|
|
65
|
-
item={item}
|
|
66
|
-
showSubMenuHandler={showSubMenu}
|
|
67
|
-
gtmClass={gtmClass}
|
|
68
|
-
options={{
|
|
69
|
-
mobile: {
|
|
70
|
-
subMenuDropDownButton: options.mobile.subMenuDropDownButton,
|
|
71
|
-
},
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
60
|
+
link = <Item item={item} gtmClass={gtmClass} />;
|
|
75
61
|
menu = (
|
|
76
|
-
<ul
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})}
|
|
62
|
+
<ul
|
|
63
|
+
ref={subMenuListRef}
|
|
64
|
+
className={`${styles.subMenuList || ''} ${
|
|
65
|
+
itemHasChildren(item) ? styles.hasChildWithSubmenu || '' : ''
|
|
66
|
+
}`}
|
|
67
|
+
>
|
|
68
|
+
{item.children.map((child) => (
|
|
69
|
+
<Items
|
|
70
|
+
key={keygen()}
|
|
71
|
+
item={child}
|
|
72
|
+
menuListRef={menuListRef}
|
|
73
|
+
gtmClass={gtmClass}
|
|
74
|
+
canOpenAllSubMenus={canOpenAllSubMenus}
|
|
75
|
+
level={level + 1}
|
|
76
|
+
/>
|
|
77
|
+
))}
|
|
93
78
|
</ul>
|
|
94
79
|
);
|
|
95
80
|
} else {
|
|
96
|
-
link =
|
|
97
|
-
<Item
|
|
98
|
-
hasChildren={false}
|
|
99
|
-
item={item}
|
|
100
|
-
gtmClass={gtmClass}
|
|
101
|
-
options={{ mobile: { subMenuDropDownButton: options.mobile.subMenuDropDownButton } }}
|
|
102
|
-
/>
|
|
103
|
-
);
|
|
81
|
+
link = <Item item={item} gtmClass={gtmClass} />;
|
|
104
82
|
}
|
|
105
83
|
|
|
106
84
|
return (
|
|
107
|
-
<li
|
|
85
|
+
<li
|
|
86
|
+
ref={parentMenuRef}
|
|
87
|
+
className={`${styles.menuItem || ''} ${styles[`level${level.toString()}`] || ''}
|
|
88
|
+
${item.children !== undefined ? styles.hasChildren || '' : ''}
|
|
89
|
+
`}
|
|
90
|
+
onFocus={(e) => getPositionClass(e.target, styles)}
|
|
91
|
+
onMouseOver={(e) => getPositionClass(e.target, styles)}
|
|
92
|
+
role="menuitem"
|
|
93
|
+
tabIndex="0"
|
|
94
|
+
onKeyDown={(e) => {
|
|
95
|
+
if (e.defaultPrevented) return;
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
onClick(e);
|
|
98
|
+
}}
|
|
99
|
+
onClick={(e) => {
|
|
100
|
+
if (e.defaultPrevented) return;
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
onClick(e);
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
108
105
|
{link}
|
|
109
106
|
{menu}
|
|
110
107
|
</li>
|
|
@@ -123,13 +120,10 @@ Items.propTypes = {
|
|
|
123
120
|
),
|
|
124
121
|
}).isRequired,
|
|
125
122
|
menuListRef: PropTypes.oneOfType([PropTypes.element, PropTypes.any]),
|
|
126
|
-
options: PropTypes.shape({
|
|
127
|
-
mobile: PropTypes.shape({
|
|
128
|
-
canOpenAllSubMenus: PropTypes.bool,
|
|
129
|
-
subMenuDropDownButton: PropTypes.bool,
|
|
130
|
-
}),
|
|
131
|
-
}),
|
|
132
123
|
gtmClass: PropTypes.string,
|
|
124
|
+
level: PropTypes.number,
|
|
125
|
+
dropdownButtonWidth: PropTypes.number,
|
|
126
|
+
canOpenAllSubMenus: PropTypes.bool,
|
|
133
127
|
};
|
|
134
128
|
|
|
135
129
|
export default Items;
|
|
@@ -1,64 +1,26 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Link from '~hooks/link';
|
|
5
|
-
import ConditionalWrapper from '~atoms/conditional-wrapper';
|
|
6
5
|
import { imagePrettyUrl } from '~helpers/getters';
|
|
7
6
|
import { NavigationContext } from '~organisms/navigation/navigationContext';
|
|
8
7
|
|
|
9
8
|
import styles from './item.module.scss';
|
|
10
9
|
|
|
11
|
-
export default function Item({
|
|
12
|
-
item,
|
|
13
|
-
hasChildren,
|
|
14
|
-
showSubMenuHandler,
|
|
15
|
-
options = {
|
|
16
|
-
mobile: {
|
|
17
|
-
subMenuDropDownButton: true,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
gtmClass = '',
|
|
21
|
-
}) {
|
|
22
|
-
const [active, setActive] = useState('');
|
|
23
|
-
const [opened, setOpened] = useState(false);
|
|
24
|
-
|
|
10
|
+
export default function Item({ item, gtmClass = '' }) {
|
|
25
11
|
const { setShowMenu } = useContext(NavigationContext);
|
|
26
12
|
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const url = typeof window !== 'undefined' ? new URL(window.location.href) : '';
|
|
29
|
-
setActive(
|
|
30
|
-
url.pathname === item.value || url.pathname.substr(1) === item.value ? styles.active : ''
|
|
31
|
-
);
|
|
32
|
-
}, [active, item]);
|
|
33
|
-
|
|
34
13
|
const handleClose = () => {
|
|
35
14
|
setShowMenu(false);
|
|
36
15
|
};
|
|
37
16
|
|
|
38
|
-
const toggleDropDown = (e) => {
|
|
39
|
-
e.target.classList.toggle(styles.active);
|
|
40
|
-
setOpened(e.target.classList.contains(styles.active));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
17
|
const ItemImage = () =>
|
|
44
18
|
item.image ? (
|
|
45
|
-
<img width="
|
|
19
|
+
<img width="32" height="32" src={imagePrettyUrl(item.image, 32, 32)} alt={item.title} />
|
|
46
20
|
) : null;
|
|
47
21
|
|
|
48
22
|
return (
|
|
49
|
-
|
|
50
|
-
condition={hasChildren}
|
|
51
|
-
wrapper={(items) => (
|
|
52
|
-
<div
|
|
53
|
-
className={`${styles.itemWrapper || ''} ${
|
|
54
|
-
item.image ? styles?.itemWrapperIcon || '' : ''
|
|
55
|
-
}`}
|
|
56
|
-
onTouchStart={!options.mobile.subMenuDropDownButton ? showSubMenuHandler : null}
|
|
57
|
-
>
|
|
58
|
-
{items}
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
>
|
|
23
|
+
<>
|
|
62
24
|
{item.value?.includes('http') || item.value?.includes('www') ? (
|
|
63
25
|
<a
|
|
64
26
|
aria-label={`${item?.title} link`}
|
|
@@ -66,61 +28,31 @@ export default function Item({
|
|
|
66
28
|
title={item.title}
|
|
67
29
|
rel={`noreferrer ${item.nofollow && 'nofollow'}`}
|
|
68
30
|
target="_blank"
|
|
69
|
-
className={`${
|
|
70
|
-
|
|
71
|
-
} ${active || ''} ${
|
|
72
|
-
!options?.mobile?.subMenuDropDownButton
|
|
73
|
-
? hasChildren || ''
|
|
74
|
-
? styles.inactiveLink
|
|
75
|
-
: ''
|
|
76
|
-
: ''
|
|
77
|
-
} ${hasChildren ? styles.hasChildren || '' : ''} ${
|
|
78
|
-
!options?.mobile?.subMenuDropDownButton ? styles.noDropDownButton || '' : ''
|
|
79
|
-
}`}
|
|
31
|
+
className={`${styles.item || ''} ${gtmClass || ''}`}
|
|
32
|
+
onClick={() => handleClose()}
|
|
80
33
|
>
|
|
81
34
|
<ItemImage />
|
|
82
35
|
{item.title}
|
|
83
36
|
</a>
|
|
84
37
|
) : item.value !== null ? (
|
|
85
38
|
<Link
|
|
86
|
-
className={`${gtmClass || ''} ${styles.item || ''} ${
|
|
87
|
-
opened && (styles.openedLink || '')
|
|
88
|
-
} ${active || ''} ${
|
|
89
|
-
(!options?.mobile?.subMenuDropDownButton && hasChildren) || ''
|
|
90
|
-
? styles.inactiveLink || ''
|
|
91
|
-
: ''
|
|
92
|
-
} ${hasChildren ? styles.hasChildren || '' : ''} ${
|
|
93
|
-
!options.mobile.subMenuDropDownButton ? styles.noDropDownButton || '' : ''
|
|
94
|
-
}`}
|
|
95
39
|
disabled={item.value === null}
|
|
96
40
|
to={item.value}
|
|
97
41
|
title={item.title}
|
|
98
42
|
rel={item.nofollow && 'nofollow'}
|
|
99
43
|
aria-label={`${item?.title} link`}
|
|
100
|
-
|
|
44
|
+
className={`${styles.item || ''} ${gtmClass || ''}`}
|
|
45
|
+
onClick={() => handleClose()}
|
|
101
46
|
>
|
|
102
47
|
<ItemImage />
|
|
103
48
|
{item.title}
|
|
104
49
|
</Link>
|
|
105
50
|
) : (
|
|
106
|
-
<
|
|
51
|
+
<span className={`${styles.item || ''} ${gtmClass || ''} ${styles.inactiveLink}`}>
|
|
107
52
|
{item.title}
|
|
108
|
-
</
|
|
109
|
-
)}
|
|
110
|
-
{options.mobile.subMenuDropDownButton && hasChildren && (
|
|
111
|
-
<button
|
|
112
|
-
aria-label={`${item?.title} Dropdown`}
|
|
113
|
-
type="button"
|
|
114
|
-
className={`${gtmClass || ''} btn-cta`}
|
|
115
|
-
onClick={(e) => {
|
|
116
|
-
showSubMenuHandler(styles);
|
|
117
|
-
toggleDropDown(e);
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
{' '}
|
|
121
|
-
</button>
|
|
53
|
+
</span>
|
|
122
54
|
)}
|
|
123
|
-
|
|
55
|
+
</>
|
|
124
56
|
);
|
|
125
57
|
}
|
|
126
58
|
|
|
@@ -130,19 +62,6 @@ Item.propTypes = {
|
|
|
130
62
|
value: PropTypes.string,
|
|
131
63
|
nofollow: PropTypes.bool,
|
|
132
64
|
image: PropTypes.string,
|
|
133
|
-
children: PropTypes.arrayOf(
|
|
134
|
-
PropTypes.shape({
|
|
135
|
-
title: PropTypes.string,
|
|
136
|
-
value: PropTypes.string,
|
|
137
|
-
})
|
|
138
|
-
),
|
|
139
65
|
}).isRequired,
|
|
140
|
-
hasChildren: PropTypes.bool,
|
|
141
|
-
showSubMenuHandler: PropTypes.func,
|
|
142
|
-
options: PropTypes.shape({
|
|
143
|
-
mobile: PropTypes.shape({
|
|
144
|
-
subMenuDropDownButton: PropTypes.bool,
|
|
145
|
-
}),
|
|
146
|
-
}),
|
|
147
66
|
gtmClass: PropTypes.string,
|
|
148
67
|
};
|