@dnanpm/styleguide 3.12.3 → 4.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/build/cjs/components/Button/Button.d.ts +1 -7
- package/build/cjs/components/Button/Button.js +3 -3
- package/build/cjs/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/cjs/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/cjs/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/cjs/components/Chip/Chip.d.ts +2 -18
- package/build/cjs/components/Chip/Chip.js +2 -2
- package/build/cjs/components/Drawer/Drawer.d.ts +0 -7
- package/build/cjs/components/Drawer/Drawer.js +1 -1
- package/build/cjs/components/Footer/Components/FooterComponents.js +0 -1
- package/build/cjs/components/Hero/Hero.js +3 -2
- package/build/cjs/components/Icon/Icon.d.ts +2 -8
- package/build/cjs/components/Icon/Icon.js +3 -10
- package/build/cjs/components/Input/Input.d.ts +1 -10
- package/build/cjs/components/LabelText/LabelText.d.ts +1 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LanguageSelector.js +10 -9
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LoginTooltip.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -4
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +4 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +4 -8
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/PageSearch.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/cjs/components/Modal/Modal.d.ts +0 -5
- package/build/cjs/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/cjs/components/ReadMore/ReadMore.js +2 -8
- package/build/cjs/components/Tab/Tab.d.ts +2 -30
- package/build/cjs/components/Tab/Tab.js +2 -33
- package/build/cjs/components/Tabs/Tabs.d.ts +1 -9
- package/build/cjs/components/Tabs/Tabs.js +9 -17
- package/build/cjs/components/Tooltip/Tooltip.js +1 -1
- package/build/cjs/components/index.d.ts +0 -4
- package/build/cjs/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/cjs/index.js +0 -8
- package/build/cjs/themes/themeComponents/navigation.js +0 -4
- package/build/es/components/Button/Button.d.ts +1 -7
- package/build/es/components/Button/Button.js +3 -3
- package/build/es/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/es/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/es/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/es/components/Chip/Chip.d.ts +2 -18
- package/build/es/components/Chip/Chip.js +2 -2
- package/build/es/components/Drawer/Drawer.d.ts +0 -7
- package/build/es/components/Drawer/Drawer.js +1 -1
- package/build/es/components/Footer/Components/FooterComponents.js +0 -1
- package/build/es/components/Hero/Hero.js +3 -2
- package/build/es/components/Icon/Icon.d.ts +2 -8
- package/build/es/components/Icon/Icon.js +3 -10
- package/build/es/components/Input/Input.d.ts +1 -10
- package/build/es/components/LabelText/LabelText.d.ts +1 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/LanguageSelector.js +11 -10
- package/build/es/components/MainHeaderNavigation/ChildComponents/LoginTooltip.js +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -4
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +4 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +5 -9
- package/build/es/components/MainHeaderNavigation/ChildComponents/PageSearch.js +2 -2
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/es/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/es/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/es/components/Modal/Modal.d.ts +0 -5
- package/build/es/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/es/components/ReadMore/ReadMore.js +2 -8
- package/build/es/components/Tab/Tab.d.ts +2 -30
- package/build/es/components/Tab/Tab.js +2 -33
- package/build/es/components/Tabs/Tabs.d.ts +1 -9
- package/build/es/components/Tabs/Tabs.js +9 -17
- package/build/es/components/Tooltip/Tooltip.js +1 -1
- package/build/es/components/index.d.ts +0 -4
- package/build/es/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/es/index.js +0 -4
- package/build/es/themes/themeComponents/navigation.js +1 -3
- package/package.json +14 -14
- package/build/cjs/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/cjs/components/ButtonRound/ButtonRound.js +0 -37
- package/build/cjs/components/Icons/index.js +0 -224
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -59
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -259
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -168
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -104
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -62
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -26
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.js +0 -193
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.js +0 -74
- package/build/cjs/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/cjs/components/MainNavigation/MainNavigation.js +0 -319
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.js +0 -11
- package/build/cjs/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/cjs/components/MainNavigation/context/NavContext.js +0 -46
- package/build/cjs/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/cjs/components/MainNavigation/globalNavStyles.js +0 -94
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.js +0 -207
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -34
- package/build/cjs/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/cjs/components/TooltipMenu/TooltipMenu.js +0 -76
- package/build/es/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/es/components/ButtonRound/ButtonRound.js +0 -29
- package/build/es/components/Icons/index.js +0 -109
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -51
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -251
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -159
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -30
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +0 -29
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -96
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -57
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -18
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.js +0 -185
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.js +0 -66
- package/build/es/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/es/components/MainNavigation/MainNavigation.js +0 -311
- package/build/es/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/es/components/MainNavigation/context/MobileMenuContext.js +0 -7
- package/build/es/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/es/components/MainNavigation/context/NavContext.js +0 -42
- package/build/es/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/es/components/MainNavigation/globalNavStyles.js +0 -89
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.js +0 -199
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -31
- package/build/es/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/es/components/TooltipMenu/TooltipMenu.js +0 -68
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var ramda = require('ramda');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var useScrollPosition = require('../../hooks/useScrollPosition.js');
|
|
8
|
-
var useWindowSize = require('../../hooks/useWindowSize.js');
|
|
9
|
-
var styledComponents = require('styled-components');
|
|
10
|
-
var theme = require('../../themes/theme.js');
|
|
11
|
-
var navigation = require('../../themes/themeComponents/navigation.js');
|
|
12
|
-
var styledUtils = require('../../utils/styledUtils.js');
|
|
13
|
-
var Notification = require('../Notification/Notification.js');
|
|
14
|
-
var HeaderNavigationElements = require('./ChildComponents/HeaderNavigationElements.js');
|
|
15
|
-
var MobileMenu = require('./ChildComponents/MobileMenu.js');
|
|
16
|
-
var Ribbon = require('./ChildComponents/Ribbon.js');
|
|
17
|
-
var NavContext = require('./context/NavContext.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
|
-
|
|
21
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
|
-
|
|
23
|
-
const GlobalStyle = styledComponents.createGlobalStyle `
|
|
24
|
-
body.overflow-hidden {
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
// detect common touch screen devices
|
|
29
|
-
const isIosDevice = () => {
|
|
30
|
-
const validate = /iPad|iPhone|iPod|iPad Simulator|iPhone Simulator/i;
|
|
31
|
-
if (typeof navigator !== 'undefined' && typeof window !== 'undefined') {
|
|
32
|
-
return (validate.test(navigator.userAgent) &&
|
|
33
|
-
!window.MSStream);
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
const iosDevice = isIosDevice();
|
|
38
|
-
const fadeIn = styledComponents.keyframes `
|
|
39
|
-
0% {
|
|
40
|
-
opacity: 0;
|
|
41
|
-
transform: translateY(-5px);
|
|
42
|
-
}
|
|
43
|
-
5% {
|
|
44
|
-
opacity: 0;
|
|
45
|
-
transform: translateY(-5px);
|
|
46
|
-
}
|
|
47
|
-
100% {
|
|
48
|
-
opacity: 1;
|
|
49
|
-
transform: translateY(0px);
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
const preventBodyScroll = () => {
|
|
53
|
-
const { scrollY } = window;
|
|
54
|
-
document.body.style.position = 'fixed';
|
|
55
|
-
document.body.style.top = `-${scrollY}px`;
|
|
56
|
-
};
|
|
57
|
-
const resumeBodyScroll = () => {
|
|
58
|
-
const scrollY = document.body.style.top;
|
|
59
|
-
document.body.style.position = '';
|
|
60
|
-
document.body.style.top = '';
|
|
61
|
-
// if the call to close overlay is done multiple times, scroll only the first time
|
|
62
|
-
if (scrollY) {
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
window.scrollTo(0, parseInt(scrollY, 10) * -1);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const PageOverlay = styledComponents.styled.div `
|
|
69
|
-
position: fixed;
|
|
70
|
-
animation: ${fadeIn} 0.2s ease-in-out;
|
|
71
|
-
top: 0;
|
|
72
|
-
left: 0;
|
|
73
|
-
width: 100%;
|
|
74
|
-
height: 100%;
|
|
75
|
-
background: ${theme.default.color.background.plum.default + theme.default.color.transparency.T10};
|
|
76
|
-
z-index: ${({ $navZIndex }) => $navZIndex - 1};
|
|
77
|
-
`;
|
|
78
|
-
const scrollThreshold = 82;
|
|
79
|
-
const checkThreshold = (prevPos, currPos) => {
|
|
80
|
-
if (prevPos >= currPos) {
|
|
81
|
-
return prevPos - currPos > scrollThreshold;
|
|
82
|
-
}
|
|
83
|
-
return currPos - prevPos > scrollThreshold;
|
|
84
|
-
};
|
|
85
|
-
const GlobalNavigationContainer = styledComponents.styled.nav `
|
|
86
|
-
z-index: ${({ $navZIndex }) => $navZIndex};
|
|
87
|
-
position: relative;
|
|
88
|
-
position: sticky;
|
|
89
|
-
display: block;
|
|
90
|
-
top: 0;
|
|
91
|
-
left: 0;
|
|
92
|
-
width: 100%;
|
|
93
|
-
background-color: ${theme.default.color.background.white.default};
|
|
94
|
-
color: ${theme.default.color.text.black};
|
|
95
|
-
top: ${({ $menuLevel, $tooltipMenuActive }) => ($menuLevel === null || $menuLevel === void 0 ? void 0 : $menuLevel.hideOnScroll) && !($menuLevel === null || $menuLevel === void 0 ? void 0 : $menuLevel.level1) && !$tooltipMenuActive
|
|
96
|
-
? `calc(-${navigation.desktopNavMaxHeight} - ${navigation.ribbonHeight})`
|
|
97
|
-
: '0px'} !important;
|
|
98
|
-
transition: top 0.2s ease-in-out;
|
|
99
|
-
box-sizing: border-box;
|
|
100
|
-
`;
|
|
101
|
-
const NavigationWrapper = styledComponents.styled.div `
|
|
102
|
-
display: flex;
|
|
103
|
-
width: 100%;
|
|
104
|
-
max-width: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 256)};
|
|
105
|
-
margin: 0 auto;
|
|
106
|
-
height: ${navigation.mobileNavMaxHeight};
|
|
107
|
-
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
108
|
-
height: ${navigation.desktopNavMaxHeight};
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
let previousValue = false;
|
|
112
|
-
const isStickySupported = typeof CSS !== 'undefined' &&
|
|
113
|
-
typeof CSS.supports !== 'undefined' &&
|
|
114
|
-
(CSS.supports('position', 'sticky') || CSS.supports('position', '-webkit-sticky'));
|
|
115
|
-
const initiateScrollToHeader = (componentRef) => {
|
|
116
|
-
if ((componentRef === null || componentRef === void 0 ? void 0 : componentRef.current) && isStickySupported && typeof window !== 'undefined') {
|
|
117
|
-
window.scrollTo({ top: componentRef.current.offsetTop, left: 0 });
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* @visibleName Main Navigation
|
|
122
|
-
* @deprecated Use `MainHeaderNavigation` component
|
|
123
|
-
*/
|
|
124
|
-
const MainNavigation = ({ items = {}, language = 'fi', zIndex = 1030, languageSelector = false, search = true, searchText = 'Haku', searchComponent = false, minicart = true, minicartText = 'Ostoskori', minicartComponent = false, minicartAmount = 0, showMinicart = false, showLoginTooltip = false, login = true, loginText = 'Kirjaudu', loginComponent, isLoggedIn = false, collapseSize = 767, nextJSLinkComponent = false, ribbon = true, ribbonData, className, currentUrl = '', notificationText = '', }) => {
|
|
125
|
-
const { isMobile } = useWindowSize.default(collapseSize);
|
|
126
|
-
const props = {
|
|
127
|
-
items,
|
|
128
|
-
language,
|
|
129
|
-
zIndex,
|
|
130
|
-
search,
|
|
131
|
-
searchText,
|
|
132
|
-
minicart,
|
|
133
|
-
minicartText,
|
|
134
|
-
minicartComponent,
|
|
135
|
-
minicartAmount,
|
|
136
|
-
showMinicart,
|
|
137
|
-
showLoginTooltip,
|
|
138
|
-
login,
|
|
139
|
-
loginText,
|
|
140
|
-
loginComponent,
|
|
141
|
-
isLoggedIn,
|
|
142
|
-
searchComponent,
|
|
143
|
-
collapseSize,
|
|
144
|
-
languageSelector,
|
|
145
|
-
nextJSLinkComponent,
|
|
146
|
-
ribbonData,
|
|
147
|
-
notificationText,
|
|
148
|
-
};
|
|
149
|
-
const navigationEl = React.useRef(null);
|
|
150
|
-
const key = ramda.prop('id');
|
|
151
|
-
// Index & memoize menu levels
|
|
152
|
-
const level1 = React.useMemo(() => { var _a, _b; return (_b = (_a = items.mainNavigation) === null || _a === void 0 ? void 0 : _a.pages) !== null && _b !== void 0 ? _b : []; }, [items.mainNavigation]);
|
|
153
|
-
const level1Items = React.useMemo(() => ramda.indexBy(key, level1), [level1, key]);
|
|
154
|
-
const level2 = React.useMemo(() => level1.map(item => ramda.indexBy(key, item.pages)), [level1, key]);
|
|
155
|
-
const level2Items = Object.assign({}, ...level2);
|
|
156
|
-
// All states to for handling menus
|
|
157
|
-
const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false);
|
|
158
|
-
const [menuLevel, setMenuLevel] = React.useState({
|
|
159
|
-
level1: null,
|
|
160
|
-
animate1: true,
|
|
161
|
-
level2: null,
|
|
162
|
-
animate2: true,
|
|
163
|
-
level1Mobile: null,
|
|
164
|
-
level2Mobile: null,
|
|
165
|
-
scrollPosition: 0,
|
|
166
|
-
hideOnScroll: false,
|
|
167
|
-
});
|
|
168
|
-
const [lang] = React.useState(language);
|
|
169
|
-
// As scroll position cannot be always retained, close mobile menu when orientation changes
|
|
170
|
-
const initRotation = () => {
|
|
171
|
-
setIsMobileMenuOpen(false);
|
|
172
|
-
};
|
|
173
|
-
React.useEffect(() => {
|
|
174
|
-
if (iosDevice && isMobileMenuOpen) {
|
|
175
|
-
window.addEventListener('orientationchange', initRotation, false);
|
|
176
|
-
preventBodyScroll();
|
|
177
|
-
}
|
|
178
|
-
if (iosDevice && !isMobileMenuOpen) {
|
|
179
|
-
window.removeEventListener('orientationchange', initRotation, false);
|
|
180
|
-
resumeBodyScroll();
|
|
181
|
-
}
|
|
182
|
-
return () => {
|
|
183
|
-
window.removeEventListener('orientationchange', initRotation, false);
|
|
184
|
-
resumeBodyScroll();
|
|
185
|
-
};
|
|
186
|
-
}, [isMobileMenuOpen]);
|
|
187
|
-
const [tooltipItems, setTooltipItems] = React.useState(React.useMemo(() => ({
|
|
188
|
-
minicart: false,
|
|
189
|
-
login: false,
|
|
190
|
-
search: false,
|
|
191
|
-
}), []));
|
|
192
|
-
const tooltipMenuActive = tooltipItems.minicart || tooltipItems.login || tooltipItems.search;
|
|
193
|
-
const freezeOverflow = isMobileMenuOpen || (tooltipMenuActive && isMobile);
|
|
194
|
-
const isPageOverlay = tooltipMenuActive || menuLevel.level1 || menuLevel.level2;
|
|
195
|
-
React.useEffect(() => {
|
|
196
|
-
const bodyClasses = ['overflow-shown', 'overflow-hidden'];
|
|
197
|
-
document.body.classList.remove(...bodyClasses);
|
|
198
|
-
document.body.classList.add(bodyClasses[Number(Boolean(freezeOverflow))]);
|
|
199
|
-
}, [freezeOverflow]);
|
|
200
|
-
const navigationContext = React.useMemo(() => {
|
|
201
|
-
const handleNavMenuClick = (newValue, updatedLevel) => {
|
|
202
|
-
let clickedItself = false;
|
|
203
|
-
switch (updatedLevel) {
|
|
204
|
-
case 'level1':
|
|
205
|
-
clickedItself = newValue === menuLevel.level1;
|
|
206
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level1: !clickedItself ? newValue : null, animate1: !clickedItself, level2: null, animate2: true }));
|
|
207
|
-
break;
|
|
208
|
-
case 'level2':
|
|
209
|
-
clickedItself = newValue === menuLevel.level2;
|
|
210
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level2: newValue !== menuLevel.level2 ? newValue : null, animate1: false, animate2: !clickedItself }));
|
|
211
|
-
break;
|
|
212
|
-
case 'level1Mobile':
|
|
213
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level1Mobile: newValue || menuLevel.level1Mobile, scrollPosition: newValue ? 1 : 0 }));
|
|
214
|
-
break;
|
|
215
|
-
case 'level2Mobile':
|
|
216
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level2Mobile: newValue || menuLevel.level2Mobile, scrollPosition: newValue ? 2 : 1 }));
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const resetMenuEvents = () => {
|
|
221
|
-
setMenuLevel({
|
|
222
|
-
level2: null,
|
|
223
|
-
animate2: true,
|
|
224
|
-
level1: null,
|
|
225
|
-
animate1: true,
|
|
226
|
-
level1Mobile: null,
|
|
227
|
-
level2Mobile: null,
|
|
228
|
-
scrollPosition: 0,
|
|
229
|
-
hideOnScroll: false,
|
|
230
|
-
});
|
|
231
|
-
if (isMobileMenuOpen) {
|
|
232
|
-
setIsMobileMenuOpen(false);
|
|
233
|
-
}
|
|
234
|
-
setTooltipItems({
|
|
235
|
-
minicart: false,
|
|
236
|
-
login: false,
|
|
237
|
-
search: false,
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
const handleToggleClick = () => {
|
|
241
|
-
resetMenuEvents();
|
|
242
|
-
initiateScrollToHeader(navigationEl);
|
|
243
|
-
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
244
|
-
};
|
|
245
|
-
const getBackLink = (menuElements, i) => {
|
|
246
|
-
const idValue = menuLevel[`level${i}Mobile`];
|
|
247
|
-
return menuElements[idValue];
|
|
248
|
-
};
|
|
249
|
-
// Resets menu states when menu content alters between mobile and desktop
|
|
250
|
-
const menuChanged = previousValue !== isMobile;
|
|
251
|
-
if (menuChanged) {
|
|
252
|
-
resetMenuEvents();
|
|
253
|
-
previousValue = isMobile;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
lang,
|
|
257
|
-
navZIndex: zIndex,
|
|
258
|
-
menuLevel,
|
|
259
|
-
handleNavMenuClick,
|
|
260
|
-
getBackLink,
|
|
261
|
-
isMobileMenu: isMobile,
|
|
262
|
-
items,
|
|
263
|
-
level1Items,
|
|
264
|
-
level2Items,
|
|
265
|
-
resetMenuEvents,
|
|
266
|
-
handleToggleClick,
|
|
267
|
-
isMobileMenuOpen,
|
|
268
|
-
nextJSLinkComponent,
|
|
269
|
-
loginComponent,
|
|
270
|
-
isLoggedIn,
|
|
271
|
-
collapseSize,
|
|
272
|
-
tooltipItems,
|
|
273
|
-
setTooltipItems,
|
|
274
|
-
minicartComponent,
|
|
275
|
-
showMinicart,
|
|
276
|
-
showLoginTooltip,
|
|
277
|
-
searchComponent,
|
|
278
|
-
currentUrl,
|
|
279
|
-
};
|
|
280
|
-
}, [
|
|
281
|
-
isMobile,
|
|
282
|
-
lang,
|
|
283
|
-
zIndex,
|
|
284
|
-
menuLevel,
|
|
285
|
-
items,
|
|
286
|
-
level1Items,
|
|
287
|
-
level2Items,
|
|
288
|
-
isMobileMenuOpen,
|
|
289
|
-
nextJSLinkComponent,
|
|
290
|
-
loginComponent,
|
|
291
|
-
isLoggedIn,
|
|
292
|
-
collapseSize,
|
|
293
|
-
tooltipItems,
|
|
294
|
-
minicartComponent,
|
|
295
|
-
showMinicart,
|
|
296
|
-
showLoginTooltip,
|
|
297
|
-
searchComponent,
|
|
298
|
-
currentUrl,
|
|
299
|
-
]);
|
|
300
|
-
useScrollPosition.default(({ prevPos, currPos }) => {
|
|
301
|
-
const overThreshold = checkThreshold(prevPos.y, currPos.y);
|
|
302
|
-
const isShow = currPos.y < prevPos.y;
|
|
303
|
-
if (isShow !== menuLevel.hideOnScroll && overThreshold && !menuLevel.level1) {
|
|
304
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { animate1: false, animate2: false, hideOnScroll: isShow }));
|
|
305
|
-
}
|
|
306
|
-
}, undefined, false, 200);
|
|
307
|
-
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
308
|
-
isPageOverlay && React__default.default.createElement(PageOverlay, { "data-testid": "navigation-overlay", "$navZIndex": zIndex }),
|
|
309
|
-
React__default.default.createElement(GlobalNavigationContainer, { className: className, ref: navigationEl, "$collapseSize": collapseSize, "$menuLevel": menuLevel, "$navZIndex": zIndex, "$tooltipMenuActive": tooltipMenuActive, "data-testid": "main-navigation" },
|
|
310
|
-
React__default.default.createElement(NavContext.default.Provider, { value: navigationContext },
|
|
311
|
-
React__default.default.createElement(GlobalStyle, null),
|
|
312
|
-
!items.mainNavigation && notificationText && (React__default.default.createElement(Notification.default, { type: "info" }, notificationText)),
|
|
313
|
-
ribbon && ribbonData && React__default.default.createElement(Ribbon.default, { ribbonData: ribbonData, lang: language }),
|
|
314
|
-
React__default.default.createElement(NavigationWrapper, { "$collapseSize": collapseSize },
|
|
315
|
-
React__default.default.createElement(HeaderNavigationElements.default, { navElementProps: props }),
|
|
316
|
-
isMobile && React__default.default.createElement(MobileMenu.default, null))))));
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
exports.default = MainNavigation;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import type { GlobalNavItems, MenuLevelItem, MenuStates, MenuTooltipItems, MobileMenuLevel } from '../types/globalNavProps';
|
|
3
|
-
export interface NavContextProps {
|
|
4
|
-
collapseSize: number;
|
|
5
|
-
currentUrl: string;
|
|
6
|
-
getBackLink: (menuElements: MenuLevelItem[], i: number) => MenuLevelItem;
|
|
7
|
-
handleNavMenuClick: (id: string | null, level: string) => void;
|
|
8
|
-
handleToggleClick: () => void;
|
|
9
|
-
isLoggedIn: boolean;
|
|
10
|
-
isMobileMenu: boolean;
|
|
11
|
-
isMobileMenuOpen: boolean;
|
|
12
|
-
items: GlobalNavItems;
|
|
13
|
-
level1Items: MobileMenuLevel;
|
|
14
|
-
level2Items: MobileMenuLevel;
|
|
15
|
-
lang: string;
|
|
16
|
-
loginComponent?: ReactNode | boolean | undefined;
|
|
17
|
-
menuLevel: MenuStates;
|
|
18
|
-
minicartComponent?: ReactNode | boolean | undefined;
|
|
19
|
-
navZIndex: number;
|
|
20
|
-
nextJSLinkComponent: ReactNode | boolean;
|
|
21
|
-
resetMenuEvents: () => void;
|
|
22
|
-
searchComponent?: ReactNode | boolean | undefined;
|
|
23
|
-
setTooltipItems: Dispatch<SetStateAction<MenuTooltipItems>>;
|
|
24
|
-
showLoginTooltip: boolean;
|
|
25
|
-
showMinicart: boolean;
|
|
26
|
-
tooltipItems: MenuTooltipItems;
|
|
27
|
-
}
|
|
28
|
-
declare const NavContext: import("react").Context<NavContextProps>;
|
|
29
|
-
export default NavContext;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
const NavContext = React.createContext({
|
|
8
|
-
collapseSize: 767,
|
|
9
|
-
currentUrl: '',
|
|
10
|
-
getBackLink: () => ({ id: '', pages: [], titles: {}, urls: {} }),
|
|
11
|
-
handleNavMenuClick: () => { },
|
|
12
|
-
handleToggleClick: () => { },
|
|
13
|
-
isLoggedIn: false,
|
|
14
|
-
isMobileMenu: false,
|
|
15
|
-
isMobileMenuOpen: false,
|
|
16
|
-
items: {},
|
|
17
|
-
lang: 'fi',
|
|
18
|
-
level1Items: { level1: { id: '', pages: [], titles: {}, urls: {} } },
|
|
19
|
-
level2Items: { level2: { id: '', pages: [], titles: {}, urls: {} } },
|
|
20
|
-
loginComponent: false,
|
|
21
|
-
menuLevel: {
|
|
22
|
-
level1: null,
|
|
23
|
-
animate1: true,
|
|
24
|
-
level2: null,
|
|
25
|
-
animate2: true,
|
|
26
|
-
level1Mobile: null,
|
|
27
|
-
level2Mobile: null,
|
|
28
|
-
scrollPosition: 0,
|
|
29
|
-
hideOnScroll: false,
|
|
30
|
-
},
|
|
31
|
-
minicartComponent: undefined,
|
|
32
|
-
navZIndex: 1030,
|
|
33
|
-
nextJSLinkComponent: false,
|
|
34
|
-
resetMenuEvents: () => { },
|
|
35
|
-
searchComponent: false,
|
|
36
|
-
setTooltipItems: () => { },
|
|
37
|
-
showLoginTooltip: false,
|
|
38
|
-
showMinicart: true,
|
|
39
|
-
tooltipItems: {
|
|
40
|
-
minicart: false,
|
|
41
|
-
login: false,
|
|
42
|
-
search: false,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
exports.default = NavContext;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const MenuItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {
|
|
2
|
-
isActive?: boolean;
|
|
3
|
-
}>> & string;
|
|
4
|
-
export declare const MenuLink: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {
|
|
5
|
-
isActive?: boolean;
|
|
6
|
-
}>> & string;
|
|
7
|
-
export declare const MenuLinkWithChildren: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
8
|
-
isActive?: boolean;
|
|
9
|
-
isHighlighted?: boolean;
|
|
10
|
-
}>> & string;
|
|
11
|
-
export declare const MenuList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {
|
|
12
|
-
isInView?: boolean;
|
|
13
|
-
}>> & string;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var styledComponents = require('styled-components');
|
|
4
|
-
var theme = require('../../themes/theme.js');
|
|
5
|
-
|
|
6
|
-
const MenuItem = styledComponents.styled.li `
|
|
7
|
-
position: relative;
|
|
8
|
-
padding: 0;
|
|
9
|
-
margin: 0;
|
|
10
|
-
height: 100%;
|
|
11
|
-
color: ${theme.default.color.text.black};
|
|
12
|
-
& > a {
|
|
13
|
-
color: ${p => (p.isActive ? theme.default.color.text.pink : theme.default.color.text.black)};
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
const MenuLink = styledComponents.styled.a `
|
|
17
|
-
border: none;
|
|
18
|
-
margin: 0;
|
|
19
|
-
padding: 0;
|
|
20
|
-
width: 100%;
|
|
21
|
-
overflow: visible;
|
|
22
|
-
background: transparent;
|
|
23
|
-
color: inherit;
|
|
24
|
-
font: inherit;
|
|
25
|
-
line-height: normal;
|
|
26
|
-
-webkit-font-smoothing: inherit;
|
|
27
|
-
-moz-osx-font-smoothing: inherit;
|
|
28
|
-
-webkit-appearance: none;
|
|
29
|
-
line-height: 1rem;
|
|
30
|
-
display: block;
|
|
31
|
-
text-decoration: none;
|
|
32
|
-
text-align: left;
|
|
33
|
-
color: ${p => (p.isActive ? theme.default.color.text.pink : theme.default.color.text.black)};
|
|
34
|
-
padding: 0.5em 1em;
|
|
35
|
-
white-space: normal;
|
|
36
|
-
&:hover,
|
|
37
|
-
&:focus {
|
|
38
|
-
text-decoration: none;
|
|
39
|
-
color: ${theme.default.color.text.pink};
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
outline: none;
|
|
42
|
-
border-bottom: none;
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
const MenuLinkWithChildren = styledComponents.styled.button `
|
|
46
|
-
line-height: 1rem;
|
|
47
|
-
text-align: left;
|
|
48
|
-
display: block;
|
|
49
|
-
text-decoration: none;
|
|
50
|
-
border: none;
|
|
51
|
-
background: none;
|
|
52
|
-
outline: none;
|
|
53
|
-
font-size: inherit;
|
|
54
|
-
font-family: inherit;
|
|
55
|
-
white-space: normal;
|
|
56
|
-
color: ${p => p && (p.isActive || p.isHighlighted) ? theme.default.color.text.pink : theme.default.color.default.black};
|
|
57
|
-
padding: 0.5em 1em;
|
|
58
|
-
span {
|
|
59
|
-
position: relative;
|
|
60
|
-
&:first-child:after {
|
|
61
|
-
position: absolute;
|
|
62
|
-
content: '';
|
|
63
|
-
width: 100%;
|
|
64
|
-
bottom: -6px;
|
|
65
|
-
left: 0;
|
|
66
|
-
border-bottom: 1px solid
|
|
67
|
-
${p => (p.isHighlighted ? theme.default.color.default.pink : 'transparent')};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
&:hover,
|
|
71
|
-
&:focus {
|
|
72
|
-
text-decoration: none;
|
|
73
|
-
color: ${theme.default.color.text.pink};
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
outline: none;
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
const MenuList = styledComponents.styled.ul `
|
|
79
|
-
display: inline-flex;
|
|
80
|
-
max-height: ${p => (typeof p.isInView !== 'boolean' || p.isInView ? 'auto' : '5px')};
|
|
81
|
-
overflow: ${p => (typeof p.isInView === 'boolean' ? 'hidden' : 'unset')};
|
|
82
|
-
align-items: center;
|
|
83
|
-
position: relative;
|
|
84
|
-
list-style: none;
|
|
85
|
-
margin: 0;
|
|
86
|
-
padding: 0;
|
|
87
|
-
background-color: ${theme.default.color.default.white};
|
|
88
|
-
transition: all 300ms ease-in-out;
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
exports.MenuItem = MenuItem;
|
|
92
|
-
exports.MenuLink = MenuLink;
|
|
93
|
-
exports.MenuLinkWithChildren = MenuLinkWithChildren;
|
|
94
|
-
exports.MenuList = MenuList;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { LangProps } from '../../types/language';
|
|
4
|
-
interface MenuItem {
|
|
5
|
-
id: string;
|
|
6
|
-
titles: LangProps;
|
|
7
|
-
urls: LangProps;
|
|
8
|
-
icon?: string;
|
|
9
|
-
target?: string;
|
|
10
|
-
}
|
|
11
|
-
interface SecondaryNavigationData {
|
|
12
|
-
name?: string;
|
|
13
|
-
categoryId?: string;
|
|
14
|
-
pages?: MenuItem[] | null;
|
|
15
|
-
}
|
|
16
|
-
interface NextJSLink {
|
|
17
|
-
linkUrl: string;
|
|
18
|
-
linkTitle: string;
|
|
19
|
-
iconName: string;
|
|
20
|
-
showNotification: boolean;
|
|
21
|
-
collapseSize: number;
|
|
22
|
-
children?: ReactNode;
|
|
23
|
-
}
|
|
24
|
-
interface Props {
|
|
25
|
-
/**
|
|
26
|
-
* Component data in JSON format
|
|
27
|
-
*/
|
|
28
|
-
data: SecondaryNavigationData;
|
|
29
|
-
/**
|
|
30
|
-
* Highlight active item
|
|
31
|
-
*/
|
|
32
|
-
currentUrl: string;
|
|
33
|
-
/**
|
|
34
|
-
* Allows to use nextJS component instead of HTML Anchor
|
|
35
|
-
*/
|
|
36
|
-
nextJSSecondaryNavLink?: ComponentType<NextJSLink>;
|
|
37
|
-
/**
|
|
38
|
-
* Allows to change language of component
|
|
39
|
-
*
|
|
40
|
-
* @default 'fi'
|
|
41
|
-
*/
|
|
42
|
-
lang?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Allows to set threshold in px, when desktop style changes to mobile style
|
|
45
|
-
*
|
|
46
|
-
* @default 767
|
|
47
|
-
*/
|
|
48
|
-
collapseSize?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Allows to set maximum width of component
|
|
51
|
-
*/
|
|
52
|
-
'max-width'?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Defines how active item is determined relative to `currentUrl` property
|
|
55
|
-
*
|
|
56
|
-
* @default true
|
|
57
|
-
*/
|
|
58
|
-
matchFullUrl?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Allows to hide component in desktop mode
|
|
61
|
-
*
|
|
62
|
-
* @default false
|
|
63
|
-
*/
|
|
64
|
-
mobileOnly?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Allows to highlight component items
|
|
67
|
-
*/
|
|
68
|
-
highlightIds?: string[];
|
|
69
|
-
/**
|
|
70
|
-
* Allows to set Secondary navigation background to white
|
|
71
|
-
*
|
|
72
|
-
* @default false
|
|
73
|
-
*/
|
|
74
|
-
whiteBg?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Allows to pass a custom className
|
|
77
|
-
*/
|
|
78
|
-
className?: string;
|
|
79
|
-
/**
|
|
80
|
-
* Allows to pass testid string for testing purposes
|
|
81
|
-
*/
|
|
82
|
-
'data-testid'?: string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @visibleName Secondary Navigation
|
|
86
|
-
* @deprecated Use `PriorityNavigation` component
|
|
87
|
-
*/
|
|
88
|
-
declare const SecondaryNavigation: ({ currentUrl, lang, nextJSSecondaryNavLink: NextJSSecondaryNavLink, collapseSize, "max-width": maxWidth, matchFullUrl, highlightIds, className, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
89
|
-
/** @component */
|
|
90
|
-
export default SecondaryNavigation;
|