@thecb/components 4.1.14-beta.0 → 4.1.14

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.1.14-beta.0",
3
+ "version": "4.1.14",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React from "react";
2
2
  import styled, { css } from "styled-components";
3
3
  import { fallbackValues } from "./Checkbox.theme";
4
4
  import { noop } from "../../../util/general";
@@ -87,72 +87,58 @@ const Checkbox = ({
87
87
  checked,
88
88
  onChange = noop,
89
89
  disabled = false,
90
+ focused = false,
90
91
  themeValues,
91
92
  hidden = false,
92
93
  error = false
93
- }) => {
94
- const [focused, setFocused] = useState(false);
95
-
96
- const handleClick = (e, func) => {
97
- if (e?.keyCode === 13) {
98
- func();
99
- }
100
- };
101
-
102
- return (
103
- <Box
104
- padding="0"
105
- tabIndex="0"
106
- onFocus={() => setFocused(true)}
107
- onBlur={() => setFocused(false)}
108
- onKeyDown={e => handleClick(e, onChange)}
109
- hiddenStyles={hidden}
110
- background={themeValues.backgroundColor}
111
- extraStyles="outline: none;"
112
- >
113
- <CheckboxLabelContainer>
114
- <CheckboxContainer data-qa="Checkbox">
115
- <HiddenCheckbox
116
- id={`checkbox-${name}`}
117
- disabled={disabled}
118
- name={name}
119
- aria-label={name}
120
- checked={checked}
121
- onChange={onChange}
122
- tabIndex="-1"
123
- />
124
- <StyledCheckbox
125
- error={error}
94
+ }) => (
95
+ <Box
96
+ padding="0"
97
+ hiddenStyles={hidden}
98
+ background={themeValues.backgroundColor}
99
+ >
100
+ <CheckboxLabelContainer>
101
+ <CheckboxContainer data-qa="Checkbox">
102
+ <HiddenCheckbox
103
+ id={`checkbox-${name}`}
104
+ disabled={disabled}
105
+ name={name}
106
+ aria-label={name}
107
+ checked={checked}
108
+ onChange={onChange}
109
+ tabIndex="-1"
110
+ />
111
+ <StyledCheckbox
112
+ error={error}
113
+ disabled={disabled}
114
+ checked={checked}
115
+ focused={focused}
116
+ defaultStyles={themeValues.defaultStyles}
117
+ checkedStyles={themeValues.checkedStyles}
118
+ errorStyles={themeValues.errorStyles}
119
+ disabledStyles={themeValues.disabledStyles}
120
+ focusedStyles={themeValues.focusedStyles}
121
+ >
122
+ <CheckboxIcon
123
+ viewBox="0 0 24 24"
126
124
  disabled={disabled}
127
- checked={checked}
128
- focused={focused}
129
- defaultStyles={themeValues.defaultStyles}
130
- checkedStyles={themeValues.checkedStyles}
131
- errorStyles={themeValues.errorStyles}
132
- disabledStyles={themeValues.disabledStyles}
133
- focusedStyles={themeValues.focusedStyles}
125
+ disabledCheckColor={themeValues.disabledCheckColor}
126
+ checkColor={themeValues.checkColor}
134
127
  >
135
- <CheckboxIcon
136
- viewBox="0 0 24 24"
137
- disabled={disabled}
138
- disabledCheckColor={themeValues.disabledCheckColor}
139
- checkColor={themeValues.checkColor}
140
- >
141
- <polyline points="20 6 9 17 4 12" />
142
- </CheckboxIcon>
143
- </StyledCheckbox>
144
- </CheckboxContainer>
145
- <Text
146
- variant="p"
147
- weight={themeValues.textFontWeight}
148
- color={themeValues.textColor}
149
- extraStyles={`margin-left: 1rem`}
150
- >
151
- {title}
152
- </Text>
153
- </CheckboxLabelContainer>
154
- </Box>
155
- );
156
- };
128
+ <polyline points="20 6 9 17 4 12" />
129
+ </CheckboxIcon>
130
+ </StyledCheckbox>
131
+ </CheckboxContainer>
132
+ <Text
133
+ variant="p"
134
+ weight={themeValues.textFontWeight}
135
+ color={themeValues.textColor}
136
+ extraStyles={`margin-left: 1rem`}
137
+ >
138
+ {title}
139
+ </Text>
140
+ </CheckboxLabelContainer>
141
+ </Box>
142
+ );
157
143
 
