@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
|
@@ -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
|
*/
|
|
@@ -31,6 +31,8 @@ const shade = {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
const Element = styledComponents.styled.button `
|
|
34
|
+
text-align: center;
|
|
35
|
+
transition: all 0.2s ease-in-out;
|
|
34
36
|
display: inline-block;
|
|
35
37
|
font-family: ${theme.default.fontFamily.default};
|
|
36
38
|
font-weight: ${theme.default.fontWeight.bold};
|
|
@@ -51,7 +53,7 @@ const Element = styledComponents.styled.button `
|
|
|
51
53
|
display: inline-flex;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
&:focus-visible {
|
|
56
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
55
57
|
color: ${({ $darkBg }) => ($darkBg ? theme.default.color.text.plum : theme.default.color.text.white)};
|
|
56
58
|
background-color: ${({ $darkBg }) => $darkBg ? theme.default.color.default.white : shade.plum.darker};
|
|
57
59
|
border: 2px solid
|
|
@@ -61,9 +63,10 @@ const Element = styledComponents.styled.button `
|
|
|
61
63
|
outline: none;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
&:hover {
|
|
66
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
65
67
|
color: ${({ $darkBg }) => ($darkBg ? theme.default.color.text.plum : theme.default.color.text.white)};
|
|
66
68
|
background-color: ${({ $darkBg }) => $darkBg ? theme.default.color.default.white : shade.plum.darker};
|
|
69
|
+
text-decoration: none;
|
|
67
70
|
|
|
68
71
|
&:focus-visible {
|
|
69
72
|
border: 2px solid
|
|
@@ -73,7 +76,7 @@ const Element = styledComponents.styled.button `
|
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
&:active {
|
|
79
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
77
80
|
color: ${({ $darkBg }) => ($darkBg ? theme.default.color.text.plum : theme.default.color.text.white)};
|
|
78
81
|
background-color: ${({ $darkBg }) => $darkBg
|
|
79
82
|
? theme.default.color.default.white + theme.default.color.transparency.T90
|
|
@@ -86,7 +89,8 @@ const Element = styledComponents.styled.button `
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
&:disabled,
|
|
89
|
-
&[disabled]
|
|
92
|
+
&[disabled],
|
|
93
|
+
&[aria-disabled='true'] {
|
|
90
94
|
color: ${({ $darkBg }) => $darkBg
|
|
91
95
|
? theme.default.color.text.white + theme.default.color.transparency.T70
|
|
92
96
|
: theme.default.color.text.gray};
|
|
@@ -94,19 +98,10 @@ const Element = styledComponents.styled.button `
|
|
|
94
98
|
${({ $darkBg }) => $darkBg
|
|
95
99
|
? theme.default.color.default.white + theme.default.color.transparency.T30
|
|
96
100
|
: theme.default.color.default.plum + theme.default.color.transparency.T30};
|
|
97
|
-
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
outline: none;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
${({ href }) => href &&
|
|
101
|
-
`
|
|
102
|
-
text-align: center;
|
|
103
|
-
|
|
104
|
-
&:hover {
|
|
105
|
-
text-decoration: none;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
`}
|
|
109
|
-
|
|
110
105
|
${({ $loading }) => $loading &&
|
|
111
106
|
`
|
|
112
107
|
pointer-events: none;
|
|
@@ -127,7 +122,18 @@ const Element = styledComponents.styled.button `
|
|
|
127
122
|
const Button = (_a) => {
|
|
128
123
|
var _b;
|
|
129
124
|
var { type = 'submit', 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel } = _a, props = tslib.__rest(_a, ["type", 'data-testid', 'data-track-value', 'aria-label']);
|
|
130
|
-
|
|
125
|
+
const isDisabledAnchor = props.disabled && props.href;
|
|
126
|
+
const handleClick = (event) => {
|
|
127
|
+
if (isDisabledAnchor) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (props.onClick) {
|
|
133
|
+
props.onClick(event);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return (React__default.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 && {
|
|
131
137
|
name: props.name,
|
|
132
138
|
disabled: props.disabled,
|
|
133
139
|
})), props.loading ? (React__default.default.createElement(PixelLoader.default, { color: props.darkBg ? theme.default.color.default.white : theme.default.color.default.plum, label: props.loadingLabel })) : (React__default.default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, props.children))));
|
|
@@ -13,25 +13,27 @@ const ButtonPrimary = styledComponents.styled(Button.default) `
|
|
|
13
13
|
background-color: ${theme.default.color.default.pink};
|
|
14
14
|
border: 2px solid ${theme.default.color.default.pink};
|
|
15
15
|
|
|
16
|
-
&:focus
|
|
16
|
+
&:focus:not(:disabled):not([disabled]):not([aria-disabled='true']),
|
|
17
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
17
18
|
color: ${theme.default.color.text.white};
|
|
18
19
|
background-color: ${theme.default.color.default.pink};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
&:hover {
|
|
22
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
22
23
|
color: ${theme.default.color.text.white};
|
|
23
24
|
background-color: ${Button.shade.pink.darker};
|
|
24
25
|
border: 2px solid ${Button.shade.pink.darker};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
&:active {
|
|
28
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
28
29
|
color: ${theme.default.color.text.white};
|
|
29
30
|
background-color: ${Button.shade.pink.lighter};
|
|
30
31
|
border: 2px solid ${Button.shade.pink.lighter};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
&:disabled,
|
|
34
|
-
&[disabled]
|
|
35
|
+
&[disabled],
|
|
36
|
+
&[aria-disabled='true'] {
|
|
35
37
|
background-color: ${theme.default.color.default.pink + theme.default.color.transparency.T30};
|
|
36
38
|
border: 2px solid ${theme.default.color.default.pink + theme.default.color.transparency.T30};
|
|
37
39
|
background-clip: padding-box;
|
|
@@ -13,25 +13,27 @@ const ButtonSecondary = styledComponents.styled(Button.default) `
|
|
|
13
13
|
background-color: ${theme.default.color.background.sand.E02};
|
|
14
14
|
border: 2px solid ${theme.default.color.line.L02};
|
|
15
15
|
|
|
16
|
-
&:focus
|
|
16
|
+
&:focus:not(:disabled):not([disabled]):not([aria-disabled='true']),
|
|
17
|
+
&:focus-visible:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
17
18
|
color: ${theme.default.color.text.plum};
|
|
18
19
|
background-color: ${theme.default.color.background.sand.E02};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
&:hover {
|
|
22
|
+
&:hover:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
22
23
|
color: ${theme.default.color.text.plum};
|
|
23
24
|
background-color: ${Button.shade.sand.E02.darker};
|
|
24
25
|
border: 2px solid ${Button.shade.sand.E02.darker};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
&:active {
|
|
28
|
+
&:active:not(:disabled):not([disabled]):not([aria-disabled='true']) {
|
|
28
29
|
color: ${theme.default.color.text.plum};
|
|
29
30
|
background-color: ${Button.shade.sand.E02.lighter};
|
|
30
31
|
border: 2px solid ${Button.shade.sand.E02.lighter};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
&:disabled,
|
|
34
|
-
&[disabled]
|
|
35
|
+
&[disabled],
|
|
36
|
+
&[aria-disabled='true'] {
|
|
35
37
|
background-color: ${theme.default.color.background.sand.E02 + theme.default.color.transparency.T30};
|
|
36
38
|
border: 2px solid ${theme.default.color.line.L02 + theme.default.color.transparency.T30};
|
|
37
39
|
background-clip: padding-box;
|
|
@@ -37,7 +37,7 @@ const BaseContainer = styledComponents.styled.div `
|
|
|
37
37
|
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2)};
|
|
38
38
|
gap: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 3)};
|
|
39
39
|
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
40
|
-
max-width:
|
|
40
|
+
max-width: ${theme.default.layout.content.containerMaxWidth.wide}px;
|
|
41
41
|
margin-left: auto;
|
|
42
42
|
margin-right: auto;
|
|
43
43
|
|
|
@@ -17,18 +17,19 @@ const HERO_CONSTANTS = {
|
|
|
17
17
|
mobileHeight: 220,
|
|
18
18
|
desktopMinHeight: 460,
|
|
19
19
|
logoMaxWidth: 500,
|
|
20
|
+
contentMaxWidth: 650,
|
|
20
21
|
};
|
|
21
22
|
const HeroContainer = styledComponents.styled.div `
|
|
22
23
|
position: relative;
|
|
23
24
|
margin-bottom: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.25)};
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
${({ $variant }) => styledUtils.media.md `
|
|
26
27
|
min-height: calc(
|
|
27
28
|
${HERO_CONSTANTS.desktopMinHeight}px + ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 4)}
|
|
28
29
|
);
|
|
29
30
|
display: flex;
|
|
30
|
-
justify-content: ${
|
|
31
|
-
}
|
|
31
|
+
justify-content: ${$variant === 'centered' || $variant === 'centered-text-left' ? 'center' : 'flex-start'};
|
|
32
|
+
`}
|
|
32
33
|
`;
|
|
33
34
|
const HeroImage = styledComponents.styled.div `
|
|
34
35
|
position: relative;
|
|
@@ -43,14 +44,14 @@ const HeroImage = styledComponents.styled.div `
|
|
|
43
44
|
background-position: bottom;
|
|
44
45
|
`}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
${styledUtils.media.md `
|
|
47
48
|
height: auto;
|
|
48
49
|
position: absolute;
|
|
49
50
|
top: 0;
|
|
50
51
|
left: 0;
|
|
51
52
|
right: 0;
|
|
52
53
|
bottom: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 4)};
|
|
53
|
-
}
|
|
54
|
+
`}
|
|
54
55
|
|
|
55
56
|
img {
|
|
56
57
|
width: 100%;
|
|
@@ -85,31 +86,32 @@ const LogoImageContainer = styledComponents.styled.div `
|
|
|
85
86
|
object-fit: contain;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
${styledUtils.media.md `
|
|
89
90
|
top: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.25)};
|
|
90
91
|
bottom: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.25)};
|
|
91
92
|
right: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.25)};
|
|
92
93
|
left: 50%;
|
|
93
|
-
}
|
|
94
|
+
`}
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
left: calc(min(64%,
|
|
97
|
-
}
|
|
96
|
+
${styledUtils.media.lg `
|
|
97
|
+
left: calc(min(64%, ${HERO_CONSTANTS.contentMaxWidth + 100}px));
|
|
98
|
+
`}
|
|
98
99
|
`;
|
|
99
100
|
const ContentWrap = styledComponents.styled.div `
|
|
100
101
|
width: 100%;
|
|
102
|
+
max-width: ${theme.default.layout.content.containerMaxWidth.wide}px;
|
|
101
103
|
padding: 0 ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.25)};
|
|
102
104
|
margin: -${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 4)} auto 0;
|
|
103
105
|
z-index: 1;
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
${({ $variant }) => styledUtils.media.md `
|
|
106
108
|
display: flex;
|
|
107
109
|
align-items: flex-end;
|
|
108
110
|
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 4)}
|
|
109
111
|
${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)} 0;
|
|
110
112
|
margin: 0 auto;
|
|
111
|
-
justify-content: ${
|
|
112
|
-
}
|
|
113
|
+
justify-content: ${$variant === 'centered' || $variant === 'centered-text-left' ? 'center' : 'flex-start'};
|
|
114
|
+
`}
|
|
113
115
|
`;
|
|
114
116
|
const Content = styledComponents.styled(Box.default).attrs({
|
|
115
117
|
elevation: 'extraHigh',
|
|
@@ -118,19 +120,19 @@ const Content = styledComponents.styled(Box.default).attrs({
|
|
|
118
120
|
position: relative;
|
|
119
121
|
text-align: ${({ $variant }) => ($variant === 'centered' ? 'center' : 'left')};
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
${styledUtils.media.md `
|
|
122
124
|
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 3)};
|
|
123
125
|
width: 50%;
|
|
124
|
-
max-width:
|
|
125
|
-
}
|
|
126
|
+
max-width: ${HERO_CONSTANTS.contentMaxWidth}px;
|
|
127
|
+
`}
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
${({ $variant }) => styledUtils.media.lg `
|
|
128
130
|
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)};
|
|
129
131
|
width: 60%;
|
|
130
|
-
margin-left: ${
|
|
132
|
+
margin-left: ${$variant === 'centered' || $variant === 'centered-text-left'
|
|
131
133
|
? '0'
|
|
132
134
|
: `${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)}`};
|
|
133
|
-
}
|
|
135
|
+
`}
|
|
134
136
|
`;
|
|
135
137
|
const LabelContainer = styledComponents.styled.div `
|
|
136
138
|
margin: 0 0 ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 1)};
|
|
@@ -161,14 +163,14 @@ const TextContent = styledComponents.styled.div `
|
|
|
161
163
|
const CtaArea = styledComponents.styled.div `
|
|
162
164
|
margin: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 3)} 0 0;
|
|
163
165
|
display: flex;
|
|
164
|
-
flex-direction:
|
|
166
|
+
flex-direction: row;
|
|
167
|
+
flex-wrap: wrap;
|
|
165
168
|
gap: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.5)};
|
|
166
169
|
justify-content: ${({ $variant }) => ($variant === 'centered' ? 'center' : 'flex-start')};
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
flex-direction: row;
|
|
171
|
+
${styledUtils.media.md `
|
|
170
172
|
margin: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)} 0 0;
|
|
171
|
-
}
|
|
173
|
+
`}
|
|
172
174
|
`;
|
|
173
175
|
const renderImage = (ImageComponent, imageProps) => {
|
|
174
176
|
if (!imageProps)
|
|
@@ -6,9 +6,7 @@ var icons = require('@dnanpm/icons');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var styledComponents = require('styled-components');
|
|
8
8
|
var theme = require('../../../themes/theme.js');
|
|
9
|
-
var navigation = require('../../../themes/themeComponents/navigation.js');
|
|
10
9
|
var styledUtils = require('../../../utils/styledUtils.js');
|
|
11
|
-
var NavContext = require('../context/NavContext.js');
|
|
12
10
|
var globalNavStyles = require('../globalNavStyles.js');
|
|
13
11
|
var MainNavTooltipMenu = require('./MainNavTooltipMenu.js');
|
|
14
12
|
|
|
@@ -16,22 +14,25 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
14
|
|
|
17
15
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
18
16
|
|
|
19
|
-
const
|
|
17
|
+
const MenuWrapper = styledComponents.styled.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 2)};
|
|
21
|
+
margin: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2)}
|
|
22
|
+
${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 3)};
|
|
20
23
|
font-weight: ${theme.default.fontWeight.medium};
|
|
21
|
-
margin: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 1)} auto;
|
|
22
24
|
text-align: center;
|
|
23
25
|
`;
|
|
24
|
-
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.default.createElement(
|
|
26
|
+
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.default.createElement(MenuWrapper, null, Object.entries(languagesObject)
|
|
25
27
|
.filter(([key]) => key.toLowerCase() !== currentLanguage.toLowerCase())
|
|
26
|
-
.map(([key, value]) => (React__default.default.createElement(
|
|
28
|
+
.map(([key, value]) => (React__default.default.createElement(globalNavStyles.MenuLink, { key: `language-${key}`, href: value }, key.toUpperCase())))));
|
|
27
29
|
const LanguageSelector = ({ currentLanguage, languagesObject, languageSelectorLabel, }) => {
|
|
28
|
-
const { isMobileMenu, navZIndex } = React.useContext(NavContext.default);
|
|
29
30
|
const LngComponent = React.useCallback(() => (React__default.default.createElement(LangComponent, { languageSelectorLabel: languageSelectorLabel, currentLanguage: currentLanguage, languagesObject: languagesObject })), [currentLanguage, languagesObject, languageSelectorLabel]);
|
|
30
31
|
if (Object.keys(languagesObject).length < 2) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
|
-
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight:
|
|
34
|
-
React__default.default.createElement(icons.Globe,
|
|
34
|
+
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight: "auto" },
|
|
35
|
+
React__default.default.createElement(icons.Globe, null),
|
|
35
36
|
React__default.default.createElement("span", { "data-testid": "header-lang-label" }, currentLanguage.toUpperCase())));
|
|
36
37
|
};
|
|
37
38
|
|
|
@@ -12,8 +12,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
13
|
|
|
14
14
|
const LoginTooltip = ({ isLogged, loginLabel }) => {
|
|
15
|
-
const {
|
|
16
|
-
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem'
|
|
15
|
+
const { isMobileMenu, loginComponent } = React.useContext(NavContext.default);
|
|
16
|
+
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem' }, !isLogged ? (loginLabel) : (React__default.default.createElement(React__default.default.Fragment, null,
|
|
17
17
|
React__default.default.createElement(icons.User, null),
|
|
18
18
|
React__default.default.createElement("span", { "data-testid": "header-login-label" }, loginLabel)))));
|
|
19
19
|
};
|
|
@@ -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;
|
|
@@ -49,9 +49,7 @@ const Tooltip = styledComponents.styled.div `
|
|
|
49
49
|
min-height: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 5)};
|
|
50
50
|
// 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.
|
|
51
51
|
max-height: calc(var(--vh100, 100vh) - ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 12)});
|
|
52
|
-
width: 100%;
|
|
53
52
|
position: absolute;
|
|
54
|
-
right: 0;
|
|
55
53
|
top: ${navigation.navMaxHeight};
|
|
56
54
|
z-index: ${p => p.$zIndex};
|
|
57
55
|
display: flex;
|
|
@@ -85,8 +83,8 @@ const Caret = styledComponents.styled.div `
|
|
|
85
83
|
}
|
|
86
84
|
`;
|
|
87
85
|
const MainNavTooltipMenu = (_a) => {
|
|
88
|
-
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.default.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem'
|
|
89
|
-
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, } = React.useContext(NavContext.default);
|
|
86
|
+
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.default.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem' } = _a, props = tslib.__rest(_a, ["ariaLabel", "children", "closeWhenTagClicked", "contentComponent", "contentWidth", "fullWidthBreakpoint", "fullWidthDesktop", "globalStateString", "tooltipRight"]);
|
|
87
|
+
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, navZIndex, } = React.useContext(NavContext.default);
|
|
90
88
|
const ref = React.useRef(null);
|
|
91
89
|
const globalStateKey = globalStateString;
|
|
92
90
|
const isLoginItemAndLoggedIn = globalStateKey === 'login' && isLoggedIn;
|
|
@@ -113,8 +111,8 @@ const MainNavTooltipMenu = (_a) => {
|
|
|
113
111
|
return (React__default.default.createElement(IconContainer, { "data-testid": `header-${globalStateKey}-container`, "$collapseSize": collapseSize, ref: ref },
|
|
114
112
|
globalStateKey === 'login' && !isLoggedIn ? (React__default.default.createElement(ButtonPrimary.default, { onClick: ContentComponent ? toggleState : undefined, small: true }, children)) : (React__default.default.createElement(MainNavTooltipMenuExportedStyles.default, { "aria-label": ariaLabel, "aria-expanded": tooltipItems[globalStateKey], "$isLoggedIn": isLoginItemAndLoggedIn, "$collapseSize": collapseSize, "$isHighlighted": tooltipItems[globalStateKey] || isLoginItemAndLoggedIn, onClick: props.onCartButtonClick || (ContentComponent ? toggleState : undefined) }, children)),
|
|
115
113
|
tooltipItems[globalStateKey] && ContentComponent && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
116
|
-
React__default.default.createElement(Caret, { "$zIndex":
|
|
117
|
-
React__default.default.createElement(Tooltip, { "$zIndex":
|
|
114
|
+
React__default.default.createElement(Caret, { "$zIndex": navZIndex + 1, "$collapseSize": collapseSize }),
|
|
115
|
+
React__default.default.createElement(Tooltip, { "$zIndex": navZIndex + 1, "$tooltipRight": tooltipRight, "$contentWidth": contentWidth, "$collapseSize": collapseSize, "$fullWidthDesktop": fullWidthDesktop, "$fullWidthBreakpoint": fullWidthBreakpoint },
|
|
118
116
|
React__default.default.createElement(TooltipBox, { elevation: "high", padding: "0", width: "100%" },
|
|
119
117
|
React__default.default.createElement(ContentComponent, { mobileView: isMobileMenu })))))));
|
|
120
118
|
};
|
|
@@ -6,19 +6,15 @@ var icons = require('@dnanpm/icons');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var theme = require('../../../themes/theme.js');
|
|
8
8
|
var NotificationBadge = require('../../NotificationBadge/NotificationBadge.js');
|
|
9
|
-
var NavContext = require('../context/NavContext.js');
|
|
10
9
|
var MainNavTooltipMenu = require('./MainNavTooltipMenu.js');
|
|
11
10
|
|
|
12
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
12
|
|
|
14
13
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
14
|
|
|
16
|
-
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
React__default.default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
21
|
-
minicartAmount > 0 && (React__default.default.createElement(NotificationBadge.default, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
22
|
-
};
|
|
15
|
+
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => (React__default.default.createElement(MainNavTooltipMenu.default, { closeWhenTagClicked: ['a', 'button'], onCartButtonClick: onCartButtonClick, contentWidth: "35rem", fullWidthBreakpoint: theme.default.breakpoints.md, globalStateString: "minicart", tooltipRight: "5rem" },
|
|
16
|
+
React__default.default.createElement(icons.Cart, null),
|
|
17
|
+
React__default.default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
18
|
+
minicartAmount > 0 && (React__default.default.createElement(NotificationBadge.default, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
23
19
|
|
|
24
20
|
exports.default = MinicartTooltip;
|
|
@@ -12,8 +12,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
13
|
|
|
14
14
|
const PageSearch = ({ searchLabel }) => {
|
|
15
|
-
const {
|
|
16
|
-
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0"
|
|
15
|
+
const { searchComponent } = React.useContext(NavContext.default);
|
|
16
|
+
return (React__default.default.createElement(MainNavTooltipMenu.default, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0" },
|
|
17
17
|
React__default.default.createElement(icons.Search, null),
|
|
18
18
|
React__default.default.createElement("span", null, searchLabel)));
|
|
19
19
|
};
|
|
@@ -100,7 +100,7 @@ const GlobalNavigationContainer = styledComponents.styled.header `
|
|
|
100
100
|
width: 100%;
|
|
101
101
|
background-color: ${theme.default.color.background.white.default};
|
|
102
102
|
color: ${theme.default.color.text.black};
|
|
103
|
-
max-width:
|
|
103
|
+
max-width: ${theme.default.layout.page.maxWidth}px;
|
|
104
104
|
margin: 0 auto;
|
|
105
105
|
> nav {
|
|
106
106
|
background-color: ${theme.default.color.background.plum.E02};
|
|
@@ -109,7 +109,7 @@ const GlobalNavigationContainer = styledComponents.styled.header `
|
|
|
109
109
|
const NavigationWrapper = styledComponents.styled.div `
|
|
110
110
|
display: flex;
|
|
111
111
|
width: 100%;
|
|
112
|
-
max-width: ${
|
|
112
|
+
max-width: ${theme.default.layout.page.maxWidth}px;
|
|
113
113
|
margin: 0 auto;
|
|
114
114
|
height: ${navigation.navMaxHeight};
|
|
115
115
|
position: relative;
|
|
@@ -118,13 +118,15 @@ const Input = styledComponents.styled.input `
|
|
|
118
118
|
&:focus-visible {
|
|
119
119
|
outline: 0 none;
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
${({ $isDisabled }) => `cursor: ${$isDisabled ? 'not-allowed' : 'pointer'};`}
|
|
121
123
|
`;
|
|
122
124
|
const Pill = (_a) => {
|
|
123
125
|
var { type = 'none', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
124
126
|
const isDefaultType = type === 'none';
|
|
125
127
|
return (React__default.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 },
|
|
126
128
|
props.children,
|
|
127
|
-
!isDefaultType && (React__default.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 }))));
|
|
129
|
+
!isDefaultType && (React__default.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 }))));
|
|
128
130
|
};
|
|
129
131
|
|
|
130
132
|
exports.default = Pill;
|
|
@@ -108,7 +108,7 @@ const Tooltip = (_a) => {
|
|
|
108
108
|
scroll: true,
|
|
109
109
|
};
|
|
110
110
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
111
|
-
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500
|
|
111
|
+
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500 },
|
|
112
112
|
React__default.default.createElement(Icon.default, { icon: icons.Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
113
113
|
React__default.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)));
|
|
114
114
|
};
|
|
@@ -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;
|
|
@@ -11,6 +11,7 @@ var fontFamily = require('./themeComponents/fontFamily.js');
|
|
|
11
11
|
var fontSize = require('./themeComponents/fontSize.js');
|
|
12
12
|
var fontWeight = require('./themeComponents/fontWeight.js');
|
|
13
13
|
var forms = require('./themeComponents/forms.js');
|
|
14
|
+
var layout = require('./themeComponents/layout.js');
|
|
14
15
|
var lineHeight = require('./themeComponents/lineHeight.js');
|
|
15
16
|
var radius = require('./themeComponents/radius.js');
|
|
16
17
|
|
|
@@ -23,6 +24,7 @@ const theme = {
|
|
|
23
24
|
fontWeight: fontWeight.default,
|
|
24
25
|
form: forms.default,
|
|
25
26
|
grid: gridTheme.default,
|
|
27
|
+
layout: layout.default,
|
|
26
28
|
lineHeight: lineHeight.default,
|
|
27
29
|
media: styledUtils.media,
|
|
28
30
|
radius: radius.default,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page layout constants for consistent sizing across the design system.
|
|
3
|
+
*
|
|
4
|
+
* All values are numbers in pixels. Add 'px' suffix when used in CSS.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const Container = styled.div`
|
|
8
|
+
* max-width: ${theme.layout.content.maxWidth.wide}px; // 1200px
|
|
9
|
+
* margin: 0 auto;
|
|
10
|
+
* `;
|
|
11
|
+
*/
|
|
12
|
+
declare const layout: {
|
|
13
|
+
/** Page-level layout constraints */
|
|
14
|
+
readonly page: {
|
|
15
|
+
/** Minimum page width: 320px */
|
|
16
|
+
readonly minWidth: 320;
|
|
17
|
+
/** Maximum page width: 2560px */
|
|
18
|
+
readonly maxWidth: 2560;
|
|
19
|
+
};
|
|
20
|
+
/** Content area layout constraints */
|
|
21
|
+
readonly content: {
|
|
22
|
+
/** Content max-width values (pure content area without padding) */
|
|
23
|
+
readonly maxWidth: {
|
|
24
|
+
/** Wide/Normal content: 1200px */
|
|
25
|
+
readonly wide: 1200;
|
|
26
|
+
/** Medium content: 860px */
|
|
27
|
+
readonly medium: 860;
|
|
28
|
+
/** Narrow/Small content: 640px */
|
|
29
|
+
readonly narrow: 640;
|
|
30
|
+
};
|
|
31
|
+
/** Container max-width values (content + 80px padding on each side) */
|
|
32
|
+
readonly containerMaxWidth: {
|
|
33
|
+
/** Wide container: 1280px (1200 + 80) */
|
|
34
|
+
readonly wide: 1280;
|
|
35
|
+
/** Medium container: 940px (860 + 80) */
|
|
36
|
+
readonly medium: 940;
|
|
37
|
+
/** Narrow container: 720px (640 + 80) */
|
|
38
|
+
readonly narrow: 720;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type LayoutTheme = typeof layout;
|
|
43
|
+
export default layout;
|