@thecb/components 7.9.0-beta.1 → 7.9.0

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.9.0-beta.1",
3
+ "version": "7.9.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,6 @@ export interface ClusterProps {
13
13
  justifySelf?: string;
14
14
  alignSelf?: string;
15
15
  flexGrow?: string;
16
- innerWrapperAs?: string;
17
16
  }
18
17
 
19
18
  export const Cluster: React.FC<Expand<ClusterProps> &
@@ -24,7 +24,6 @@ const Cluster = ({
24
24
  flexGrow,
25
25
  extraStyles,
26
26
  children,
27
- innerWrapperAs = "div",
28
27
  ...rest
29
28
  }) => (
30
29
  <ClusterWrapper
@@ -42,7 +41,6 @@ const Cluster = ({
42
41
  minHeight={minHeight}
43
42
  minWidth={minWidth}
44
43
  $nowrap={nowrap}
45
- as={innerWrapperAs}
46
44
  >
47
45
  {safeChildren(children, <Fragment />)}
48
46
  </ClusterInnerWrapper>
@@ -9,7 +9,7 @@ const LineItem = ({
9
9
  subDescription,
10
10
  amount,
11
11
  themeValues,
12
- quantity = null
12
+ displayQuantity = null
13
13
  }) => (
14
14
  <Cluster nowrap justify="space-between" align="start">
15
15
  <Stack childGap="0px">
@@ -23,12 +23,12 @@ const LineItem = ({
23
23
  {subDescription}
24
24
  </Paragraph>
25
25
  </Stack>
26
- {!!quantity && (
26
+ {!!displayQuantity && (
27
27
  <Paragraph
28
28
  variant={themeValues.paragraphVariant}
29
29
  weight={themeValues.weightTitle}
30
30
  >
31
- {`x${quantity}`}
31
+ {`x${displayQuantity}`}
32
32
  </Paragraph>
33
33
  )}
34
34
  <Paragraph
@@ -23,6 +23,6 @@ export const lineItemWithQuantity = () => (
23
23
  description={text("description", "Foo", "props")}
24
24
  subDescription={text("subDescription", "Bar", "props")}
25
25
  amount={text("amount", "$4.00", "props")}
26
- quantity={2}
26
+ displayQuantity={2}
27
27
  />
28
28
  );
@@ -23,7 +23,6 @@ const PrevNextPlaceholder = ({ buttonHeight, buttonWidth }) => (
23
23
 
24
24
  const PrevNextButton = ({
25
25
  action,
26
- ariaLabel,
27
26
  arrowColor,
28
27
  borderRadius,
29
28
  buttonHeight,
@@ -35,13 +34,11 @@ const PrevNextButton = ({
35
34
  padding="0"
36
35
  minHeight={buttonHeight}
37
36
  extraStyles={`max-height: ${buttonHeight};`}
38
- as="li"
39
37
  >
40
38
  <ButtonWithAction
41
39
  action={action}
42
40
  contentOverride
43
41
  dataQa={type}
44
- aria-label={ariaLabel}
45
42
  extraStyles={`
46
43
  background-color: ${numberColor};
47
44
  border-color: ${numberColor};
@@ -51,6 +48,9 @@ const PrevNextButton = ({
51
48
  min-height: 100%;
52
49
  min-width: ${buttonWidth};
53
50
  padding: 0;
51
+ &:focus {
52
+ outline: none
53
+ }
54
54
  `}
55
55
  >
56
56
  <Box padding="0" extraStyles={type === "prev" && "transform: scaleX(-1)"}>
@@ -68,23 +68,19 @@ export const getPagesPanel = (page, pagesCount) => {
68
68
  const space = page === 1 ? PAGING_INIT_SPACE : PAGING_SPACE;
69
69
  const pages = [{ index: 1, isButton: true }];
70
70
  if (page > space + 1) {
71
- pages.push({ isDelimiter: true, id: "first-delimiter" });
71
+ pages.push({ isDelimiter: true });
72
72
  }
73
73
  for (
74
74
  let j = Math.max(1, page - space) + 1;
75
75
  j < Math.min(lastPageNumber, page + space);
76
76
  j++
77
77
  ) {
78
- pages.push({ index: j, isButton: true, id: `page-${j}` });
78
+ pages.push({ index: j, isButton: true });
79
79
  }
80
80
  if (page < lastPageNumber - space) {
81
- pages.push({ isDelimiter: true, id: "last-delimiter" });
81
+ pages.push({ isDelimiter: true });
82
82
  }
83
- pages.push({
84
- index: lastPageNumber,
85
- isButton: true,
86
- id: `page-${lastPageNumber}`
87
- });
83
+ pages.push({ index: lastPageNumber, isButton: true });
88
84
  const activePage = pages.find(p => p.index === page);
89
85
  if (activePage) {
90
86
  activePage.active = true;
@@ -107,7 +103,6 @@ const Pagination = ({
107
103
  pageNext,
108
104
  pagePrevious,
109
105
  setCurrentPage,
110
- ariaLabel,
111
106
  themeValues
112
107
  }) => {
113
108
  const { isMobile } = useContext(ThemeContext);
@@ -128,9 +123,12 @@ const Pagination = ({
128
123
  &:hover {
129
124
  background-color: ${themeValues.hoverBackgroundColor}
130
125
  }
126
+ &:focus {
127
+ outline: none
128
+ }
131
129
  `;
132
130
 
133
- const currentPageStyles = `
131
+ const extraDisabledStyles = `
134
132
  border: ${activeBorderWidth} solid ${numberColor ??
135
133
  themeValues.numberColor};
136
134
  color: ${numberColor ?? themeValues.activeColor};
@@ -140,27 +138,14 @@ const Pagination = ({
140
138
  }
141
139
  &:hover {
142
140
  background-color: initial;
143
- border: ${activeBorderWidth} solid ${numberColor ??
144
- themeValues.numberColor};
145
- background-color: ${themeValues.activeBackgroundColor};
146
141
  }
147
142
  `;
148
143
 
149
144
  return (
150
- <Cluster
151
- justify="center"
152
- childGap={childGap}
153
- overflow={true}
154
- as="nav"
155
- role="navigation"
156
- innerWrapperAs="ul"
157
- aria-label={ariaLabel}
158
- extraStyles="> ul { padding: 0px; > li { list-style-type: none; } };"
159
- >
145
+ <Cluster justify="center" childGap={childGap}>
160
146
  {currentPage > 1 ? (
161
147
  <PrevNextButton
162
148
  action={pagePrevious}
163
- ariaLabel={`Previous Page`}
164
149
  arrowColor={arrowColor ?? themeValues.arrowColor}
165
150
  borderRadius={borderRadius}
166
151
  buttonHeight={buttonHeight}
@@ -193,43 +178,35 @@ const Pagination = ({
193
178
  )
194
179
  : getPagesPanel(currentPage, pageCount).map((item, index) =>
195
180
  item.isButton ? (
196
- <Box
197
- padding="0"
198
- extraStyles={`max-height: ${buttonHeight};`}
199
- as="li"
200
- key={item.id}
201
- >
181
+ <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
202
182
  <ButtonWithAction
203
183
  variant="ghost"
184
+ key={item.index}
204
185
  text={item.index}
205
- aria-current={item.active ? "page" : undefined}
206
- aria-label={`${
207
- item.index == pageCount ? "Last Page, " : ""
208
- }page ${item.index}`}
186
+ disabled={item.active}
187
+ extraDisabledStyles={extraDisabledStyles}
209
188
  action={
210
189
  !item.active
211
190
  ? () => setCurrentPage({ pageNumber: item.index })
212
191
  : noop
213
192
  }
214
193
  textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
215
- extraStyles={`${extraStyles}${
216
- item.active ? currentPageStyles : ""
217
- }`}
194
+ extraStyles={extraStyles}
218
195
  dataQa={index}
219
196
  >
220
197
  {item.index}
221
198
  </ButtonWithAction>
222
199
  </Box>
223
200
  ) : (
224
- <Box padding="0 10px" as="li" key={item.id}>
201
+ <Box padding="0 10px">
225
202
  <Cluster justify="flex-end">
226
203
  <Text
204
+ key={index}
227
205
  variant="pXL"
228
206
  weight={fontWeight}
229
207
  color={numberColor ?? themeValues.numberColor}
230
- role="presentation"
231
208
  >
232
- {""}
209
+ {"..."}
233
210
  </Text>
234
211
  </Cluster>
235
212
  </Box>
@@ -238,7 +215,6 @@ const Pagination = ({
238
215
  {currentPage < pageCount ? (
239
216
  <PrevNextButton
240
217
  action={pageNext}
241
- ariaLabel={`Next Page`}
242
218
  arrowColor={arrowColor ?? themeValues.arrowColor}
243
219
  borderRadius={borderRadius}
244
220
  buttonHeight={buttonHeight}
@@ -14,7 +14,6 @@ export interface PaginationProps {
14
14
  fontWeight?: string;
15
15
  numberColor?: string;
16
16
  pageCount: number;
17
- ariaLabel?: string;
18
17
  pageNext: () => void;
19
18
  pagePrevious: () => void;
20
19
  setCurrentPage: ({ currentPage: number }) => void;
@@ -14,9 +14,6 @@ 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";
20
17
 
21
18
  const PaymentFormACH = ({
22
19
  variant = "default",
@@ -31,18 +28,13 @@ const PaymentFormACH = ({
31
28
  handleSubmit = noop,
32
29
  showWalletCheckbox,
33
30
  saveToWallet,
34
- walletCheckboxMarked,
35
- termsContent,
36
- termsTitle = "Terms &amp; Conditions"
31
+ walletCheckboxMarked
37
32
  }) => {
38
33
  if (clearOnDismount) {
39
34
  useEffect(() => () => actions.form.clear(), []);
40
35
  }
41
36
  const [showRouting, toggleShowRouting] = useState(false);
42
37
  const [showAccount, toggleShowAccount] = useState(false);
43
- const [termsModalOpen, setTermsModalOpen] = useState(false);
44
- const showTerms = !!termsContent;
45
- const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
46
38
 
47
39
  const nameErrors = {
48
40
  [required.error]: "Name is required"
@@ -161,32 +153,13 @@ const PaymentFormACH = ({
161
153
  hidden={hideDefaultPayment}
162
154
  />
163
155
  )}
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>
156
+ {showWalletCheckbox && (
157
+ <Checkbox
158
+ name="bank checkbox"
159
+ title="Save checking account to wallet"
160
+ checked={walletCheckboxMarked}
161
+ onChange={saveToWallet}
162
+ />
190
163
  )}
191
164
  </FormInputColumn>
192
165
  </FormContainer>
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useContext, useState } from "react";
1
+ import React, { useEffect, useContext } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import {
4
4
  required,
@@ -26,10 +26,8 @@ import {
26
26
  FormContainer,
27
27
  FormInputRow
28
28
  } from "../../atoms/form-layouts";
29
- import { Box, Cluster, Cover } from "../../atoms/layouts";
29
+ import { Box } from "../../atoms/layouts";
30
30
  import withWindowSize from "../../withWindowSize";
31
- import TermsAndConditionsModal from "../terms-and-conditions-modal/TermsAndConditionsModal";
32
- import Text from "../../atoms/text";
33
31
 
34
32
  const PaymentFormCard = ({
35
33
  variant = "default",
@@ -42,15 +40,9 @@ const PaymentFormCard = ({
42
40
  showWalletCheckbox,
43
41
  saveToWallet,
44
42
  walletCheckboxMarked,
45
- deniedCards,
46
- termsContent,
47
- termsTitle = "Terms &amp; Conditions"
43
+ deniedCards
48
44
  }) => {
49
45
  const { isMobile } = useContext(ThemeContext);
50
- const [termsModalOpen, setTermsModalOpen] = useState(false);
51
- const showTerms = !!termsContent;
52
- const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
53
-
54
46
  useEffect(() => {
55
47
  if (deniedCards) {
56
48
  deniedCards.map(card =>
@@ -185,32 +177,13 @@ const PaymentFormCard = ({
185
177
  />
186
178
  </Box>
187
179
  )}
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>
180
+ {showWalletCheckbox && (
181
+ <Checkbox
182
+ name="credit card checkbox"
183
+ title="Save credit card to wallet"
184
+ checked={walletCheckboxMarked}
185
+ onChange={saveToWallet}
186
+ />
214
187
  )}
215
188
  </FormInputColumn>
216
189
  </FormContainer>
@@ -9,8 +9,7 @@ const TermsAndConditions = ({
9
9
  isChecked,
10
10
  html,
11
11
  terms,
12
- error = false,
13
- linkVariant
12
+ error = false
14
13
  }) => {
15
14
  const [showTerms, toggleShowTerms] = useState(false);
16
15
  return (
@@ -32,7 +31,6 @@ const TermsAndConditions = ({
32
31
  terms={terms}
33
32
  isOpen={showTerms}
34
33
  toggleOpen={toggleShowTerms}
35
- linkVariant={linkVariant}
36
34
  />
37
35
  )}
38
36
  </Stack>
@@ -14,7 +14,6 @@ const TermsAndConditionsModal = ({
14
14
  acceptText,
15
15
  terms,
16
16
  variant,
17
- linkVariant = "p",
18
17
  themeValues
19
18
  }) => (
20
19
  <Modal
@@ -43,14 +42,14 @@ const TermsAndConditionsModal = ({
43
42
  }}
44
43
  >
45
44
  <Text
46
- variant={linkVariant}
45
+ variant={variant === "default" ? "pS" : "pXS"}
47
46
  onClick={() => toggleOpen(true)}
48
47
  onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
49
48
  tabIndex="0"
50
49
  color={themeValues.linkColor}
51
50
  weight={themeValues.fontWeight}
52
51
  hoverStyles={themeValues.modalLinkHoverFocus}
53
- extraStyles={`display: inline-block; width: fit-content; cursor: pointer`}
52
+ extraStyles={`display: inline-block; width: fit-content;`}
54
53
  >
55
54
  {link}
56
55
  </Text>
@@ -11,15 +11,6 @@ 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
-
23
14
  export const termsAndConditionsModal = () => (
24
15
  <TermsAndConditionsModal
25
16
  link={text("text", "Show modal", groupId)}
@@ -30,7 +21,6 @@ export const termsAndConditionsModal = () => (
30
21
  acceptText={text("acceptText", "Accept", groupId)}
31
22
  terms={text("terms", "terms and conditions", groupId)}
32
23
  variant={select("variants", variants, "default", groupId)}
33
- linkVariant={select("linkVariants", linkVariants, groupId)}
34
24
  />
35
25
  );
36
26