@hlf-fe/pulmo-ui 1.5.8 → 1.5.10
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/dist/components/modules/email-signup-form/email-signup-form.d.ts +2 -0
- package/dist/components/modules/email-signup-form/email-signup-form.js +40 -37
- package/dist/components/modules/navigation/navigation-desktop/nav-cell/nav-cell.d.ts +2 -1
- package/dist/components/modules/navigation/navigation-desktop/nav-cell/nav-cell.js +16 -2
- package/dist/components/modules/navigation/navigation-desktop/navigation-desktop.js +15 -3
- package/dist/components/modules/navigation/navigation-mobile/nav-panel.d.ts +2 -2
- package/dist/components/modules/navigation/navigation-mobile/nav-panel.js +25 -6
- package/dist/components/modules/navigation/shared/types/types.d.ts +3 -1
- package/dist/components/modules/navigation/shared/types/types.js +3 -1
- package/package.json +1 -1
|
@@ -9,55 +9,58 @@ import { Alert } from "../../../components/feedback/alert/alert";
|
|
|
9
9
|
import styled from "styled-components";
|
|
10
10
|
import { media } from "../../../styles/mixins";
|
|
11
11
|
import { rem } from "../../../styles/units";
|
|
12
|
-
const
|
|
13
|
-
email: yup
|
|
12
|
+
const createSchema = (invalidMsg, requiredMsg) => yup.object({
|
|
13
|
+
email: yup
|
|
14
|
+
.string()
|
|
15
|
+
.email(invalidMsg ?? undefined) // Undefined leads to default error message in yup (null does not)
|
|
16
|
+
.required(requiredMsg ?? undefined),
|
|
14
17
|
});
|
|
15
18
|
export const EmailSignupForm = ({ heading, description, localeText, onSubmit, loading, success, failed, }) => {
|
|
16
|
-
const { emailLabel, sendButtonText, successMessage, errorMessage } = localeText;
|
|
19
|
+
const { emailLabel, sendButtonText, successMessage, errorMessage, emailInvalidErrorMessage, emailRequiredErrorMessage, } = localeText;
|
|
17
20
|
const { register, handleSubmit, formState: { errors }, } = useForm({
|
|
18
21
|
mode: "onChange",
|
|
19
|
-
resolver: yupResolver(
|
|
22
|
+
resolver: yupResolver(createSchema(emailInvalidErrorMessage, emailRequiredErrorMessage)),
|
|
20
23
|
});
|
|
21
24
|
return (_jsx(Container, { children: !success ? (_jsxs(Box, { children: [heading && _jsx(Heading, { children: heading }), description && _jsx(Text, { children: description }), _jsx(FormLabel, { htmlFor: "email", children: emailLabel }), _jsxs(TextFieldAndButton, { children: [_jsx(TextField, { type: "email", name: "email", errors: errors, register: register("email") }), _jsx(StyledLoadingButton, { onClick: handleSubmit(({ email }) => onSubmit(email)), children: sendButtonText, disabled: loading, loading: loading, btnSize: "l", fullWidthMobile: true })] }), failed && _jsx(StyledAlert, { severity: "error", children: errorMessage })] })) : (_jsx(BoxCenter, { children: _jsx(Heading, { children: successMessage }) })) }));
|
|
22
25
|
};
|
|
23
26
|
const Container = styled.form ``;
|
|
24
|
-
const TextFieldAndButton = styled.div `
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
width: 100%;
|
|
28
|
-
|
|
29
|
-
${media.L `
|
|
30
|
-
flex-direction: row;
|
|
31
|
-
`}
|
|
27
|
+
const TextFieldAndButton = styled.div `
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
width: 100%;
|
|
31
|
+
|
|
32
|
+
${media.L `
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
`}
|
|
32
35
|
`;
|
|
33
36
|
const Box = styled.div ``;
|
|
34
|
-
const BoxCenter = styled(Box) `
|
|
35
|
-
display: flex;
|
|
36
|
-
width: 100%;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
align-items: center;
|
|
37
|
+
const BoxCenter = styled(Box) `
|
|
38
|
+
display: flex;
|
|
39
|
+
width: 100%;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
align-items: center;
|
|
39
42
|
`;
|
|
40
|
-
const Heading = styled.h2 `
|
|
41
|
-
font-family: ${({ theme }) => theme.valueBold};
|
|
42
|
-
font-size: ${rem(32)};
|
|
43
|
-
color: ${({ theme }) => theme.blackLight};
|
|
44
|
-
line-height: 1.5;
|
|
45
|
-
margin: 0;
|
|
43
|
+
const Heading = styled.h2 `
|
|
44
|
+
font-family: ${({ theme }) => theme.valueBold};
|
|
45
|
+
font-size: ${rem(32)};
|
|
46
|
+
color: ${({ theme }) => theme.blackLight};
|
|
47
|
+
line-height: 1.5;
|
|
48
|
+
margin: 0;
|
|
46
49
|
`;
|
|
47
|
-
const Text = styled.p `
|
|
48
|
-
color: ${({ theme }) => theme.blackLight};
|
|
49
|
-
font-size: ${rem(18)};
|
|
50
|
+
const Text = styled.p `
|
|
51
|
+
color: ${({ theme }) => theme.blackLight};
|
|
52
|
+
font-size: ${rem(18)};
|
|
50
53
|
`;
|
|
51
|
-
const StyledAlert = styled(Alert) `
|
|
52
|
-
margin-top: ${rem(15)};
|
|
54
|
+
const StyledAlert = styled(Alert) `
|
|
55
|
+
margin-top: ${rem(15)};
|
|
53
56
|
`;
|
|
54
|
-
const StyledLoadingButton = styled(LoadingButton) `
|
|
55
|
-
width: 100%;
|
|
56
|
-
margin-top: ${rem(15)};
|
|
57
|
-
|
|
58
|
-
${media.L `
|
|
59
|
-
margin-left: ${rem(15)};
|
|
60
|
-
margin-top: 0;
|
|
61
|
-
width: auto;
|
|
62
|
-
`}
|
|
57
|
+
const StyledLoadingButton = styled(LoadingButton) `
|
|
58
|
+
width: 100%;
|
|
59
|
+
margin-top: ${rem(15)};
|
|
60
|
+
|
|
61
|
+
${media.L `
|
|
62
|
+
margin-left: ${rem(15)};
|
|
63
|
+
margin-top: 0;
|
|
64
|
+
width: auto;
|
|
65
|
+
`}
|
|
63
66
|
`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type NavigationCellProps = {
|
|
2
2
|
title: string;
|
|
3
3
|
active?: boolean;
|
|
4
|
+
url?: string;
|
|
4
5
|
onToggleCell: () => void;
|
|
5
6
|
};
|
|
6
|
-
export declare const NavigationCell: ({ title, active, onToggleCell, }: NavigationCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const NavigationCell: ({ title, active, url, onToggleCell, }: NavigationCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link } from 'gatsby';
|
|
2
3
|
import { ToggableChevron } from "../../../../../components/icons/toggable-chevron/toggable-chevron";
|
|
3
4
|
import styled, { css } from "styled-components";
|
|
4
5
|
import { media } from "../../../../../styles/mixins";
|
|
5
6
|
import { rem } from "../../../../../styles/units";
|
|
6
|
-
export const NavigationCell = ({ title, active, onToggleCell, }) =>
|
|
7
|
+
export const NavigationCell = ({ title, active, url, onToggleCell, }) => {
|
|
8
|
+
if (url) {
|
|
9
|
+
return (_jsx(StyledListItem, { children: _jsx(NavCellAsLink, { "data-test": "nav-cell-link", to: url, children: title }) }));
|
|
10
|
+
}
|
|
11
|
+
return (_jsx(StyledListItem, { children: _jsxs(NavCell, { "data-test": "nav-cell", "$active": active, onClick: onToggleCell, children: [title, _jsx(StyledToggle, { toggled: active })] }) }));
|
|
12
|
+
};
|
|
7
13
|
const StyledListItem = styled.li `
|
|
8
14
|
display: inline-block;
|
|
9
15
|
height: 100%;
|
|
@@ -17,7 +23,7 @@ const StyledListItem = styled.li `
|
|
|
17
23
|
}
|
|
18
24
|
`}
|
|
19
25
|
`;
|
|
20
|
-
const
|
|
26
|
+
const NavCellStyles = css `
|
|
21
27
|
padding: 0;
|
|
22
28
|
border: 0;
|
|
23
29
|
background: none;
|
|
@@ -27,6 +33,7 @@ const NavCell = styled.button `
|
|
|
27
33
|
align-items: center;
|
|
28
34
|
height: 100%;
|
|
29
35
|
font-size: ${rem(14)};
|
|
36
|
+
text-decoration: none;
|
|
30
37
|
|
|
31
38
|
${media.XL `
|
|
32
39
|
font-size: ${rem(18)};
|
|
@@ -44,6 +51,9 @@ const NavCell = styled.button `
|
|
|
44
51
|
color: ${theme.blackLight};
|
|
45
52
|
font-family: ${theme.valueBold};
|
|
46
53
|
`};
|
|
54
|
+
`;
|
|
55
|
+
const NavCell = styled.button `
|
|
56
|
+
${NavCellStyles}
|
|
47
57
|
|
|
48
58
|
${({ $active }) => $active &&
|
|
49
59
|
css `
|
|
@@ -53,6 +63,10 @@ const NavCell = styled.button `
|
|
|
53
63
|
`};
|
|
54
64
|
`};
|
|
55
65
|
`;
|
|
66
|
+
const NavCellAsLink = styled(Link) `
|
|
67
|
+
${NavCellStyles}
|
|
68
|
+
grid-template-columns: 1fr;
|
|
69
|
+
`;
|
|
56
70
|
const StyledToggle = styled(ToggableChevron).attrs({
|
|
57
71
|
disableCircle: true,
|
|
58
72
|
}) `
|
|
@@ -6,6 +6,7 @@ import { NavigationCell } from './nav-cell/nav-cell';
|
|
|
6
6
|
import { Image } from '../../../../components/layout/image/image';
|
|
7
7
|
import { Button } from '../../../../components/buttons/button/button';
|
|
8
8
|
import { ExternalIcon } from '../../../../components/icons/external-icon/external-icon';
|
|
9
|
+
import { isNavLink } from '../shared/types/types';
|
|
9
10
|
import styled, { css } from 'styled-components';
|
|
10
11
|
import { rem } from '../../../../styles/units';
|
|
11
12
|
export const NavigationDesktop = ({ logotype, mainMenuItems, topMenuItems, ctaButton, localeText = {
|
|
@@ -14,11 +15,22 @@ export const NavigationDesktop = ({ logotype, mainMenuItems, topMenuItems, ctaBu
|
|
|
14
15
|
const [currentSection, setCurrentSection] = useState();
|
|
15
16
|
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
|
16
17
|
const { ariaLabelHome } = localeText;
|
|
17
|
-
const onOpenSection = (
|
|
18
|
-
|
|
18
|
+
const onOpenSection = (item) => {
|
|
19
|
+
if (item && isNavLink(item)) {
|
|
20
|
+
setCurrentSection(undefined);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const sectionModel = item;
|
|
24
|
+
const sectionToShow = currentSection?.key !== sectionModel?.key ? sectionModel : undefined;
|
|
19
25
|
setCurrentSection(sectionToShow);
|
|
20
26
|
};
|
|
21
|
-
return (_jsxs(Wrapper, { ref: menuRef, children: [_jsxs(MenuContainer, { children: [!!topMenuItems?.length && (_jsx(TopBar, { "data-test": "nav-top-bar", children: topMenuItems.map(({ webUrlName, internalLink, externalUrl }) => (_jsx(StyledTopLink, { to: externalUrl || internalLink?.slug?.current || '/', children: webUrlName }, webUrlName))) })), _jsxs(NavBar, { children: [logotype && (_jsx(StyledLogoLink, { "data-test": "nav-logo", to: '/', "aria-label": ariaLabelHome, children: _jsx(Image, { image: logotype?.asset, width: "127", height: "32" }) })), _jsx(StyledList, { "data-test": "nav-list", children: mainMenuItems?.map(
|
|
27
|
+
return (_jsxs(Wrapper, { ref: menuRef, children: [_jsxs(MenuContainer, { children: [!!topMenuItems?.length && (_jsx(TopBar, { "data-test": "nav-top-bar", children: topMenuItems.map(({ webUrlName, internalLink, externalUrl }) => (_jsx(StyledTopLink, { to: externalUrl || internalLink?.slug?.current || '/', children: webUrlName }, webUrlName))) })), _jsxs(NavBar, { children: [logotype && (_jsx(StyledLogoLink, { "data-test": "nav-logo", to: '/', "aria-label": ariaLabelHome, children: _jsx(Image, { image: logotype?.asset, width: "127", height: "32" }) })), _jsx(StyledList, { "data-test": "nav-list", children: mainMenuItems?.map(item => {
|
|
28
|
+
const isLink = isNavLink(item);
|
|
29
|
+
const title = isLink ? item.webUrlName : item.title;
|
|
30
|
+
const url = isLink ? (item.externalUrl || item.internalLink?.slug?.current) : undefined;
|
|
31
|
+
const key = isLink ? item.webUrlName : item.key;
|
|
32
|
+
return (_jsx(NavigationCell, { active: !isLink && currentSection?.key === item.key, title: title || '', url: url, onToggleCell: () => onOpenSection(item) }, key || (isLink ? item.webUrlName : item.title)));
|
|
33
|
+
}) }), ctaButton && (_jsxs(StyledButton, { dataTest: "nav-cta", to: ctaButton?.internalLink?.slug?.current, href: ctaButton?.externalUrl, target: ctaButton?.openInNewWindow ? "_blank" : "_self", children: [ctaButton.webUrlName, _jsx(IconWrapper, { children: _jsx(ExternalIcon, {}) })] }))] })] }), currentSection && (_jsx(StyledNavSection, { section: currentSection, closeSection: () => onOpenSection(undefined) })), (currentSection || isSearchOpen) && (_jsx(Overlay, { "data-test": "nav-overlay", "$isSearchOpen": isSearchOpen, "$playFadeOut": !isMenuVisible, onClick: () => {
|
|
22
34
|
onOpenSection(undefined);
|
|
23
35
|
setIsSearchOpen(false);
|
|
24
36
|
} }))] }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebPageUrl } from "../../../../models/web-page-url";
|
|
2
|
-
import {
|
|
2
|
+
import { MainMenuItemModel } from "../shared/types/types";
|
|
3
3
|
type Props = {
|
|
4
|
-
mainMenuItems?:
|
|
4
|
+
mainMenuItems?: MainMenuItemModel[];
|
|
5
5
|
topMenuItems?: WebPageUrl[];
|
|
6
6
|
scrollToTop: () => void;
|
|
7
7
|
closeMenu: () => void;
|
|
@@ -4,6 +4,7 @@ import { Link } from "gatsby";
|
|
|
4
4
|
import { ToggableChevron } from "../../../../components/icons/toggable-chevron/toggable-chevron";
|
|
5
5
|
import { CardBanner } from "../../../../components/surfaces/cards/card-banner/card-banner";
|
|
6
6
|
import { NavigationItem } from "../shared/nav-item/nav-item";
|
|
7
|
+
import { isNavLink } from "../shared/types/types";
|
|
7
8
|
import styled, { css } from "styled-components";
|
|
8
9
|
import { rem } from '../../../../styles/units';
|
|
9
10
|
const NavigationPanel = ({ mainMenuItems, topMenuItems, scrollToTop, closeMenu, goBackText }) => {
|
|
@@ -11,13 +12,17 @@ const NavigationPanel = ({ mainMenuItems, topMenuItems, scrollToTop, closeMenu,
|
|
|
11
12
|
const [currentItem, setCurrentItem] = useState();
|
|
12
13
|
const [isShowingSection, setIsShowingSection] = useState(false);
|
|
13
14
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
14
|
-
const toggleSection = (
|
|
15
|
+
const toggleSection = (item) => {
|
|
15
16
|
if (isAnimating)
|
|
16
17
|
return;
|
|
17
|
-
if (
|
|
18
|
-
|
|
18
|
+
if (item && isNavLink(item)) {
|
|
19
|
+
closeMenu();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (item) {
|
|
23
|
+
setCurrentSection(item);
|
|
19
24
|
}
|
|
20
|
-
setIsShowingSection(!!
|
|
25
|
+
setIsShowingSection(!!item);
|
|
21
26
|
setIsAnimating(true);
|
|
22
27
|
scrollToTop();
|
|
23
28
|
};
|
|
@@ -25,7 +30,13 @@ const NavigationPanel = ({ mainMenuItems, topMenuItems, scrollToTop, closeMenu,
|
|
|
25
30
|
setCurrentItem(currentItem?.key !== item?.key ? item : undefined);
|
|
26
31
|
};
|
|
27
32
|
const renderColumn = (title, items) => (items && (_jsxs(_Fragment, { children: [title && _jsx(Header, { children: title }), _jsx(StyledList, { children: items.map((item) => (_jsx(NavigationItem, { model: item, expanded: currentItem?.key === item.key, parent: currentSection?.title, onToggle: toggleItem, onLinkClick: closeMenu }, item.key))) })] })));
|
|
28
|
-
return (_jsxs(Wrapper, { "data-test": "nav-panel-wrapper", toggled: isShowingSection, onTransitionEnd: () => setIsAnimating(false), children: [_jsx(Panel, { visible: true, children: _jsxs(PanelLayout, { children: [_jsx(StyledList, { "data-test": "nav-list", children: mainMenuItems?.map((
|
|
33
|
+
return (_jsxs(Wrapper, { "data-test": "nav-panel-wrapper", toggled: isShowingSection, onTransitionEnd: () => setIsAnimating(false), children: [_jsx(Panel, { visible: true, children: _jsxs(PanelLayout, { children: [_jsx(StyledList, { "data-test": "nav-list", children: mainMenuItems?.map((item) => {
|
|
34
|
+
const isLink = isNavLink(item);
|
|
35
|
+
const title = isLink ? item.webUrlName : item.title;
|
|
36
|
+
const url = isLink ? (item.externalUrl || item.internalLink?.slug?.current) : undefined;
|
|
37
|
+
const key = isLink ? item.webUrlName : item.key;
|
|
38
|
+
return (_jsx("li", { children: isLink ? (_jsx(NavLink, { to: url || "/", "data-test": "nav-cell-link", onClick: closeMenu, children: _jsx("p", { children: title }) })) : (_jsxs(NavCell, { "data-test": "nav-cell", onClick: () => toggleSection(item), children: [_jsx("p", { children: title }), _jsx(Chevron, {})] })) }, key || (isLink ? item.webUrlName : item.title)));
|
|
39
|
+
}) }), !!topMenuItems?.length && (_jsx(LinkContainer, { "data-test": "nav-sub-menu", children: topMenuItems.map(({ webUrlName, internalLink, externalUrl }) => (_jsx(StyledLink, { to: externalUrl || internalLink?.slug?.current || "/", children: webUrlName }, webUrlName))) }))] }) }), _jsxs(Panel, { "data-test": "nav-panel-section", visible: isShowingSection || isAnimating, children: [_jsxs(PanelLayout, { children: [_jsxs(BackCell, { "data-test": "nav-panel-back", onClick: () => toggleSection(undefined), children: [_jsx(BackChevron, { disableCircle: false }), goBackText] }), renderColumn(currentSection?.column1Title, currentSection?.column1Items), renderColumn(currentSection?.column2Title, currentSection?.column2Items)] }), _jsx(InfoWrapper, { color: currentSection?.backgroundColor?.hex, children: currentSection?.linkBanners && currentSection?.linkBanners?.map((banner, i) => (_jsx(CardBanner, { ...banner, externalUrl: banner?.link?.externalUrl, internalLink: banner?.link?.internalLink?.slug?.current, onClick: closeMenu }, `${banner.title.trim()}-${i}`))) })] })] }));
|
|
29
40
|
};
|
|
30
41
|
const Wrapper = styled.div `
|
|
31
42
|
width: 100%;
|
|
@@ -65,7 +76,7 @@ const StyledList = styled.ul `
|
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
78
|
`;
|
|
68
|
-
const
|
|
79
|
+
const NavCellStyles = css `
|
|
69
80
|
padding: 0;
|
|
70
81
|
border: 0;
|
|
71
82
|
background: none;
|
|
@@ -75,6 +86,7 @@ const NavCell = styled.button `
|
|
|
75
86
|
align-items: center;
|
|
76
87
|
width: 100%;
|
|
77
88
|
font-size: ${rem(20)};
|
|
89
|
+
text-decoration: none;
|
|
78
90
|
|
|
79
91
|
p {
|
|
80
92
|
font-size: inherit;
|
|
@@ -90,6 +102,13 @@ const NavCell = styled.button `
|
|
|
90
102
|
font-family: ${theme.valueBold};
|
|
91
103
|
`};
|
|
92
104
|
`;
|
|
105
|
+
const NavCell = styled.button `
|
|
106
|
+
${NavCellStyles}
|
|
107
|
+
`;
|
|
108
|
+
const NavLink = styled(Link) `
|
|
109
|
+
${NavCellStyles}
|
|
110
|
+
grid-template-columns: 1fr;
|
|
111
|
+
`;
|
|
93
112
|
const Chevron = styled(ToggableChevron).attrs({
|
|
94
113
|
rotation: -90,
|
|
95
114
|
}) `
|
|
@@ -28,9 +28,10 @@ export type LinkBanner = {
|
|
|
28
28
|
image?: SanityImage;
|
|
29
29
|
link?: WebPageUrl;
|
|
30
30
|
};
|
|
31
|
+
export type MainMenuItemModel = NavigationSectionModel | WebPageUrl;
|
|
31
32
|
export type NavigationModel = {
|
|
32
33
|
topMenuItems?: WebPageUrl[];
|
|
33
|
-
mainMenuItems?:
|
|
34
|
+
mainMenuItems?: MainMenuItemModel[];
|
|
34
35
|
logotype?: SanityImage;
|
|
35
36
|
ctaButton?: WebPageUrl;
|
|
36
37
|
__typename: string;
|
|
@@ -41,3 +42,4 @@ export type NavigationModel = {
|
|
|
41
42
|
isMenuVisible?: boolean;
|
|
42
43
|
menuRef?: RefObject<HTMLElement>;
|
|
43
44
|
};
|
|
45
|
+
export declare const isNavLink: (item: MainMenuItemModel) => item is WebPageUrl;
|