@thecb/components 11.11.0-beta.4 → 11.11.0-beta.7

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 (35) hide show
  1. package/README.md +8 -4
  2. package/dist/index.cjs.js +95 -67
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +95 -67
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/atoms/card-type/CardType.js +10 -2
  8. package/src/components/atoms/dropdown/Dropdown.js +2 -3
  9. package/src/components/atoms/dropdown/DropdownIcon.js +1 -0
  10. package/src/components/atoms/dropdown/DropdownIconV2.js +1 -0
  11. package/src/components/atoms/form-layouts/FormInput.js +9 -16
  12. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.js +2 -2
  13. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.theme.js +2 -2
  14. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +12 -9
  15. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.theme.js +2 -2
  16. package/src/components/atoms/icons/AmExSmallIcon.js +2 -0
  17. package/src/components/atoms/icons/DiscoverSmallIcon.js +2 -0
  18. package/src/components/atoms/icons/GenericCardLarge.js +1 -1
  19. package/src/components/atoms/icons/GenericSmallIcon.js +2 -0
  20. package/src/components/atoms/icons/MasterCardSmallIcon.js +2 -0
  21. package/src/components/atoms/icons/VisaSmallIcon.js +2 -0
  22. package/src/components/molecules/email-form/EmailForm.js +2 -1
  23. package/src/components/molecules/email-form/EmailForm.stories.js +210 -0
  24. package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +2 -1
  25. package/src/components/molecules/login-form/LoginForm.js +2 -1
  26. package/src/components/molecules/radio-section/InnerRadioSection.js +3 -3
  27. package/src/components/molecules/radio-section/RadioSection.stories.js +142 -0
  28. package/src/components/molecules/registration-form/RegistrationForm.js +2 -1
  29. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +1 -1
  30. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.stories.js +110 -0
  31. package/src/components/molecules/tooltip/Tooltip.js +28 -15
  32. package/src/components/molecules/tooltip/Tooltip.stories.js +5 -5
  33. package/src/components/molecules/tooltip/Tooltip.theme.js +10 -11
  34. package/src/components/molecules/tooltip/index.d.ts +1 -1
  35. package/src/util/formats.js +6 -3
