@hlf-fe/pulmo-ui 1.5.4 → 1.5.6

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.
@@ -1,14 +1,20 @@
1
1
  import { ReactNode, CSSProperties } from "react";
2
- type Sizes = "sm" | "lg" | "xl";
2
+ type Sizes = "sm" | "md" | "lg" | "xl" | "auto";
3
3
  type CSSTypes = Pick<CSSProperties, "position" | "display">;
4
4
  export type ContainerProps = {
5
5
  children: ReactNode;
6
6
  maxWidth?: Sizes;
7
7
  className?: string;
8
+ innerContainerWidth?: string;
9
+ alignBlock?: "center" | "left";
10
+ innerWidth?: number;
8
11
  } & CSSTypes;
9
12
  export declare const Container: import("react").ForwardRefExoticComponent<{
10
13
  children: ReactNode;
11
14
  maxWidth?: Sizes;
12
15
  className?: string;
16
+ innerContainerWidth?: string;
17
+ alignBlock?: "center" | "left";
18
+ innerWidth?: number;
13
19
  } & CSSTypes & import("react").RefAttributes<HTMLDivElement>>;
14
20
  export {};
@@ -1,20 +1,38 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { siteWidthRow, siteWidthRowXL, siteWidthRowS } from "../../../styles/mixins";
3
+ import { siteWidthRow, siteWidthRowMd, siteWidthRowXL, siteWidthRowS, siteWidthRowAuto, } from "../../../styles/mixins";
4
+ import { rem } from "../../../styles/units";
4
5
  import styled from "styled-components";
5
6
  const MAX_WIDTH = {
6
7
  sm: siteWidthRowS,
8
+ md: siteWidthRowMd,
7
9
  lg: siteWidthRow,
8
10
  xl: siteWidthRowXL,
11
+ auto: siteWidthRowAuto,
12
+ };
13
+ const INNER_WIDTH = {
14
+ sm: 676,
15
+ md: 800,
16
+ lg: 1024,
17
+ xl: 1200,
9
18
  };
10
19
  const getMaxWidth = (size) => {
11
20
  return MAX_WIDTH?.[size];
12
21
  };
13
- export const Container = forwardRef(({ children, className, maxWidth = "lg", position = "static", display = "block", }, ref) => {
14
- return (_jsx(Div, { ref: ref, className: className, "$maxWidth": getMaxWidth(maxWidth), display: display, position: position, children: children }));
22
+ const getInnerWidth = (size) => {
23
+ return INNER_WIDTH?.[size];
24
+ };
25
+ export const Container = forwardRef(({ children, className, maxWidth = "lg", position = "static", display = "block", alignBlock = "center", innerWidth, }, ref) => {
26
+ const containerWidth = alignBlock === "left" ? "lg" : maxWidth;
27
+ const innerContainerWidth = alignBlock == "left" ? getInnerWidth(maxWidth) : innerWidth;
28
+ const content = innerContainerWidth ? (_jsx(Inner, { "$innerContainerWidth": innerContainerWidth, children: children })) : (children);
29
+ return (_jsx(Div, { ref: ref, className: className, "$maxWidth": getMaxWidth(containerWidth), "$display": display, "$position": position, children: content }));
15
30
  });
16
31
  const Div = styled.div `
17
32
  ${({ $maxWidth }) => $maxWidth};
18
- display: ${({ display }) => display};
19
- position: ${({ position }) => position};
33
+ display: ${({ $display }) => $display};
34
+ position: ${({ $position }) => $position};
35
+ `;
36
+ const Inner = styled.div `
37
+ max-width: ${({ $innerContainerWidth }) => rem($innerContainerWidth)};
20
38
  `;
@@ -5,5 +5,6 @@ export default meta;
5
5
  type Story = StoryObj<typeof Container>;
6
6
  export declare const Default: Story;
7
7
  export declare const Small: Story;
8
+ export declare const Medium: Story;
8
9
  export declare const Large: Story;
9
10
  export declare const ExtraLarge: Story;
@@ -33,6 +33,12 @@ export const Small = {
33
33
  children: (_jsx(PlaceholderBlock, { children: _jsx(Heading, { children: "sm" }) })),
34
34
  },
35
35
  };
36
+ export const Medium = {
37
+ args: {
38
+ maxWidth: "md",
39
+ children: (_jsx(PlaceholderBlock, { children: _jsx(Heading, { children: "md" }) })),
40
+ },
41
+ };
36
42
  export const Large = {
37
43
  args: {
38
44
  maxWidth: "lg",
@@ -18,7 +18,7 @@ export const NavigationDesktop = ({ logotype, mainMenuItems, topMenuItems, ctaBu
18
18
  const sectionToShow = currentSection?.key !== section?.key ? section : undefined;
19
19
  setCurrentSection(sectionToShow);
20
20
  };
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: "142", height: "35" }) })), _jsx(StyledList, { "data-test": "nav-list", children: mainMenuItems?.map(section => (_jsx(NavigationCell, { active: currentSection?.key === section.key, title: section.title, onToggleCell: () => onOpenSection(section) }, section.key))) }), ctaButton && (_jsxs(StyledButton, { dataTest: "nav-cta", to: ctaButton?.internalLink?.slug?.current, href: ctaButton?.externalUrl, 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: () => {
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(section => (_jsx(NavigationCell, { active: currentSection?.key === section.key, title: section.title, onToggleCell: () => onOpenSection(section) }, section.key))) }), ctaButton && (_jsxs(StyledButton, { dataTest: "nav-cta", to: ctaButton?.internalLink?.slug?.current, href: ctaButton?.externalUrl, 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
22
  onOpenSection(undefined);
23
23
  setIsSearchOpen(false);
24
24
  } }))] }));
