@dnanpm/styleguide 3.9.9 → 3.9.11
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/Chip/Chip.d.ts +18 -5
- package/build/cjs/components/Chip/Chip.js +32 -8
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.d.ts +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +7 -10
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +17 -26
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +1 -1
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.js +4 -19
- package/build/cjs/components/Notification/Notification.d.ts +18 -4
- package/build/cjs/components/Notification/Notification.js +25 -10
- package/build/cjs/components/NotificationBadge/NotificationBadge.d.ts +5 -1
- package/build/cjs/components/NotificationBadge/NotificationBadge.js +16 -2
- package/build/cjs/components/Pill/Pill.d.ts +15 -2
- package/build/cjs/components/Pill/Pill.js +61 -20
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.d.ts +13 -1
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.js +67 -28
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/cjs/components/Toaster/Toaster.d.ts +1 -1
- package/build/cjs/components/Toaster/Toaster.js +6 -7
- package/build/cjs/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/cjs/components/Tooltip/Tooltip.js +46 -6
- package/build/es/components/Chip/Chip.d.ts +18 -5
- package/build/es/components/Chip/Chip.js +32 -8
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.d.ts +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +7 -10
- package/build/es/components/MainHeaderNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +18 -27
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +1 -1
- package/build/es/components/MainHeaderNavigation/globalNavStyles.js +4 -19
- package/build/es/components/Notification/Notification.d.ts +18 -4
- package/build/es/components/Notification/Notification.js +26 -11
- package/build/es/components/NotificationBadge/NotificationBadge.d.ts +5 -1
- package/build/es/components/NotificationBadge/NotificationBadge.js +16 -2
- package/build/es/components/Pill/Pill.d.ts +15 -2
- package/build/es/components/Pill/Pill.js +61 -20
- package/build/es/components/PriorityNavigation/PriorityNavigation.d.ts +13 -1
- package/build/es/components/PriorityNavigation/PriorityNavigation.js +68 -29
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/es/components/Toaster/Toaster.d.ts +1 -1
- package/build/es/components/Toaster/Toaster.js +6 -7
- package/build/es/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/es/components/Tooltip/Tooltip.js +46 -6
- package/package.json +8 -8
|
@@ -20,8 +20,8 @@ const LinkModifier = ({ menuItem, tabIndex, showIcon }) => {
|
|
|
20
20
|
const { lang, nextJSLinkComponent, resetMenuEvents } = useContext(NavContext);
|
|
21
21
|
const menuItemLink = menuItem.urls[lang] || '';
|
|
22
22
|
const isExternalLink = menuItem.target === '_blank';
|
|
23
|
-
const MenuLinkComponent = (React__default.createElement(MenuLink, { href: menuItemLink, id: menuItem.id, onClick: resetMenuEvents,
|
|
24
|
-
showIcon && (React__default.createElement(Icon, { icon: isExternalLink ? Open : ArrowRight, size: "
|
|
23
|
+
const MenuLinkComponent = (React__default.createElement(MenuLink, { href: menuItemLink, id: menuItem.id, onClick: resetMenuEvents, tabIndex: tabIndex ? -1 : undefined, target: isExternalLink ? '_blank' : '_self' },
|
|
24
|
+
showIcon && (React__default.createElement(Icon, { icon: isExternalLink ? Open : ArrowRight, size: "1.25rem", color: theme.color.default.pink })),
|
|
25
25
|
React__default.createElement("span", null, menuItem.titles[lang])));
|
|
26
26
|
if (nextJSLinkComponent && !isMenuItemLinkAbsolute(menuItemLink)) {
|
|
27
27
|
const NextJSLinkComponent = nextJSLinkComponent;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ChevronLeft, ChevronRight } from '@dnanpm/icons';
|
|
2
2
|
import React__default, { useContext, useRef, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { animated, useSpring } from 'react-spring';
|
|
4
4
|
import styled from '../../../themes/styled.js';
|
|
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 Icon from '../../Icon/Icon.js';
|
|
9
8
|
import MobileMenuContext from '../context/MobileMenuContext.js';
|
|
10
9
|
import NavContext from '../context/NavContext.js';
|
|
11
10
|
import { MenuLink, MenuList, MenuItem, MenuLinkWithChildren, FeaturedBlock } from '../globalNavStyles.js';
|
|
12
11
|
import LinkModifier, { isSelected } from './LinkModifier.js';
|
|
13
12
|
|
|
14
|
-
const MobileMenuWrapper = styled.div `
|
|
13
|
+
const MobileMenuWrapper = styled(animated.div) `
|
|
15
14
|
width: ${100 * menuLevelsAmount}%;
|
|
15
|
+
display: flex;
|
|
16
16
|
button {
|
|
17
17
|
border: 0;
|
|
18
18
|
background: transparent;
|
|
@@ -28,16 +28,15 @@ const MobileMenuContainer = styled.div `
|
|
|
28
28
|
overflow: hidden;
|
|
29
29
|
overflow-y: auto;
|
|
30
30
|
transition: max-height 0.2s ease-in-out;
|
|
31
|
-
background: ${theme.color.background.
|
|
31
|
+
background-color: ${theme.color.background.sand.default};
|
|
32
32
|
max-height: ${mobileMenu};
|
|
33
33
|
height: ${mobileMenu};
|
|
34
34
|
max-width: ${mobileNavMaxWidth};
|
|
35
35
|
${MenuList} {
|
|
36
36
|
display: block;
|
|
37
|
-
float: left;
|
|
38
37
|
width: ${100 / menuLevelsAmount}%;
|
|
39
38
|
position: relative;
|
|
40
|
-
|
|
39
|
+
border-top: 4px solid ${theme.color.background.white.default};
|
|
41
40
|
&:first-of-type {
|
|
42
41
|
background: ${theme.color.background.white.default};
|
|
43
42
|
> ${MenuItem} > ${MenuLink} {
|
|
@@ -50,17 +49,12 @@ const MobileMenuContainer = styled.div `
|
|
|
50
49
|
}
|
|
51
50
|
${MenuItem} {
|
|
52
51
|
border-bottom: 1px solid ${theme.color.line.L04};
|
|
53
|
-
&:last-of-type {
|
|
54
|
-
margin-bottom: ${headerMaxHeight}; // make sure items are visible in different devices which might calculate vh differently
|
|
55
|
-
}
|
|
56
52
|
}
|
|
53
|
+
margin-bottom: ${headerMaxHeight}; // make sure items are visible in different devices which might calculate vh differently
|
|
57
54
|
}
|
|
58
55
|
${MenuLink}, ${MenuLinkWithChildren} {
|
|
59
56
|
line-height: ${theme.lineHeight.default};
|
|
60
|
-
padding: ${getMultipliedSize(theme.base.
|
|
61
|
-
${getMultipliedSize(theme.base.baseWidth, 1.5)}
|
|
62
|
-
${getMultipliedSize(theme.base.baseHeight, 1.75)}
|
|
63
|
-
${getMultipliedSize(theme.base.baseWidth, 2)};
|
|
57
|
+
padding: ${getMultipliedSize(theme.base.baseWidth, 2)};
|
|
64
58
|
font-size: ${theme.fontSize.default};
|
|
65
59
|
display: flex;
|
|
66
60
|
flex-grow: 1;
|
|
@@ -77,7 +71,7 @@ const MobileMenuContainer = styled.div `
|
|
|
77
71
|
color: ${theme.color.text.pink};
|
|
78
72
|
justify-content: flex-start;
|
|
79
73
|
gap: ${getMultipliedSize(theme.base.baseHeight, 1)};
|
|
80
|
-
height:
|
|
74
|
+
height: ${getMultipliedSize(theme.base.baseHeight, 6)};
|
|
81
75
|
}
|
|
82
76
|
${FeaturedBlock} {
|
|
83
77
|
border-bottom: 1px solid ${theme.color.line.L04};
|
|
@@ -89,7 +83,6 @@ const MobileMenuContainer = styled.div `
|
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
`;
|
|
92
|
-
const useTabNavigationDisabled = (scrollPosition, indexLevel) => scrollPosition !== indexLevel;
|
|
93
86
|
const MenuItemBackLink = ({ currentLevel }) => {
|
|
94
87
|
const { handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = useContext(NavContext);
|
|
95
88
|
const levels = {
|
|
@@ -104,17 +97,16 @@ const MenuItemBackLink = ({ currentLevel }) => {
|
|
|
104
97
|
const tabNavigationDisabled = scrollPosition !== currentLevel - 1;
|
|
105
98
|
const backLink = getBackLink(menuElements, currentLevel - 1);
|
|
106
99
|
return (React__default.createElement(MenuItem, { key: `back-${backLink.id}`, "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
107
|
-
React__default.createElement(MenuLinkBackLink, {
|
|
108
|
-
React__default.createElement(
|
|
100
|
+
React__default.createElement(MenuLinkBackLink, { as: "button", onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
101
|
+
React__default.createElement(ChevronLeft, { size: "1.5rem" }),
|
|
109
102
|
backLink.titles[lang])));
|
|
110
103
|
};
|
|
111
104
|
const CreateSubMenuItem = ({ menuItem, currentLevel, itemIndex }) => {
|
|
112
|
-
var _a;
|
|
113
105
|
const { handleNavMenuClick, menuLevel, lang, currentUrl } = useContext(NavContext);
|
|
114
106
|
const { mobileMenuRef } = useContext(MobileMenuContext);
|
|
115
|
-
const hasChildren =
|
|
107
|
+
const hasChildren = menuItem.pages.length;
|
|
116
108
|
const indexLevel = currentLevel - 1;
|
|
117
|
-
const tabNavigationDisabled =
|
|
109
|
+
const tabNavigationDisabled = menuLevel.scrollPosition !== indexLevel;
|
|
118
110
|
const menuUrl = menuItem.urls[lang] || '';
|
|
119
111
|
const mobileMenuClick = (element) => (e) => {
|
|
120
112
|
var _a, _b;
|
|
@@ -126,11 +118,11 @@ const CreateSubMenuItem = ({ menuItem, currentLevel, itemIndex }) => {
|
|
|
126
118
|
e.preventDefault();
|
|
127
119
|
handleNavMenuClick(element.id, `level${currentLevel}Mobile`);
|
|
128
120
|
};
|
|
129
|
-
const renderMenuItem = (children) => (React__default.createElement(MenuItem, { key: menuItem.id,
|
|
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));
|
|
130
122
|
if (hasChildren && currentLevel < 3) {
|
|
131
|
-
return renderMenuItem(React__default.createElement(MenuLink, { as: "button", onClick: mobileMenuClick(menuItem),
|
|
123
|
+
return renderMenuItem(React__default.createElement(MenuLink, { as: "button", onClick: mobileMenuClick(menuItem), tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
132
124
|
menuItem.titles[lang],
|
|
133
|
-
React__default.createElement(
|
|
125
|
+
React__default.createElement(ChevronRight, { color: theme.color.default.pink })));
|
|
134
126
|
}
|
|
135
127
|
return renderMenuItem(React__default.createElement(LinkModifier, { menuItem: menuItem, tabIndex: tabNavigationDisabled }));
|
|
136
128
|
};
|
|
@@ -138,7 +130,7 @@ const SubMenuMobile = ({ currentLevel, menuItem }) => {
|
|
|
138
130
|
const featuredItems = menuItem.pages.filter(subMenuItem => !subMenuItem.pages.length && currentLevel === 2);
|
|
139
131
|
const indexLevel = currentLevel - 1;
|
|
140
132
|
const { collapseSize, menuLevel: { scrollPosition }, } = useContext(NavContext);
|
|
141
|
-
const tabNavigationDisabled =
|
|
133
|
+
const tabNavigationDisabled = scrollPosition !== indexLevel;
|
|
142
134
|
if (!menuItem.pages.length) {
|
|
143
135
|
return null;
|
|
144
136
|
}
|
|
@@ -178,9 +170,8 @@ const RenderMobileMenu = () => {
|
|
|
178
170
|
}
|
|
179
171
|
return (React__default.createElement(MobileMenuContainer, { ref: mobileMenuRef },
|
|
180
172
|
React__default.createElement(MobileMenuContext.Provider, { value: mobileMenuContext },
|
|
181
|
-
React__default.createElement(MobileMenuWrapper,
|
|
182
|
-
React__default.createElement(
|
|
183
|
-
React__default.createElement(NavigationMenuMobile, null))))));
|
|
173
|
+
React__default.createElement(MobileMenuWrapper, { style: slidingMenuAnimation },
|
|
174
|
+
React__default.createElement(NavigationMenuMobile, null)))));
|
|
184
175
|
};
|
|
185
176
|
|
|
186
177
|
export { RenderMobileMenu as default };
|
|
@@ -27,14 +27,9 @@ const MobileMenuButton = styled.button `
|
|
|
27
27
|
border: 0;
|
|
28
28
|
padding: 0;
|
|
29
29
|
background: transparent;
|
|
30
|
-
svg {
|
|
31
|
-
color: ${theme.color.text.black};
|
|
32
|
-
fill: ${theme.color.text.black};
|
|
33
|
-
}
|
|
34
30
|
&:focus,
|
|
35
31
|
&:active {
|
|
36
32
|
svg {
|
|
37
|
-
color: ${theme.color.text.pink};
|
|
38
33
|
fill: ${theme.color.text.pink};
|
|
39
34
|
}
|
|
40
35
|
}
|
|
@@ -45,6 +40,9 @@ const MobileMenuButton = styled.button `
|
|
|
45
40
|
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
46
41
|
color: ${theme.color.text.black};
|
|
47
42
|
}
|
|
43
|
+
svg {
|
|
44
|
+
fill: ${theme.color.text.black};
|
|
45
|
+
}
|
|
48
46
|
`;
|
|
49
47
|
const HeaderIconContainer = styled.div `
|
|
50
48
|
display: flex;
|
|
@@ -74,9 +72,6 @@ const MenuItem = styled.li `
|
|
|
74
72
|
padding: ${getMultipliedSize(theme.base.baseHeight, 0.5)}
|
|
75
73
|
${getMultipliedSize(theme.base.baseWidth, 3)};
|
|
76
74
|
}
|
|
77
|
-
> button {
|
|
78
|
-
background-color: ${theme.color.background.white};
|
|
79
|
-
}
|
|
80
75
|
> button,
|
|
81
76
|
> a {
|
|
82
77
|
color: ${p => (p.isActive ? theme.color.text.pink : theme.color.text.black)};
|
|
@@ -97,14 +92,6 @@ const MenuLink = styled.a `
|
|
|
97
92
|
overflow: visible;
|
|
98
93
|
text-decoration: none;
|
|
99
94
|
color: ${p => (p.isActive ? theme.color.text.pink : theme.color.text.black)};
|
|
100
|
-
&:hover,
|
|
101
|
-
&:focus {
|
|
102
|
-
color: ${theme.color.hover.pink};
|
|
103
|
-
text-underline-offset: 0.2em;
|
|
104
|
-
-webkit-text-decoration-skip: ink;
|
|
105
|
-
text-decoration-skip-ink: auto;
|
|
106
|
-
text-decoration-thickness: from-font;
|
|
107
|
-
}
|
|
108
95
|
`;
|
|
109
96
|
const MenuLinkWithChildren = styled.button `
|
|
110
97
|
line-height: ${theme.lineHeight.xs};
|
|
@@ -123,7 +110,7 @@ const MenuLinkWithChildren = styled.button `
|
|
|
123
110
|
cursor: pointer;
|
|
124
111
|
outline: none;
|
|
125
112
|
}
|
|
126
|
-
>
|
|
113
|
+
> svg {
|
|
127
114
|
transform: rotate( ${p => (p.isOpen ? '270deg' : '90deg')});
|
|
128
115
|
transition: transform .2s ease-in-out;
|
|
129
116
|
}
|
|
@@ -133,8 +120,6 @@ const MenuLinkWithChildren = styled.button `
|
|
|
133
120
|
const MenuList = styled.ul `
|
|
134
121
|
display: flex;
|
|
135
122
|
max-height: ${p => (typeof p.isInView !== 'boolean' || p.isInView ? 'auto' : '5px')};
|
|
136
|
-
overflow: ${p => (typeof p.isInView === 'boolean' ? 'hidden' : 'unset')};
|
|
137
|
-
list-style: none;
|
|
138
123
|
margin: 0;
|
|
139
124
|
padding: 0;
|
|
140
125
|
background-color: ${theme.color.background.white};
|
|
@@ -16,13 +16,17 @@ interface Props {
|
|
|
16
16
|
/**
|
|
17
17
|
* Content of the component
|
|
18
18
|
*/
|
|
19
|
-
children
|
|
19
|
+
children: ReactNode;
|
|
20
20
|
/**
|
|
21
21
|
* Allows to show and hide close button
|
|
22
22
|
*
|
|
23
23
|
* @default false
|
|
24
24
|
*/
|
|
25
25
|
closeButton?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Label for the close button
|
|
28
|
+
*/
|
|
29
|
+
closeButtonLabel?: string;
|
|
26
30
|
/**
|
|
27
31
|
* On close button click callback
|
|
28
32
|
*/
|
|
@@ -41,8 +45,18 @@ interface Props {
|
|
|
41
45
|
* Allows to pass testid string for testing purposes
|
|
42
46
|
*/
|
|
43
47
|
'data-testid'?: string;
|
|
48
|
+
/**
|
|
49
|
+
* If true, the component is treated as static (non-interactive),
|
|
50
|
+
* and uses `aria-label` instead of `role="alert"`.
|
|
51
|
+
*
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
isStatic?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Accessible label for the notification. Required when `isStatic` is true
|
|
57
|
+
* and no type-based default label is desired.
|
|
58
|
+
*/
|
|
59
|
+
ariaLabel?: string;
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
declare const Notification: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
|
|
47
|
-
/** @component */
|
|
61
|
+
declare const Notification: ({ type, "data-testid": dataTestId, isStatic, className, children, closeButton, closeButtonLabel, onClickCloseButton, dismissed, ariaLabel, }: Props) => React.JSX.Element | null;
|
|
48
62
|
export default Notification;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { Close, Info, Check, Warning, Error } from '@dnanpm/icons';
|
|
3
2
|
import React__default from 'react';
|
|
4
|
-
import styled__default from 'styled-components';
|
|
3
|
+
import styled__default, { css } from 'styled-components';
|
|
5
4
|
import theme from '../../themes/theme.js';
|
|
6
5
|
import ButtonClose from '../ButtonClose/ButtonClose.js';
|
|
7
6
|
import Icon from '../Icon/Icon.js';
|
|
@@ -12,7 +11,7 @@ const iconsMap = {
|
|
|
12
11
|
warning: Warning,
|
|
13
12
|
error: Error,
|
|
14
13
|
};
|
|
15
|
-
const
|
|
14
|
+
const sharedStyles = css `
|
|
16
15
|
display: flex;
|
|
17
16
|
gap: 1rem;
|
|
18
17
|
line-height: ${theme.lineHeight.default};
|
|
@@ -21,6 +20,14 @@ const NotificationWrapper = styled__default.div `
|
|
|
21
20
|
border-radius: ${theme.radius.s};
|
|
22
21
|
border: 2px solid ${({ $type }) => theme.color.notification[$type]};
|
|
23
22
|
`;
|
|
23
|
+
const NotificationWrapper = styled__default.div `
|
|
24
|
+
${sharedStyles}
|
|
25
|
+
border-color: ${({ $type }) => theme.color.notification[$type]};
|
|
26
|
+
`;
|
|
27
|
+
const StaticWrapper = styled__default.section `
|
|
28
|
+
${sharedStyles}
|
|
29
|
+
border-color: ${({ $type }) => theme.color.notification[$type]};
|
|
30
|
+
`;
|
|
24
31
|
const IconWrapper = styled__default.div `
|
|
25
32
|
display: flex;
|
|
26
33
|
align-items: center;
|
|
@@ -35,16 +42,24 @@ const ContentWrapper = styled__default.span `
|
|
|
35
42
|
const ButtonCloseStyled = styled__default(ButtonClose) `
|
|
36
43
|
position: static;
|
|
37
44
|
margin: auto 0.5rem;
|
|
45
|
+
|
|
46
|
+
&:focus-visible {
|
|
47
|
+
outline: none;
|
|
48
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
49
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
50
|
+
}
|
|
38
51
|
`;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
const Notification = ({ type = 'info', 'data-testid': dataTestId, isStatic = false, className, children, closeButton = false, closeButtonLabel, onClickCloseButton, dismissed = false, ariaLabel, }) => {
|
|
53
|
+
if (dismissed)
|
|
54
|
+
return null;
|
|
55
|
+
const IconToUse = iconsMap[type];
|
|
56
|
+
const renderContent = () => (React__default.createElement(React__default.Fragment, null,
|
|
43
57
|
React__default.createElement(IconWrapper, { "$type": type },
|
|
44
|
-
React__default.createElement(Icon, { icon:
|
|
45
|
-
React__default.createElement(ContentWrapper, null,
|
|
46
|
-
|
|
47
|
-
React__default.createElement(Icon, { icon: Close, color: "currentColor" })))))
|
|
58
|
+
React__default.createElement(Icon, { icon: IconToUse, size: "2rem", color: theme.color.default.white, "aria-hidden": true })),
|
|
59
|
+
React__default.createElement(ContentWrapper, null, children),
|
|
60
|
+
closeButton && (React__default.createElement(ButtonCloseStyled, { onClick: onClickCloseButton, "aria-label": closeButtonLabel },
|
|
61
|
+
React__default.createElement(Icon, { icon: Close, color: "currentColor", "aria-hidden": true })))));
|
|
62
|
+
return isStatic ? (React__default.createElement(StaticWrapper, { "$type": type, className: className, "data-testid": dataTestId, "aria-label": ariaLabel }, renderContent())) : (React__default.createElement(NotificationWrapper, { "$type": type, className: className, "data-testid": dataTestId, role: "alert" }, renderContent()));
|
|
48
63
|
};
|
|
49
64
|
|
|
50
65
|
export { Notification as default };
|
|
@@ -35,8 +35,12 @@ interface Props {
|
|
|
35
35
|
* Allows to pass testid string for testing purposes
|
|
36
36
|
*/
|
|
37
37
|
'data-testid'?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Screen reader label for the badge (visually hidden)
|
|
40
|
+
*/
|
|
41
|
+
visuallyHiddenText?: string;
|
|
38
42
|
}
|
|
39
43
|
/** @visibleName Notification Badge */
|
|
40
|
-
declare const NotificationBadge: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
44
|
+
declare const NotificationBadge: ({ "data-testid": dataTestId, visuallyHiddenText, ...props }: Props) => React.JSX.Element;
|
|
41
45
|
/** @component */
|
|
42
46
|
export default NotificationBadge;
|
|
@@ -18,10 +18,24 @@ const NotificationBadgeElement = styled.div `
|
|
|
18
18
|
background-color: ${theme.color.notification.error};
|
|
19
19
|
border-radius: ${theme.radius.circle};
|
|
20
20
|
`;
|
|
21
|
+
const VisuallyHidden = styled.span `
|
|
22
|
+
position: absolute;
|
|
23
|
+
width: 1px;
|
|
24
|
+
height: 1px;
|
|
25
|
+
padding: 0;
|
|
26
|
+
margin: -1px;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
clip: rect(0 0 0 0);
|
|
29
|
+
clip-path: inset(50%);
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
border: 0;
|
|
32
|
+
`;
|
|
21
33
|
/** @visibleName Notification Badge */
|
|
22
34
|
const NotificationBadge = (_a) => {
|
|
23
|
-
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
24
|
-
return (React__default.createElement(
|
|
35
|
+
var { 'data-testid': dataTestId, visuallyHiddenText } = _a, props = __rest(_a, ['data-testid', "visuallyHiddenText"]);
|
|
36
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
37
|
+
visuallyHiddenText && React__default.createElement(VisuallyHidden, null, visuallyHiddenText),
|
|
38
|
+
React__default.createElement(NotificationBadgeElement, { id: props.id, position: props.position, top: props.top, right: props.right, className: props.className, "data-testid": dataTestId, "aria-hidden": "true" }, props.children)));
|
|
25
39
|
};
|
|
26
40
|
|
|
27
41
|
export { NotificationBadge as default };
|
|
@@ -4,7 +4,11 @@ type PillType = 'none' | 'checkbox' | 'radio';
|
|
|
4
4
|
type Position = 'auto' | 'left' | 'right' | 'middle';
|
|
5
5
|
interface Props {
|
|
6
6
|
/**
|
|
7
|
-
* Unique ID
|
|
7
|
+
* Unique ID
|
|
8
|
+
*
|
|
9
|
+
* This ID is used to associate the label with the input for
|
|
10
|
+
* "checkbox" and "radio" types. For "none" types, the ID
|
|
11
|
+
* is applied directly to the button element.
|
|
8
12
|
*/
|
|
9
13
|
id: string;
|
|
10
14
|
/**
|
|
@@ -14,7 +18,7 @@ interface Props {
|
|
|
14
18
|
/**
|
|
15
19
|
* Allows to change the functionality of component while retaining style
|
|
16
20
|
*
|
|
17
|
-
* @param {PillType} none
|
|
21
|
+
* @param {PillType} none Acts as a button
|
|
18
22
|
* @param {PillType} checkbox Acts as a checkbox input type
|
|
19
23
|
* @param {PillType} radio Acts as a radiobutton input type
|
|
20
24
|
*
|
|
@@ -72,7 +76,16 @@ interface Props {
|
|
|
72
76
|
* Allows to pass a custom className
|
|
73
77
|
*/
|
|
74
78
|
className?: string;
|
|
79
|
+
/**
|
|
80
|
+
* A styled version that is designed to look like the default Button component
|
|
81
|
+
*/
|
|
82
|
+
isDefaultButtonStyle?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* A screen reader label that describes the purpose of the Pill component when the default text is not sufficiently descriptive.
|
|
85
|
+
*/
|
|
86
|
+
ariaLabel?: string;
|
|
75
87
|
}
|
|
76
88
|
declare const Pill: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
77
89
|
/** @component */
|
|
78
90
|
export default Pill;
|
|
91
|
+
export { PillType, Position };
|
|
@@ -3,36 +3,73 @@ import React__default from 'react';
|
|
|
3
3
|
import styled__default from 'styled-components';
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
5
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
|
+
import { shade } from '../Button/Button.js';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
const getBackgroundColor = ({ isChecked, isDisabled }) => {
|
|
8
|
+
const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
|
|
9
9
|
const alphaValue = isDisabled ? theme.color.transparency.T30 : theme.color.transparency.T100;
|
|
10
|
-
const
|
|
10
|
+
const bgColor = isChecked
|
|
11
11
|
? theme.color.background.plum.default
|
|
12
12
|
: theme.color.background.orange.E02;
|
|
13
|
-
// Only Pill component specific colors to be used on user interaction styles
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const hoverBgColor = isChecked ? '#441632' : '#FFB557'; // Only Pill component specific colors to be used on user interaction styles
|
|
14
|
+
const textColor = isChecked ? theme.color.default.white : theme.color.default.black;
|
|
15
|
+
const disabledTextColor = isDisabled ? theme.color.text.gray : textColor;
|
|
16
|
+
return `
|
|
17
|
+
font-size: ${theme.fontSize.s};
|
|
18
|
+
font-weight: ${theme.fontWeight.medium};
|
|
19
|
+
padding: 2px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
20
|
+
background-color: ${bgColor}${alphaValue};
|
|
21
|
+
color: ${disabledTextColor};
|
|
22
|
+
border: 2px solid transparent;
|
|
23
|
+
${!isDisabled ? `&:hover { background-color: ${hoverBgColor}; }` : ''}
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
26
|
+
const getDefaultButtonStyles = ({ isChecked, isDisabled, }) => {
|
|
27
|
+
const alphaValue = isDisabled ? theme.color.transparency.T30 : theme.color.transparency.T100;
|
|
28
|
+
const hoverColor = '#441632'; // Only Pill component specific colors to be used on user interaction styles
|
|
29
|
+
const disabledBgColor = isDisabled ? theme.color.default.plum : shade.plum.lighter;
|
|
30
|
+
const bgColor = isChecked ? disabledBgColor : 'transparent';
|
|
31
|
+
const textColor = isChecked ? theme.color.default.white : theme.color.default.plum;
|
|
32
|
+
const disabledTextColor = isDisabled ? theme.color.text.gray : textColor;
|
|
33
|
+
const disabledBorderColor = isDisabled ? 'transparent' : shade.plum.lighter;
|
|
34
|
+
const borderColor = isChecked
|
|
35
|
+
? disabledBorderColor
|
|
36
|
+
: `${theme.color.default.plum}${alphaValue}`;
|
|
37
|
+
return `
|
|
38
|
+
font-size: ${theme.fontSize.default};
|
|
39
|
+
font-weight: ${theme.fontWeight.bold};
|
|
40
|
+
padding: 6px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
41
|
+
background-color: ${bgColor}${alphaValue};
|
|
42
|
+
color: ${disabledTextColor};
|
|
43
|
+
border: 2px solid ${borderColor};
|
|
44
|
+
${!isDisabled
|
|
45
|
+
? `
|
|
46
|
+
&:hover {
|
|
47
|
+
border: 2px solid ${hoverColor};
|
|
48
|
+
color: ${theme.color.default.white};
|
|
49
|
+
background-color: ${hoverColor};
|
|
50
|
+
}`
|
|
51
|
+
: ''}
|
|
52
|
+
`;
|
|
18
53
|
};
|
|
19
54
|
const Label = styled__default.label `
|
|
55
|
+
all: unset;
|
|
56
|
+
position: relative;
|
|
20
57
|
display: inline-block;
|
|
21
58
|
border-radius: ${theme.radius.pill};
|
|
22
|
-
font-size: ${theme.fontSize.s};
|
|
23
59
|
line-height: ${theme.lineHeight.default};
|
|
24
|
-
font-weight: ${theme.fontWeight.medium};
|
|
25
|
-
color: ${({ isChecked }) => isChecked ? theme.color.default.white : theme.color.default.black};
|
|
26
|
-
border: 2px solid transparent;
|
|
27
|
-
padding: 2px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
28
60
|
text-align: center;
|
|
61
|
+
transition: all 0.2s ease-in-out;
|
|
62
|
+
|
|
63
|
+
${({ isChecked, isDisabled, isDefaultButtonStyle }) => isDefaultButtonStyle
|
|
64
|
+
? getDefaultButtonStyles({ isChecked, isDisabled })
|
|
65
|
+
: getStandardPillStyles({ isChecked, isDisabled })}
|
|
29
66
|
|
|
30
|
-
${({ isDisabled
|
|
31
|
-
${({ isChecked, isDisabled }) => getBackgroundColor({ isChecked, isDisabled })}
|
|
67
|
+
${({ isDisabled }) => `cursor: ${isDisabled ? 'not-allowed' : 'pointer'};`}
|
|
32
68
|
|
|
33
69
|
&:focus-within, *:focus > & {
|
|
34
|
-
|
|
35
|
-
|
|
70
|
+
outline: none;
|
|
71
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
72
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
36
73
|
}
|
|
37
74
|
|
|
38
75
|
${({ position }) => (position === 'right' || position === 'middle') &&
|
|
@@ -64,7 +101,10 @@ const Input = styled__default.input `
|
|
|
64
101
|
border: 0 none;
|
|
65
102
|
margin: 0;
|
|
66
103
|
width: 0;
|
|
67
|
-
height:
|
|
104
|
+
height: 100%;
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: 0;
|
|
107
|
+
left: 0;
|
|
68
108
|
|
|
69
109
|
&:focus-visible {
|
|
70
110
|
outline: 0 none;
|
|
@@ -72,9 +112,10 @@ const Input = styled__default.input `
|
|
|
72
112
|
`;
|
|
73
113
|
const Pill = (_a) => {
|
|
74
114
|
var { type = 'none', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
|
|
75
|
-
|
|
115
|
+
const isDefaultType = type === 'none';
|
|
116
|
+
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 },
|
|
76
117
|
props.children,
|
|
77
|
-
|
|
118
|
+
!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` }))));
|
|
78
119
|
};
|
|
79
120
|
|
|
80
121
|
export { Pill as default };
|
|
@@ -49,10 +49,22 @@ interface Props {
|
|
|
49
49
|
* Allows to pass testid string for testing purposes
|
|
50
50
|
*/
|
|
51
51
|
'data-testid'?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Allows to pass a custom aria-label for mobile dropdown button
|
|
54
|
+
*/
|
|
55
|
+
mobileDropdownAriaLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Allows to pass a custom aria-label for current page
|
|
58
|
+
*/
|
|
59
|
+
currentPageAriaLabel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Allows to pass a custom aria-label for open more subpages button
|
|
62
|
+
*/
|
|
63
|
+
openMoreSubpagesAriaLabel?: string;
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
54
66
|
* @visibleName Priority Navigation
|
|
55
67
|
*/
|
|
56
|
-
declare const PriorityNavigation: ({ dropdownButtonLabel, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
68
|
+
declare const PriorityNavigation: ({ dropdownButtonLabel, "data-testid": dataTestId, mobileDropdownAriaLabel, currentPageAriaLabel, openMoreSubpagesAriaLabel, ...props }: Props) => React.JSX.Element;
|
|
57
69
|
/** @component */
|
|
58
70
|
export default PriorityNavigation;
|