@thecb/components 4.0.6 → 4.0.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.
Files changed (27) hide show
  1. package/.tool-versions +1 -0
  2. package/dist/index.cjs.js +1341 -326
  3. package/package.json +2 -1
  4. package/src/components/atoms/button-with-action/ButtonWithAction.js +3 -1
  5. package/src/components/atoms/card/Card.js +121 -0
  6. package/src/components/atoms/card/Card.theme.js +9 -0
  7. package/src/components/atoms/card/index.js +37 -0
  8. package/src/components/atoms/form-layouts/FormLayouts.theme.js +2 -2
  9. package/src/components/atoms/heading/Heading.js +3 -1
  10. package/src/components/atoms/icons/PropertiesAddIcon.js +1 -6
  11. package/src/components/atoms/index.js +1 -0
  12. package/src/components/atoms/labeled-amount/LabeledAmount.js +3 -1
  13. package/src/components/atoms/paragraph/Paragraph.js +2 -0
  14. package/src/components/atoms/placeholder/Placeholder.js +20 -7
  15. package/src/components/atoms/text/Text.js +2 -0
  16. package/src/components/molecules/collapsible-section/CollapsibleSection.js +1 -1
  17. package/src/components/molecules/editable-list/EditableList.js +0 -1
  18. package/src/components/molecules/editable-table/TableListItem.js +1 -1
  19. package/src/components/molecules/index.js +1 -0
  20. package/src/components/molecules/module/Module.js +1 -2
  21. package/src/components/molecules/module/Module.theme.js +1 -1
  22. package/src/components/molecules/obligation/modules/TitleModule.js +2 -2
  23. package/src/components/molecules/payment-details/PaymentDetails.js +3 -2
  24. package/src/components/molecules/radio-section/RadioSection.js +2 -1
  25. package/src/components/molecules/welcome-module/WelcomeModule.js +52 -0
  26. package/src/components/molecules/welcome-module/WelcomeModule.theme.js +15 -0
  27. package/src/components/molecules/welcome-module/index.js +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.0.6",
3
+ "version": "4.0.10",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -76,6 +76,7 @@
76
76
  "formatted-input": "^0.1.3",
77
77
  "framer-motion": "^1.11.0",
78
78
  "numeral": "^2.0.6",
79
+ "polished": "^4.0.3",
79
80
  "ramda": "^0.27.0",
80
81
  "react-aria-modal": "^4.0.0",
81
82
  "react-pose": "^4.0.10",
