@thecb/components 11.2.6-beta.3 → 11.2.6-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "11.2.6-beta.3",
3
+ "version": "11.2.6-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  // Comments assume desktop base font size of 16px, mobile base font size of 14px
2
2
 
3
3
  const fontSize = {
4
- hero: "3rem", // 48px
4
+ hero: "3.5rem", // 56px
5
5
  large: "1.5rem", // 24px (at base font size of 16px)
6
6
  small: "1.25rem" // 20px
7
7
  };
@@ -13,7 +13,7 @@ const fontFamily = {
13
13
  };
14
14
 
15
15
  const mobileFontSize = {
16
- hero: "2.5rem", // 40px
16
+ hero: "3rem", // 48px
17
17
  large: "1.5rem", // 21px (at base font size of 14px)
18
18
  small: "1.2142rem" // 17px
19
19
  };
@@ -5,51 +5,52 @@ import { themeComponent } from "../../../util/themeUtils";
5
5
  import Paragraph from "../../atoms/paragraph";
6
6
  import Title from "../../atoms/title";
7
7
  import { fallbackValues } from "./HeroImage.theme";
8
+ import withWindowSize from "../../withWindowSize";
8
9
  import {
9
10
  FONT_WEIGHT_BOLD,
10
11
  FONT_WEIGHT_SEMIBOLD
11
12
  } from "../../../constants/style_constants";
12
13
  import * as Styled from "./HeroImage.styled";
13
- import { getNextHeading } from "../../../util/general";
14
14
 
