@thecb/components 4.0.7-beta.0 → 4.0.11

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": "4.0.7-beta.0",
3
+ "version": "4.0.11",
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;
@@ -15,7 +15,7 @@ const Heading = ({
15
15
  extraStyles = ``,
16
16
  className,
17
17
  variant = "h1",
18
- as = "h1",
18
+ as = variant,
19
19
  dataQa,
20
20
  children,
21
21
  ...rest
@@ -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";
@@ -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";
@@ -24,6 +24,7 @@ const Modal = ({
24
24
  ModalLink,
25
25
  hideModal,
26
26
  continueAction,
27
+ cancelAction,
27
28
  modalOpen,
28
29
  modalHeaderText,
29
30
  modalBodyText,
@@ -34,7 +35,8 @@ const Modal = ({
34
35
  useDangerButton = false,
35
36
  defaultWrapper = true,
36
37
  onlyCloseButton = false,
37
- maxHeight
38
+ maxHeight,
39
+ underlayClickExits = true
38
40
  }) => {
39
41
  const { isMobile } = useContext(ThemeContext);
40
42
  return (
@@ -54,6 +56,7 @@ const Modal = ({
54
56
  dialogStyle={{
55
57
  width: "615px"
56
58
  }}
59
+ underlayClickExits={underlayClickExits}
57
60
  >
58
61
  <Box
59
62
  padding="0"
@@ -95,7 +98,7 @@ const Modal = ({
95
98
  >
96
99
  <ButtonWithAction
97
100
  variant="secondary"
98
- action={hideModal}
101
+ action={cancelAction ? cancelAction : hideModal}
99
102
  text={cancelButtonText}
100
103
  dataQa={cancelButtonText}
101
104
  extraStyles="width: 100%;"
@@ -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>
@@ -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>
@@ -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;