@thecb/components 7.8.3 → 7.9.0-beta.1

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": "7.8.3",
3
+ "version": "7.9.0-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -4,7 +4,13 @@ import Paragraph from "../paragraph";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
5
  import { fallbackValues } from "./LineItem.theme";
6
6
 
7
- const LineItem = ({ description, subDescription, amount, themeValues }) => (
7
+ const LineItem = ({
8
+ description,
9
+ subDescription,
10
+ amount,
11
+ themeValues,
12
+ quantity = null
13
+ }) => (
8
14
  <Cluster nowrap justify="space-between" align="start">
9
15
  <Stack childGap="0px">
10
16
  <Paragraph
@@ -17,6 +23,14 @@ const LineItem = ({ description, subDescription, amount, themeValues }) => (
17
23
  {subDescription}
18
24
  </Paragraph>
19
25
  </Stack>
26
+ {!!quantity && (
27
+ <Paragraph
28
+ variant={themeValues.paragraphVariant}
29
+ weight={themeValues.weightTitle}
30
+ >
31
+ {`x${quantity}`}
32
+ </Paragraph>
33
+ )}
20
34
  <Paragraph
21
35
  variant={themeValues.paragraphVariant}
22
36
  weight="600"
@@ -17,3 +17,12 @@ export const lineItem = () => (
17
17
  amount={text("amount", "$4.00", "props")}
18
18
  />
19
19
  );
20
+
21
+ export const lineItemWithQuantity = () => (
22
+ <LineItem
23
+ description={text("description", "Foo", "props")}
24
+ subDescription={text("subDescription", "Bar", "props")}
25
+ amount={text("amount", "$4.00", "props")}
26
+ quantity={2}
27
+ />
28
+ );
@@ -14,6 +14,9 @@ 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";
18
+ import TermsAndConditionsModal from "../terms-and-conditions-modal/TermsAndConditionsModal";
19
+ import Text from "../../atoms/text";
17
20
 
18
21
  const PaymentFormACH = ({
19
22
  variant = "default",
@@ -28,13 +31,18 @@ const PaymentFormACH = ({
28
31
  handleSubmit = noop,
29
32
  showWalletCheckbox,
30
33
  saveToWallet,
31
- walletCheckboxMarked
34
+ walletCheckboxMarked,
35
+ termsContent,
36
+ termsTitle = "Terms &amp; Conditions"
32
37
  }) => {
33
38
  if (clearOnDismount) {
34
39
  useEffect(() => () => actions.form.clear(), []);
35
40
  }
36
41
  const [showRouting, toggleShowRouting] = useState(false);
37
42
  const [showAccount, toggleShowAccount] = useState(false);
43
+ const [termsModalOpen, setTermsModalOpen] = useState(false);
44
+ const showTerms = !!termsContent;
45
+ const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
38
46
 
39
47
  const nameErrors = {
40
48
  [required.error]: "Name is required"
@@ -153,13 +161,32 @@ const PaymentFormACH = ({
153
161
  hidden={hideDefaultPayment}
154
162
  />
155
163
  )}
156
- {showWalletCheckbox && (
157
- <Checkbox
158
- name="bank checkbox"
159
- title="Save checking account to wallet"
160
- checked={walletCheckboxMarked}
161
- onChange={saveToWallet}
162
- />
164
+ {(showWalletCheckbox || showTerms) && (
165
+ <Cluster childGap={"4px"}>
166
+ {showWalletCheckbox && (
167
+ <Checkbox
168
+ name="bank checkbox"
169
+ title="Save checking account to wallet."
170
+ checked={walletCheckboxMarked}
171
+ onChange={saveToWallet}
172
+ />
173
+ )}
174
+ {showTerms && (
175
+ <Cover singleChild>
176
+ <Cluster childGap={0}>
177
+ <Text variant={showTermsLinkVariant}>View&nbsp;</Text>
178
+ <TermsAndConditionsModal
179
+ link={termsTitle}
180
+ linkVariant={showTermsLinkVariant}
181
+ terms={termsContent}
182
+ title={termsTitle}
183
+ isOpen={termsModalOpen}
184
+ toggleOpen={setTermsModalOpen}
185
+ />
186
+ </Cluster>
187
+ </Cover>
188
+ )}
189
+ </Cluster>
163
190
  )}
164
191
  </FormInputColumn>
165
192
  </FormContainer>
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useContext } from "react";
1
+ import React, { useEffect, useContext, useState } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import {
4
4
  required,
@@ -26,8 +26,10 @@ import {
26
26
  FormContainer,
27
27
  FormInputRow
28
28
  } from "../../atoms/form-layouts";
29
- import { Box } from "../../atoms/layouts";
29
+ import { Box, Cluster, Cover } from "../../atoms/layouts";
30
30
  import withWindowSize from "../../withWindowSize";
31
+ import TermsAndConditionsModal from "../terms-and-conditions-modal/TermsAndConditionsModal";
32
+ import Text from "../../atoms/text";
31
33
 
32
34
  const PaymentFormCard = ({
33
35
  variant = "default",
@@ -40,9 +42,15 @@ const PaymentFormCard = ({
40
42
  showWalletCheckbox,
41
43
  saveToWallet,
42
44
  walletCheckboxMarked,
43
- deniedCards
45
+ deniedCards,
46
+ termsContent,
47
+ termsTitle = "Terms &amp; Conditions"
44
48
  }) => {
45
49
  const { isMobile } = useContext(ThemeContext);
50
+ const [termsModalOpen, setTermsModalOpen] = useState(false);
51
+ const showTerms = !!termsContent;
52
+ const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
53
+
46
54
  useEffect(() => {
47
55
  if (deniedCards) {
48
56
  deniedCards.map(card =>
@@ -177,13 +185,32 @@ const PaymentFormCard = ({
177
185
  />
178
186
  </Box>
179
187
  )}
180
- {showWalletCheckbox && (
181
- <Checkbox
182
- name="credit card checkbox"
183
- title="Save credit card to wallet"
184
- checked={walletCheckboxMarked}
185
- onChange={saveToWallet}
186
- />
188
+ {(showWalletCheckbox || showTerms) && (
189
+ <Cluster childGap={"4px"}>
190
+ {showWalletCheckbox && (
191
+ <Checkbox
192
+ name="credit card checkbox"
193
+ title="Save credit card to wallet."
194
+ checked={walletCheckboxMarked}
195
+ onChange={saveToWallet}
196
+ />
197
+ )}
198
+ {showTerms && (
199
+ <Cover singleChild>
200
+ <Cluster childGap={0}>
201
+ <Text variant={showTermsLinkVariant}>View&nbsp;</Text>
202
+ <TermsAndConditionsModal
203
+ link={termsTitle}
204
+ linkVariant={showTermsLinkVariant}
205
+ terms={termsContent}
206
+ title={termsTitle}
207
+ isOpen={termsModalOpen}
208
+ toggleOpen={setTermsModalOpen}
209
+ />
210
+ </Cluster>
211
+ </Cover>
212
+ )}
213
+ </Cluster>
187
214
  )}
188
215
  </FormInputColumn>
189
216
  </FormContainer>
@@ -9,7 +9,8 @@ const TermsAndConditions = ({
9
9
  isChecked,
10
10
  html,
11
11
  terms,
12
- error = false
12
+ error = false,
13
+ linkVariant
13
14
  }) => {
14
15
  const [showTerms, toggleShowTerms] = useState(false);
15
16
  return (
@@ -31,6 +32,7 @@ const TermsAndConditions = ({
31
32
  terms={terms}
32
33
  isOpen={showTerms}
33
34
  toggleOpen={toggleShowTerms}
35
+ linkVariant={linkVariant}
34
36
  />
35
37
  )}
36
38
  </Stack>
@@ -14,6 +14,7 @@ const TermsAndConditionsModal = ({
14
14
  acceptText,
15
15
  terms,
16
16
  variant,
17
+ linkVariant = "p",
17
18
  themeValues
18
19
  }) => (
19
20
  <Modal
@@ -42,14 +43,14 @@ const TermsAndConditionsModal = ({
42
43
  }}
43
44
  >
44
45
  <Text
45
- variant={variant === "default" ? "pS" : "pXS"}
46
+ variant={linkVariant}
46
47
  onClick={() => toggleOpen(true)}
47
48
  onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
48
49
  tabIndex="0"
49
50
  color={themeValues.linkColor}
50
51
  weight={themeValues.fontWeight}
51
52
  hoverStyles={themeValues.modalLinkHoverFocus}
52
- extraStyles={`display: inline-block; width: fit-content;`}
53
+ extraStyles={`display: inline-block; width: fit-content; cursor: pointer`}
53
54
  >
54
55
  {link}
55
56
  </Text>
@@ -11,6 +11,15 @@ const variants = {
11
11
  };
12
12
  const groupId = "props";
13
13
 
14
+ const linkVariants = {
15
+ p: "p",
16
+ pL: "pL",
17
+ pS: "pS",
18
+ pXS: "pXS",
19
+ pXXS: "pXXS",
20
+ pXL: "PXL"
21
+ };
22
+
14
23
  export const termsAndConditionsModal = () => (
15
24
  <TermsAndConditionsModal
16
25
  link={text("text", "Show modal", groupId)}
@@ -21,6 +30,7 @@ export const termsAndConditionsModal = () => (
21
30
  acceptText={text("acceptText", "Accept", groupId)}
22
31
  terms={text("terms", "terms and conditions", groupId)}
23
32
  variant={select("variants", variants, "default", groupId)}
33
+ linkVariant={select("linkVariants", linkVariants, groupId)}
24
34
  />
25
35
  );
26
36