@@ -36,7 +36,8 @@ const RegistrationForm = ({
36
36
  };
37
37
  const emailErrorMessages = {
38
38
  [required.error]: "Email is required",
39
- [isProbablyEmail.error]: "Invalid email address"
39
+ [isProbablyEmail.error]:
40
+ "Please enter a valid email address in the format user@example.com"
40
41
  };
41
42
  const passwordErrorMessages = {
42
43
  [required.error]: "Password is required",
@@ -54,7 +54,7 @@ const TermsAndConditionsModal = ({
54
54
  weight={themeValues.fontWeight}
55
55
  hoverStyles={themeValues.modalLinkHoverFocus}
56
56
  textDecoration={themeValues.modalLinkTextDecoration}
57
- extraStyles={`display: inline-block; width: fit-content; cursor: pointer`}
57
+ extraStyles={`display: inline-block; width: fit-content; cursor: pointer; min-height: 24px; line-height: 24px;`}
58
58
  role="button" // This should always be a "button" since it opens a modal
59
59
  className="modal-trigger"
60
60
  >
@@ -0,0 +1,110 @@
1
+ import React from "react";
2
+ import TermsAndConditionsModal from "./TermsAndConditionsModal";
3
+
4
+ const TermsContent = () => (
5
+ <p>
6
+ By enrolling, you agree to the automatic payment terms. Payments will be
7
+ processed on the first of each month using your selected payment method. You
8
+ may cancel at any time by contacting support. See our{" "}
9
+ <a href="#">Privacy Policy</a> for more details.
10
+ </p>
11
+ );
12
+
13
+ const meta = {
14
+ title: "Molecules/TermsAndConditionsModal",
15
+ component: TermsAndConditionsModal,
16
+ parameters: {
17
+ layout: "centered"
18
+ },
19
+ tags: ["!autodocs"],
20
+ args: {
21
+ link: "Terms and Conditions",
22
+ title: "Terms and Conditions",
23
+ terms: <TermsContent />,
24
+ isOpen: false,
25
+ linkVariant: "p",
26
+ initialFocusSelector: "[name='Cancel']"
27
+ },
28
+ argTypes: {
29
+ link: {
30
+ description: "Text displayed for the modal trigger link",
31
+ table: {
32
+ type: { summary: "string" },
33
+ defaultValue: { summary: "Terms and Conditions" }
34
+ }
35
+ },
36
+ title: {
37
+ description: "Title displayed in the modal header",
38
+ table: {
39
+ type: { summary: "string" },
40
+ defaultValue: { summary: "Terms & Conditions" }
41
+ }
42
+ },
43
+ isOpen: {
44
+ description: "Whether the modal is currently open",
45
+ table: {
46
+ type: { summary: "boolean" },
47
+ defaultValue: { summary: false }
48
+ }
49
+ },
50
+ acceptText: {
51
+ description:
52
+ "Text for the accept button. If omitted, only a close button is shown.",
53
+ table: {
54
+ type: { summary: "string" },
55
+ defaultValue: { summary: undefined }
56
+ }
57
+ },
58
+ linkVariant: {
59
+ description: "Text size variant for the trigger link",
60
+ control: "select",
61
+ options: ["p", "pL", "pS", "pXS", "pXXS", "pXL"],
62
+ table: {
63
+ type: { summary: "string" },
64
+ defaultValue: { summary: "p" }
65
+ }
66
+ },
67
+ initialFocusSelector: {
68
+ description: "CSS selector for the element that receives initial focus",
69
+ table: {
70
+ type: { summary: "string" },
71
+ defaultValue: { summary: "" }
72
+ }
73
+ }
74
+ }
75
+ };
76
+
77
+ export default meta;
78
+
79
+ export const Default = {};
80
+
81
+ export const SmallVariant = {
82
+ args: {
83
+ linkVariant: "pS"
84
+ }
85
+ };
86
+
87
+ export const ExtraSmallVariant = {
88
+ args: {
89
+ linkVariant: "pXS"
90
+ }
91
+ };
92
+
93
+ export const LargeVariant = {
94
+ args: {
95
+ linkVariant: "pL"
96
+ }
97
+ };
98
+
99
+ export const WithAcceptButton = {
100
+ args: {
101
+ acceptText: "I Accept"
102
+ }
103
+ };
104
+
105
+ export const CustomLinkText = {
106
+ args: {
107
+ link: "Learn More",
108
+ linkVariant: "pS"
109
+ }
110
+ };
@@ -1,11 +1,12 @@
1
1
  import React, { useContext, useEffect, useRef, useState } from "react";
2
2
  import { createThemeValues } from "../../../util/themeUtils";
3
+ import { WHITE } from "../../../constants/colors";
3
4
  import { ThemeContext } from "styled-components";
4
5
  import Text from "../../atoms/text";
5
6
  import { Box } from "../../atoms/layouts";
6
7
  import ButtonWithAction from "../../atoms/button-with-action";
7
8
  import { noop, arrowBorder } from "../../../util/general";
8
- import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
9
+ import { fallbackValues } from "./Tooltip.theme";
9
10
 
10
11
  const Tooltip = ({
11
12
  tooltipID,
@@ -32,7 +33,7 @@ const Tooltip = ({
32
33
  arrowBottom: "-8px",
33
34
  arrowLeft: "auto"
34
35
  },
35
- arrowColor
36
+ backgroundColor = WHITE
36
37
  }) => {
37
38
  const closeTimeoutRef = useRef(null);
38
39
  const [tooltipOpen, setTooltipOpen] = useState(false);
@@ -40,7 +41,7 @@ const Tooltip = ({
40
41
  const themeValues = createThemeValues(
41
42
  themeContext,
42
43
  fallbackValues,
43
- TOOLTIP_THEME_SOURCE
44
+ "Tooltip"
44
45
  );
45
46
 
46
47
  const { top, right, bottom, left } = contentPosition;
@@ -82,13 +83,28 @@ const Tooltip = ({
82
83
 
83
84
  const renderTrigger = () => {
84
85
  if (hasCustomTrigger && children) {
85
- return React.cloneElement(React.Children.only(children), {
86
+ const child = React.Children.only(children);
87
+ const {
88
+ onFocus: childOnFocus,
89
+ onBlur: childOnBlur,
90
+ onKeyDown: childOnKeyDown
91
+ } = child.props ?? {};
92
+ return React.cloneElement(child, {
86
93
  "aria-describedby": tooltipID,
87
- onFocus: () => handleToggleTooltip(true),
88
- onBlur: () => handleToggleTooltip(false),
89
- onKeyDown: handleKeyDown,
94
+ onFocus: e => {
95
+ childOnFocus?.(e);
96
+ handleToggleTooltip(true);
97
+ },
98
+ onBlur: e => {
99
+ childOnBlur?.(e);
100
+ handleToggleTooltip(false);
101
+ },
102
+ onKeyDown: e => {
103
+ childOnKeyDown?.(e);
104
+ handleKeyDown(e);
105
+ },
90
106
  tabIndex: "0",
91
- style: { cursor: "pointer" }
107
+ style: { ...child.props?.style, cursor: "pointer" }
92
108
  });
93
109
  }
94
110
 
@@ -127,7 +143,7 @@ const Tooltip = ({
127
143
  role="tooltip"
128
144
  id={tooltipID}
129
145
  aria-hidden={!tooltipOpen}
130
- background={themeValues.borderColor}
146
+ background={backgroundColor}
131
147
  data-qa="tooltip-contents"
132
148
  extraStyles={`
133
149
  position: absolute;
@@ -137,6 +153,7 @@ const Tooltip = ({
137
153
  bottom: ${bottom};
138
154
  left: ${left};
139
155
  height: ${height};
156
+ color: ${themeValues.textColor};
140
157
  ${contentExtraStyles}
141
158
  `}
142
159
  boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
@@ -146,7 +163,7 @@ const Tooltip = ({
146
163
  maxWidth={maxWidth}
147
164
  >
148
165
  {typeof content === "string" ? (
149
- <Text color={themeValues.linkColor}>{content}</Text>
166
+ <Text color={themeValues.textColor}>{content}</Text>
150
167
  ) : (
151
168
  content
152
169
  )}
@@ -157,11 +174,7 @@ const Tooltip = ({
157
174
  content: "";
158
175
  width: 0;
159
176
  height: 0;
160
- ${arrowBorder(
161
- arrowColor || themeValues.borderColor,
162
- arrowDirection,
163
- "8px"
164
- )};
177
+ ${arrowBorder(backgroundColor, arrowDirection, "8px")};
165
178
  filter: drop-shadow(2px 8px 14px black);
166
179
  bottom: ${arrowBottom};
167
180
  right: ${arrowRight};
@@ -3,7 +3,7 @@ import Tooltip from "./Tooltip";
3
3
  import Text from "../../atoms/text/Text";
4
4
  import AutopayOnIcon from "../../atoms/icons/AutopayOnIcon";
5
5
  import Box from "../../atoms/layouts/Box";
6
- import { SEA_GREEN } from "../../../constants/colors";
6
+ import { SEA_GREEN, WHITE } from "../../../constants/colors";
7
7
 
8
8
  const meta = {
9
9
  title: "Molecules/Tooltip",
@@ -161,12 +161,12 @@ const meta = {
161
161
  defaultValue: { summary: '""' }
162
162
  }
163
163
  },
164
- arrowColor: {
164
+ backgroundColor: {
165
165
  description:
166
- "Override color for the tooltip arrow. Defaults to the theme border color when not provided.",
166
+ "Override backgroundColor for the tooltip arrow. Defaults to WHITE when not provided.",
167
167
  table: {
168
168
  type: { summary: "string" },
169
- defaultValue: { summary: undefined }
169
+ defaultValue: { summary: WHITE }
170
170
  }
171
171
  }
172
172
  }
@@ -215,7 +215,7 @@ export const RichTooltipContent = {
215
215
  tooltipID: "tooltip-node-content",
216
216
  contentExtraStyles: "background-color: #000000; color: #ffffff;",
217
217
  triggerText: "Rich content",
218
- arrowColor: "black",
218
+ backgroundColor: "black",
219
219
  contentPosition: {
220
220
  top: "-126px",
221
221
  right: "auto",
@@ -1,19 +1,18 @@
1
1
  import {
2
- MATISSE_BLUE,
3
- PEACOCK_BLUE,
4
- SAPPHIRE_BLUE
2
+ ROYAL_BLUE_VIVID,
3
+ ROYAL_BLUE,
4
+ CONGRESS_BLUE,
5
+ CHARADE_GREY
5
6
  } from "../../../constants/colors";
6
7
 
7
- const hoverColor = SAPPHIRE_BLUE;
8
- const activeColor = PEACOCK_BLUE;
9
- const linkColor = MATISSE_BLUE;
10
- const borderColor = "rgba(255, 255, 255, 0.85)";
11
-
12
- export const TOOLTIP_THEME_SOURCE = "Button";
8
+ const hoverColor = ROYAL_BLUE;
9
+ const activeColor = CONGRESS_BLUE;
10
+ const linkColor = ROYAL_BLUE_VIVID;
11
+ const textColor = CHARADE_GREY;
13
12
 
14
13
  export const fallbackValues = {
15
- borderColor,
16
14
  linkColor,
17
15
  hoverColor,
18
- activeColor
16
+ activeColor,
17
+ textColor
19
18
  };
@@ -26,7 +26,7 @@ export interface TooltipProps {
26
26
  height?: string;
27
27
  containerExtraStyles?: string;
28
28
  contentExtraStyles?: string;
29
- arrowColor?: string;
29
+ backgroundColor?: string;
30
30
  }
31
31
 
32
32
  export const Tooltip: React.FC<Expand<TooltipProps> &
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { createFormat } from "formatted-input";
3
3
  import Text from "../components/atoms/text";
4
- import { ASH_GREY, FIRE_YELLOW } from "../constants/colors";
4
+ import { ASH_GREY, FIRE_YELLOW, STORM_GREY } from "../constants/colors";
5
5
  export const formatDelimiter = "_";
6
6
 
7
7
  export const phoneFormats = [
@@ -101,7 +101,8 @@ export const renderCardStatus = (
101
101
  <Text
102
102
  as={as}
103
103
  variant="pXS"
104
- color={ASH_GREY}
104
+ fontSize=".75rem"
105
+ color={STORM_GREY}
105
106
  extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
106
107
  >
107
108
  Exp Date {expireDate}
@@ -112,6 +113,7 @@ export const renderCardStatus = (
112
113
  <Text
113
114
  as={as}
114
115
  variant="pXS"
116
+ fontSize=".75rem"
115
117
  color={FIRE_YELLOW}
116
118
  extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
117
119
  >
@@ -123,7 +125,8 @@ export const renderCardStatus = (
123
125
  <Text
124
126
  as={as}
125
127
  variant="pXS"
126
- color={ASH_GREY}
128
+ fontSize=".75rem"
129
+ color={STORM_GREY}
127
130
  extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
128
131
  >
129
132
  Expired