@thecb/components 11.2.6-beta.0 → 11.2.6-beta.1

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.0",
3
+ "version": "11.2.6-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -4,6 +4,7 @@ export const CenterWrapper = styled.div`
4
4
  box-sizing: content-box;
5
5
  margin-left: auto;
6
6
  margin-right: auto;
7
+ width: ${({ width }) => width || "auto"};
7
8
  max-width: ${({ maxWidth }) => maxWidth};
8
9
  padding-left: ${({ gutters }) => gutters};
9
10
  padding-right: ${({ gutters }) => gutters};
@@ -15,4 +16,5 @@ export const CenterWrapper = styled.div`
15
16
  align-items: center;
16
17
  `
17
18
  : ``};
19
+ ${({ extraStyles }) => extraStyles}
18
20
  `;
@@ -6,6 +6,7 @@ import { StyledExternalLink } from "./ExternalLink.styled";
6
6
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
7
7
  import { safeChildren } from "../../../util/general";
8
8
  import { Box } from "../layouts";
9
+ import { LINK_TEXT_DECORATION } from "../../../constants/style_constants";
9
10
 
10
11
  const ExternalLink = forwardRef(
11
12
  (
@@ -57,11 +58,12 @@ const ExternalLink = forwardRef(
57
58
  activeColor={themeValues.activeColor}
58
59
  fontFamily={themeValues.fontFamily}
59
60
  tabIndex={tabIndex}
60
- extrastyles={extraStyles}
61
+ extrastyles={`${
62
+ isUnderlined ? LINK_TEXT_DECORATION : "none"
63
+ } ${extraStyles}`}
61
64
  rel={newTab ? "noopener" : ""}
62
65
  data-qa={dataQa}
63
66
  aria-label={ariaLabel}
64
- isUnderlined={isUnderlined}
65
67
  ref={ref}
66
68
  >
67
69
  {safeChildren(children, <span />)}
@@ -22,8 +22,7 @@ export const StyledExternalLink = styled(
22
22
  font-weight: ${({ weight }) => weight};
23
23
  font-family: ${({ fontFamily }) => fontFamily};
24
24
  line-height: ${({ lineheight }) => lineheight};
25
- text-decoration: ${({ isUnderlined }) =>
26
- isUnderlined ? LINK_TEXT_DECORATION : "none"};
25
+ text-decoration: ${LINK_TEXT_DECORATION};
27
26
 
28
27
  &:hover {
29
28
  color: ${({ hoverColor }) => hoverColor};
@@ -4,6 +4,7 @@ import { fallbackValues } from "./Link.theme";
4
4
  import { createThemeValues } from "../../../util/themeUtils";
5
5
  import { StyledInternalLink } from "./InternalLink.styled";
6
6
  import { safeChildren } from "../../../util/general";
7
+ import { LINK_TEXT_DECORATION } from "../../../constants/style_constants";
7
8
 
8
9
  const InternalLink = forwardRef(
9
10
  (
@@ -45,9 +46,10 @@ const InternalLink = forwardRef(
45
46
  hoverColor={themeValues.hoverColor}
46
47
  activeColor={themeValues.activeColor}
47
48
  tabIndex={tabIndex}
48
- extrastyles={extraStyles}
49
+ extrastyles={`${
50
+ isUnderlined ? LINK_TEXT_DECORATION : "none"
51
+ } ${extraStyles}`}
49
52
  data-qa={dataQa}
50
- isUnderlined={isUnderlined}
51
53
  ref={ref}
52
54
  >
53
55
  {safeChildren(children, <span />)}
@@ -28,8 +28,7 @@ export const StyledInternalLink = styled(
28
28
  font-size: ${({ fontSize }) => fontSize};
29
29
  font-family: ${({ fontFamily }) => fontFamily};
30
30
  margin: ${({ margin }) => margin};
31
- text-decoration: ${({ isUnderlined }) =>
32
- isUnderlined ? LINK_TEXT_DECORATION : "none"};
31
+ text-decoration: ${LINK_TEXT_DECORATION};
33
32
 
34
33
  &:hover {
35
34
  color: ${({ hoverColor }) => hoverColor};
@@ -101,10 +101,9 @@ const ContactCard = ({
101
101
  "contact-card-link"
102
102
  );
103
103
  return (
104
- <>
104
+ <React.Fragment key={linkID}>
105
105
  {R.test(URL_TEST, link.link) ? (
106
106
  <ExternalLink
107
- key={linkID}
108
107
  dataQa={linkID}
109
108
  href={link.link}
110
109
  newTab={true}
@@ -129,7 +128,6 @@ const ContactCard = ({
129
128
  </ExternalLink>
130
129
  ) : (
131
130
  <InternalLink
132
- key={linkID}
133
131
  to={link.link}
134
132
  dataQa={linkID}
135
133
  fontSize={FONT_SIZE.SM}
@@ -145,7 +143,7 @@ const ContactCard = ({
145
143
  {link.text}
146
144
  </InternalLink>
147
145
  )}
148
- </>
146
+ </React.Fragment>
149
147
  );
150
148
  })}
151
149
  </Stack>
@@ -1,27 +1,32 @@
1
1
  import React, { useContext } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
- import { Box, Cluster, Stack } from "../../atoms/layouts";
4
- import BoxWithShadow from "../../atoms/box-with-shadow";
3
+ import { Box, Center, Stack } from "../../atoms/layouts";
5
4
  import { themeComponent } from "../../../util/themeUtils";
6
5
  import Paragraph from "../../atoms/paragraph";
7
6
  import Title from "../../atoms/title";
8
7
  import { fallbackValues } from "./HeroImage.theme";
9
- import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
8
+ import {
9
+ FONT_WEIGHT_BOLD,
10
+ FONT_WEIGHT_SEMIBOLD
11
+ } from "../../../constants/style_constants";
10
12
  import * as Styled from "./HeroImage.styled";
13
+ import { getNextHeading } from "../../../util/general";
11
14
 
12
15
  const HeroImage = ({
13
16
  themeValues,
14
17
  heading,
18
+ headingVariant = "h2",
15
19
  subheading,
16
20
  description,
17
21
  imageUrl,
18
22
  variant = "v1",
19
- padding = "4rem",
20
23
  minWidth = "100%",
21
24
  minHeight = "auto",
22
- contentSpacing = "0.5rem"
25
+ contentSpacing = "0.5rem",
26
+ paddingOverride
23
27
  }) => {
24
28
  const { isMobile } = useContext(ThemeContext);
29
+ const secondaryHeadingVariant = getNextHeading(headingVariant);
25
30
 
26
31
  return (
27
32
  <>
@@ -29,37 +34,46 @@ const HeroImage = ({
29
34
  <Styled.HeroImageContainer
30
35
  minWidth={minWidth}
31
36
  minHeight={minHeight}
32
- padding={padding}
37
+ padding={paddingOverride ?? (isMobile ? "2rem" : "3rem 5.75rem")}
33
38
  extraStyles={Styled.getHeroImageVariantStyles({
34
39
  imageUrl,
40
+ isMobile,
35
41
  variant,
36
- gradientPrimary: themeValues.gradientColorPrimary,
37
- gradientSecondary: themeValues.gradientColorSecondary
42
+ gradientColorPrimary: themeValues.gradientColorPrimary,
43
+ gradientColorSecondary: themeValues.gradientColorSecondary
38
44
  })}
39
45
  >
40
- <Box
41
- padding="0"
42
- maxWidth={isMobile ? "100%" : "50%"}
43
- extraStyles={"display: flex; align-items: center;"}
46
+ <Center
47
+ maxWidth={"78.5rem"}
48
+ width={"100%"}
49
+ intrinsic
50
+ extraStyles={`
51
+ flex-flow: unset;
52
+ justify-content: flex-start;
53
+ flex-wrap: nowrap;"
54
+ `}
44
55
  >
45
- <Stack childGap={contentSpacing}>
56
+ <Stack
57
+ childGap={contentSpacing}
58
+ extraStyles={`max-width: ${isMobile ? "100%" : "50%"};`}
59
+ >
46
60
  <Stack childGap="0">
47
61
  <Title
48
62
  variant="hero"
49
- as="h2"
50
- weight={FONT_WEIGHT_SEMIBOLD}
63
+ as={headingVariant}
64
+ weight={FONT_WEIGHT_BOLD}
51
65
  color={themeValues.textColor}
52
- extraStyles={`line-height: 115%;`}
66
+ extraStyles={`line-height: ${isMobile ? "125%" : "115%"};`}
53
67
  >
54
68
  {heading}
55
69
  </Title>
56
70
  <Title
57
71
  variant={"large"}
58
- as="h3"
72
+ as={secondaryHeadingVariant}
59
73
  weight={FONT_WEIGHT_SEMIBOLD}
60
- fontSize={!isMobile && "2rem"}
74
+ fontSize={isMobile ? "1.5rem" : "2rem"}
61
75
  color={themeValues.textColor}
62
- extraStyles={`line-height: 115%;`}
76
+ extraStyles={`line-height: ${isMobile ? "150%" : "115%"};`}
63
77
  >
64
78
  {subheading}
65
79
  </Title>
@@ -67,14 +81,15 @@ const HeroImage = ({
67
81
  <Box padding="0">
68
82
  <Paragraph
69
83
  color={themeValues.textColor}
70
- extraStyles={`line-height: 150%; ${!isMobile &&
71
- `font-size: 1.125rem;`}`}
84
+ extraStyles={`line-height: ${
85
+ isMobile ? "150%" : "115%"
86
+ }; ${!isMobile && `font-size: 1.125rem;`}`}
72
87
  >
73
88
  {description}
74
89
  </Paragraph>
75
90
  </Box>
76
91
  </Stack>
77
- </Box>
92
+ </Center>
78
93
  </Styled.HeroImageContainer>
79
94
  )}
80
95
  </>
@@ -1,4 +1,3 @@
1
- import { variants } from "styled-theming";
2
1
  import HeroImage from "./HeroImage";
3
2
 
4
3
  const meta = {
@@ -14,7 +13,7 @@ const meta = {
14
13
  description:
15
14
  "Find and make payments quickly and conveniently from your computer or phone.",
16
15
  imageUrl:
17
- "https://thecitybase.wpenginepowered.com/wp-content/uploads/2020/02/homepage-hero2.jpg",
16
+ "https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?q=80&w=1844&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
18
17
  contentSpacing: "0.5rem"
19
18
  },
20
19
  argTypes: {
@@ -25,6 +24,13 @@ const meta = {
25
24
  defaultValue: { summary: undefined }
26
25
  }
27
26
  },
27
+ headingVariant: {
28
+ description: "Heading variant for the hero image heading",
29
+ table: {
30
+ type: { summary: "string" },
31
+ defaultValue: { summary: undefined }
32
+ }
33
+ },
28
34
  subheading: {
29
35
  description: "Hero image sub-heading",
30
36
  table: {
@@ -46,8 +52,8 @@ const meta = {
46
52
  defaultValue: { summary: undefined }
47
53
  }
48
54
  },
49
- padding: {
50
- description: "Padding around the HeroImage content (desktop)",
55
+ paddingOverride: {
56
+ description: "padding override around the HeroImage content (desktop)",
51
57
  table: {
52
58
  type: { summary: "string" },
53
59
  defaultValue: { summary: "0.5rem 1.5rem" }
@@ -1,20 +1,28 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { Box } from "../../atoms";
3
+ import { rgba } from "polished";
3
4
 
4
5
  export const getHeroImageVariantStyles = ({
5
6
  imageUrl,
7
+ isMobile,
6
8
  variant,
7
- gradientPrimary,
8
- gradientSecondary
9
- }) => `
10
- background: linear-gradient(
11
- 90deg,
12
- ${gradientPrimary} 33%,
13
- rgba(59, 91, 219, 0) 100%
14
- ),
15
- url(${imageUrl});
16
- background-size: cover;
9
+ gradientColorPrimary,
10
+ gradientColorSecondary
11
+ }) => {
12
+ return css`
13
+ background: ${!isMobile
14
+ ? `linear-gradient(
15
+ 90deg,
16
+ ${gradientColorPrimary} 33%,
17
+ transparent 100%
18
+ )`
19
+ : `linear-gradient(
20
+ ${rgba(gradientColorPrimary, 0.8)},
21
+ ${rgba(gradientColorPrimary, 0.8)}
22
+ )`},
23
+ url(${imageUrl}) center / cover no-repeat;
17
24
  `;
25
+ };
18
26
 
19
27
  export const HeroImageContainer = styled(Box)`
20
28
  display: flex;
@@ -213,3 +213,15 @@ 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
+ };