@thecb/components 11.2.8-beta.0 → 11.2.8-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.8-beta.0",
3
+ "version": "11.2.8-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",
@@ -2,7 +2,6 @@ import React, { useContext } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import { Box, Center, Stack } from "../../atoms/layouts";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
- import Title from "../../atoms/title";
6
5
  import { fallbackValues } from "./HeroImage.theme";
7
6
  import withWindowSize from "../../withWindowSize";
8
7
  import {
@@ -26,25 +25,19 @@ const HeroImage = ({
26
25
  secondaryHeadingVariant = "h2",
27
26
  extraStyles
28
27
  }) => {
29
- const { isMobile } = useContext(ThemeContext);
30
- const gradientStyles = Styled.getHeroGradientStyles({
31
- variant,
32
- isMobile,
33
- heroPrimaryColor: themeValues.heroPrimaryColor,
34
- heroSecondaryColor: themeValues.heroSecondaryColor
35
- });
28
+ const themeContext = useContext(ThemeContext);
29
+ const { isMobile } = themeContext;
36
30
 
37
31
  return (
38
- <Box
32
+ <Styled.HeroContainer
33
+ variant={variant}
39
34
  minWidth={minWidth}
40
35
  minHeight={minHeight}
41
36
  padding={isMobile ? "2rem" : "3rem 2rem"}
42
- extraStyles={`
43
- display: flex;
44
- background: ${gradientStyles},
45
- url(${imageUrl}) center / cover no-repeat, ${themeValues.heroPrimaryColor};
46
- ${extraStyles}
47
- `}
37
+ extraStyles={extraStyles}
38
+ imageUrl={imageUrl}
39
+ isMobile={isMobile}
40
+ theme={themeValues}
48
41
  >
49
42
  <Center
50
43
  maxWidth={contentMaxWidth}
@@ -52,7 +45,10 @@ const HeroImage = ({
52
45
  intrinsic
53
46
  extraStyles={`
54
47
  flex-flow: unset;
55
- justify-content: ${variant === "v2" ? "center" : "flex-start"};
48
+ justify-content: ${Styled.getDeviceStyles(
49
+ isMobile,
50
+ themeValues.justifyContent
51
+ )};
56
52
  flex-wrap: nowrap;
57
53
  `}
58
54
  >
@@ -65,43 +61,55 @@ const HeroImage = ({
65
61
  {variant === "v1" ? (
66
62
  <Stack childGap="0">
67
63
  {heading && (
68
- <Title
64
+ <Styled.HeroHeading
69
65
  variant="hero"
70
66
  as={headingVariant}
71
67
  weight={FONT_WEIGHT_BOLD}
72
68
  color={themeValues.heroTextColor}
73
- extraStyles={`line-height: ${isMobile ? "125%" : "115%"};`}
69
+ textAlign={Styled.getDeviceStyles(
70
+ isMobile,
71
+ themeValues.textAlign
72
+ )}
73
+ isMobile={isMobile}
74
+ theme={themeValues}
74
75
  >
75
76
  {heading}
76
- </Title>
77
+ </Styled.HeroHeading>
77
78
  )}
78
79
  {subheading && (
79
- <Title
80
- variant={"large"}
80
+ <Styled.HeroSubheading
81
+ variant="large"
81
82
  as={secondaryHeadingVariant}
82
83
  weight={FONT_WEIGHT_SEMIBOLD}
83
- fontSize={isMobile ? "2rem" : "2.5rem"}
84
+ textAlign={Styled.getDeviceStyles(
85
+ isMobile,
86
+ themeValues.textAlign
87
+ )}
84
88
  color={themeValues.heroTextColor}
85
- extraStyles={`line-height: ${isMobile ? "150%" : "115%"};`}
89
+ isMobile={isMobile}
90
+ theme={themeValues}
86
91
  >
87
92
  {subheading}
88
- </Title>
93
+ </Styled.HeroSubheading>
89
94
  )}
90
95
  </Stack>
91
96
  ) : (
92
97
  <>
93
98
  {heading && (
94
- <Title
99
+ <Styled.HeroHeading
95
100
  variant="hero"
96
101
  as={headingVariant}
97
102
  weight={FONT_WEIGHT_BOLD}
98
103
  color={themeValues.heroTextColor}
99
- extraStyles={`text-align: center; line-height: ${
100
- isMobile ? "125%" : "115%"
101
- };`}
104
+ textAlign={Styled.getDeviceStyles(
105
+ isMobile,
106
+ themeValues.textAlign
107
+ )}
108
+ isMobile={isMobile}
109
+ theme={themeValues}
102
110
  >
103
111
  {heading}
104
- </Title>
112
+ </Styled.HeroHeading>
105
113
  )}
106
114
  </>
107
115
  )}
@@ -110,7 +118,7 @@ const HeroImage = ({
110
118
  <Styled.HeroDescription
111
119
  color={themeValues.heroTextColor}
112
120
  isMobile={isMobile}
113
- variant={variant}
121
+ theme={themeValues}
114
122
  >
115
123
  {description}
116
124
  </Styled.HeroDescription>
@@ -118,10 +126,10 @@ const HeroImage = ({
118
126
  )}
119
127
  </Stack>
120
128
  </Center>
121
- </Box>
129
+ </Styled.HeroContainer>
122
130
  );
123
131
  };
124
132
 
125
133
  export default withWindowSize(
126
- themeComponent(HeroImage, "HeroImage", fallbackValues)
134
+ themeComponent(HeroImage, "HeroImage", fallbackValues, "v1")
127
135
  );
@@ -1,14 +1,10 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
- import { Paragraph } from "../../atoms";
4
- import { rgba } from "polished";
3
+ import { Paragraph, Box } from "../../atoms";
4
+ import Title from "../../atoms/title/Title.js";
5
+ import { rgba, adjustHue, darken } from "polished";
5
6
 
6
- export const getHeroGradientStyles = ({
7
- variant,
8
- isMobile,
9
- heroPrimaryColor,
10
- heroSecondaryColor
11
- }) => {
7
+ const getHeroGradientStyles = ({ variant, isMobile, heroPrimaryColor }) => {
12
8
  const v1Gradient = `linear-gradient(
13
9
  90deg,
14
10
  ${heroPrimaryColor} 33%,
@@ -18,24 +14,70 @@ export const getHeroGradientStyles = ({
18
14
  ${rgba(heroPrimaryColor, 0.8)},
19
15
  ${rgba(heroPrimaryColor, 0.8)}
20
16
  )`;
17
+ const heroSecondaryColor = darken(0.18, adjustHue(-29, heroPrimaryColor));
21
18
  const v2Gradient = `linear-gradient(
22
19
  90deg,
23
20
  ${rgba(heroPrimaryColor, 0.8)} 0%,
24
21
  ${rgba(heroSecondaryColor, 0.8)} 100%
25
22
  )`;
26
23
 
27
- return {
28
- v1: isMobile ? v1GradientMobile : v1Gradient,
29
- v2: v2Gradient
30
- }[variant];
24
+ return variant === "v1"
25
+ ? isMobile
26
+ ? v1GradientMobile
27
+ : v1Gradient
28
+ : v2Gradient;
31
29
  };
32
30
 
33
- export const HeroDescription = styled(({ variant, isMobile, ...props }) => (
31
+ export const getDeviceStyles = (isMobile, theme) =>
32
+ isMobile ? theme.mobile : theme.desktop;
33
+
34
+ export const HeroContainer = styled(
35
+ ({ variant, imageUrl, isMobile, theme, extraStyles, ...props }) => (
36
+ <Box {...props} />
37
+ )
38
+ )`
39
+ display: flex;
40
+ background: ${({ variant, imageUrl, isMobile, theme }) =>
41
+ `${getHeroGradientStyles({
42
+ variant,
43
+ isMobile,
44
+ heroPrimaryColor: theme.heroPrimaryColor
45
+ })},
46
+ url(${imageUrl}) center / cover no-repeat, ${theme.heroPrimaryColor}`};
47
+ ${({ extraStyles }) => extraStyles}
48
+ `;
49
+
50
+ export const HeroHeading = styled(({ theme, isMobile, ...props }) => (
51
+ <Title {...props} />
52
+ ))`
53
+ font-size: ${({ theme, isMobile }) =>
54
+ getDeviceStyles(isMobile, theme.headingFontSize)};
55
+ color: ${({ color }) => color};
56
+ font-weight: ${({ weight }) => weight};
57
+ text-align: ${({ textAlign }) => textAlign};
58
+ line-height: ${({ theme, isMobile }) =>
59
+ getDeviceStyles(isMobile, theme.headingLineHeight)};
60
+ `;
61
+
62
+ export const HeroSubheading = styled(({ theme, isMobile, ...props }) => (
63
+ <Title {...props} />
64
+ ))`
65
+ font-size: ${({ theme, isMobile }) =>
66
+ getDeviceStyles(isMobile, theme.subheadingFontSize)};
67
+ color: ${({ color }) => color};
68
+ font-weight: ${({ weight }) => weight};
69
+ text-align: ${({ textAlign }) => textAlign};
70
+ line-height: ${({ theme, isMobile }) =>
71
+ getDeviceStyles(isMobile, theme.subheadingLineHeight)};
72
+ `;
73
+
74
+ export const HeroDescription = styled(({ theme, isMobile, ...props }) => (
34
75
  <Paragraph {...props} />
35
76
  ))`
36
- line-height: 150%;
37
- font-size: ${({ isMobile }) => (!isMobile ? "1.25rem" : "inherit")};
38
- text-align: ${({ variant }) => (variant === "v2" ? "center" : "inherit")};
39
- font-size: ${({ variant, isMobile }) =>
40
- variant === "v2" ? (isMobile ? "1.125rem" : "1.25rem") : "inherit"};
77
+ line-height: ${({ theme, isMobile }) =>
78
+ getDeviceStyles(isMobile, theme.descriptionLineHeight)};
79
+ font-size: ${({ theme, isMobile }) =>
80
+ getDeviceStyles(isMobile, theme.descriptionFontSize)};
81
+ text-align: ${({ theme, isMobile }) =>
82
+ getDeviceStyles(isMobile, theme.textAlign)};
41
83
  `;
@@ -3,13 +3,107 @@ import {
3
3
  ROYAL_BLUE_VIVID,
4
4
  WHITE
5
5
  } from "../../../constants/colors";
6
+ import { FONT_SIZE } from "../../../constants/style_constants";
6
7
 
8
+ // Colors
7
9
  const heroPrimaryColor = ROYAL_BLUE_VIVID;
8
- const heroSecondaryColor = MATISSE_BLUE;
9
10
  const heroTextColor = WHITE;
10
11
 
12
+ // Font Sizes
13
+ const headingFontSize = {
14
+ v1: {
15
+ mobile: "3.00rem",
16
+ desktop: "3.50rem"
17
+ },
18
+ v2: {
19
+ mobile: "2.50rem",
20
+ desktop: "3.50rem"
21
+ }
22
+ };
23
+ const subheadingFontSize = {
24
+ v1: {
25
+ mobile: "2.00rem",
26
+ desktop: "2.50rem"
27
+ }
28
+ };
29
+
30
+ const descriptionFontSize = {
31
+ v1: {
32
+ mobile: FONT_SIZE.MD,
33
+ desktop: FONT_SIZE.XL
34
+ },
35
+ v2: {
36
+ mobile: FONT_SIZE.LG,
37
+ desktop: FONT_SIZE.XL
38
+ }
39
+ };
40
+
41
+ // Line Heights
42
+ const headingLineHeight = {
43
+ v1: {
44
+ mobile: 1.25,
45
+ desktop: 1.15
46
+ },
47
+ v2: {
48
+ mobile: 1.25,
49
+ desktop: 1.15
50
+ }
51
+ };
52
+
53
+ const subheadingLineHeight = {
54
+ v1: {
55
+ mobile: 1.5,
56
+ desktop: 1.15
57
+ }
58
+ };
59
+
60
+ const descriptionLineHeight = {
61
+ v1: {
62
+ mobile: 1.5,
63
+ desktop: 1.5
64
+ },
65
+ v2: {
66
+ mobile: 1.5,
67
+ desktop: 1.5
68
+ }
69
+ };
70
+
71
+ // Alignment
72
+ const textAlign = {
73
+ v1: {
74
+ mobile: "left",
75
+ desktop: "left"
76
+ },
77
+ v2: {
78
+ mobile: "left",
79
+ desktop: "center"
80
+ }
81
+ };
82
+
83
+ const justifyContent = {
84
+ v1: {
85
+ mobile: "flex-start",
86
+ desktop: "flex-start"
87
+ },
88
+ v2: {
89
+ mobile: "flex-start",
90
+ desktop: "center"
91
+ }
92
+ };
93
+
11
94
  export const fallbackValues = {
95
+ // Colors
12
96
  heroPrimaryColor,
13
- heroSecondaryColor,
14
- heroTextColor
97
+ heroTextColor,
98
+ // Font sizes
99
+ headingFontSize,
100
+ descriptionFontSize,
101
+ subheadingFontSize,
102
+ // Line heights
103
+ headingLineHeight,
104
+ subheadingLineHeight,
105
+ descriptionLineHeight,
106
+ // Alignment
107
+ textAlign,
108
+ justifyContent
15
109
  };