@@ -82,7 +82,9 @@ const ButtonWithAction = ({
82
82
  "Button",
83
83
  variant
84
84
  );
85
- const loadingExtraStyles = `${extraStyles}; padding-top: 0.75rem; padding-bottom: 0.75rem;`;
85
+ const loadingExtraStyles = `${extraStyles}; padding-top: 0.75rem; padding-bottom: 0.75rem; height: ${
86
+ themeContext.isMobile ? "50px" : "57px"
87
+ } `;
86
88
  const hoverStyles = `
87
89
  outline: none;
88
90
  background-color: ${themeValues.hoverBackgroundColor};
@@ -0,0 +1,121 @@
1
+ import React, { Fragment, useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
3
+ import { useNavigate } from "react-router-dom";
4
+ import { Box, Stack, Cover } from "../layouts";
5
+ import Text from "../text";
6
+ import Heading from "../heading";
7
+ import ButtonWithAction from "../button-with-action";
8
+ import { fallbackValues } from "./Card.theme";
9
+ import { themeComponent } from "../../../util/themeUtils";
10
+ import {
11
+ AccountsAddIcon,
12
+ PropertiesAddIcon,
13
+ PaymentMethodIcon
14
+ } from "../icons";
15
+ import withWindowSize from "../../withWindowSize";
16
+
17
+ const CardVariantSwitcher = ({ variant, children }) => {
18
+ return variant === "vertical" ? (
19
+ <Fragment>{children}</Fragment>
20
+ ) : (
21
+ <Box padding="0" extraStyles={`width: 100%`}>
22
+ <Stack childGap="0" maxWidth="100%" fullHeight>
23
+ {children}
24
+ </Stack>
25
+ </Box>
26
+ );
27
+ };
28
+
29
+ const Card = ({
30
+ themeValues,
31
+ icon,
32
+ heading,
33
+ text,
34
+ cardAction = "/profile",
35
+ buttonText,
36
+ variant = "vertical"
37
+ }) => {
38
+ const { isMobile } = useContext(ThemeContext);
39
+ let navigate = useNavigate();
40
+
41
+ const renderIcon = icon => {
42
+ switch (icon) {
43
+ case "accounts":
44
+ return <AccountsAddIcon />;
45
+ case "properties":
46
+ return <PropertiesAddIcon />;
47
+ case "payment":
48
+ return <PaymentMethodIcon />;
49
+ default:
50
+ return <PaymentMethodIcon />;
51
+ }
52
+ };
53
+
54
+ return (
55
+ <Box
56
+ background={themeValues.backgroundColor}
57
+ borderRadius="4px"
58
+ boxShadow=" 0px 1px 10px 0px rgb(246, 246, 249),
59
+ 0px 2px 5px 0px rgb(202, 206, 216)"
60
+ padding="0"
61
+ maxWidth="100%"
62
+ minHeight="100%"
63
+ minWidth={variant !== "vertical" && "300px"}
64
+ >
65
+ <Cover singleChild fillCenter>
66
+ <Stack
67
+ direction={variant === "vertical" ? "column" : "row"}
68
+ justify={variant === "vertical" && "center"}
69
+ fullHeight
70
+ childGap="0"
71
+ >
72
+ {icon && (
73
+ <Box padding="0" background={themeValues.iconBackgroundColor}>
74
+ <Stack
75
+ direction={variant === "vertical" ? "row" : "column"}
76
+ justify="center"
77
+ fullHeight
78
+ >
79
+ <Box
80
+ padding={
81
+ variant === "vertical"
82
+ ? "0.5rem 0"
83
+ : isMobile
84
+ ? "1rem 1.5rem"
85
+ : "2rem 2.5rem"
86
+ }
87
+ >
88
+ {renderIcon(icon)}
89
+ </Box>
90
+ </Stack>
91
+ </Box>
92
+ )}
93
+ <CardVariantSwitcher variant={variant}>
94
+ <Box
95
+ padding="0.5rem 1rem"
96
+ width="100%"
97
+ extraStyles={`flex-grow: 1; width: 100%;`}
98
+ >
99
+ <Cover singleChild fillCenter>
100
+ <Box padding="0">
101
+ <Heading variant="h6">{heading}</Heading>
102
+ <Text variant="pS">{text}</Text>
103
+ </Box>
104
+ </Cover>
105
+ </Box>
106
+ <Box padding="0.5rem 1rem 1rem">
107
+ <ButtonWithAction
108
+ variant="smallPrimary"
109
+ text={buttonText}
110
+ action={() => navigate(cardAction)}
111
+ extraStyles={`width: 100%;`}
112
+ />
113
+ </Box>
114
+ </CardVariantSwitcher>
115
+ </Stack>
116
+ </Cover>
117
+ </Box>
118
+ );
119
+ };
120
+
121
+ export default themeComponent(withWindowSize(Card), "Card", fallbackValues);
@@ -0,0 +1,9 @@
1
+ import { WHITE, GRECIAN_GREY } from "../../../constants/colors";
2
+
3
+ const backgroundColor = WHITE;
4
+ const iconBackgroundColor = GRECIAN_GREY;
5
+
6
+ export const fallbackValues = {
7
+ backgroundColor,
8
+ iconBackgroundColor
9
+ };
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import Card from "./Card";
3
+
4
+ export const cardRegistry = {
5
+ accounts: props => (
6
+ <Card
7
+ icon="accounts"
8
+ heading="Add an Account"
9
+ buttonText="Add Account"
10
+ text="Add your accounts to this profile to make your payments simple."
11
+ cardAction="/profile/accounts"
12
+ {...props}
13
+ />
14
+ ),
15
+ properties: props => (
16
+ <Card
17
+ icon="properties"
18
+ heading="Add a Property"
19
+ buttonText="Add Property"
20
+ text="Add a home, car, or other types of personal or business property."
21
+ cardAction="/profile/properties"
22
+ {...props}
23
+ />
24
+ ),
25
+ payment: props => (
26
+ <Card
27
+ icon="payment"
28
+ heading="Add a Payment Method"
29
+ buttonText="Add Payment Method"
30
+ text="Save cards and/or bank accounts to your profile for fast future payments."
31
+ cardAction="/profile/settings"
32
+ {...props}
33
+ />
34
+ )
35
+ };
36
+
37
+ export default cardRegistry;
@@ -1,5 +1,5 @@
1
1
  import {
2
- STORM_GREY,
2
+ FIREFLY_GREY,
3
3
  MATISSE_BLUE,
4
4
  WHITE,
5
5
  SEASHELL_WHITE,
@@ -23,7 +23,7 @@ const inputBackgroundColor = {
23
23
  disabled: `${SEASHELL_WHITE}`
24
24
  };
25
25
  const color = { default: `${MINESHAFT_GREY}`, disabled: `${DUSTY_GREY}` };
26
- const labelColor = { default: `${STORM_GREY}`, disabled: `${STORM_GREY}` };
26
+ const labelColor = { default: `${FIREFLY_GREY}`, disabled: `${FIREFLY_GREY}` };
27
27
  const borderColor = { default: `${GREY_CHATEAU}`, disabled: `${GREY_CHATEAU}` };
28
28
  const lineHeight = { default: "1rem", disabled: "1rem" };
29
29
  const fontSize = { default: "0.875rem", disabled: "0.875rem" };
@@ -15,12 +15,14 @@ const Heading = ({
15
15
  extraStyles = ``,
16
16
  className,
17
17
  variant = "h1",
18
+ as = variant,
18
19
  dataQa,
19
20
  children,
20
21
  ...rest
21
22
  }) => (
22
23
  <HeadingText
23
- as={variant}
24
+ variant={variant}
25
+ as={as}
24
26
  weight={weight}
25
27
  color={color}
26
28
  margin={margin}
@@ -3,12 +3,7 @@ import { fallbackValues } from "./Icons.theme";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  const PropertiesAddIcon = ({ themeValues }) => {
5
5
  return (
6
- <svg
7
- width={100}
8
- height={100}
9
- viewBox="0 0 100 100"
10
- style={{ paddingLeft: "16px" }}
11
- >
6
+ <svg width={100} height={100} viewBox="0 0 84 100">
12
7
  <title>{"8330C897-662E-49C5-B716-3661563AA1FB@1.00x"}</title>
13
8
  <defs>
14
9
  <path id="prefix__a" d="M0 0h100v100H0z" />
@@ -4,6 +4,7 @@ export { default as AmountCallout } from "./amount-callout";
4
4
  export { default as Breadcrumb } from "./breadcrumb";
5
5
  export { default as ButtonWithAction } from "./button-with-action";
6
6
  export { default as ButtonWithLink } from "./button-with-link";
7
+ export { default as cardRegistry } from "./card";
7
8
  export { default as Checkbox } from "./checkbox";
8
9
  export { default as CheckboxList } from "./checkbox-list";
9
10
  export { default as CountryDropdown } from "./country-dropdown";
@@ -5,12 +5,13 @@ import { Stack } from "../layouts";
5
5
  import Heading from "../heading";
6
6
  import Paragraph from "../paragraph";
7
7
 
8
- const LabeledAmount = ({ variant = "pL", label, amount, themeValues }) => {
8
+ const LabeledAmount = ({ variant = "pL", label, amount, themeValues, as }) => {
9
9
  const LabeledAmountText = variant === "h6" ? Heading : Paragraph;
10
10
  return (
11
11
  <Stack direction="row">
12
12
  <LabeledAmountText
13
13
  variant={variant}
14
+ as={as}
14
15
  weight={themeValues.fontWeight}
15
16
  extraStyles="text-align: start; flex: 3;"
16
17
  >
@@ -18,6 +19,7 @@ const LabeledAmount = ({ variant = "pL", label, amount, themeValues }) => {
18
19
  </LabeledAmountText>
19
20
  <LabeledAmountText
20
21
  variant={variant}
22
+ as={as}
21
23
  weight={themeValues.fontWeight}
22
24
  extraStyles="text-align: end; flex: 1;"
23
25
  >
@@ -14,6 +14,7 @@ const Paragraph = ({
14
14
  extraStyles = ``,
15
15
  dataQa,
16
16
  children,
17
+ as,
17
18
  ...rest
18
19
  }) => (
19
20
  <ParagraphText
@@ -22,6 +23,7 @@ const Paragraph = ({
22
23
  margin={margin}
23
24
  fontFamily={themeValues.fontFamily}
24
25
  fontSize={themeValues.fontSize}
26
+ as={as}
25
27
  extraStyles={extraStyles}
26
28
  data-qa={dataQa}
27
29
  {...rest}
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { tint } from "polished";
2
3
  import { Link } from "react-router-dom";
3
4
  import Text from "../text";
4
5
  import { Box, Switcher, Center, Cluster, Cover } from "../layouts";
@@ -63,19 +64,27 @@ const Placeholder = ({
63
64
  extraStyles={`
64
65
  background: linear-gradient(
65
66
  to right,
66
- ${STORM_GREY} 40%,
67
+ ${variant === "large" ? STORM_GREY : themeValues.color} 40%,
67
68
  rgba(255, 255, 255, 0) 0%
68
69
  ),
69
- linear-gradient(${STORM_GREY} 40%, rgba(255, 255, 255, 0) 0%),
70
- linear-gradient(to right, ${STORM_GREY} 40%, rgba(255, 255, 255, 0) 0%),
71
- linear-gradient(${STORM_GREY} 40%, rgba(255, 255, 255, 0) 0%);
70
+ linear-gradient(${
71
+ variant === "large" ? STORM_GREY : themeValues.color
72
+ } 40%, rgba(255, 255, 255, 0) 0%),
73
+ linear-gradient(to right, ${
74
+ variant === "large" ? STORM_GREY : themeValues.color
75
+ } 40%, rgba(255, 255, 255, 0) 0%),
76
+ linear-gradient(${
77
+ variant === "large" ? STORM_GREY : themeValues.color
78
+ } 40%, rgba(255, 255, 255, 0) 0%);
72
79
  background-position: top, right, bottom, left;
73
80
  background-repeat: repeat-x, repeat-y;
74
81
  background-size: 5px 1px, 1px 5px;
75
82
  display: flex;
76
83
  justify-content: center;
77
84
  align-items:center;`}
78
- hoverStyles={`background-color: ${GRECIAN_GREY};`}
85
+ hoverStyles={`background-color: ${
86
+ variant === "large" ? GRECIAN_GREY : tint(0.9, themeValues.color)
87
+ };`}
79
88
  >
80
89
  <Center maxWidth="300px">
81
90
  <Box padding="0px 0px 0px 0px">
@@ -85,9 +94,13 @@ const Placeholder = ({
85
94
  <Box
86
95
  padding="0"
87
96
  extraStyles={`.fill {
88
- fill: ${CHARADE_GREY};
97
+ fill: ${
98
+ variant === "large" ? CHARADE_GREY : themeValues.color
99
+ };
89
100
  } .stroke {
90
- stroke: ${CHARADE_GREY};
101
+ stroke: ${
102
+ variant === "large" ? CHARADE_GREY : themeValues.color
103
+ };
91
104
  }`}
92
105
  >
93
106
  {variant === "large" ? (
@@ -13,6 +13,7 @@ const Text = ({
13
13
  extraStyles = ``,
14
14
  hoverStyles,
15
15
  onClick,
16
+ as,
16
17
  dataQa,
17
18
  children,
18
19
  ...rest
@@ -22,6 +23,7 @@ const Text = ({
22
23
  weight={weight}
23
24
  color={color}
24
25
  fontFamily={themeValues.fontFamily}
26
+ as={as}
25
27
  extraStyles={extraStyles}
26
28
  hoverStyles={hoverStyles}
27
29
  onClick={onClick}
@@ -86,7 +86,7 @@ const CollapsibleSection = ({
86
86
  variant="h6"
87
87
  weight={FONT_WEIGHT_SEMIBOLD}
88
88
  color={themeValues.titleColor}
89
- aria-level="3"
89
+ as="h6"
90
90
  >
91
91
  {title}
92
92
  </Heading>
@@ -43,7 +43,6 @@ const EditableList = ({
43
43
  weight={titleWeight}
44
44
  color={CHARADE_GREY}
45
45
  extraStyles="letter-spacing: 0.29px;"
46
- aria-level="3"
47
46
  >
48
47
  {title}
49
48
  </Paragraph>
@@ -29,7 +29,7 @@ const TableListItem = ({
29
29
  <ItemWrapper>
30
30
  <EditableTableListItem isMobile={isMobile}>
31
31
  <TableItemKey isMobile={isMobile}>
32
- <Text variant="pS" color={CHARADE_GREY} aria-level="3">
32
+ <Text variant="pS" color={CHARADE_GREY}>
33
33
  {title}
34
34
  </Text>
35
35
  </TableItemKey>
@@ -28,4 +28,5 @@ export { default as TabSidebar } from "./tab-sidebar";
28
28
  export { default as TermsAndConditions } from "./terms-and-conditions";
29
29
  export { default as TermsAndConditionsModal } from "./terms-and-conditions-modal";
30
30
  export { default as Timeout } from "./timeout";
31
+ export { default as WelcomeModule } from "./welcome-module";
31
32
  export { default as WorkflowTile } from "./workflow-tile";
@@ -16,12 +16,11 @@ const Module = ({
16
16
  <Fragment>
17
17
  {heading && (
18
18
  <Heading
19
- variant={variant === "default" ? "h5" : "h3"}
19
+ variant={variant === "default" ? "h5" : "h2"}
20
20
  weight={themeValues.fontWeight}
21
21
  color={themeValues.fontColor}
22
22
  margin={`${spacing} 0 ${themeValues.titleSpacing} 0`}
23
23
  textAlign={themeValues.textAlign}
24
- aria-level={variant === "default" ? "3" : "1"}
25
24
  >
26
25
  {heading}
27
26
  </Heading>
@@ -5,7 +5,7 @@ const fontWeight = { default: "600", largeTitle: "700" };
5
5
  const fontColor = { default: CHARADE_GREY, largeTitle: CHARADE_GREY };
6
6
  const lineHeight = { default: "2rem", largeTitle: "2rem" };
7
7
  const textAlign = { default: "left", largeTitle: "left" };
8
- const titleType = { default: "h5", largeTitle: "h3" };
8
+ const titleType = { default: "h5", largeTitle: "h1" };
9
9
  const titleSpacing = { default: "0.5rem", largeTitle: "1.125rem" };
10
10
  const boxShadow = {
11
11
  default:
@@ -11,11 +11,11 @@ const TitleModule = ({ title, subtitle, titleColor, subtitleColor }) => (
11
11
  variant="h6"
12
12
  weight={FONT_WEIGHT_SEMIBOLD}
13
13
  color={titleColor}
14
- aria-level="2"
14
+ as="h2"
15
15
  >
16
16
  {title}
17
17
  </Heading>
18
- <Text variant="pS" color={subtitleColor} aria-level="3">
18
+ <Text variant="pS" color={subtitleColor}>
19
19
  {subtitle}
20
20
  </Text>
21
21
  </Stack>
@@ -31,6 +31,7 @@ const PaymentDetailsContent = ({
31
31
  </Box>
32
32
  <SolidDivider />
33
33
  <LabeledAmount
34
+ as="h2"
34
35
  variant={themeValues.labeledAmountTotal}
35
36
  label="Total"
36
37
  amount={displayCurrency(total)}
@@ -123,14 +124,14 @@ const PaymentDetails = ({
123
124
  ) : isCollapsible ? (
124
125
  <Box width="100%" padding="none">
125
126
  <Cluster justify="space-between" align="center">
126
- <Heading variant="h6" weight="700">
127
+ <Heading variant="h5" weight="700" as="h1">
127
128
  {titleText}
128
129
  </Heading>
129
130
  {displayCurrency(total)}
130
131
  </Cluster>
131
132
  </Box>
132
133
  ) : (
133
- <Heading variant="h3" weight="700" margin="1rem 0 0 0">
134
+ <Heading as="h1" variant="h3" weight="700" margin="1rem 0 0 0">
134
135
  {titleText}
135
136
  </Heading>
136
137
  );
@@ -168,7 +168,7 @@ const RadioSection = ({
168
168
  <Cluster align="center">{section.titleIcon}</Cluster>
169
169
  )}
170
170
  <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
171
- <Text variant="p" color={CHARADE_GREY} aria-level="3">
171
+ <Text variant="p" color={CHARADE_GREY}>
172
172
  {section.title}
173
173
  </Text>
174
174
  </Box>
@@ -181,6 +181,7 @@ const RadioSection = ({
181
181
  key={icon.img}
182
182
  fade={!icon.enabled}
183
183
  isMobile={isMobile}
184
+ alt={icon.altText}
184
185
  />
185
186
  ))}
186
187
  </Cluster>
@@ -0,0 +1,52 @@
1
+ import React, { Fragment, memo } from "react";
2
+ import styled from "styled-components";
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+ import { fallbackValues } from "./WelcomeModule.theme";
5
+ import Heading from "../../atoms/heading";
6
+ import { Box, Cluster } from "../../atoms/layouts";
7
+
8
+ const WelcomeImage = styled.img`
9
+ width: 100%;
10
+ height: auto;
11
+ `;
12
+
13
+ const WelcomeModule = ({ heading, isMobile, themeValues }) => {
14
+ const welcomeImage =
15
+ "https://cb-public-assets.s3-us-west-2.amazonaws.com/profile-assets/profile-welcome-image.png";
16
+
17
+ return (
18
+ <Fragment>
19
+ <Box padding="0">
20
+ {isMobile && (
21
+ <Box padding="0" background={themeValues.imageBackgroundColor}>
22
+ <Cluster justify="center">
23
+ <WelcomeImage src={welcomeImage} />
24
+ </Cluster>
25
+ </Box>
26
+ )}
27
+ <Box background={themeValues.headerBackgroundColor}>
28
+ <Heading
29
+ variant="h5"
30
+ weight={themeValues.fontWeight}
31
+ color={themeValues.fontColor}
32
+ textAlign={themeValues.textAlign}
33
+ as="h5"
34
+ >
35
+ {heading}
36
+ </Heading>
37
+ </Box>
38
+ {!isMobile && (
39
+ <Box padding="0" background={themeValues.imageBackgroundColor}>
40
+ <Cluster justify="center" align="flex-end">
41
+ <WelcomeImage src={welcomeImage} />
42
+ </Cluster>
43
+ </Box>
44
+ )}
45
+ </Box>
46
+ </Fragment>
47
+ );
48
+ };
49
+
50
+ export default memo(
51
+ themeComponent(WelcomeModule, "WelcomeModule", fallbackValues)
52
+ );
@@ -0,0 +1,15 @@
1
+ import { MATISSE_BLUE, BRIGHT_GREY, WHITE } from "../../../constants/colors";
2
+
3
+ const fontWeight = "600";
4
+ const fontColor = WHITE;
5
+ const textAlign = "left";
6
+ const headerBackgroundColor = BRIGHT_GREY;
7
+ const imageBackgroundColor = MATISSE_BLUE;
8
+
9
+ export const fallbackValues = {
10
+ fontWeight,
11
+ fontColor,
12
+ textAlign,
13
+ headerBackgroundColor,
14
+ imageBackgroundColor
15
+ };
@@ -0,0 +1,3 @@
1
+ import WelcomeModule from "./WelcomeModule";
2
+
3
+ export default WelcomeModule;