158
144
  export default themeComponent(Checkbox, "Checkbox", fallbackValues, "default");
@@ -201,6 +201,7 @@ const Dropdown = ({
201
201
  <Box
202
202
  onKeyDown={onKeyDown}
203
203
  onClick={onClick}
204
+ tabIndex={0}
204
205
  padding="0"
205
206
  width="100%"
206
207
  hoverStyles={`background-color: ${themeValues.hoverColor};`}
@@ -221,8 +222,7 @@ const Dropdown = ({
221
222
  : GREY_CHATEAU
222
223
  }
223
224
  borderRadius="2px"
224
- tabIndex={0}
225
- extraStyles={`height: 48px;`}
225
+ extraStyles={`tabindex: 0; height: 48px;`}
226
226
  dataQa={placeholder}
227
227
  >
228
228
  <Stack direction="row" bottomItem={2}>
@@ -13,7 +13,6 @@ const Text = ({
13
13
  extraStyles = ``,
14
14
  hoverStyles,
15
15
  onClick,
16
- onKeyPress,
17
16
  as,
18
17
  dataQa,
19
18
  children,
@@ -28,7 +27,6 @@ const Text = ({
28
27
  extraStyles={extraStyles}
29
28
  hoverStyles={hoverStyles}
30
29
  onClick={onClick}
31
- onKeyPress={onKeyPress}
32
30
  data-qa={dataQa}
33
31
  {...rest}
34
32
  >
@@ -16,9 +16,24 @@ const AccountAndRoutingModal = ({
16
16
  acceptText,
17
17
  content,
18
18
  imageType,
19
+ variant,
19
20
  themeValues
20
21
  }) => (
21
22
  <Modal
23
+ ModalLink={() => (
24
+ <Text
25
+ variant={variant === "default" ? "pS" : "pXS"}
26
+ onClick={() => toggleOpen(true)}
27
+ color={themeValues.linkColor}
28
+ weight={themeValues.fontWeight}
29
+ hoverStyles={themeValues.modalLinkHoverFocus}
30
+ extraStyles={`cursor: pointer;`}
31
+ tabIndex="0"
32
+ onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
33
+ >
34
+ {link}
35
+ </Text>
36
+ )}
22
37
  modalOpen={isOpen}
23
38
  hideModal={() => toggleOpen(false)}
24
39
  showModal={() => toggleOpen(true)}
@@ -48,20 +63,7 @@ const AccountAndRoutingModal = ({
48
63
  toggleAccepted(true);
49
64
  toggleOpen(false);
50
65
  }}
51
- >
52
- <Text
53
- variant="pS"
54
- onClick={() => toggleOpen(true)}
55
- onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
56
- tabIndex="0"
57
- color={themeValues.linkColor}
58
- weight={themeValues.fontWeight}
59
- hoverStyles={themeValues.modalLinkHoverFocus}
60
- extraStyles={`cursor: pointer;`}
61
- >
62
- {link}
63
- </Text>
64
- </Modal>
66
+ />
65
67
  );
66
68
 
67
69
  export default themeComponent(
@@ -1,13 +1,18 @@
1
- import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
1
+ import {
2
+ FONT_WEIGHT_REGULAR,
3
+ FONT_WEIGHT_SEMIBOLD
4
+ } from "../../../constants/style_constants";
2
5
 
3
- const linkColor = { default: "#357fb8" };
4
- const fontSize = { default: "1rem" };
5
- const lineHeight = { default: "1.5rem" };
6
+ const linkColor = { default: "#357fb8", footer: "#ffffff" };
7
+ const fontSize = { default: "1rem", footer: "0.875rem" };
8
+ const lineHeight = { default: "1.5rem", footer: "1.25rem" };
6
9
  const fontWeight = {
7
- default: FONT_WEIGHT_REGULAR
10
+ default: FONT_WEIGHT_REGULAR,
11
+ footer: FONT_WEIGHT_SEMIBOLD
8
12
  };
9
13
  const modalLinkHoverFocus = {
10
- default: `outline: none; text-decoration: underline;`
14
+ default: ``,
15
+ footer: `outline: none; text-decoration: underline;`
11
16
  };
12
17
 
13
18
  export const fallbackValues = {
@@ -1,5 +1,6 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { required, hasLength } from "redux-freeform";
3
+ import styled from "styled-components";
3
4
  import StateProvinceDropdown from "../../atoms/state-province-dropdown";
4
5
  import Checkbox from "../../atoms/checkbox";
5
6
  import CountryDropdown from "../../atoms/country-dropdown";
@@ -11,6 +12,10 @@ import {
11
12
  FormInputColumn
12
13
  } from "../../atoms/form-layouts";
13
14
 
15
+ const CheckboxWrapper = styled.div`
16
+ outline: none;
17
+ `;
18
+
14
19
  const AddressForm = ({
15
20
  variant = "default",
16
21
  fields,
@@ -22,6 +27,13 @@ const AddressForm = ({
22
27
  saveToWallet,
23
28
  walletCheckboxMarked
24
29
  }) => {
30
+ const [checkboxFocused, focusCheckbox] = useState(false);
31
+
32
+ const handleClick = (e, func) => {
33
+ if (e?.keyCode === 13) {
34
+ func();
35
+ }
36
+ };
25
37
  if (clearOnDismount) {
26
38
  useEffect(() => () => actions.form.clear(), []);
27
39
  }
@@ -108,12 +120,20 @@ const AddressForm = ({
108
120
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
109
121
  />
110
122
  {showWalletCheckbox && (
111
- <Checkbox
112
- name="address checkbox"
113
- title="Save address to wallet"
114
- checked={walletCheckboxMarked}
115
- onChange={saveToWallet}
116
- />
123
+ <CheckboxWrapper
124
+ tabIndex="0"
125
+ onFocus={() => focusCheckbox(true)}
126
+ onBlur={() => focusCheckbox(false)}
127
+ onKeyDown={e => handleClick(e, saveToWallet)}
128
+ >
129
+ <Checkbox
130
+ name="address checkbox"
131
+ title="Save address to wallet"
132
+ checked={walletCheckboxMarked}
133
+ onChange={saveToWallet}
134
+ focused={checkboxFocused}
135
+ />
136
+ </CheckboxWrapper>
117
137
  )}
118
138
  </FormInputColumn>
119
139
  </FormContainer>
@@ -1,4 +1,5 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useState } from "react";
2
+ import styled from "styled-components";
2
3
  import { required, isProbablyEmail } from "redux-freeform";
3
4
  import {
4
5
  FormInput,
@@ -9,6 +10,10 @@ import Checkbox from "../../atoms/checkbox";
9
10
  import Paragraph from "../../atoms/paragraph";
10
11
  import { noop } from "../../../util/general";
11
12
 
13
+ const CheckboxWrapper = styled.div`
14
+ outline: none;
15
+ `;
16
+
12
17
  const EmailForm = ({
13
18
  variant = "default",
14
19
  clearOnDismount,
@@ -21,6 +26,13 @@ const EmailForm = ({
21
26
  saveToWallet,
22
27
  walletCheckboxMarked
23
28
  }) => {
29
+ const [checkboxFocused, focusCheckbox] = useState(false);
30
+ const handleClick = (e, func) => {
31
+ if (e?.keyCode === 13) {
32
+ func();
33
+ }
34
+ };
35
+
24
36
  if (clearOnDismount) {
25
37
  useEffect(() => () => actions.form.clear(), []);
26
38
  }
@@ -47,12 +59,20 @@ const EmailForm = ({
47
59
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
48
60
  />
49
61
  {showWalletCheckbox && (
50
- <Checkbox
51
- name="email checkbox"
52
- title="Save email address to wallet"
53
- checked={walletCheckboxMarked}
54
- onChange={saveToWallet}
55
- />
62
+ <CheckboxWrapper
63
+ tabIndex="0"
64
+ onFocus={() => focusCheckbox(true)}
65
+ onBlur={() => focusCheckbox(false)}
66
+ onKeyDown={e => handleClick(e, saveToWallet)}
67
+ >
68
+ <Checkbox
69
+ name="email checkbox"
70
+ title="Save email address to wallet"
71
+ checked={walletCheckboxMarked}
72
+ onChange={saveToWallet}
73
+ focused={checkboxFocused}
74
+ />
75
+ </CheckboxWrapper>
56
76
  )}
57
77
  </FormInputColumn>
58
78
  </FormContainer>
@@ -20,8 +20,5 @@ const ConnectedForm = connect(
20
20
  EmailFormState.mapDispatchToProps
21
21
  )(EmailForm);
22
22
  export const emailForm = () => (
23
- <ConnectedForm
24
- showErrors={boolean("showErrors", false, "props")}
25
- showWalletCheckbox={boolean("showWalletCheckbox", false, "props")}
26
- />
23
+ <ConnectedForm showErrors={boolean("showErrors", false, "props")} />
27
24
  );
@@ -21,6 +21,7 @@ a different route (as with a link) connect() and use "push" from connected-react
21
21
  const getApplicationNode = () => document.getElementById("root");
22
22
 
23
23
  const Modal = ({
24
+ ModalLink,
24
25
  hideModal,
25
26
  continueAction,
26
27
  cancelAction,
@@ -35,12 +36,12 @@ const Modal = ({
35
36
  defaultWrapper = true,
36
37
  onlyCloseButton = false,
37
38
  maxHeight,
38
- underlayClickExits = true,
39
- children
39
+ underlayClickExits = true
40
40
  }) => {
41
41
  const { isMobile } = useContext(ThemeContext);
42
42
  return (
43
43
  <Fragment>
44
+ <ModalLink />
44
45
  {modalOpen && (
45
46
  <AriaModal
46
47
  onExit={hideModal}
@@ -133,7 +134,6 @@ const Modal = ({
133
134
  </Box>
134
135
  </AriaModal>
135
136
  )}
136
- {children}
137
137
  </Fragment>
138
138
  );
139
139
  };
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import Modal from "../../modal";
3
3
  import ButtonWithAction from "../../../atoms/button-with-action";
4
- import Text from "../../../atoms/text";
5
4
  import { AutopayOnIcon } from "../../../atoms/icons";
6
5
  import { Box, Cluster } from "../../../atoms/layouts";
7
6
  import { fallbackValues } from "./AutopayModalModule.theme";
@@ -62,56 +61,48 @@ const AutopayModal = ({
62
61
  `;
63
62
  return (
64
63
  <Modal
64
+ ModalLink={() =>
65
+ buttonLinkType ? (
66
+ <ButtonWithAction
67
+ text={autoPayActive ? `Manage ${planType}` : `Set Up ${planType}`}
68
+ variant="tertiary"
69
+ action={() => {
70
+ toggleModal(true);
71
+ }}
72
+ dataQa="Manage Autopay"
73
+ extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
74
+ />
75
+ ) : (
76
+ <Box
77
+ padding="0"
78
+ onClick={() => {
79
+ toggleModal(true);
80
+ }}
81
+ hoverStyles={hoverStyles}
82
+ activeStyles={activeStyles}
83
+ extraStyles={defaultStyles}
84
+ >
85
+ <Cluster
86
+ justify={isMobile ? "flex-start" : "flex-end"}
87
+ align="center"
88
+ >
89
+ <AutopayOnIcon />
90
+ <ButtonWithAction
91
+ text={`${planType} On`}
92
+ variant="smallGhost"
93
+ dataQa="Autopay On"
94
+ textExtraStyles={`font-size: 0.875rem; `}
95
+ extraStyles={`min-width: auto; padding: 0 0 0 6px;`}
96
+ />
97
+ </Cluster>
98
+ </Box>
99
+ )
100
+ }
65
101
  showModal={() => toggleModal(true)}
66
102
  hideModal={() => toggleModal(false)}
67
103
  modalOpen={modalOpen}
68
104
  {...modalExtraProps}
69
- >
70
- {buttonLinkType ? (
71
- <ButtonWithAction
72
- text={autoPayActive ? `Manage ${planType}` : `Set Up ${planType}`}
73
- variant="tertiary"
74
- action={() => {
75
- toggleModal(true);
76
- }}
77
- dataQa="Manage Autopay"
78
- extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
79
- />
80
- ) : (
81
- <Box
82
- padding="0"
83
- onClick={() => {
84
- toggleModal(true);
85
- }}
86
- hoverStyles={hoverStyles}
87
- activeStyles={activeStyles}
88
- extraStyles={defaultStyles}
89
- >
90
- <Cluster
91
- justify={isMobile ? "flex-start" : "flex-end"}
92
- align="center"
93
- >
94
- <AutopayOnIcon />
95
- <Text
96
- variant="pS"
97
- onClick={() => toggleModal(true)}
98
- onKeyPress={e => {
99
- console.log({ e });
100
- e.key === "Enter" && toggleModal(true);
101
- }}
102
- tabIndex="0"
103
- dataQa={`${planType} On`}
104
- color={themeValues.linkColor}
105
- weight={themeValues.fontWeight}
106
- hoverStyles={themeValues.modalLinkHoverFocus}
107
- extraStyles={`padding: 0 0 0 6px;`}
108
- >
109
- {`${planType} On`}
110
- </Text>
111
- </Cluster>
112
- </Box>
113
- )}
114
- </Modal>
105
+ />
115
106
  );
116
107
  };
117
108
 
@@ -1,20 +1,9 @@
1
- import { FONT_WEIGHT_REGULAR } from "../../../../constants/style_constants";
2
-
3
1
  const color = "#15749D";
4
2
  const hoverColor = "#116285";
5
3
  const activeColor = "#0E506D";
6
- const linkColor = "#357fb8";
7
- const fontWeight = FONT_WEIGHT_REGULAR;
8
- const modalLinkHoverFocus = `outline: none;
9
- cursor: pointer;
10
- text-decoration: underline;
11
- text-decoration-color: #357fb8;`;
12
4
 
13
5
  export const fallbackValues = {
14
6
  color,
15
7
  hoverColor,
16
- activeColor,
17
- linkColor,
18
- fontWeight,
19
- modalLinkHoverFocus
8
+ activeColor
20
9
  };
@@ -1,4 +1,5 @@
1
1
  import React, { useEffect, useState } from "react";
2
+ import styled from "styled-components";
2
3
  import Checkbox from "../../atoms/checkbox";
3
4
  import {
4
5
  required,
@@ -15,6 +16,12 @@ import {
15
16
  import AccountAndRoutingModal from "../account-and-routing-modal";
16
17
  import { noop } from "../../../util/general";
17
18
 
19
+ const ModalWrapper = styled.div``;
20
+
21
+ const CheckboxWrapper = styled.div`
22
+ outline: none;
23
+ `;
24
+
18
25
  const PaymentFormACH = ({
19
26
  variant = "default",
20
27
  defaultMethod,
@@ -30,6 +37,12 @@ const PaymentFormACH = ({
30
37
  saveToWallet,
31
38
  walletCheckboxMarked
32
39
  }) => {
40
+ const [checkboxFocused, focusCheckbox] = useState(false);
41
+ const handleClick = (e, func) => {
42
+ if (e?.keyCode === 13) {
43
+ func();
44
+ }
45
+ };
33
46
  if (clearOnDismount) {
34
47
  useEffect(() => () => actions.form.clear(), []);
35
48
  }
@@ -78,15 +91,22 @@ const PaymentFormACH = ({
78
91
  fieldActions={actions.fields.routingNumber}
79
92
  showErrors={showErrors}
80
93
  helperModal={() => (
81
- <AccountAndRoutingModal
82
- link="What is this?"
83
- title="Where is my routing number?"
84
- content="Your routing number is the 9-digit number in the bottom left
94
+ <ModalWrapper
95
+ tabIndex="0"
96
+ onKeyDown={e =>
97
+ e.key === "Enter" && toggleShowAccount(!showRouting)
98
+ }
99
+ >
100
+ <AccountAndRoutingModal
101
+ link="What is this?"
102
+ title="Where is my routing number?"
103
+ content="Your routing number is the 9-digit number in the bottom left
85
104
  corner of your check."
86
- imageType="Routing"
87
- isOpen={showRouting}
88
- toggleOpen={toggleShowRouting}
89
- />
105
+ imageType="Routing"
106
+ isOpen={showRouting}
107
+ toggleOpen={toggleShowRouting}
108
+ />
109
+ </ModalWrapper>
90
110
  )}
91
111
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
92
112
  />
@@ -105,15 +125,22 @@ const PaymentFormACH = ({
105
125
  fieldActions={actions.fields.accountNumber}
106
126
  showErrors={showErrors}
107
127
  helperModal={() => (
108
- <AccountAndRoutingModal
109
- link="What is this?"
110
- title="Where is my account number?"
111
- content="Your account number is usually the 10-digit number in the bottom
128
+ <ModalWrapper
129
+ tabIndex="0"
130
+ onKeyDown={e =>
131
+ e.key === "Enter" && toggleShowAccount(!showAccount)
132
+ }
133
+ >
134
+ <AccountAndRoutingModal
135
+ link="What is this?"
136
+ title="Where is my account number?"
137
+ content="Your account number is usually the 10-digit number in the bottom
112
138
  of your check to the right of the routing number."
113
- imageType="Account"
114
- isOpen={showAccount}
115
- toggleOpen={toggleShowAccount}
116
- />
139
+ imageType="Account"
140
+ isOpen={showAccount}
141
+ toggleOpen={toggleShowAccount}
142
+ />
143
+ </ModalWrapper>
117
144
  )}
118
145
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
119
146
  />
@@ -149,12 +176,20 @@ const PaymentFormACH = ({
149
176
  />
150
177
  )}
151
178
  {showWalletCheckbox && (
152
- <Checkbox
153
- name="bank checkbox"
154
- title="Save bank account to wallet"
155
- checked={walletCheckboxMarked}
156
- onChange={saveToWallet}
157
- />
179
+ <CheckboxWrapper
180
+ tabIndex="0"
181
+ onFocus={() => focusCheckbox(true)}
182
+ onBlur={() => focusCheckbox(false)}
183
+ onKeyDown={e => handleClick(e, saveToWallet)}
184
+ >
185
+ <Checkbox
186
+ name="bank checkbox"
187
+ title="Save bank account to wallet"
188
+ checked={walletCheckboxMarked}
189
+ onChange={saveToWallet}
190
+ focused={checkboxFocused}
191
+ />
192
+ </CheckboxWrapper>
158
193
  )}
159
194
  </FormInputColumn>
160
195
  </FormContainer>