@thecb/components 10.6.0-beta.4 → 10.6.0-beta.6

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.
@@ -1,23 +1,22 @@
1
1
  import React, { Fragment, useContext } from "react";
2
2
  import { Box, Cluster } from "../layouts";
3
- import { themeComponent } from "../../../util/themeUtils";
4
3
  import ButtonWithAction from "../button-with-action";
5
4
  import { Center } from "../layouts";
6
5
  import Text from "../text/Text";
7
6
  import { ThemeContext } from "styled-components";
8
- import { fallbackValues } from "./WalletName.theme";
9
7
  import Module from "../../molecules/module/Module";
10
8
  import Spinner from "../spinner/Spinner";
9
+ import { CHARADE_GREY } from "../../../constants/colors";
10
+ import { noop } from "../../../util/general";
11
11
 
12
12
  const WalletName = ({
13
- mainText,
14
- action,
15
- text,
16
- actionText,
17
- themeValues,
13
+ mainText, // left side text
14
+ action, // right side link/button action
15
+ text = null, // right side non-hyperlinked text
16
+ actionText = null, // right side hyperlinked text
18
17
  disableAction = false,
19
- buttonExtraStyles = "",
20
- isLoading = false
18
+ linkButtonExtraStyles = "", // hyperlinked text extraStyles
19
+ isLoading = false // shows a spinner on the left when true
21
20
  }) => {
22
21
  const { isMobile } = useContext(ThemeContext);
23
22
 
@@ -28,12 +27,14 @@ const WalletName = ({
28
27
  align="center"
29
28
  justify={!!text || !!actionText ? "space-between" : "flex-start"}
30
29
  extraStyles={`
31
- box-shadow: ${themeValues.boxShadow};
30
+ box-shadow: 0px 1px 2px 0px rgba(${CHARADE_GREY}, 0.1);
31
+ box-shadow: 0px 2px 6px 0px rgba(${CHARADE_GREY}, 0.2);
32
+ box-shadow: 0px -1px 0px 0px rgba(${CHARADE_GREY}, 0.1) inset;
32
33
  padding: 1.5rem;
33
34
  ${isMobile ? `span {text-align: right;}` : ``}
34
35
  `}
35
36
  >
36
- <Box padding="0" extraStyles="">
37
+ <Box padding="0">
37
38
  {isLoading ? (
38
39
  <Center as="span" style={{ padding: "24px 24px 0" }} intrinsic>
39
40
  <Spinner
@@ -45,7 +46,7 @@ const WalletName = ({
45
46
  />
46
47
  </Center>
47
48
  ) : (
48
- <Text>{mainText}</Text>
49
+ mainText && <Text>{mainText}</Text>
49
50
  )}
50
51
  </Box>
51
52
  {!isMobile && (
@@ -59,10 +60,10 @@ const WalletName = ({
59
60
  action={action}
60
61
  variant="smallGhost"
61
62
  extraStyles={`
62
- margin: 0;
63
- min-width: 0;
64
- span {font-size: 0.75rem;}
65
- ${buttonExtraStyles}
63
+ margin: 0;
64
+ min-width: 0;
65
+ span {font-size: 0.75rem;}
66
+ ${linkButtonExtraStyles}
66
67
  `}
67
68
  />
68
69
  )}
@@ -98,9 +99,4 @@ const WalletName = ({
98
99
  );
99
100
  };
100
101
 
101
- export default themeComponent(
102
- WalletName,
103
- "WalletName",
104
- fallbackValues,
105
- "primary"
106
- );
102
+ export default WalletName;
@@ -2,11 +2,12 @@ import React from "react";
2
2
  import Expand from "../../../util/expand";
3
3
 
4
4
  export interface WalletNameProps {
5
- action?: () => void;
6
- text: string;
5
+ action: () => void;
7
6
  actionText: string;
7
+ disableAction: boolean;
8
8
  mainText: string;
9
- disableAction?: boolean;
9
+ text?: string | null;
10
+ isLoading: boolean;
10
11
  buttonExtraStyles?: string;
11
12
  }
12
13
 
@@ -40,7 +40,8 @@ const EditableList = ({
40
40
  listPadding = "0rem 0rem 1.5rem 0rem",
41
41
  qaPrefix,
42
42
  ariaLabel,
43
- editItemAriaRole = ""
43
+ editItemAriaRole = "",
44
+ disablePlaceholder = false
44
45
  }) => {
45
46
  const addText = `Add a${
46
47
  itemName[0].match(/[aieouAIEOU]/) ? "n" : ""
@@ -168,6 +169,7 @@ const EditableList = ({
168
169
  action={addItem}
169
170
  dataQa={"Add " + qaPrefix}
170
171
  aria-label={addText}
172
+ isDisabled={disablePlaceholder}
171
173
  />
172
174
  </Box>
173
175
  )}
@@ -1,6 +1,4 @@
1
- import React, { useState } from "react";
2
- import { boolean } from "@storybook/addon-knobs";
3
-
1
+ import React from "react";
4
2
  import EditableList from "./EditableList";
5
3
  import page from "../../../../.storybook/page";
6
4
 
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import { equals } from "ramda";
3
+ import { FormInput } from "../../atoms/form-layouts";
4
+ import { displayCurrency } from "../../../util/general";
5
+ import Text from "../../atoms/text";
6
+
7
+ const PartialAmountField = ({
8
+ lineItem,
9
+ field,
10
+ showErrors,
11
+ errorMessages,
12
+ moneyFormat,
13
+ fieldActions
14
+ }) => (
15
+ <FormInput
16
+ labelTextWhenNoError={lineItem.description}
17
+ key={lineItem.id}
18
+ field={field}
19
+ fieldActions={fieldActions}
20
+ showErrors={showErrors}
21
+ errorMessages={errorMessages}
22
+ style={{ textAlign: "right" }}
23
+ placeholder="$0.00"
24
+ formatter={moneyFormat}
25
+ isNum
26
+ decorator={
27
+ <Text variant="p">
28
+ Amount owed:{" "}
29
+ {
30
+ <Text variant="p" weight="600">
31
+ {displayCurrency(lineItem.amount)}
32
+ </Text>
33
+ }
34
+ </Text>
35
+ }
36
+ />
37
+ );
38
+
39
+ function arePropsEqual(prevProps, nextProps) {
40
+ return (
41
+ equals(prevProps.errorMessages, nextProps.errorMessages) &&
42
+ equals(prevProps.field, nextProps.field) &&
43
+ equals(prevProps.showErrors, nextProps.showErrors) &&
44
+ equals(prevProps.moneyFormat, nextProps.moneyFormat) &&
45
+ equals(prevProps.lineItem, nextProps.lineItem)
46
+ );
47
+ }
48
+
49
+ export default React.memo(PartialAmountField, arePropsEqual);
@@ -4,13 +4,11 @@ import {
4
4
  numberGreaterThanOrEqualTo,
5
5
  numberLessThanOrEqualTo
6
6
  } from "redux-freeform";
7
+
8
+ import PartialAmountField from "./PartialAmountField";
7
9
  import { displayCurrency } from "../../../util/general";
8
10
  import Text from "../../atoms/text";
9
- import {
10
- FormInput,
11
- FormInputColumn,
12
- FormContainer
13
- } from "../../atoms/form-layouts";
11
+ import { FormInputColumn, FormContainer } from "../../atoms/form-layouts";
14
12
  import { moneyFormat } from "../../../util/formats";
15
13
 
16
14
  const PartialAmountForm = ({
@@ -68,27 +66,15 @@ const PartialAmountForm = ({
68
66
  <div style={{ height: "16px" }}></div>
69
67
  <FormInputColumn>
70
68
  {lineItemsNew.map(li => (
71
- <FormInput
72
- labelTextWhenNoError={li.description}
69
+ <PartialAmountField
73
70
  key={li.id}
71
+ lineItem={li}
74
72
  field={fields[li.id]}
75
- fieldActions={actions.fields[li.id]}
73
+ actions={actions}
76
74
  showErrors={showErrors}
75
+ moneyFormat={moneyFormat}
76
+ fieldActions={actions.fields[li.id]}
77
77
  errorMessages={getPartialAmountFormErrors(li.amount)}
78
- style={{ textAlign: "right" }}
79
- placeholder="$0.00"
80
- formatter={moneyFormat}
81
- isNum
82
- decorator={
83
- <Text variant="p">
84
- Amount owed:{" "}
85
- {
86
- <Text variant="p" weight="600">
87
- {displayCurrency(li.amount)}
88
- </Text>
89
- }
90
- </Text>
91
- }
92
78
  />
93
79
  ))}
94
80
  </FormInputColumn>
@@ -94,12 +94,17 @@ const InnerRadioSection = ({
94
94
  aria-labelledby={ariaLabelledBy}
95
95
  aria-describedby={ariaDescribedBy}
96
96
  onClick={
97
- (isMobile && supportsTouch) || section.disabled
97
+ (isMobile && supportsTouch) ||
98
+ section.disabled ||
99
+ section.id === openSection
98
100
  ? noop
99
101
  : () => toggleOpenSection(section.id)
100
102
  }
101
103
  onTouchEnd={
102
- isMobile && supportsTouch && !section.disabled
104
+ isMobile &&
105
+ supportsTouch &&
106
+ !section.disabled &&
107
+ section.id !== openSection
103
108
  ? () => toggleOpenSection(section.id)
104
109
  : noop
105
110
  }
@@ -1,25 +0,0 @@
1
- import {
2
- CHARADE_GREY,
3
- ROYAL_BLUE_VIVID,
4
- WHITE
5
- } from "../../../constants/colors";
6
-
7
- const backgroundColor = {
8
- primary: WHITE
9
- };
10
-
11
- const color = {
12
- primary: ROYAL_BLUE_VIVID
13
- };
14
-
15
- const boxShadow = {
16
- primary: `box-shadow: 0px 1px 2px 0px rgba(${CHARADE_GREY}, 0.1);
17
- box-shadow: 0px 2px 6px 0px rgba(${CHARADE_GREY}, 0.2);
18
- box-shadow: 0px -1px 0px 0px rgba(${CHARADE_GREY}, 0.1) inset;`
19
- };
20
-
21
- export const fallbackValues = {
22
- backgroundColor,
23
- color,
24
- boxShadow
25
- };