15
15
  const HeroImage = ({
16
+ variant = "v1",
16
17
  themeValues,
17
18
  heading,
18
- headingVariant = "h2",
19
19
  subheading,
20
20
  description,
21
21
  imageUrl,
22
- variant = "v1",
23
22
  minWidth = "100%",
24
23
  minHeight = "auto",
24
+ contentMaxWidth = "76.5rem",
25
25
  contentSpacing = "0.5rem",
26
- paddingOverride
26
+ headingVariant = "h1",
27
+ secondaryHeadingVariant = "h2",
28
+ extraStyles
27
29
  }) => {
28
30
  const { isMobile } = useContext(ThemeContext);
29
- const secondaryHeadingVariant = getNextHeading(headingVariant);
31
+ const heroImageVariantStyles = Styled.getHeroImageVariantStyles({
32
+ variant,
33
+ imageUrl,
34
+ isMobile,
35
+ heroPrimaryColor: themeValues.heroPrimaryColor
36
+ });
30
37
 
31
38
  return (
32
39
  <>
33
40
  <Styled.HeroImageContainer
34
41
  minWidth={minWidth}
35
42
  minHeight={minHeight}
36
- padding={paddingOverride ?? (isMobile ? "2rem" : "3rem 2rem")}
37
- extraStyles={Styled.getHeroImageVariantStyles({
38
- imageUrl,
39
- isMobile,
40
- variant,
41
- heroPrimaryColor: themeValues.heroPrimaryColor,
42
- heroSecondaryColor: themeValues.heroSecondaryColor
43
- })}
43
+ padding={isMobile ? "2rem" : "3rem 2rem"}
44
+ extraStyles={`${heroImageVariantStyles} ${extraStyles}`}
44
45
  >
45
46
  <Center
46
- maxWidth={"78.5rem"}
47
+ maxWidth={contentMaxWidth}
47
48
  width={"100%"}
48
49
  intrinsic
49
50
  extraStyles={`
50
51
  flex-flow: unset;
51
52
  justify-content: flex-start;
52
- flex-wrap: nowrap;"
53
+ flex-wrap: nowrap;
53
54
  `}
54
55
  >
55
56
  <Stack
@@ -57,36 +58,42 @@ const HeroImage = ({
57
58
  extraStyles={`max-width: ${isMobile ? "100%" : "50%"};`}
58
59
  >
59
60
  <Stack childGap="0">
60
- <Title
61
- variant="hero"
62
- as={headingVariant}
63
- weight={FONT_WEIGHT_BOLD}
64
- color={themeValues.heroTextColor}
65
- extraStyles={`line-height: ${isMobile ? "125%" : "115%"};`}
66
- >
67
- {heading}
68
- </Title>
69
- <Title
70
- variant={"large"}
71
- as={secondaryHeadingVariant}
72
- weight={FONT_WEIGHT_SEMIBOLD}
73
- fontSize={isMobile ? "1.5rem" : "2rem"}
74
- color={themeValues.heroTextColor}
75
- extraStyles={`line-height: ${isMobile ? "150%" : "115%"};`}
76
- >
77
- {subheading}
78
- </Title>
61
+ {heading && (
62
+ <Title
63
+ variant="hero"
64
+ as={headingVariant}
65
+ weight={FONT_WEIGHT_BOLD}
66
+ color={themeValues.heroTextColor}
67
+ extraStyles={`line-height: ${isMobile ? "125%" : "115%"};`}
68
+ >
69
+ {heading}
70
+ </Title>
71
+ )}
72
+ {subheading && (
73
+ <Title
74
+ variant={"large"}
75
+ as={secondaryHeadingVariant}
76
+ weight={FONT_WEIGHT_SEMIBOLD}
77
+ fontSize={isMobile ? "2rem" : "2.5rem"}
78
+ color={themeValues.heroTextColor}
79
+ extraStyles={`line-height: ${isMobile ? "150%" : "115%"};`}
80
+ >
81
+ {subheading}
82
+ </Title>
83
+ )}
79
84
  </Stack>
80
- <Box padding="0">
81
- <Paragraph
82
- color={themeValues.heroTextColor}
83
- extraStyles={`line-height: ${
84
- isMobile ? "150%" : "115%"
85
- }; ${!isMobile && `font-size: 1.125rem;`}`}
86
- >
87
- {description}
88
- </Paragraph>
89
- </Box>
85
+ {description && (
86
+ <Box padding="0">
87
+ <Paragraph
88
+ color={themeValues.heroTextColor}
89
+ extraStyles={`line-height: 150%; ${
90
+ !isMobile ? "font-size: 1.25rem;" : ""
91
+ }`}
92
+ >
93
+ {description}
94
+ </Paragraph>
95
+ </Box>
96
+ )}
90
97
  </Stack>
91
98
  </Center>
92
99
  </Styled.HeroImageContainer>
@@ -94,4 +101,6 @@ const HeroImage = ({
94
101
  );
95
102
  };
96
103
 
97
- export default themeComponent(HeroImage, "HeroImage", fallbackValues);
104
+ export default withWindowSize(
105
+ themeComponent(HeroImage, "HeroImage", fallbackValues)
106
+ );
@@ -1,3 +1,4 @@
1
+ import { head } from "ramda";
1
2
  import HeroImage from "./HeroImage";
2
3
 
3
4
  const meta = {
@@ -25,7 +26,14 @@ const meta = {
25
26
  description: "Heading variant for the hero image heading",
26
27
  table: {
27
28
  type: { summary: "string" },
28
- defaultValue: { summary: undefined }
29
+ defaultValue: { summary: "h1" }
30
+ }
31
+ },
32
+ secondaryHeadingVariant: {
33
+ description: "secondary heading variant for the hero image heading",
34
+ table: {
35
+ type: { summary: "string" },
36
+ defaultValue: { summary: "h2" }
29
37
  }
30
38
  },
31
39
  subheading: {
@@ -43,17 +51,18 @@ const meta = {
43
51
  }
44
52
  },
45
53
  imageUrl: {
46
- description: "Image URL for the hero image",
54
+ description:
55
+ "Image URL for the hero image. If excluded or contains an invalid URL, a solid background (primaryHeroColor) will display.",
47
56
  table: {
48
57
  type: { summary: "string" },
49
58
  defaultValue: { summary: undefined }
50
59
  }
51
60
  },
52
- paddingOverride: {
53
- description: "padding override around the HeroImage content (desktop)",
61
+ extraStyles: {
62
+ description: "styles for the HeroImage container",
54
63
  table: {
55
64
  type: { summary: "string" },
56
- defaultValue: { summary: "0.5rem 1.5rem" }
65
+ defaultValue: { summary: undefined }
57
66
  }
58
67
  },
59
68
  minWidth: {
@@ -79,6 +88,20 @@ const meta = {
79
88
  type: { summary: "string" },
80
89
  defaultValue: { summary: "3rem" }
81
90
  }
91
+ },
92
+ contentMaxWidth: {
93
+ description: "Maximum width of the content inside the hero image",
94
+ table: {
95
+ type: { summary: "string" },
96
+ defaultValue: { summary: "76.5rem" }
97
+ }
98
+ },
99
+ variant: {
100
+ description: "Variant of the hero image (v1 or v2)",
101
+ table: {
102
+ type: { summary: "string" },
103
+ defaultValue: { summary: "v1" }
104
+ }
82
105
  }
83
106
  }
84
107
  };
@@ -1,16 +1,16 @@
1
- import styled, { css } from "styled-components";
1
+ import styled from "styled-components";
2
2
  import { Box } from "../../atoms";
3
3
  import { rgba } from "polished";
4
4
 
5
5
  export const getHeroImageVariantStyles = ({
6
+ variant,
6
7
  imageUrl,
7
8
  isMobile,
8
- variant,
9
- heroPrimaryColor,
10
- heroSecondaryColor
9
+ heroPrimaryColor
11
10
  }) => {
12
- return css`
13
- background: ${!isMobile
11
+ return `
12
+ background: ${
13
+ !isMobile
14
14
  ? `linear-gradient(
15
15
  90deg,
16
16
  ${heroPrimaryColor} 33%,
@@ -19,7 +19,8 @@ export const getHeroImageVariantStyles = ({
19
19
  : `linear-gradient(
20
20
  ${rgba(heroPrimaryColor, 0.8)},
21
21
  ${rgba(heroPrimaryColor, 0.8)}
22
- )`},
22
+ )`
23
+ },
23
24
  url(${imageUrl}) center / cover no-repeat, ${heroPrimaryColor};
24
25
  `;
25
26
  };
@@ -213,15 +213,3 @@ export const adjustHexColor = (hex, percent, action) => {
213
213
  .slice(1)
214
214
  .padStart(6, "0")}`;
215
215
  };
216
-
217
- /**
218
- * Gets the next heading level in the sequence.
219
- *
220
- * @param {string} heading - The current heading level (e.g., "h1").
221
- * @returns {string} - The next heading level in the sequence.
222
- */
223
- const headingOrder = ["h1", "h2", "h3", "h4", "h5", "h6"];
224
- export const getNextHeading = heading => {
225
- const index = headingOrder.indexOf(heading);
226
- return index >= 0 && index < 5 ? headingOrder[index + 1] : headingOrder[5];
227
- };