@dnanpm/styleguide 3.11.0 → 3.11.2
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/Checkbox/Checkbox.js +2 -1
- package/build/cjs/components/Chip/Chip.js +2 -1
- package/build/cjs/components/DateTimePicker/DateTimePicker.d.ts +22 -6
- package/build/cjs/components/DateTimePicker/DateTimePicker.js +61 -29
- package/build/cjs/components/Footer/Components/FooterComponents.js +11 -23
- package/build/cjs/components/Footer/Footer.js +2 -1
- package/build/cjs/components/Input/Input.d.ts +7 -1
- package/build/cjs/components/Input/Input.js +16 -16
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/BusinessMenu.js +2 -1
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +13 -13
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +12 -12
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +3 -3
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +7 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.d.ts +4 -0
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +44 -41
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +3 -1
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.js +14 -10
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.d.ts +2 -0
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.js +4 -2
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.d.ts +8 -8
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.js +29 -24
- package/build/cjs/components/Notification/Notification.js +2 -1
- package/build/cjs/components/Pill/Pill.js +2 -1
- package/build/cjs/components/RadioButton/RadioButton.js +4 -3
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.js +3 -1
- package/build/cjs/components/Switch/Switch.js +1 -2
- package/build/cjs/components/Tooltip/Tooltip.js +2 -1
- package/build/cjs/utils/styledUtils.js +4 -4
- package/build/es/components/Checkbox/Checkbox.js +2 -1
- package/build/es/components/Chip/Chip.js +2 -1
- package/build/es/components/DateTimePicker/DateTimePicker.d.ts +22 -6
- package/build/es/components/DateTimePicker/DateTimePicker.js +61 -29
- package/build/es/components/Footer/Components/FooterComponents.js +11 -23
- package/build/es/components/Footer/Footer.js +2 -1
- package/build/es/components/Input/Input.d.ts +7 -1
- package/build/es/components/Input/Input.js +17 -17
- package/build/es/components/MainHeaderNavigation/ChildComponents/BusinessMenu.js +2 -1
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +13 -13
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +12 -12
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +3 -3
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +7 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.d.ts +4 -0
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +45 -43
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +3 -1
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.js +14 -10
- package/build/es/components/MainHeaderNavigation/context/NavContext.d.ts +2 -0
- package/build/es/components/MainHeaderNavigation/context/NavContext.js +4 -2
- package/build/es/components/MainHeaderNavigation/globalNavStyles.d.ts +8 -8
- package/build/es/components/MainHeaderNavigation/globalNavStyles.js +29 -24
- package/build/es/components/Notification/Notification.js +2 -1
- package/build/es/components/Pill/Pill.js +2 -1
- package/build/es/components/RadioButton/RadioButton.js +4 -3
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.js +3 -1
- package/build/es/components/Switch/Switch.js +1 -2
- package/build/es/components/Tooltip/Tooltip.js +2 -1
- package/build/es/utils/styledUtils.js +4 -4
- package/package.json +12 -10
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.js +0 -11
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.js +0 -7
package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js
CHANGED
|
@@ -9,15 +9,15 @@ const TooltipWrapper = styled.button `
|
|
|
9
9
|
padding: 0;
|
|
10
10
|
overflow: visible;
|
|
11
11
|
background: transparent;
|
|
12
|
-
color: ${p => (p
|
|
12
|
+
color: ${p => (p.$isHighlighted ? theme.color.text.pink : 'inherit')};
|
|
13
13
|
font: inherit;
|
|
14
14
|
line-height: normal;
|
|
15
15
|
-webkit-font-smoothing: inherit;
|
|
16
16
|
-moz-osx-font-smoothing: inherit;
|
|
17
17
|
-webkit-appearance: none;
|
|
18
18
|
cursor: pointer;
|
|
19
|
-
width: ${p => (p
|
|
20
|
-
border-left: ${p => (p
|
|
19
|
+
width: ${p => (p.$isLoggedIn ? '6.25rem' : '100%')};
|
|
20
|
+
border-left: ${p => (p.$isLoggedIn ? `2px solid ${theme.color.line.L03}` : 'none')};
|
|
21
21
|
&:active,
|
|
22
22
|
&:focus {
|
|
23
23
|
> svg,
|
|
@@ -28,7 +28,8 @@ const TooltipWrapper = styled.button `
|
|
|
28
28
|
&:focus-visible {
|
|
29
29
|
outline: 0;
|
|
30
30
|
border-radius: ${theme.radius.s};
|
|
31
|
-
box-shadow:
|
|
31
|
+
box-shadow:
|
|
32
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
32
33
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
33
34
|
> svg,
|
|
34
35
|
> span {
|
|
@@ -39,14 +40,14 @@ const TooltipWrapper = styled.button `
|
|
|
39
40
|
align-content: center;
|
|
40
41
|
display: flex;
|
|
41
42
|
margin: 0 auto;
|
|
42
|
-
@media (min-width: ${p => p
|
|
43
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
43
44
|
height: 1.625em;
|
|
44
45
|
width: 1.625em;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
> span {
|
|
48
49
|
display: none;
|
|
49
|
-
@media (min-width: ${p => p
|
|
50
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
50
51
|
font-size: ${theme.fontSize.xs};
|
|
51
52
|
font-weight: ${theme.fontWeight.medium};
|
|
52
53
|
width: 100%;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { MobileMenuBackLink } from '../types/globalNavProps';
|
|
3
|
+
export declare const MenuItemBackLink: ({ currentLevel, backRef, }: MobileMenuBackLink & {
|
|
4
|
+
backRef?: React.RefObject<HTMLButtonElement>;
|
|
5
|
+
}) => React.JSX.Element;
|
|
2
6
|
declare const RenderMobileMenu: () => React.JSX.Element | null;
|
|
3
7
|
export default RenderMobileMenu;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ChevronLeft, ChevronRight } from '@dnanpm/icons';
|
|
2
|
-
import React__default, { useContext, useRef,
|
|
2
|
+
import React__default, { useContext, useRef, useEffect } from 'react';
|
|
3
3
|
import { animated, useSpring } from 'react-spring';
|
|
4
4
|
import { styled } from 'styled-components';
|
|
5
5
|
import theme from '../../../themes/theme.js';
|
|
6
6
|
import { menuLevelsAmount, navMaxHeight, mobileNavMaxWidth, headerMaxHeight } from '../../../themes/themeComponents/navigation.js';
|
|
7
7
|
import { getMultipliedSize } from '../../../utils/styledUtils.js';
|
|
8
|
-
import MobileMenuContext from '../context/MobileMenuContext.js';
|
|
9
8
|
import NavContext from '../context/NavContext.js';
|
|
10
9
|
import { MenuLink, MenuList, MenuItem, MenuLinkWithChildren, FeaturedBlock } from '../globalNavStyles.js';
|
|
11
10
|
import LinkModifier, { isSelected } from './LinkModifier.js';
|
|
@@ -20,7 +19,7 @@ const MobileMenuWrapper = styled(animated.div) `
|
|
|
20
19
|
`;
|
|
21
20
|
const mobileMenu = `calc(100vh - ${headerMaxHeight})`;
|
|
22
21
|
const MenuLinkBackLink = styled(MenuLink) ``;
|
|
23
|
-
const MobileMenuContainer = styled.
|
|
22
|
+
const MobileMenuContainer = styled.nav `
|
|
24
23
|
width: 100%;
|
|
25
24
|
position: absolute;
|
|
26
25
|
top: ${navMaxHeight};
|
|
@@ -75,7 +74,7 @@ const MobileMenuContainer = styled.div `
|
|
|
75
74
|
}
|
|
76
75
|
${FeaturedBlock} {
|
|
77
76
|
border-bottom: 1px solid ${theme.color.line.L04};
|
|
78
|
-
> a {
|
|
77
|
+
section > a {
|
|
79
78
|
font-size: ${theme.fontSize.s};
|
|
80
79
|
line-height: ${theme.lineHeight.s};
|
|
81
80
|
padding: ${getMultipliedSize(theme.base.baseHeight, 1)};
|
|
@@ -83,31 +82,25 @@ const MobileMenuContainer = styled.div `
|
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
`;
|
|
86
|
-
const MenuItemBackLink = ({ currentLevel }) => {
|
|
87
|
-
const { handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = useContext(NavContext);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
const menuElementLevel = `level${currentLevel - 1}Items`;
|
|
93
|
-
const menuElements = levels[menuElementLevel];
|
|
85
|
+
const MenuItemBackLink = ({ currentLevel, backRef, }) => {
|
|
86
|
+
const { backToPreviousCategoryLabel, handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = useContext(NavContext);
|
|
87
|
+
const menuElements = currentLevel === 2 ? level1Items : level2Items;
|
|
88
|
+
const tabNavigationDisabled = scrollPosition !== currentLevel - 1;
|
|
89
|
+
const backLink = getBackLink(menuElements, currentLevel - 1);
|
|
94
90
|
const mobileMenuBackClick = () => {
|
|
95
91
|
handleNavMenuClick(null, `level${currentLevel - 1}Mobile`);
|
|
96
92
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return (React__default.createElement(MenuItem, { key: `back-${backLink.id}`, "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
100
|
-
React__default.createElement(MenuLinkBackLink, { as: "button", onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
93
|
+
return (React__default.createElement(MenuItem, { "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
94
|
+
React__default.createElement(MenuLinkBackLink, { as: "button", ref: backRef, onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined, "aria-label": `${backToPreviousCategoryLabel} ${backLink.titles[lang]}` },
|
|
101
95
|
React__default.createElement(ChevronLeft, { size: "1.5rem" }),
|
|
102
96
|
backLink.titles[lang])));
|
|
103
97
|
};
|
|
104
|
-
const
|
|
98
|
+
const SubMenuItem = ({ menuItem, currentLevel, itemIndex, mobileMenuRef, firstItemRef, }) => {
|
|
105
99
|
const { handleNavMenuClick, menuLevel, lang, currentUrl } = useContext(NavContext);
|
|
106
|
-
const
|
|
107
|
-
const hasChildren = menuItem.pages.length;
|
|
100
|
+
const hasChildren = !!menuItem.pages.length;
|
|
108
101
|
const indexLevel = currentLevel - 1;
|
|
109
102
|
const tabNavigationDisabled = menuLevel.scrollPosition !== indexLevel;
|
|
110
|
-
const menuUrl = menuItem.urls[lang]
|
|
103
|
+
const menuUrl = menuItem.urls[lang];
|
|
111
104
|
const mobileMenuClick = (element) => (e) => {
|
|
112
105
|
var _a, _b;
|
|
113
106
|
(_b = (_a = mobileMenuRef === null || mobileMenuRef === void 0 ? void 0 : mobileMenuRef.current) === null || _a === void 0 ? void 0 : _a.scroll) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
@@ -118,37 +111,50 @@ const CreateSubMenuItem = ({ menuItem, currentLevel, itemIndex }) => {
|
|
|
118
111
|
e.preventDefault();
|
|
119
112
|
handleNavMenuClick(element.id, `level${currentLevel}Mobile`);
|
|
120
113
|
};
|
|
121
|
-
const renderMenuItem = (children) => (React__default.createElement(MenuItem, { key: menuItem.id, "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, isActive: isSelected(currentUrl, menuUrl, true) }, children));
|
|
114
|
+
const renderMenuItem = (children) => (React__default.createElement(MenuItem, { key: menuItem.id, "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, "$isActive": isSelected(currentUrl, menuUrl, true) }, children));
|
|
122
115
|
if (hasChildren && currentLevel < 3) {
|
|
123
|
-
return renderMenuItem(React__default.createElement(MenuLink, { as: "button", onClick: mobileMenuClick(menuItem), tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
116
|
+
return renderMenuItem(React__default.createElement(MenuLink, { as: "button", ref: firstItemRef, onClick: mobileMenuClick(menuItem), tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
124
117
|
menuItem.titles[lang],
|
|
125
118
|
React__default.createElement(ChevronRight, { color: theme.color.default.pink })));
|
|
126
119
|
}
|
|
127
120
|
return renderMenuItem(React__default.createElement(LinkModifier, { menuItem: menuItem, disabledTabIndex: tabNavigationDisabled }));
|
|
128
121
|
};
|
|
129
|
-
const SubMenuMobile = ({ currentLevel, menuItem }) => {
|
|
130
|
-
const
|
|
122
|
+
const SubMenuMobile = ({ currentLevel, menuItem, mobileMenuRef }) => {
|
|
123
|
+
const { collapseSize, featuredItemsAriaLabel, menuLevel } = useContext(NavContext);
|
|
131
124
|
const indexLevel = currentLevel - 1;
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
125
|
+
const tabNavigationDisabled = menuLevel.scrollPosition !== indexLevel;
|
|
126
|
+
const backRef = useRef(null);
|
|
127
|
+
const firstItemRef = useRef(null);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
// Delay focus to allow animation to finish
|
|
130
|
+
const timer = setTimeout(() => {
|
|
131
|
+
if (currentLevel === 1 && firstItemRef.current) {
|
|
132
|
+
firstItemRef.current.focus();
|
|
133
|
+
}
|
|
134
|
+
if (currentLevel > 1 && backRef.current) {
|
|
135
|
+
backRef.current.focus();
|
|
136
|
+
}
|
|
137
|
+
}, 300);
|
|
138
|
+
return () => clearTimeout(timer);
|
|
139
|
+
}, [menuItem, currentLevel]);
|
|
140
|
+
if (!(menuItem === null || menuItem === void 0 ? void 0 : menuItem.pages.length)) {
|
|
135
141
|
return null;
|
|
136
142
|
}
|
|
143
|
+
const featuredItems = currentLevel === 2 ? menuItem.pages.filter(subMenuItem => !subMenuItem.pages.length) : [];
|
|
144
|
+
const menuItems = menuItem.pages.filter(subMenuItem => !featuredItems.includes(subMenuItem));
|
|
137
145
|
return (React__default.createElement(React__default.Fragment, null,
|
|
138
|
-
currentLevel > 1 && React__default.createElement(MenuItemBackLink, { currentLevel: currentLevel }),
|
|
139
|
-
featuredItems.length > 0 && (React__default.createElement(FeaturedBlock, { collapseSize: collapseSize },
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.map((subMenuItem, index) => (React__default.createElement(CreateSubMenuItem, { currentLevel: currentLevel, itemIndex: index, key: subMenuItem.id, menuItem: subMenuItem })))));
|
|
146
|
+
currentLevel > 1 && React__default.createElement(MenuItemBackLink, { backRef: backRef, currentLevel: currentLevel }),
|
|
147
|
+
featuredItems.length > 0 && (React__default.createElement(FeaturedBlock, { "$collapseSize": collapseSize },
|
|
148
|
+
React__default.createElement("section", { "aria-label": featuredItemsAriaLabel }, featuredItems.map(subMenuItem => (React__default.createElement(LinkModifier, { key: subMenuItem.id, menuItem: subMenuItem, showIcon: true, disabledTabIndex: tabNavigationDisabled })))))),
|
|
149
|
+
menuItems.map((subMenuItem, index) => (React__default.createElement(SubMenuItem, { currentLevel: currentLevel, itemIndex: index, key: subMenuItem.id, menuItem: subMenuItem, mobileMenuRef: mobileMenuRef, firstItemRef: index === 0 ? firstItemRef : undefined })))));
|
|
143
150
|
};
|
|
144
|
-
const NavigationMenuMobile = () => {
|
|
151
|
+
const NavigationMenuMobile = ({ mobileMenuRef }) => {
|
|
145
152
|
const { items, menuLevel, level1Items, level2Items } = useContext(NavContext);
|
|
146
153
|
const { mainNavigation } = items;
|
|
147
154
|
if (!(mainNavigation === null || mainNavigation === void 0 ? void 0 : mainNavigation.pages.length)) {
|
|
148
155
|
return null;
|
|
149
156
|
}
|
|
150
|
-
const renderMenuList = (scrollPosition, level, menuItem) => (React__default.createElement(MenuList, { "aria-hidden": menuLevel.scrollPosition !== scrollPosition, "aria-disabled": menuLevel.scrollPosition !== scrollPosition, "data-testid": `mobile-nav-menu-level-${level}`, isInView: menuLevel.scrollPosition === scrollPosition },
|
|
151
|
-
React__default.createElement(SubMenuMobile, { currentLevel: level, menuItem: menuItem })));
|
|
157
|
+
const renderMenuList = (scrollPosition, level, menuItem) => (React__default.createElement(MenuList, { "aria-hidden": menuLevel.scrollPosition !== scrollPosition, "aria-disabled": menuLevel.scrollPosition !== scrollPosition, "data-testid": `mobile-nav-menu-level-${level}`, "$isInView": menuLevel.scrollPosition === scrollPosition }, menuLevel.scrollPosition === scrollPosition && (React__default.createElement(SubMenuMobile, { currentLevel: level, menuItem: menuItem, mobileMenuRef: mobileMenuRef }))));
|
|
152
158
|
return (React__default.createElement(React__default.Fragment, null,
|
|
153
159
|
renderMenuList(0, 1, mainNavigation),
|
|
154
160
|
menuLevel.level1Mobile !== null &&
|
|
@@ -162,16 +168,12 @@ const RenderMobileMenu = () => {
|
|
|
162
168
|
const slidingMenuAnimation = useSpring({
|
|
163
169
|
transform: `translateX(${(menuLevel.scrollPosition / menuLevelsAmount) * -100}%)`,
|
|
164
170
|
});
|
|
165
|
-
const mobileMenuContext = useMemo(() => ({
|
|
166
|
-
mobileMenuRef,
|
|
167
|
-
}), [mobileMenuRef]);
|
|
168
171
|
if (!isMobileMenuOpen) {
|
|
169
172
|
return null;
|
|
170
173
|
}
|
|
171
|
-
return (React__default.createElement(MobileMenuContainer, { ref: mobileMenuRef },
|
|
172
|
-
React__default.createElement(
|
|
173
|
-
React__default.createElement(
|
|
174
|
-
React__default.createElement(NavigationMenuMobile, null)))));
|
|
174
|
+
return (React__default.createElement(MobileMenuContainer, { ref: mobileMenuRef, role: "dialog", "aria-modal": "true" },
|
|
175
|
+
React__default.createElement(MobileMenuWrapper, { style: slidingMenuAnimation },
|
|
176
|
+
React__default.createElement(NavigationMenuMobile, { mobileMenuRef: mobileMenuRef }))));
|
|
175
177
|
};
|
|
176
178
|
|
|
177
|
-
export { RenderMobileMenu as default };
|
|
179
|
+
export { MenuItemBackLink, RenderMobileMenu as default };
|
|
@@ -2,10 +2,12 @@ import type { ComponentType, MouseEvent, ReactNode } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { GlobalNavItems } from './types/globalNavProps';
|
|
4
4
|
export interface MainHeaderNavigationProps {
|
|
5
|
+
backToPreviousCategoryLabel?: string;
|
|
5
6
|
businessMenuAriaLabel?: string;
|
|
6
7
|
categoryCollectionText?: string;
|
|
7
8
|
/** Allows to pass a custom className */
|
|
8
9
|
className?: string;
|
|
10
|
+
featuredItemsAriaLabel?: string;
|
|
9
11
|
items?: GlobalNavItems;
|
|
10
12
|
language?: string;
|
|
11
13
|
zIndex?: number;
|
|
@@ -44,6 +46,6 @@ export interface MainHeaderNavigationProps {
|
|
|
44
46
|
notificationText?: string;
|
|
45
47
|
}
|
|
46
48
|
/** @visibleName MainHeaderNavigation */
|
|
47
|
-
declare const MainHeaderNavigation: ({ businessMenuAriaLabel, categoryCollectionText, closeMainMenuAriaLabel, className, collapseSize, currentUrl, dnaLogoLinkAriaLabel, isLoggedIn, items, language, languageSelector, languageSelectorText, login, loginComponent, loginText, mainMenuAriaLabel, minicart, minicartAmount, minicartAmountLabel, minicartComponent, minicartText, nextJSLinkComponent, notificationText, openMainMenuAriaLabel, search, searchComponent, searchText, showLoginTooltip, showMinicart, zIndex, ...props }: MainHeaderNavigationProps) => React.JSX.Element;
|
|
49
|
+
declare const MainHeaderNavigation: ({ backToPreviousCategoryLabel, businessMenuAriaLabel, categoryCollectionText, closeMainMenuAriaLabel, className, collapseSize, currentUrl, dnaLogoLinkAriaLabel, featuredItemsAriaLabel, isLoggedIn, items, language, languageSelector, languageSelectorText, login, loginComponent, loginText, mainMenuAriaLabel, minicart, minicartAmount, minicartAmountLabel, minicartComponent, minicartText, nextJSLinkComponent, notificationText, openMainMenuAriaLabel, search, searchComponent, searchText, showLoginTooltip, showMinicart, zIndex, ...props }: MainHeaderNavigationProps) => React.JSX.Element;
|
|
48
50
|
/** @component */
|
|
49
51
|
export default MainHeaderNavigation;
|
|
@@ -74,7 +74,7 @@ const PageOverlay = styled.div `
|
|
|
74
74
|
width: 100%;
|
|
75
75
|
height: 100%;
|
|
76
76
|
background: ${theme.color.background.plum.default + theme.color.transparency.T10};
|
|
77
|
-
z-index: ${({ navZIndex }) => navZIndex - 1};
|
|
77
|
+
z-index: ${({ $navZIndex }) => $navZIndex - 1};
|
|
78
78
|
`;
|
|
79
79
|
const scrollThreshold = 82;
|
|
80
80
|
const checkThreshold = (prevPos, currPos) => {
|
|
@@ -84,7 +84,7 @@ const checkThreshold = (prevPos, currPos) => {
|
|
|
84
84
|
return currPos - prevPos > scrollThreshold;
|
|
85
85
|
};
|
|
86
86
|
const GlobalNavigationContainer = styled.header `
|
|
87
|
-
z-index: ${({ navZIndex }) => navZIndex};
|
|
87
|
+
z-index: ${({ $navZIndex }) => $navZIndex};
|
|
88
88
|
position: sticky;
|
|
89
89
|
top: 0;
|
|
90
90
|
left: 0;
|
|
@@ -109,7 +109,7 @@ const NavigationWrapper = styled.div `
|
|
|
109
109
|
gap: 0;
|
|
110
110
|
background-color: ${theme.color.background.white.default};
|
|
111
111
|
border-bottom: 1px solid ${theme.color.line.L04};
|
|
112
|
-
@media (min-width: ${p => p
|
|
112
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
113
113
|
flex-wrap: nowrap;
|
|
114
114
|
gap: 0 ${getMultipliedSize(theme.base.baseWidth, 1.5)};
|
|
115
115
|
}
|
|
@@ -126,7 +126,7 @@ const initiateScrollToHeader = (componentRef) => {
|
|
|
126
126
|
/** @visibleName MainHeaderNavigation */
|
|
127
127
|
const MainHeaderNavigation = (_a) => {
|
|
128
128
|
var _b, _c, _d;
|
|
129
|
-
var { businessMenuAriaLabel = 'Sivustot', categoryCollectionText = 'Muut kategoriat', closeMainMenuAriaLabel, className, collapseSize = 767, currentUrl = '', dnaLogoLinkAriaLabel, isLoggedIn = false, items = {}, language = 'fi', languageSelector = false, languageSelectorText = 'Vaihda kieltä', login = true, loginComponent, loginText = 'Kirjaudu', mainMenuAriaLabel = 'Päänavigaatio', minicart = true, minicartAmount = 0, minicartAmountLabel, minicartComponent = false, minicartText = 'Ostoskori', nextJSLinkComponent = false, notificationText = '', openMainMenuAriaLabel, search = true, searchComponent = false, searchText = 'Haku', showLoginTooltip = false, showMinicart = false, zIndex = 1030 } = _a, props = __rest(_a, ["businessMenuAriaLabel", "categoryCollectionText", "closeMainMenuAriaLabel", "className", "collapseSize", "currentUrl", "dnaLogoLinkAriaLabel", "isLoggedIn", "items", "language", "languageSelector", "languageSelectorText", "login", "loginComponent", "loginText", "mainMenuAriaLabel", "minicart", "minicartAmount", "minicartAmountLabel", "minicartComponent", "minicartText", "nextJSLinkComponent", "notificationText", "openMainMenuAriaLabel", "search", "searchComponent", "searchText", "showLoginTooltip", "showMinicart", "zIndex"]);
|
|
129
|
+
var { backToPreviousCategoryLabel = '', businessMenuAriaLabel = 'Sivustot', categoryCollectionText = 'Muut kategoriat', closeMainMenuAriaLabel, className, collapseSize = 767, currentUrl = '', dnaLogoLinkAriaLabel, featuredItemsAriaLabel = '', isLoggedIn = false, items = {}, language = 'fi', languageSelector = false, languageSelectorText = 'Vaihda kieltä', login = true, loginComponent, loginText = 'Kirjaudu', mainMenuAriaLabel = 'Päänavigaatio', minicart = true, minicartAmount = 0, minicartAmountLabel, minicartComponent = false, minicartText = 'Ostoskori', nextJSLinkComponent = false, notificationText = '', openMainMenuAriaLabel, search = true, searchComponent = false, searchText = 'Haku', showLoginTooltip = false, showMinicart = false, zIndex = 1030 } = _a, props = __rest(_a, ["backToPreviousCategoryLabel", "businessMenuAriaLabel", "categoryCollectionText", "closeMainMenuAriaLabel", "className", "collapseSize", "currentUrl", "dnaLogoLinkAriaLabel", "featuredItemsAriaLabel", "isLoggedIn", "items", "language", "languageSelector", "languageSelectorText", "login", "loginComponent", "loginText", "mainMenuAriaLabel", "minicart", "minicartAmount", "minicartAmountLabel", "minicartComponent", "minicartText", "nextJSLinkComponent", "notificationText", "openMainMenuAriaLabel", "search", "searchComponent", "searchText", "showLoginTooltip", "showMinicart", "zIndex"]);
|
|
130
130
|
const { isMobile } = useWindowSize(collapseSize);
|
|
131
131
|
const navigationEl = useRef(null);
|
|
132
132
|
const key = prop('id');
|
|
@@ -230,10 +230,12 @@ const MainHeaderNavigation = (_a) => {
|
|
|
230
230
|
previousValue = isMobile;
|
|
231
231
|
}
|
|
232
232
|
return {
|
|
233
|
+
backToPreviousCategoryLabel,
|
|
233
234
|
categoryCollectionText,
|
|
234
235
|
collapseSize,
|
|
235
236
|
currentUrl,
|
|
236
237
|
getBackLink,
|
|
238
|
+
featuredItemsAriaLabel,
|
|
237
239
|
handleNavMenuClick,
|
|
238
240
|
isLoggedIn,
|
|
239
241
|
isMobileMenu: isMobile,
|
|
@@ -255,9 +257,11 @@ const MainHeaderNavigation = (_a) => {
|
|
|
255
257
|
tooltipItems,
|
|
256
258
|
};
|
|
257
259
|
}, [
|
|
260
|
+
backToPreviousCategoryLabel,
|
|
258
261
|
categoryCollectionText,
|
|
259
262
|
collapseSize,
|
|
260
263
|
currentUrl,
|
|
264
|
+
featuredItemsAriaLabel,
|
|
261
265
|
isLoggedIn,
|
|
262
266
|
isMobile,
|
|
263
267
|
isMobileMenuOpen,
|
|
@@ -291,23 +295,23 @@ const MainHeaderNavigation = (_a) => {
|
|
|
291
295
|
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
292
296
|
};
|
|
293
297
|
return (React__default.createElement(React__default.Fragment, null,
|
|
294
|
-
isPageOverlay && React__default.createElement(PageOverlay, { "data-testid": "navigation-overlay", navZIndex: zIndex }),
|
|
295
|
-
React__default.createElement(GlobalNavigationContainer, { className: className, collapseSize: collapseSize, "data-testid": "dna-main-header", navZIndex: zIndex, ref: navigationEl },
|
|
298
|
+
isPageOverlay && React__default.createElement(PageOverlay, { "data-testid": "navigation-overlay", "$navZIndex": zIndex }),
|
|
299
|
+
React__default.createElement(GlobalNavigationContainer, { className: className, "$collapseSize": collapseSize, "data-testid": "dna-main-header", "$navZIndex": zIndex, ref: navigationEl },
|
|
296
300
|
React__default.createElement(NavContext.Provider, { value: navigationContext },
|
|
297
301
|
React__default.createElement(GlobalStyle, null),
|
|
298
302
|
!items.mainNavigation && notificationText && (React__default.createElement(Notification, { type: "info" }, notificationText)),
|
|
299
303
|
React__default.createElement(BusinessMenu, { ariaLabel: businessMenuAriaLabel, currentBusinessId: items.businessId, items: (_d = items.businessSelector) === null || _d === void 0 ? void 0 : _d.items, lang: language }),
|
|
300
|
-
React__default.createElement(NavigationWrapper, { collapseSize: collapseSize },
|
|
304
|
+
React__default.createElement(NavigationWrapper, { "$collapseSize": collapseSize },
|
|
301
305
|
React__default.createElement(LogoLink, { "data-testid": "dna-logo-link", href: currentBusinessSite === null || currentBusinessSite === void 0 ? void 0 : currentBusinessSite.urls[language], "aria-label": dnaLogoLinkAriaLabel },
|
|
302
306
|
React__default.createElement(DnaLogo, { size: headerLogoSize })),
|
|
303
|
-
React__default.createElement(DesktopMenuContainer, { "aria-label": mainMenuAriaLabel, collapseSize: collapseSize },
|
|
307
|
+
React__default.createElement(DesktopMenuContainer, { "aria-label": mainMenuAriaLabel, "$collapseSize": collapseSize },
|
|
304
308
|
React__default.createElement(DesktopMenu, null)),
|
|
305
|
-
React__default.createElement(HeaderIconContainer, { collapseSize: collapseSize },
|
|
309
|
+
React__default.createElement(HeaderIconContainer, { "$collapseSize": collapseSize },
|
|
306
310
|
languagesObject && languageSelector && (React__default.createElement(LanguageSelector, { currentLanguage: language, languagesObject: languagesObject, languageSelectorLabel: languageSelectorText })),
|
|
307
311
|
search && React__default.createElement(PageSearch, { searchLabel: searchText }),
|
|
308
312
|
minicart && (React__default.createElement(MinicartTooltip, { minicartAmount: minicartAmount, minicartAmountLabel: minicartAmountLabel !== null && minicartAmountLabel !== void 0 ? minicartAmountLabel : '', minicartLabel: minicartText, onCartButtonClick: props.onCartButtonClick })),
|
|
309
313
|
login && React__default.createElement(LoginTooltip, { loginLabel: loginText, isLogged: isLoggedIn }),
|
|
310
|
-
React__default.createElement(IconContainer, { collapseSize: collapseSize, "data-testid": "header-mobile-menu-container" },
|
|
314
|
+
React__default.createElement(IconContainer, { "$collapseSize": collapseSize, "data-testid": "header-mobile-menu-container" },
|
|
311
315
|
React__default.createElement(MobileMenuButton, { "aria-expanded": isMobileMenuOpen, "aria-label": isMobileMenuOpen
|
|
312
316
|
? closeMainMenuAriaLabel
|
|
313
317
|
: openMainMenuAriaLabel, "data-testid": "header-mobile-menu-toggle", onClick: handleToggleClick }, isMobileMenuOpen ? React__default.createElement(Close, null) : React__default.createElement(Menu, null)))),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ComponentType, Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import type { GlobalNavItems, MenuLevelItem, MenuStates, MenuTooltipItems, MobileMenuLevel } from '../types/globalNavProps';
|
|
3
3
|
export interface NavContextProps {
|
|
4
|
+
backToPreviousCategoryLabel: string;
|
|
4
5
|
categoryCollectionText: string;
|
|
5
6
|
collapseSize: number;
|
|
6
7
|
currentUrl: string;
|
|
8
|
+
featuredItemsAriaLabel: string;
|
|
7
9
|
getBackLink: (menuElements: MobileMenuLevel, i: number) => MenuLevelItem;
|
|
8
10
|
handleNavMenuClick: (id: string | null, level: string) => void;
|
|
9
11
|
isLoggedIn: boolean;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const NavContext = createContext({
|
|
4
|
-
|
|
4
|
+
backToPreviousCategoryLabel: '',
|
|
5
|
+
categoryCollectionText: '',
|
|
5
6
|
collapseSize: 767,
|
|
6
7
|
currentUrl: '',
|
|
8
|
+
featuredItemsAriaLabel: '',
|
|
7
9
|
getBackLink: () => ({
|
|
8
10
|
id: '',
|
|
9
11
|
pageIsLinkInDesktopNavigation: false,
|
|
@@ -16,7 +18,7 @@ const NavContext = createContext({
|
|
|
16
18
|
isMobileMenu: false,
|
|
17
19
|
isMobileMenuOpen: false,
|
|
18
20
|
items: {},
|
|
19
|
-
lang: '
|
|
21
|
+
lang: '',
|
|
20
22
|
level1Items: {
|
|
21
23
|
level1: { id: '', pageIsLinkInDesktopNavigation: false, pages: [], titles: {}, urls: {} },
|
|
22
24
|
},
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
export declare const LogoLink: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>> & string;
|
|
2
2
|
export declare const DesktopMenuContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {
|
|
3
|
-
collapseSize: number;
|
|
3
|
+
$collapseSize: number;
|
|
4
4
|
}>> & string;
|
|
5
5
|
export declare const MobileMenuButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
6
6
|
export declare const HeaderIconContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
7
|
-
collapseSize: number;
|
|
7
|
+
$collapseSize: number;
|
|
8
8
|
}>> & string;
|
|
9
9
|
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>, {
|
|
10
|
-
isActive?: boolean;
|
|
11
|
-
isFeaturedItem?: boolean;
|
|
10
|
+
$isActive?: boolean;
|
|
11
|
+
$isFeaturedItem?: boolean;
|
|
12
12
|
}>> & string;
|
|
13
13
|
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>, {
|
|
14
|
-
isActive?: boolean;
|
|
14
|
+
$isActive?: boolean;
|
|
15
15
|
}>> & string;
|
|
16
16
|
export declare const MenuLinkWithChildren: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {
|
|
17
|
-
isOpen?: boolean;
|
|
17
|
+
$isOpen?: boolean;
|
|
18
18
|
}>> & string;
|
|
19
19
|
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>, {
|
|
20
|
-
isInView?: boolean;
|
|
20
|
+
$isInView?: boolean;
|
|
21
21
|
}>> & string;
|
|
22
22
|
export declare const FeaturedBlock: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {
|
|
23
|
-
collapseSize: number;
|
|
23
|
+
$collapseSize: number;
|
|
24
24
|
}>> & string;
|
|
@@ -12,7 +12,7 @@ const DesktopMenuContainer = styled.nav `
|
|
|
12
12
|
display: none;
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
position: absolute;
|
|
15
|
-
@media (min-width: ${p => p
|
|
15
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
16
16
|
position: initial;
|
|
17
17
|
width: auto;
|
|
18
18
|
max-width: unset;
|
|
@@ -36,7 +36,8 @@ const MobileMenuButton = styled.button `
|
|
|
36
36
|
&:focus-visible {
|
|
37
37
|
outline: 0;
|
|
38
38
|
border-radius: ${theme.radius.s};
|
|
39
|
-
box-shadow:
|
|
39
|
+
box-shadow:
|
|
40
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
40
41
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
41
42
|
color: ${theme.color.text.black};
|
|
42
43
|
}
|
|
@@ -56,31 +57,32 @@ const HeaderIconContainer = styled.div `
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
> div:last-child {
|
|
59
|
-
@media (min-width: ${p => p
|
|
60
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
60
61
|
display: none;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
@media (min-width: ${p => p
|
|
64
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
64
65
|
gap: ${getMultipliedSize(theme.base.baseWidth, 2)};
|
|
65
66
|
}
|
|
66
67
|
`;
|
|
67
68
|
const MenuItem = styled.li `
|
|
68
|
-
display: ${p => (p
|
|
69
|
+
display: ${p => (p.$isFeaturedItem ? 'grid' : 'flex')};
|
|
69
70
|
align-items: center;
|
|
70
|
-
grid-template-columns: ${p => (p
|
|
71
|
+
grid-template-columns: ${p => (p.$isFeaturedItem ? '1fr 1fr' : '1fr')};
|
|
71
72
|
& > a {
|
|
72
73
|
padding: ${getMultipliedSize(theme.base.baseHeight, 0.5)}
|
|
73
74
|
${getMultipliedSize(theme.base.baseWidth, 3)};
|
|
74
75
|
}
|
|
75
76
|
> button,
|
|
76
77
|
> a {
|
|
77
|
-
color: ${p => (p
|
|
78
|
-
justify-content: ${p => (p
|
|
78
|
+
color: ${p => (p.$isActive ? theme.color.text.pink : theme.color.text.black)};
|
|
79
|
+
justify-content: ${p => (p.$isFeaturedItem ? 'flex-start' : 'space-between')};
|
|
79
80
|
font-size: ${theme.fontSize.s};
|
|
80
81
|
&:focus-visible {
|
|
81
82
|
outline: 0;
|
|
82
83
|
border-radius: ${theme.radius.s};
|
|
83
|
-
box-shadow:
|
|
84
|
+
box-shadow:
|
|
85
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
84
86
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
85
87
|
}
|
|
86
88
|
${media.xl `
|
|
@@ -91,7 +93,7 @@ const MenuItem = styled.li `
|
|
|
91
93
|
const MenuLink = styled.a `
|
|
92
94
|
overflow: visible;
|
|
93
95
|
text-decoration: none;
|
|
94
|
-
color: ${p => (p
|
|
96
|
+
color: ${p => (p.$isActive ? theme.color.text.pink : theme.color.text.black)};
|
|
95
97
|
> svg {
|
|
96
98
|
fill: ${theme.color.text.pink};
|
|
97
99
|
height: ${getMultipliedSize(theme.base.baseHeight, 2)};
|
|
@@ -104,9 +106,9 @@ const MenuLinkWithChildren = styled.a `
|
|
|
104
106
|
display: block;
|
|
105
107
|
font-family: inherit;
|
|
106
108
|
white-space: normal;
|
|
107
|
-
color: ${p => (p
|
|
109
|
+
color: ${p => (p.$isOpen ? theme.color.text.pink : theme.color.default.black)};
|
|
108
110
|
> svg {
|
|
109
|
-
transform: rotate( ${p => (p
|
|
111
|
+
transform: rotate( ${p => (p.$isOpen ? '270deg' : '90deg')});
|
|
110
112
|
transition: transform .2s ease-in-out;
|
|
111
113
|
}
|
|
112
114
|
}
|
|
@@ -116,7 +118,7 @@ const MenuList = styled.ul `
|
|
|
116
118
|
display: flex;
|
|
117
119
|
flex-direction: row;
|
|
118
120
|
gap: ${getMultipliedSize(theme.base.baseHeight, 1.5)};
|
|
119
|
-
max-height: ${p => (typeof p
|
|
121
|
+
max-height: ${p => (typeof p.$isInView !== 'boolean' || p.$isInView ? 'auto' : '5px')};
|
|
120
122
|
margin: 0;
|
|
121
123
|
padding: 0;
|
|
122
124
|
background-color: ${theme.color.background.white};
|
|
@@ -141,12 +143,9 @@ const MenuList = styled.ul `
|
|
|
141
143
|
const FeaturedBlock = styled.li `
|
|
142
144
|
background-color: ${theme.color.background.sand.E01};
|
|
143
145
|
padding: ${getMultipliedSize(theme.base.baseHeight, 1)};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
grid-column: 4;
|
|
148
|
-
grid-row: 1/4;
|
|
149
|
-
@media (min-width: ${p => p.collapseSize + 1}px) {
|
|
146
|
+
list-style: none;
|
|
147
|
+
|
|
148
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
150
149
|
${getElevationShadow({ elevation: 'high' })};
|
|
151
150
|
border-radius: 0
|
|
152
151
|
border-width: 0 0 0 1px;
|
|
@@ -155,11 +154,17 @@ const FeaturedBlock = styled.li `
|
|
|
155
154
|
${getMultipliedSize(theme.base.baseWidth, 2)}
|
|
156
155
|
${getMultipliedSize(theme.base.baseHeight, 2)}
|
|
157
156
|
${getMultipliedSize(theme.base.baseWidth, 3)};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
}
|
|
158
|
+
section {
|
|
159
|
+
display: grid;
|
|
160
|
+
grid-template-columns: 1fr 1fr;
|
|
161
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-direction: column;
|
|
164
|
+
gap: ${getMultipliedSize(theme.base.baseHeight, 1.5)};
|
|
165
|
+
align-items: stretch;
|
|
166
|
+
justify-content: flex-start;
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
169
|
a {
|
|
165
170
|
font-weight: ${theme.fontWeight.bold};
|
|
@@ -45,7 +45,8 @@ const ButtonCloseStyled = styled(ButtonClose) `
|
|
|
45
45
|
|
|
46
46
|
&:focus-visible {
|
|
47
47
|
outline: none;
|
|
48
|
-
box-shadow:
|
|
48
|
+
box-shadow:
|
|
49
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
49
50
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
50
51
|
}
|
|
51
52
|
`;
|
|
@@ -71,7 +71,8 @@ const Input = styled.input `
|
|
|
71
71
|
|
|
72
72
|
&:focus-visible {
|
|
73
73
|
outline: none;
|
|
74
|
-
box-shadow:
|
|
74
|
+
box-shadow:
|
|
75
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
75
76
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
76
77
|
}
|
|
77
78
|
`;
|
|
@@ -79,7 +80,7 @@ const Input = styled.input `
|
|
|
79
80
|
const RadioButtonComponent = (_a) => {
|
|
80
81
|
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
81
82
|
return (React__default.createElement(Container, { className: props.className, "data-testid": dataTestId },
|
|
82
|
-
React__default.createElement(Input, { id: props.id, name: props.name, type: "radio", checked: props.checked, value: props.value, disabled: props.disabled, onChange: props.onChange, "data-testid": dataTestId && `${dataTestId}-input` }),
|
|
83
|
+
React__default.createElement(Input, { id: props.id, name: props.name, type: "radio", checked: props.checked, value: props.value, disabled: props.disabled, onChange: props.onChange, "data-checked": Boolean(props.checked), "data-testid": dataTestId && `${dataTestId}-input` }),
|
|
83
84
|
props.label && (React__default.createElement("label", { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label` }, props.label))));
|
|
84
85
|
};
|
|
85
86
|
const StyledFieldset = styled.fieldset `
|
|
@@ -96,7 +97,7 @@ const RadioButtonGroup = ({ label, description, groupName, value, onChange, id,
|
|
|
96
97
|
const descriptionId = `${baseId}-description`;
|
|
97
98
|
const combinedDescribedBy = [description ? descriptionId : undefined].filter(Boolean).join(' ');
|
|
98
99
|
const content = children ||
|
|
99
|
-
(options === null || options === void 0 ? void 0 : options.map(option => (React__default.createElement(RadioButtonComponent, { key: option.id, id: option.id, name: groupName, value: option.value, label: option.label, disabled: option.disabled, checked: value === option.value, onChange: onChange, className: option.className, "data-testid": option['data-testid']
|
|
100
|
+
(options === null || options === void 0 ? void 0 : options.map(option => (React__default.createElement(RadioButtonComponent, { key: option.id, id: option.id, name: groupName, value: option.value, label: option.label, disabled: option.disabled, checked: value === option.value, onChange: onChange, className: option.className, "data-testid": option['data-testid'] }))));
|
|
100
101
|
const Wrapper = isFieldset ? StyledFieldset : 'div';
|
|
101
102
|
const renderLabel = () => {
|
|
102
103
|
if (!label)
|
|
@@ -68,7 +68,9 @@ const SecondaryNavigationList = styled.ul `
|
|
|
68
68
|
overflow: hidden;
|
|
69
69
|
display: flex;
|
|
70
70
|
flex-direction: column;
|
|
71
|
-
transition:
|
|
71
|
+
transition:
|
|
72
|
+
max-height 0.2s ease-in-out,
|
|
73
|
+
border-bottom 0.2s linear;
|
|
72
74
|
background-color: ${({ isOpen }) => isOpen ? theme.color.background.white.default : 'transparent'};
|
|
73
75
|
max-height: ${({ isOpen }) => (isOpen ? '500vh' : '0')};
|
|
74
76
|
border-bottom: ${({ isOpen }) => (isOpen ? `1px solid ${theme.color.line.L03}` : 'none')};
|
|
@@ -89,9 +89,8 @@ const Switch = (_a) => {
|
|
|
89
89
|
onChange(!props.isChecked);
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
const accessibleLabel = props.label ? undefined : ariaLabel || 'Toggle switch';
|
|
93
92
|
return (React.createElement(Container, { className: props.className, "data-testid": dataTestId },
|
|
94
|
-
React.createElement(Checkbox, { id: props.id, name: props.name, checked: Boolean(props.isChecked), "aria-label":
|
|
93
|
+
React.createElement(Checkbox, { id: props.id, name: props.name, checked: Boolean(props.isChecked), "aria-label": ariaLabel, disabled: props.disabled, onChange: handleChange, role: "switch", type: "checkbox", "data-checked": Boolean(props.isChecked) }),
|
|
95
94
|
React.createElement(LabelWrapper, { htmlFor: props.id },
|
|
96
95
|
React.createElement(Rail, { "$isChecked": props.isChecked },
|
|
97
96
|
React.createElement(Button, { "$isChecked": props.isChecked })),
|
|
@@ -25,7 +25,8 @@ const Helper = styled.button `
|
|
|
25
25
|
|
|
26
26
|
&:focus-visible {
|
|
27
27
|
outline: none;
|
|
28
|
-
box-shadow:
|
|
28
|
+
box-shadow:
|
|
29
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
29
30
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
30
31
|
border-radius: 100%;
|
|
31
32
|
}
|