@@ -123,7 +123,6 @@ const StyledTopLink = styled(Link) `
123
123
  const StyledLogoLink = styled(Link) `
124
124
  display: flex;
125
125
  align-self: center;
126
- max-width: ${rem(264)};
127
126
  margin-right: ${rem(16)};
128
127
  `;
129
128
  const StyledList = styled.ul `
@@ -28,7 +28,7 @@ export const NavigationMobile = ({ logotype, mainMenuItems, topMenuItems, ctaBut
28
28
  const scrollToTop = () => {
29
29
  stickyRef.current?.scroll({ top: 0, behavior: "smooth" });
30
30
  };
31
- return (_jsx(Wrapper, { children: _jsxs(StickyContainer, { "$expanded": isOpen, ref: stickyRef, children: [_jsxs(TopBar, { children: [logotype && (_jsx(StyledLogoLink, { "data-test": "nav-logo", to: "/", "aria-label": ariaLabelHome, children: _jsx(Image, { image: logotype?.asset, width: "112", height: "28" }) })), ctaButton && (_jsx(StyledButton, { btnSize: "s", dataTest: "nav-cta", to: ctaButton.externalUrl, href: ctaButton.internalLink?.slug?.current, target: "_blank", children: ctaButton.webUrlName })), !emptyMenuItems && (_jsx(MenuToggle, { "data-test": !isOpen ? "nav-menu-closed" : "nav-menu-open", "aria-label": "Meny", onClick: () => setIsOpen(!isOpen), children: _jsx(IconWrapper, { children: !isOpen ? _jsx(HamburgerIcon, {}) : _jsx(MenuCloseIcon, {}) }) }))] }), isOpen && (_jsx(MenuContent, { children: _jsx(NavigationPanel, { mainMenuItems: mainMenuItems, topMenuItems: topMenuItems, scrollToTop: scrollToTop, closeMenu: () => setIsOpen(false), goBackText: goBack }) }))] }) }));
31
+ return (_jsx(Wrapper, { children: _jsxs(StickyContainer, { "$expanded": isOpen, ref: stickyRef, children: [_jsxs(TopBar, { children: [logotype && (_jsx(StyledLogoLink, { "data-test": "nav-logo", to: "/", "aria-label": ariaLabelHome, children: _jsx(Image, { image: logotype?.asset, width: "95", height: "24" }) })), ctaButton && (_jsx(StyledButton, { btnSize: "s", dataTest: "nav-cta", to: ctaButton.externalUrl, href: ctaButton.internalLink?.slug?.current, target: "_blank", marginRight: emptyMenuItems, children: ctaButton.webUrlName })), !emptyMenuItems && (_jsx(MenuToggle, { "data-test": !isOpen ? "nav-menu-closed" : "nav-menu-open", "aria-label": "Meny", onClick: () => setIsOpen(!isOpen), children: _jsx(IconWrapper, { children: !isOpen ? _jsx(HamburgerIcon, {}) : _jsx(MenuCloseIcon, {}) }) }))] }), isOpen && (_jsx(MenuContent, { children: _jsx(NavigationPanel, { mainMenuItems: mainMenuItems, topMenuItems: topMenuItems, scrollToTop: scrollToTop, closeMenu: () => setIsOpen(false), goBackText: goBack }) }))] }) }));
32
32
  };
33
33
  const Wrapper = styled.nav `
34
34
  position: relative;
@@ -64,12 +64,13 @@ const TopBar = styled.div `
64
64
  const StyledLogoLink = styled(Link) `
65
65
  display: flex;
66
66
  align-self: center;
67
- max-width: ${rem(140)};
68
67
  `;
69
68
  const StyledButton = styled(Button) `
70
69
  display: flex;
71
70
  align-items: center;
71
+ white-space: nowrap;
72
72
  margin-left: auto;
73
+ margin-right: ${({ marginRight }) => (marginRight ? rem(16) : 0)};
73
74
  height: ${rem(32)};
74
75
  padding: 0 ${rem(8)};
75
76
  `;
@@ -15,6 +15,10 @@ const Wrapper = styled(Link) `
15
15
  text-decoration: none;
16
16
  box-shadow: 0 ${rem(4)} ${rem(16)} 0 rgba(0,0,0,0.08);
17
17
  padding: ${rem(16)};
18
+
19
+ &:hover {
20
+ box-shadow: 0 ${rem(4)} ${rem(16)} 0 rgba(0,0,0,0.3);
21
+ }
18
22
  `;
19
23
  const ImageWrapper = styled.div `
20
24
  border-radius: 50%;
package/dist/index.d.ts CHANGED
@@ -40,8 +40,11 @@ export declare const EmailSignupForm: import("react").FC<EmailSignupFormProps>;
40
40
  export declare const Image: import("react").FC<ImageProps>;
41
41
  export declare const Container: import("react").ForwardRefExoticComponent<{
42
42
  children: import("react").ReactNode;
43
- maxWidth?: "sm" | "lg" | "xl";
43
+ maxWidth?: "auto" | "sm" | "md" | "lg" | "xl";
44
44
  className?: string;
45
+ innerContainerWidth?: string;
46
+ alignBlock?: "center" | "left";
47
+ innerWidth?: number;
45
48
  } & {
46
49
  position?: import("csstype").Property.Position | undefined;
47
50
  display?: import("csstype").Property.Display | undefined;
@@ -14,8 +14,10 @@ export declare const media: {
14
14
  };
15
15
  export declare const dynamicFontSize: (minFontSize: number, maxFontSize: number, minScreenWidth?: number, maxScreenWidth?: number) => string;
16
16
  export declare const siteWidthRowS: () => import("styled-components").RuleSet<object>;
17
+ export declare const siteWidthRowMd: () => import("styled-components").RuleSet<object>;
17
18
  export declare const siteWidthRow: () => import("styled-components").RuleSet<object>;
18
19
  export declare const siteWidthRowXL: () => import("styled-components").RuleSet<object>;
20
+ export declare const siteWidthRowAuto: () => import("styled-components").RuleSet<object>;
19
21
  export declare const fullWidthRow: () => import("styled-components").RuleSet<object>;
20
22
  export declare const fontSize: {
21
23
  XS: () => import("styled-components").RuleSet<object>;
@@ -79,6 +79,33 @@ export const siteWidthRowS = () => css `
79
79
  margin-bottom: ${SPACING.spacingXXL};
80
80
  `}
81
81
  `;
82
+ export const siteWidthRowMd = () => css `
83
+ margin-left: ${SPACING.spacingXS};
84
+ margin-right: ${SPACING.spacingXS};
85
+ margin-bottom: ${rem(20)};
86
+ margin-top: ${rem(20)};
87
+ max-width: ${rem(800)};
88
+
89
+ ${media.XS `
90
+ margin-left: ${SPACING.spacingM};
91
+ margin-right: ${SPACING.spacingM};
92
+ `}
93
+
94
+ @media (min-width: ${em(800 + SPACING.blockSpacingM * 2)}) {
95
+ margin-left: auto;
96
+ margin-right: auto;
97
+ }
98
+
99
+ ${media.M `
100
+ margin-bottom: ${SPACING.spacingXL};
101
+ margin-top: ${SPACING.spacingXL};
102
+ `}
103
+
104
+ ${media.L `
105
+ margin-top: ${SPACING.spacingXXL};
106
+ margin-bottom: ${SPACING.spacingXXL};
107
+ `}
108
+ `;
82
109
  export const siteWidthRow = () => css `
83
110
  margin-left: ${SPACING.spacingXS};
84
111
  margin-right: ${SPACING.spacingXS};
@@ -135,6 +162,9 @@ export const siteWidthRowXL = () => css `
135
162
  padding-right: ${rem(SPACING.blockSpacingM)};
136
163
  `}
137
164
  `;
165
+ export const siteWidthRowAuto = () => css `
166
+ width: auto;
167
+ `;
138
168
  export const fullWidthRow = () => css `
139
169
  padding-top: ${SPACING.spacingL};
140
170
  padding-right: ${SPACING.spacingXS};
@@ -19,6 +19,7 @@ export declare const SPACING: {
19
19
  };
20
20
  export declare const VARIABLES: {
21
21
  siteWidthS: string;
22
+ siteWidthM: string;
22
23
  siteWidth: string;
23
24
  siteWidthXL: string;
24
25
  siteMaxWidth: string;
@@ -123,6 +124,7 @@ export declare const THEME_SETTINGS: {
123
124
  valueMedium: string;
124
125
  valueBold: string;
125
126
  siteWidthS: string;
127
+ siteWidthM: string;
126
128
  siteWidth: string;
127
129
  siteWidthXL: string;
128
130
  siteMaxWidth: string;
@@ -20,6 +20,7 @@ export const SPACING = {
20
20
  };
21
21
  export const VARIABLES = {
22
22
  siteWidthS: rem(BREAKPOINT_VALUES.S_ALT),
23
+ siteWidthM: rem(800 + SPACING.blockSpacingM * 2),
23
24
  siteWidth: rem(BREAKPOINT_VALUES.L + SPACING.blockSpacingM * 2),
24
25
  siteWidthXL: rem(BREAKPOINT_VALUES.XL + SPACING.blockSpacingM * 2),
25
26
  siteMaxWidth: rem(1920),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hlf-fe/pulmo-ui",
3
3
  "private": false,
4
- "version": "1.5.4",
4
+ "version": "1.5.6",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",