@thecb/components 12.1.0-beta.2 → 12.1.0-beta.4

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": "12.1.0-beta.2",
3
+ "version": "12.1.0-beta.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -9,7 +9,9 @@
9
9
  "scripts": {
10
10
  "storybook": "storybook dev -p 6006",
11
11
  "build": "rollup -cm",
12
- "build-storybook": "storybook build"
12
+ "build-storybook": "storybook build",
13
+ "sync": "./scripts/sync-to-project.sh",
14
+ "publish-beta": "./scripts/publish-beta.sh"
13
15
  },
14
16
  "repository": {
15
17
  "type": "git",
@@ -14,8 +14,10 @@ import {
14
14
  } from "../../atoms/form-layouts";
15
15
  import AccountAndRoutingModal from "../account-and-routing-modal";
16
16
  import { noop } from "../../../util/general";
17
- import { Cluster, Cover } from "../../atoms/layouts";
17
+ import { Cluster } from "../../atoms/layouts";
18
18
  import TermsAndConditions from "../terms-and-conditions";
19
+ import TermsAndConditionsModal from "../terms-and-conditions-modal";
20
+ import { useScrollTo } from "../../../hooks";
19
21
 
20
22
  const PaymentFormACH = ({
21
23
  variant = "default",
@@ -38,8 +40,16 @@ const PaymentFormACH = ({
38
40
  }
39
41
  const [showRouting, toggleShowRouting] = useState(false);
40
42
  const [showAccount, toggleShowAccount] = useState(false);
43
+ const [showTermsModal, setShowTermsModal] = useState(false);
41
44
  const showTerms = !!termsContent;
42
45
 
46
+ const toggleTermsModal = open => {
47
+ setShowTermsModal(open);
48
+ if (open) {
49
+ useScrollTo("terms-body-text", 0, 0, "smooth", 100);
50
+ }
51
+ };
52
+
43
53
  const nameErrors = {
44
54
  [required.error]: "Name is required"
45
55
  };
@@ -172,30 +182,39 @@ const PaymentFormACH = ({
172
182
  hidden={hideDefaultPayment}
173
183
  />
174
184
  )}
175
- {(showWalletCheckbox || showTerms) && (
176
- <Cluster childGap={"4px"} align="center" overflow>
177
- {showWalletCheckbox && (
178
- <Checkbox
179
- name="bank checkbox"
180
- dataQa="Save checking account to wallet"
181
- title="Save checking account to wallet (optional)."
182
- checked={walletCheckboxMarked}
183
- onChange={saveToWallet}
184
- />
185
- )}
186
- {showTerms && (
187
- <Cover singleChild>
188
- <TermsAndConditions
189
- version="v2"
190
- showCheckbox={false}
191
- description="View"
192
- terms={termsContent}
193
- initialFocusSelector={".modal-close-button"}
194
- textExtraStyles="vertical-align: middle; margin-left: 40px;" /* determined w 24px checkbox width + 16px margin */
195
- />
196
- </Cover>
197
- )}
198
- </Cluster>
185
+ {showWalletCheckbox && (
186
+ <Checkbox
187
+ name="bank checkbox"
188
+ dataQa="Save checking account to wallet"
189
+ title={
190
+ <>
191
+ Save checking account to wallet (optional).{" "}
192
+ {showTerms && (
193
+ <span onClick={e => e.stopPropagation()}>
194
+ View{" "}
195
+ <TermsAndConditionsModal
196
+ link="Terms and Conditions"
197
+ terms={termsContent}
198
+ isOpen={showTermsModal}
199
+ toggleOpen={toggleTermsModal}
200
+ initialFocusSelector=".modal-close-button"
201
+ />
202
+ </span>
203
+ )}
204
+ </>
205
+ }
206
+ checked={walletCheckboxMarked}
207
+ onChange={saveToWallet}
208
+ />
209
+ )}
210
+ {!showWalletCheckbox && showTerms && (
211
+ <TermsAndConditions
212
+ version="v2"
213
+ showCheckbox={false}
214
+ description="View"
215
+ terms={termsContent}
216
+ initialFocusSelector=".modal-close-button"
217
+ />
199
218
  )}
200
219
  </FormInputColumn>
201
220
  </FormContainer>
@@ -27,9 +27,11 @@ import {
27
27
  FormContainer,
28
28
  FormInputRow
29
29
  } from "../../atoms/form-layouts";
30
- import { Box, Cluster, Cover } from "../../atoms/layouts";
30
+ import { Box, Cluster } from "../../atoms/layouts";
31
31
  import withWindowSize from "../../withWindowSize";
32
32
  import TermsAndConditions from "../terms-and-conditions";
33
+ import TermsAndConditionsModal from "../terms-and-conditions-modal";
34
+ import { useScrollTo } from "../../../hooks";
33
35
 
34
36
  const PaymentFormCard = ({
35
37
  variant = "default",
@@ -46,8 +48,16 @@ const PaymentFormCard = ({
46
48
  termsContent
47
49
  }) => {
48
50
  const { isMobile } = useContext(ThemeContext);
51
+ const [showTermsModal, setShowTermsModal] = useState(false);
49
52
  const showTerms = !!termsContent;
50
53
 
54
+ const toggleTermsModal = open => {
55
+ setShowTermsModal(open);
56
+ if (open) {
57
+ useScrollTo("terms-body-text", 0, 0, "smooth", 100);
58
+ }
59
+ };
60
+
51
61
  useEffect(() => {
52
62
  if (deniedCards) {
53
63
  deniedCards.map(card =>
@@ -196,30 +206,39 @@ const PaymentFormCard = ({
196
206
  />
197
207
  </Box>
198
208
  )}
199
- {(showWalletCheckbox || showTerms) && (
200
- <Cluster childGap={"4px"} align="center" overflow>
201
- {showWalletCheckbox && (
202
- <Checkbox
203
- name="credit card checkbox"
204
- dataQa="Save credit card to wallet"
205
- title="Save credit card to wallet (optional)."
206
- checked={walletCheckboxMarked}
207
- onChange={saveToWallet}
208
- />
209
- )}
210
- {showTerms && (
211
- <Cover singleChild>
212
- <TermsAndConditions
213
- version="v2"
214
- showCheckbox={false}
215
- description="View"
216
- terms={termsContent}
217
- initialFocusSelector={".modal-close-button"}
218
- textExtraStyles="vertical-align: middle; margin-left: 40px;" /* determined w 24px checkbox width + 16px margin */
219
- />
220
- </Cover>
221
- )}
222
- </Cluster>
209
+ {showWalletCheckbox && (
210
+ <Checkbox
211
+ name="credit card checkbox"
212
+ dataQa="Save credit card to wallet"
213
+ title={
214
+ <>
215
+ Save credit card to wallet (optional).{" "}
216
+ {showTerms && (
217
+ <span onClick={e => e.stopPropagation()}>
218
+ View{" "}
219
+ <TermsAndConditionsModal
220
+ link="Terms and Conditions"
221
+ terms={termsContent}
222
+ isOpen={showTermsModal}
223
+ toggleOpen={toggleTermsModal}
224
+ initialFocusSelector=".modal-close-button"
225
+ />
226
+ </span>
227
+ )}
228
+ </>
229
+ }
230
+ checked={walletCheckboxMarked}
231
+ onChange={saveToWallet}
232
+ />
233
+ )}
234
+ {!showWalletCheckbox && showTerms && (
235
+ <TermsAndConditions
236
+ version="v2"
237
+ showCheckbox={false}
238
+ description="View"
239
+ terms={termsContent}
240
+ initialFocusSelector=".modal-close-button"
241
+ />
223
242
  )}
224
243
  </FormInputColumn>
225
244
  </FormContainer>