@dnanpm/styleguide 4.0.0 → 4.0.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/Button/Button.d.ts +2 -1
- package/build/cjs/components/Button/Button.js +22 -16
- package/build/cjs/components/ButtonArrow/ButtonArrow.js +1 -1
- package/build/cjs/components/ButtonIcon/ButtonIcon.js +2 -1
- package/build/cjs/components/ButtonPrimary/ButtonPrimary.js +6 -4
- package/build/cjs/components/ButtonSecondary/ButtonSecondary.js +6 -4
- package/build/cjs/components/Footer/Components/FooterComponents.js +1 -1
- package/build/cjs/components/Hero/Hero.js +25 -23
- 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 +1 -3
- 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.js +2 -2
- package/build/cjs/components/Pill/Pill.js +3 -1
- package/build/cjs/components/Tooltip/Tooltip.js +1 -1
- package/build/cjs/themes/theme.d.ts +18 -0
- package/build/cjs/themes/theme.js +2 -0
- package/build/cjs/themes/themeComponents/layout.d.ts +43 -0
- package/build/cjs/themes/themeComponents/layout.js +47 -0
- package/build/cjs/themes/themeComponents/navigation.d.ts +0 -1
- package/build/es/components/Button/Button.d.ts +2 -1
- package/build/es/components/Button/Button.js +22 -16
- package/build/es/components/ButtonArrow/ButtonArrow.js +1 -1
- package/build/es/components/ButtonIcon/ButtonIcon.js +2 -1
- package/build/es/components/ButtonPrimary/ButtonPrimary.js +6 -4
- package/build/es/components/ButtonSecondary/ButtonSecondary.js +6 -4
- package/build/es/components/Footer/Components/FooterComponents.js +1 -1
- package/build/es/components/Hero/Hero.js +26 -24
- 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 +1 -3
- 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.js +2 -2
- package/build/es/components/Pill/Pill.js +3 -1
- package/build/es/components/Tooltip/Tooltip.js +1 -1
- package/build/es/themes/theme.d.ts +18 -0
- package/build/es/themes/theme.js +2 -0
- package/build/es/themes/themeComponents/layout.d.ts +43 -0
- package/build/es/themes/themeComponents/layout.js +43 -0
- package/build/es/themes/themeComponents/navigation.d.ts +0 -1
- package/package.json +7 -7
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Page layout constants for consistent sizing across the design system.
|
|
7
|
+
*
|
|
8
|
+
* All values are numbers in pixels. Add 'px' suffix when used in CSS.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const Container = styled.div`
|
|
12
|
+
* max-width: ${theme.layout.content.maxWidth.wide}px; // 1200px
|
|
13
|
+
* margin: 0 auto;
|
|
14
|
+
* `;
|
|
15
|
+
*/
|
|
16
|
+
const layout = {
|
|
17
|
+
/** Page-level layout constraints */
|
|
18
|
+
page: {
|
|
19
|
+
/** Minimum page width: 320px */
|
|
20
|
+
minWidth: 320,
|
|
21
|
+
/** Maximum page width: 2560px */
|
|
22
|
+
maxWidth: 2560,
|
|
23
|
+
},
|
|
24
|
+
/** Content area layout constraints */
|
|
25
|
+
content: {
|
|
26
|
+
/** Content max-width values (pure content area without padding) */
|
|
27
|
+
maxWidth: {
|
|
28
|
+
/** Wide/Normal content: 1200px */
|
|
29
|
+
wide: 1200,
|
|
30
|
+
/** Medium content: 860px */
|
|
31
|
+
medium: 860,
|
|
32
|
+
/** Narrow/Small content: 640px */
|
|
33
|
+
narrow: 640,
|
|
34
|
+
},
|
|
35
|
+
/** Container max-width values (content + 80px padding on each side) */
|
|
36
|
+
containerMaxWidth: {
|
|
37
|
+
/** Wide container: 1280px (1200 + 80) */
|
|
38
|
+
wide: 1280,
|
|
39
|
+
/** Medium container: 940px (860 + 80) */
|
|
40
|
+
medium: 940,
|
|
41
|
+
/** Narrow container: 720px (640 + 80) */
|
|
42
|
+
narrow: 720,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.default = layout;
|
|
@@ -11,7 +11,6 @@ export declare const mobileLogoSize = "3.75em";
|
|
|
11
11
|
export declare const desktopLogoSize = "5.25em";
|
|
12
12
|
export declare const menuItemMargin = "1rem";
|
|
13
13
|
export declare const ribbonHeight = "1.5625rem";
|
|
14
|
-
export declare const wideMenuBreakpoint = 1280;
|
|
15
14
|
export declare const IconContainerWidth = "3.75rem";
|
|
16
15
|
export declare const IconContainerMinWidth = "2.5rem";
|
|
17
16
|
export declare const navMaxHeight = "3.75rem";
|
|
@@ -60,7 +60,8 @@ export interface Props {
|
|
|
60
60
|
*/
|
|
61
61
|
fullWidth?: boolean;
|
|
62
62
|
/**
|
|
63
|
-
* Allows
|
|
63
|
+
* Allows disabling the component functionality.
|
|
64
|
+
* When `href` is defined, disables the link functionality.
|
|
64
65
|
*
|
|
65
66
|
* @default false
|
|
66
67
|
*/
|
|
@@ -23,6 +23,8 @@ const shade = {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
const Element = styled.button `
|
|
26
|
+
text-align: center;
|
|
27
|
+
transition: all 0.2s ease-in-out;
|
|
26
28
|
display: inline-block;
|
|
27
29
|
font-family: ${theme.fontFamily.default};
|
|
28
30
|
font-weight: ${theme.fontWeight.bold};
|
|
@@ -43,7 +45,7 @@ const Element = styled.button `
|
|
|
43
45
|
display: inline-flex;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
&:focus-visible {
|
|
48
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
47
49
|
color: ${({ $darkBg }) => ($darkBg ? theme.color.text.plum : theme.color.text.white)};
|
|
48
50
|
background-color: ${({ $darkBg }) => $darkBg ? theme.color.default.white : shade.plum.darker};
|
|
49
51
|
border: 2px solid
|
|
@@ -53,9 +55,10 @@ const Element = styled.button `
|
|
|
53
55
|
outline: none;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
&:hover {
|
|
58
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
57
59
|
color: ${({ $darkBg }) => ($darkBg ? theme.color.text.plum : theme.color.text.white)};
|
|
58
60
|
background-color: ${({ $darkBg }) => $darkBg ? theme.color.default.white : shade.plum.darker};
|
|
61
|
+
text-decoration: none;
|
|
59
62
|
|
|
60
63
|
&:focus-visible {
|
|
61
64
|
border: 2px solid
|
|
@@ -65,7 +68,7 @@ const Element = styled.button `
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
&:active {
|
|
71
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
69
72
|
color: ${({ $darkBg }) => ($darkBg ? theme.color.text.plum : theme.color.text.white)};
|
|
70
73
|
background-color: ${({ $darkBg }) => $darkBg
|
|
71
74
|
? theme.color.default.white + theme.color.transparency.T90
|
|
@@ -78,7 +81,8 @@ const Element = styled.button `
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
&:disabled,
|
|
81
|
-
&[disabled]
|
|
84
|
+
&[disabled],
|
|
85
|
+
&[aria-disabled='true'] {
|
|
82
86
|
color: ${({ $darkBg }) => $darkBg
|
|
83
87
|
? theme.color.text.white + theme.color.transparency.T70
|
|
84
88
|
: theme.color.text.gray};
|
|
@@ -86,19 +90,10 @@ const Element = styled.button `
|
|
|
86
90
|
${({ $darkBg }) => $darkBg
|
|
87
91
|
? theme.color.default.white + theme.color.transparency.T30
|
|
88
92
|
: theme.color.default.plum + theme.color.transparency.T30};
|
|
89
|
-
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
outline: none;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
${({ href }) => href &&
|
|
93
|
-
`
|
|
94
|
-
text-align: center;
|
|
95
|
-
|
|
96
|
-
&:hover {
|
|
97
|
-
text-decoration: none;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
`}
|
|
101
|
-
|
|
102
97
|
${({ $loading }) => $loading &&
|
|
103
98
|
`
|
|
104
99
|
pointer-events: none;
|
|
@@ -119,7 +114,18 @@ const Element = styled.button `
|
|
|
119
114
|
const Button = (_a) => {
|
|
120
115
|
var _b;
|
|
121
116
|
var { type = 'submit', 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["type", 'data-testid', 'data-track-value', 'aria-label']);
|
|
122
|
-
|
|
117
|
+
const isDisabledAnchor = props.disabled && props.href;
|
|
118
|
+
const handleClick = (event) => {
|
|
119
|
+
if (isDisabledAnchor) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (props.onClick) {
|
|
125
|
+
props.onClick(event);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return (React__default.createElement(Element, Object.assign({ id: props.id, as: (_b = props.nextLink) !== null && _b !== void 0 ? _b : (props.href ? 'a' : undefined), type: props.href ? undefined : type, href: isDisabledAnchor ? undefined : props.href, target: props.href ? props.target : undefined, rel: props.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: handleClick, onMouseDown: props.onMouseDown, "$small": props.small, "$darkBg": props.darkBg, "$fullWidth": props.fullWidth, "$loading": props.loading, tabIndex: props.loading || isDisabledAnchor ? -1 : 0, "data-loading": props.loading, className: props.className, "data-testid": dataTestId, "data-track-value": dataTrackValue, "aria-label": ariaLabel, "aria-disabled": isDisabledAnchor ? 'true' : undefined }, props.dataAttributes, (!props.href && {
|
|
123
129
|
name: props.name,
|
|
124
130
|
disabled: props.disabled,
|
|
125
131
|
})), props.loading ? (React__default.createElement(PixelLoader, { color: props.darkBg ? theme.color.default.white : theme.color.default.plum, label: props.loadingLabel })) : (React__default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, props.children))));
|
|
@@ -9,25 +9,27 @@ const ButtonPrimary = styled(Button) `
|
|
|
9
9
|
background-color: ${theme.color.default.pink};
|
|
10
10
|
border: 2px solid ${theme.color.default.pink};
|
|
11
11
|
|
|
12
|
-
&:focus
|
|
12
|
+
&:focus:not(:disabled):not([disabled]):not([aria-disabled='true']),
|
|
13
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
13
14
|
color: ${theme.color.text.white};
|
|
14
15
|
background-color: ${theme.color.default.pink};
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
&:hover {
|
|
18
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
18
19
|
color: ${theme.color.text.white};
|
|
19
20
|
background-color: ${shade.pink.darker};
|
|
20
21
|
border: 2px solid ${shade.pink.darker};
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
&:active {
|
|
24
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
24
25
|
color: ${theme.color.text.white};
|
|
25
26
|
background-color: ${shade.pink.lighter};
|
|
26
27
|
border: 2px solid ${shade.pink.lighter};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
&:disabled,
|
|
30
|
-
&[disabled]
|
|
31
|
+
&[disabled],
|
|
32
|
+
&[aria-disabled='true'] {
|
|
31
33
|
background-color: ${theme.color.default.pink + theme.color.transparency.T30};
|
|
32
34
|
border: 2px solid ${theme.color.default.pink + theme.color.transparency.T30};
|
|
33
35
|
background-clip: padding-box;
|
|
@@ -9,25 +9,27 @@ const ButtonSecondary = styled(Button) `
|
|
|
9
9
|
background-color: ${theme.color.background.sand.E02};
|
|
10
10
|
border: 2px solid ${theme.color.line.L02};
|
|
11
11
|
|
|
12
|
-
&:focus
|
|
12
|
+
&:focus:not(:disabled):not([disabled]):not([aria-disabled='true']),
|
|
13
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
13
14
|
color: ${theme.color.text.plum};
|
|
14
15
|
background-color: ${theme.color.background.sand.E02};
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
&:hover {
|
|
18
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
18
19
|
color: ${theme.color.text.plum};
|
|
19
20
|
background-color: ${shade.sand.E02.darker};
|
|
20
21
|
border: 2px solid ${shade.sand.E02.darker};
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
&:active {
|
|
24
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
24
25
|
color: ${theme.color.text.plum};
|
|
25
26
|
background-color: ${shade.sand.E02.lighter};
|
|
26
27
|
border: 2px solid ${shade.sand.E02.lighter};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
&:disabled,
|
|
30
|
-
&[disabled]
|
|
31
|
+
&[disabled],
|
|
32
|
+
&[aria-disabled='true'] {
|
|
31
33
|
background-color: ${theme.color.background.sand.E02 + theme.color.transparency.T30};
|
|
32
34
|
border: 2px solid ${theme.color.line.L02 + theme.color.transparency.T30};
|
|
33
35
|
background-clip: padding-box;
|
|
@@ -31,7 +31,7 @@ const BaseContainer = styled.div `
|
|
|
31
31
|
padding: ${getMultipliedSize(theme.base.baseHeight, 2)};
|
|
32
32
|
gap: ${getMultipliedSize(theme.base.baseHeight, 3)};
|
|
33
33
|
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
34
|
-
max-width:
|
|
34
|
+
max-width: ${theme.layout.content.containerMaxWidth.wide}px;
|
|
35
35
|
margin-left: auto;
|
|
36
36
|
margin-right: auto;
|
|
37
37
|
|
|
@@ -2,25 +2,26 @@ import { __rest } from 'tslib';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
|
-
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
5
|
+
import { getMultipliedSize, media } from '../../utils/styledUtils.js';
|
|
6
6
|
import Box from '../Box/Box.js';
|
|
7
7
|
|
|
8
8
|
const HERO_CONSTANTS = {
|
|
9
9
|
mobileHeight: 220,
|
|
10
10
|
desktopMinHeight: 460,
|
|
11
11
|
logoMaxWidth: 500,
|
|
12
|
+
contentMaxWidth: 650,
|
|
12
13
|
};
|
|
13
14
|
const HeroContainer = styled.div `
|
|
14
15
|
position: relative;
|
|
15
16
|
margin-bottom: ${getMultipliedSize(theme.base.baseWidth, 1.25)};
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
${({ $variant }) => media.md `
|
|
18
19
|
min-height: calc(
|
|
19
20
|
${HERO_CONSTANTS.desktopMinHeight}px + ${getMultipliedSize(theme.base.baseHeight, 4)}
|
|
20
21
|
);
|
|
21
22
|
display: flex;
|
|
22
|
-
justify-content: ${
|
|
23
|
-
}
|
|
23
|
+
justify-content: ${$variant === 'centered' || $variant === 'centered-text-left' ? 'center' : 'flex-start'};
|
|
24
|
+
`}
|
|
24
25
|
`;
|
|
25
26
|
const HeroImage = styled.div `
|
|
26
27
|
position: relative;
|
|
@@ -35,14 +36,14 @@ const HeroImage = styled.div `
|
|
|
35
36
|
background-position: bottom;
|
|
36
37
|
`}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
${media.md `
|
|
39
40
|
height: auto;
|
|
40
41
|
position: absolute;
|
|
41
42
|
top: 0;
|
|
42
43
|
left: 0;
|
|
43
44
|
right: 0;
|
|
44
45
|
bottom: ${getMultipliedSize(theme.base.baseHeight, 4)};
|
|
45
|
-
}
|
|
46
|
+
`}
|
|
46
47
|
|
|
47
48
|
img {
|
|
48
49
|
width: 100%;
|
|
@@ -77,31 +78,32 @@ const LogoImageContainer = styled.div `
|
|
|
77
78
|
object-fit: contain;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
${media.md `
|
|
81
82
|
top: ${getMultipliedSize(theme.base.baseWidth, 1.25)};
|
|
82
83
|
bottom: ${getMultipliedSize(theme.base.baseWidth, 1.25)};
|
|
83
84
|
right: ${getMultipliedSize(theme.base.baseWidth, 1.25)};
|
|
84
85
|
left: 50%;
|
|
85
|
-
}
|
|
86
|
+
`}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
left: calc(min(64%,
|
|
89
|
-
}
|
|
88
|
+
${media.lg `
|
|
89
|
+
left: calc(min(64%, ${HERO_CONSTANTS.contentMaxWidth + 100}px));
|
|
90
|
+
`}
|
|
90
91
|
`;
|
|
91
92
|
const ContentWrap = styled.div `
|
|
92
93
|
width: 100%;
|
|
94
|
+
max-width: ${theme.layout.content.containerMaxWidth.wide}px;
|
|
93
95
|
padding: 0 ${getMultipliedSize(theme.base.baseWidth, 1.25)};
|
|
94
96
|
margin: -${getMultipliedSize(theme.base.baseHeight, 4)} auto 0;
|
|
95
97
|
z-index: 1;
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
${({ $variant }) => media.md `
|
|
98
100
|
display: flex;
|
|
99
101
|
align-items: flex-end;
|
|
100
102
|
padding: ${getMultipliedSize(theme.base.baseHeight, 4)}
|
|
101
103
|
${getMultipliedSize(theme.base.baseWidth, 4)} 0;
|
|
102
104
|
margin: 0 auto;
|
|
103
|
-
justify-content: ${
|
|
104
|
-
}
|
|
105
|
+
justify-content: ${$variant === 'centered' || $variant === 'centered-text-left' ? 'center' : 'flex-start'};
|
|
106
|
+
`}
|
|
105
107
|
`;
|
|
106
108
|
const Content = styled(Box).attrs({
|
|
107
109
|
elevation: 'extraHigh',
|
|
@@ -110,19 +112,19 @@ const Content = styled(Box).attrs({
|
|
|
110
112
|
position: relative;
|
|
111
113
|
text-align: ${({ $variant }) => ($variant === 'centered' ? 'center' : 'left')};
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
${media.md `
|
|
114
116
|
padding: ${getMultipliedSize(theme.base.baseWidth, 3)};
|
|
115
117
|
width: 50%;
|
|
116
|
-
max-width:
|
|
117
|
-
}
|
|
118
|
+
max-width: ${HERO_CONSTANTS.contentMaxWidth}px;
|
|
119
|
+
`}
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
${({ $variant }) => media.lg `
|
|
120
122
|
padding: ${getMultipliedSize(theme.base.baseWidth, 4)};
|
|
121
123
|
width: 60%;
|
|
122
|
-
margin-left: ${
|
|
124
|
+
margin-left: ${$variant === 'centered' || $variant === 'centered-text-left'
|
|
123
125
|
? '0'
|
|
124
126
|
: `${getMultipliedSize(theme.base.baseWidth, 4)}`};
|
|
125
|
-
}
|
|
127
|
+
`}
|
|
126
128
|
`;
|
|
127
129
|
const LabelContainer = styled.div `
|
|
128
130
|
margin: 0 0 ${getMultipliedSize(theme.base.baseHeight, 1)};
|
|
@@ -153,14 +155,14 @@ const TextContent = styled.div `
|
|
|
153
155
|
const CtaArea = styled.div `
|
|
154
156
|
margin: ${getMultipliedSize(theme.base.baseWidth, 3)} 0 0;
|
|
155
157
|
display: flex;
|
|
156
|
-
flex-direction:
|
|
158
|
+
flex-direction: row;
|
|
159
|
+
flex-wrap: wrap;
|
|
157
160
|
gap: ${getMultipliedSize(theme.base.baseWidth, 1.5)};
|
|
158
161
|
justify-content: ${({ $variant }) => ($variant === 'centered' ? 'center' : 'flex-start')};
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
flex-direction: row;
|
|
163
|
+
${media.md `
|
|
162
164
|
margin: ${getMultipliedSize(theme.base.baseWidth, 4)} 0 0;
|
|
163
|
-
}
|
|
165
|
+
`}
|
|
164
166
|
`;
|
|
165
167
|
const renderImage = (ImageComponent, imageProps) => {
|
|
166
168
|
if (!imageProps)
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { Globe } from '@dnanpm/icons';
|
|
2
|
-
import React__default, {
|
|
2
|
+
import React__default, { useCallback } from 'react';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import theme from '../../../themes/theme.js';
|
|
5
|
-
import { navIconSize } from '../../../themes/themeComponents/navigation.js';
|
|
6
5
|
import { getMultipliedSize } from '../../../utils/styledUtils.js';
|
|
7
|
-
import NavContext from '../context/NavContext.js';
|
|
8
6
|
import { MenuLink } from '../globalNavStyles.js';
|
|
9
7
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
10
8
|
|
|
11
|
-
const
|
|
9
|
+
const MenuWrapper = styled.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: ${getMultipliedSize(theme.base.baseWidth, 2)};
|
|
13
|
+
margin: ${getMultipliedSize(theme.base.baseHeight, 2)}
|
|
14
|
+
${getMultipliedSize(theme.base.baseHeight, 3)};
|
|
12
15
|
font-weight: ${theme.fontWeight.medium};
|
|
13
|
-
margin: ${getMultipliedSize(theme.base.baseHeight, 1)} auto;
|
|
14
16
|
text-align: center;
|
|
15
17
|
`;
|
|
16
|
-
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.createElement(
|
|
18
|
+
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.createElement(MenuWrapper, null, Object.entries(languagesObject)
|
|
17
19
|
.filter(([key]) => key.toLowerCase() !== currentLanguage.toLowerCase())
|
|
18
|
-
.map(([key, value]) => (React__default.createElement(
|
|
20
|
+
.map(([key, value]) => (React__default.createElement(MenuLink, { key: `language-${key}`, href: value }, key.toUpperCase())))));
|
|
19
21
|
const LanguageSelector = ({ currentLanguage, languagesObject, languageSelectorLabel, }) => {
|
|
20
|
-
const { isMobileMenu, navZIndex } = useContext(NavContext);
|
|
21
22
|
const LngComponent = useCallback(() => (React__default.createElement(LangComponent, { languageSelectorLabel: languageSelectorLabel, currentLanguage: currentLanguage, languagesObject: languagesObject })), [currentLanguage, languagesObject, languageSelectorLabel]);
|
|
22
23
|
if (Object.keys(languagesObject).length < 2) {
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight:
|
|
26
|
-
React__default.createElement(Globe,
|
|
26
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight: "auto" },
|
|
27
|
+
React__default.createElement(Globe, null),
|
|
27
28
|
React__default.createElement("span", { "data-testid": "header-lang-label" }, currentLanguage.toUpperCase())));
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -4,8 +4,8 @@ import NavContext from '../context/NavContext.js';
|
|
|
4
4
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
5
5
|
|
|
6
6
|
const LoginTooltip = ({ isLogged, loginLabel }) => {
|
|
7
|
-
const {
|
|
8
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem'
|
|
7
|
+
const { isMobileMenu, loginComponent } = useContext(NavContext);
|
|
8
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem' }, !isLogged ? (loginLabel) : (React__default.createElement(React__default.Fragment, null,
|
|
9
9
|
React__default.createElement(User, null),
|
|
10
10
|
React__default.createElement("span", { "data-testid": "header-login-label" }, loginLabel)))));
|
|
11
11
|
};
|
|
@@ -6,8 +6,6 @@ interface MainNavTooltipMenuProps<ContentProps extends object = object> extends
|
|
|
6
6
|
ariaLabel?: string;
|
|
7
7
|
/** Tooltip menu content */
|
|
8
8
|
children?: ReactNode;
|
|
9
|
-
/** Overlap other elements */
|
|
10
|
-
zIndex?: number;
|
|
11
9
|
/** Tooltip position from right. Default: 1.25rem */
|
|
12
10
|
tooltipRight?: string;
|
|
13
11
|
/** Mandatory Component provided as login content */
|
|
@@ -27,5 +25,5 @@ export declare const IconContainer: import("styled-components/dist/types").IStyl
|
|
|
27
25
|
$isActive?: boolean;
|
|
28
26
|
$collapseSize: number;
|
|
29
27
|
}>> & string;
|
|
30
|
-
declare const MainNavTooltipMenu: <ContentProps extends object = object>({ ariaLabel, children, closeWhenTagClicked, contentComponent, contentWidth, fullWidthBreakpoint, fullWidthDesktop, globalStateString, tooltipRight,
|
|
28
|
+
declare const MainNavTooltipMenu: <ContentProps extends object = object>({ ariaLabel, children, closeWhenTagClicked, contentComponent, contentWidth, fullWidthBreakpoint, fullWidthDesktop, globalStateString, tooltipRight, ...props }: MainNavTooltipMenuProps<ContentProps>) => React.JSX.Element;
|
|
31
29
|
export default MainNavTooltipMenu;
|
|
@@ -41,9 +41,7 @@ const Tooltip = styled.div `
|
|
|
41
41
|
min-height: ${getMultipliedSize(theme.base.baseHeight, 5)};
|
|
42
42
|
// Ensure that the tooltip's content is always visible within the viewport. So, the max-height is the viewport height minus the header's height + some margin.
|
|
43
43
|
max-height: calc(var(--vh100, 100vh) - ${getMultipliedSize(theme.base.baseHeight, 12)});
|
|
44
|
-
width: 100%;
|
|
45
44
|
position: absolute;
|
|
46
|
-
right: 0;
|
|
47
45
|
top: ${navMaxHeight};
|
|
48
46
|
z-index: ${p => p.$zIndex};
|
|
49
47
|
display: flex;
|
|
@@ -77,8 +75,8 @@ const Caret = styled.div `
|
|
|
77
75
|
}
|
|
78
76
|
`;
|
|
79
77
|
const MainNavTooltipMenu = (_a) => {
|
|
80
|
-
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem'
|
|
81
|
-
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, } = useContext(NavContext);
|
|
78
|
+
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem' } = _a, props = __rest(_a, ["ariaLabel", "children", "closeWhenTagClicked", "contentComponent", "contentWidth", "fullWidthBreakpoint", "fullWidthDesktop", "globalStateString", "tooltipRight"]);
|
|
79
|
+
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, navZIndex, } = useContext(NavContext);
|
|
82
80
|
const ref = useRef(null);
|
|
83
81
|
const globalStateKey = globalStateString;
|
|
84
82
|
const isLoginItemAndLoggedIn = globalStateKey === 'login' && isLoggedIn;
|
|
@@ -105,8 +103,8 @@ const MainNavTooltipMenu = (_a) => {
|
|
|
105
103
|
return (React__default.createElement(IconContainer, { "data-testid": `header-${globalStateKey}-container`, "$collapseSize": collapseSize, ref: ref },
|
|
106
104
|
globalStateKey === 'login' && !isLoggedIn ? (React__default.createElement(ButtonPrimary, { onClick: ContentComponent ? toggleState : undefined, small: true }, children)) : (React__default.createElement(TooltipWrapper, { "aria-label": ariaLabel, "aria-expanded": tooltipItems[globalStateKey], "$isLoggedIn": isLoginItemAndLoggedIn, "$collapseSize": collapseSize, "$isHighlighted": tooltipItems[globalStateKey] || isLoginItemAndLoggedIn, onClick: props.onCartButtonClick || (ContentComponent ? toggleState : undefined) }, children)),
|
|
107
105
|
tooltipItems[globalStateKey] && ContentComponent && (React__default.createElement(React__default.Fragment, null,
|
|
108
|
-
React__default.createElement(Caret, { "$zIndex":
|
|
109
|
-
React__default.createElement(Tooltip, { "$zIndex":
|
|
106
|
+
React__default.createElement(Caret, { "$zIndex": navZIndex + 1, "$collapseSize": collapseSize }),
|
|
107
|
+
React__default.createElement(Tooltip, { "$zIndex": navZIndex + 1, "$tooltipRight": tooltipRight, "$contentWidth": contentWidth, "$collapseSize": collapseSize, "$fullWidthDesktop": fullWidthDesktop, "$fullWidthBreakpoint": fullWidthBreakpoint },
|
|
110
108
|
React__default.createElement(TooltipBox, { elevation: "high", padding: "0", width: "100%" },
|
|
111
109
|
React__default.createElement(ContentComponent, { mobileView: isMobileMenu })))))));
|
|
112
110
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Cart } from '@dnanpm/icons';
|
|
2
|
-
import React__default
|
|
2
|
+
import React__default from 'react';
|
|
3
3
|
import theme from '../../../themes/theme.js';
|
|
4
4
|
import NotificationBadge from '../../NotificationBadge/NotificationBadge.js';
|
|
5
|
-
import NavContext from '../context/NavContext.js';
|
|
6
5
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
7
6
|
|
|
8
|
-
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
React__default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
13
|
-
minicartAmount > 0 && (React__default.createElement(NotificationBadge, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
14
|
-
};
|
|
7
|
+
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => (React__default.createElement(MainNavTooltipMenu, { closeWhenTagClicked: ['a', 'button'], onCartButtonClick: onCartButtonClick, contentWidth: "35rem", fullWidthBreakpoint: theme.breakpoints.md, globalStateString: "minicart", tooltipRight: "5rem" },
|
|
8
|
+
React__default.createElement(Cart, null),
|
|
9
|
+
React__default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
10
|
+
minicartAmount > 0 && (React__default.createElement(NotificationBadge, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
15
11
|
|
|
16
12
|
export { MinicartTooltip as default };
|
|
@@ -4,8 +4,8 @@ import NavContext from '../context/NavContext.js';
|
|
|
4
4
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
5
5
|
|
|
6
6
|
const PageSearch = ({ searchLabel }) => {
|
|
7
|
-
const {
|
|
8
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0"
|
|
7
|
+
const { searchComponent } = useContext(NavContext);
|
|
8
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0" },
|
|
9
9
|
React__default.createElement(Search, null),
|
|
10
10
|
React__default.createElement("span", null, searchLabel)));
|
|
11
11
|
};
|
|
@@ -92,7 +92,7 @@ const GlobalNavigationContainer = styled.header `
|
|
|
92
92
|
width: 100%;
|
|
93
93
|
background-color: ${theme.color.background.white.default};
|
|
94
94
|
color: ${theme.color.text.black};
|
|
95
|
-
max-width:
|
|
95
|
+
max-width: ${theme.layout.page.maxWidth}px;
|
|
96
96
|
margin: 0 auto;
|
|
97
97
|
> nav {
|
|
98
98
|
background-color: ${theme.color.background.plum.E02};
|
|
@@ -101,7 +101,7 @@ const GlobalNavigationContainer = styled.header `
|
|
|
101
101
|
const NavigationWrapper = styled.div `
|
|
102
102
|
display: flex;
|
|
103
103
|
width: 100%;
|
|
104
|
-
max-width: ${
|
|
104
|
+
max-width: ${theme.layout.page.maxWidth}px;
|
|
105
105
|
margin: 0 auto;
|
|
106
106
|
height: ${navMaxHeight};
|
|
107
107
|
position: relative;
|
|
@@ -110,13 +110,15 @@ const Input = styled.input `
|
|
|
110
110
|
&:focus-visible {
|
|
111
111
|
outline: 0 none;
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
${({ $isDisabled }) => `cursor: ${$isDisabled ? 'not-allowed' : 'pointer'};`}
|
|
113
115
|
`;
|
|
114
116
|
const Pill = (_a) => {
|
|
115
117
|
var { type = 'none', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
|
|
116
118
|
const isDefaultType = type === 'none';
|
|
117
119
|
return (React__default.createElement(Label, { as: isDefaultType ? 'button' : 'label', id: isDefaultType ? props.id : undefined, htmlFor: !isDefaultType ? props.id : undefined, type: isDefaultType ? 'button' : undefined, "$position": props.position, "$isChecked": props.isChecked || props.isDefaultChecked, "$isDisabled": props.isDisabled, className: props.className, "data-testid": dataTestId, "$isDefaultButtonStyle": props.isDefaultButtonStyle, "aria-label": props.ariaLabel, disabled: isDefaultType ? props.isDisabled : undefined, onClick: isDefaultType && !props.isDisabled ? props.onClick : undefined },
|
|
118
120
|
props.children,
|
|
119
|
-
!isDefaultType && (React__default.createElement(Input, { id: props.id, name: props.name, type: type, defaultChecked: props.isDefaultChecked, checked: props.isChecked, value: props.value, onChange: props.onChange, disabled: props.isDisabled, readOnly: !props.onChange, "data-testid": dataTestId && `${dataTestId}-input`, "data-checked": props.isChecked }))));
|
|
121
|
+
!isDefaultType && (React__default.createElement(Input, { id: props.id, name: props.name, type: type, defaultChecked: props.isDefaultChecked, checked: props.isChecked, value: props.value, onChange: props.onChange, disabled: props.isDisabled, readOnly: !props.onChange, "data-testid": dataTestId && `${dataTestId}-input`, "data-checked": props.isChecked, "$isDisabled": props.isDisabled }))));
|
|
120
122
|
};
|
|
121
123
|
|
|
122
124
|
export { Pill as default };
|
|
@@ -100,7 +100,7 @@ const Tooltip = (_a) => {
|
|
|
100
100
|
scroll: true,
|
|
101
101
|
};
|
|
102
102
|
return (React__default.createElement(React__default.Fragment, null,
|
|
103
|
-
!props.hideTriggerElement && (React__default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500
|
|
103
|
+
!props.hideTriggerElement && (React__default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500 },
|
|
104
104
|
React__default.createElement(Icon, { icon: Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
105
105
|
React__default.createElement(StyledReactTooltip, { id: props.id, place: props.placement, openOnClick: isClickable, clickable: isHoverable, "$isMultiline": props.isMultiline, disableStyleInjection: true, role: isHoverable ? 'dialog' : 'tooltip', openEvents: handleReactTooltipOpenEvents, globalCloseEvents: handleReactTooltipGlobalCloseEvents, closeEvents: handleReactTooltipCloseEvents, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
|
|
106
106
|
};
|
|
@@ -143,6 +143,24 @@ declare const theme: {
|
|
|
143
143
|
grid: {
|
|
144
144
|
gutter: string;
|
|
145
145
|
};
|
|
146
|
+
layout: {
|
|
147
|
+
readonly page: {
|
|
148
|
+
readonly minWidth: 320;
|
|
149
|
+
readonly maxWidth: 2560;
|
|
150
|
+
};
|
|
151
|
+
readonly content: {
|
|
152
|
+
readonly maxWidth: {
|
|
153
|
+
readonly wide: 1200;
|
|
154
|
+
readonly medium: 860;
|
|
155
|
+
readonly narrow: 640;
|
|
156
|
+
};
|
|
157
|
+
readonly containerMaxWidth: {
|
|
158
|
+
readonly wide: 1280;
|
|
159
|
+
readonly medium: 940;
|
|
160
|
+
readonly narrow: 720;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
146
164
|
lineHeight: {
|
|
147
165
|
default: string;
|
|
148
166
|
xl: string;
|
package/build/es/themes/theme.js
CHANGED
|
@@ -7,6 +7,7 @@ import fontFamily from './themeComponents/fontFamily.js';
|
|
|
7
7
|
import fontSize from './themeComponents/fontSize.js';
|
|
8
8
|
import fontWeight from './themeComponents/fontWeight.js';
|
|
9
9
|
import forms from './themeComponents/forms.js';
|
|
10
|
+
import layout from './themeComponents/layout.js';
|
|
10
11
|
import lineHeight from './themeComponents/lineHeight.js';
|
|
11
12
|
import radius from './themeComponents/radius.js';
|
|
12
13
|
|
|
@@ -19,6 +20,7 @@ const theme = {
|
|
|
19
20
|
fontWeight,
|
|
20
21
|
form: forms,
|
|
21
22
|
grid: gridTheme,
|
|
23
|
+
layout,
|
|
22
24
|
lineHeight,
|
|
23
25
|
media,
|
|
24
26
|
radius,
|