@thecb/components 7.2.0-beta.5 → 7.2.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.
Files changed (34) hide show
  1. package/dist/index.cjs.js +536 -21
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +8 -1
  4. package/dist/index.esm.js +532 -22
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/atoms/card/Card.js +18 -1
  8. package/src/components/atoms/card/index.d.ts +1 -0
  9. package/src/components/atoms/icons/GuidedCheckoutImage.d.ts +1 -0
  10. package/src/components/atoms/icons/GuidedCheckoutImage.js +39 -0
  11. package/src/components/atoms/icons/PaymentMethodAddIcon.js +12 -9
  12. package/src/components/atoms/icons/ProfileImage.d.ts +1 -0
  13. package/src/components/atoms/icons/ProfileImage.js +51 -0
  14. package/src/components/atoms/icons/StandardCheckoutImage.d.ts +1 -0
  15. package/src/components/atoms/icons/StandardCheckoutImage.js +371 -0
  16. package/src/components/atoms/icons/index.d.ts +3 -0
  17. package/src/components/atoms/icons/index.js +7 -1
  18. package/src/components/atoms/index.d.ts +1 -0
  19. package/src/components/atoms/index.js +2 -1
  20. package/src/components/atoms/placeholder/Placeholder.js +20 -6
  21. package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +87 -0
  22. package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.stories.js +39 -0
  23. package/src/components/atoms/radio-button-with-label/index.js +3 -0
  24. package/src/components/molecules/index.js +1 -0
  25. package/src/components/molecules/radio-group/RadioGroup.js +59 -0
  26. package/src/components/molecules/radio-group/RadioGroup.stories.js +44 -0
  27. package/src/components/molecules/radio-group/index.js +3 -0
  28. package/src/components/molecules/radio-section/RadioSection.js +1 -1
  29. package/src/components/molecules/radio-section/RadioSection.stories.js +1 -1
  30. package/src/components/{atoms → molecules/radio-section}/radio-button/RadioButton.js +2 -2
  31. package/src/components/{atoms → molecules/radio-section}/radio-button/RadioButton.theme.js +1 -1
  32. package/src/.DS_Store +0 -0
  33. package/src/components/atoms/radio-button/RadioButton.stories.js +0 -34
  34. package/src/components/atoms/radio-button/index.js +0 -3
@@ -1,6 +1,7 @@
1
1
  export * from "./card";
2
2
  export * from "./button-with-action";
3
3
  export * from "./button-with-link";
4
+ export * from "./icons";
4
5
  export * from "./layouts";
5
6
  export * from "./link";
6
7
  export * from "./nav-footer";
@@ -32,7 +32,8 @@ export { default as Paragraph } from "./paragraph";
32
32
  export { default as PasswordRequirements } from "./password-requirements";
33
33
  export { default as Placeholder } from "./placeholder";
34
34
  export { default as ProcessingFee } from "./processing-fee";
35
- export { default as RadioButton } from "./radio-button";
35
+ export { default as RadioButtonWithLabel } from "./radio-button-with-label";
36
+ export { default as RadioButton } from "../molecules/radio-section/radio-button/RadioButton";
36
37
  export { default as SearchableSelect } from "./searchable-select";
37
38
  export { default as SolidDivider } from "./solid-divider";
38
39
  export { default as Spinner } from "./spinner";
@@ -10,9 +10,27 @@ import {
10
10
  GRECIAN_GREY,
11
11
  CHARADE_GREY
12
12
  } from "../../../constants/colors";
13
- import { AccountsAddIcon, PropertiesAddIcon, IconAdd } from "../icons";
13
+ import {
14
+ AccountsAddIcon,
15
+ PropertiesAddIcon,
16
+ IconAdd,
17
+ PaymentMethodAddIcon
18
+ } from "../icons";
14
19
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
15
20
 
21
+ const getLargeIcon = iconName => {
22
+ switch (iconName) {
23
+ case "accounts":
24
+ return <AccountsAddIcon />;
25
+ case "properties":
26
+ return <PropertiesAddIcon />;
27
+ case "payments":
28
+ return <PaymentMethodAddIcon />;
29
+ default:
30
+ return <AccountsAddIcon />;
31
+ }
32
+ };
33
+
16
34
  const PlaceholderContentWrapper = ({
17
35
  isLink,
18
36
  action,
@@ -109,11 +127,7 @@ const Placeholder = ({
109
127
  >
110
128
  {variant === "large" ? (
111
129
  <Center intrinsic>
112
- {largeIcon === "accounts" ? (
113
- <AccountsAddIcon />
114
- ) : (
115
- <PropertiesAddIcon />
116
- )}
130
+ {getLargeIcon(largeIcon)}
117
131
  <Text
118
132
  variant="pS"
119
133
  color={themeValues.color}
@@ -0,0 +1,87 @@
1
+ import React from "react";
2
+ import { Cluster } from "../../atoms/layouts";
3
+ import Text from "../text";
4
+ import styled from "styled-components";
5
+ import { colors } from "../../../constants";
6
+
7
+ const HiddenRadioInput = styled.input`
8
+ // can still select the element with the keyboard, but it's invisible and doesn't interfere with the spacing of other elements around it
9
+ position: absolute;
10
+ opacity: 0;
11
+ margin: 0;
12
+ `;
13
+
14
+ const Circle = styled.div`
15
+ // this exists to override the default browser's radio circle
16
+ flex-shrink: 0;
17
+ margin-right: 8px;
18
+ width: 1.5rem;
19
+ height 1.5rem;
20
+ border: 1px solid ${colors.GREY_CHATEAU};
21
+ border-radius: 50%;
22
+ box-sizing: border-box;
23
+ padding: 2px;
24
+ :after {
25
+ content: "";
26
+ width: 100%;
27
+ height: 100%;
28
+ display: block;
29
+ background: ${colors.MATISSE_BLUE};
30
+ border-radius: 50%;
31
+ transform: scale(0);
32
+ }
33
+ `;
34
+
35
+ const InputAndLabelContainer = styled(Cluster)`
36
+ overflow: visible;
37
+ ${HiddenRadioInput}:checked + label ${Circle}:after {
38
+ transform: scale(0.85);
39
+ transition: transform 0.15s;
40
+ }
41
+ ${HiddenRadioInput}:checked + label ${Circle} {
42
+ border: 1px solid ${colors.MATISSE_BLUE};
43
+ }
44
+ ${HiddenRadioInput}:focus + label ${Circle} { {
45
+ box-shadow: 0px 0px 2px 1px ${colors.MATISSE_BLUE};
46
+ }
47
+ `;
48
+
49
+ const RadioButtonWithLabel = ({
50
+ id = "",
51
+ value = "",
52
+ labelText = "",
53
+ groupName,
54
+ setValue,
55
+ ariaInvalid,
56
+ index
57
+ }) => (
58
+ <InputAndLabelContainer align="center" childGap="0.5rem">
59
+ <HiddenRadioInput
60
+ aria-invalid={ariaInvalid}
61
+ style={{ marginTop: 0 }}
62
+ type="radio"
63
+ name={groupName}
64
+ id={id}
65
+ value={value}
66
+ onChange={e => setValue(e.target.value)}
67
+ defaultChecked={index === 0}
68
+ />
69
+ <Text
70
+ as="label"
71
+ htmlFor={id}
72
+ extraStyles={`
73
+ font-size: 1rem;
74
+ display: flex;
75
+ width: 100%;
76
+ :hover {
77
+ cursor: pointer;
78
+ }
79
+ `}
80
+ >
81
+ <Circle />
82
+ {labelText}
83
+ </Text>
84
+ </InputAndLabelContainer>
85
+ );
86
+
87
+ export default RadioButtonWithLabel;
@@ -0,0 +1,39 @@
1
+ import React, { useState } from "react";
2
+ import RadioButtonWithLabel from "./RadioButtonWithLabel";
3
+ import { Box } from "../layouts";
4
+ import page from "../../../../.storybook/page";
5
+
6
+ export const radioButtonWithLabel = () => {
7
+ const [selected, setSelected] = useState("");
8
+ const handleRadioClick = e => {
9
+ setSelected(e.currentTarget.value);
10
+ };
11
+
12
+ return (
13
+ <Box>
14
+ <RadioButtonWithLabel
15
+ id="some-id"
16
+ value="some-value"
17
+ labelText="A radio button with a label."
18
+ handleRadioClick={handleRadioClick}
19
+ selected={selected}
20
+ />
21
+ <RadioButtonWithLabel
22
+ id="another-id"
23
+ value="another-value"
24
+ labelText="Another radio button with a label."
25
+ handleRadioClick={handleRadioClick}
26
+ selected={selected}
27
+ />
28
+ </Box>
29
+ );
30
+ };
31
+
32
+ radioButtonWithLabel.storyName = "RadioButtonWithLabel";
33
+
34
+ const story = page({
35
+ title: "Components|Atoms/RadioButtonWithLabel",
36
+ Component: RadioButtonWithLabel
37
+ });
38
+
39
+ export default story;
@@ -0,0 +1,3 @@
1
+ import RadioButtonWithLabel from "./RadioButtonWithLabel";
2
+
3
+ export default RadioButtonWithLabel;
@@ -26,6 +26,7 @@ export { default as PaymentFormCard } from "./payment-form-card";
26
26
  export { default as PeriscopeDashboardIframe } from "./periscope-dashboard-iframe";
27
27
  export { default as PhoneForm } from "./phone-form";
28
28
  export { default as Popover } from "./popover";
29
+ export { default as RadioGroup } from "./radio-group";
29
30
  export { default as RadioSection } from "./radio-section";
30
31
  export { default as RegistrationForm } from "./registration-form";
31
32
  export { default as ResetConfirmationForm } from "./reset-confirmation-form";
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import RadioButtonWithLabel from "../../atoms/radio-button-with-label/RadioButtonWithLabel";
3
+ import { Stack } from "../../atoms";
4
+ import { colors } from "../../../constants";
5
+ import styled from "styled-components";
6
+
7
+ const DefaultHeading = styled.div`
8
+ font-size: 0.875rem;
9
+ color: ${colors.CHARADE_GREY}
10
+ margin: 0;
11
+ padding: 8px 0px;
12
+ `;
13
+
14
+ const StyledFieldset = styled.fieldset`
15
+ ${props => props.$extraStyles}
16
+ `;
17
+
18
+ const RadioGroup = ({
19
+ headingText,
20
+ groupName,
21
+ heading: Heading = (
22
+ <DefaultHeading role="heading" id={`radio-group-${groupName}-heading`}>
23
+ {headingText}
24
+ </DefaultHeading>
25
+ ),
26
+ config,
27
+ extraStyles,
28
+ // redux-freeform props - this is similar to how FormInput works, duplicated because the radio input is hidden for styling overrides
29
+ field,
30
+ fieldActions
31
+ }) => {
32
+ const setValue = value => fieldActions.set(value);
33
+ return (
34
+ <StyledFieldset
35
+ role="radiogroup"
36
+ aria-labelledby={`radio-group-${groupName}-heading`}
37
+ $extraStyles={extraStyles}
38
+ >
39
+ {Heading !== null && Heading}
40
+ <Stack childGap="4px">
41
+ {config.map((c, idx) => (
42
+ <RadioButtonWithLabel
43
+ index={idx}
44
+ key={c.id}
45
+ {...c}
46
+ groupName={groupName}
47
+ setValue={setValue}
48
+ aria-invalid={
49
+ (field.dirty && field.hasErrors) ||
50
+ (field.hasErrors && showErrors)
51
+ }
52
+ />
53
+ ))}
54
+ </Stack>
55
+ </StyledFieldset>
56
+ );
57
+ };
58
+
59
+ export default RadioGroup;
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import RadioGroup from "./RadioGroup";
3
+ import page from "../../../../.storybook/page";
4
+ import { noop } from "../../../util/general";
5
+
6
+ const config = [
7
+ {
8
+ id: "foo",
9
+ value: "foo",
10
+ labelText: "Foo"
11
+ },
12
+ {
13
+ id: "bar",
14
+ value: "bar",
15
+ labelText: "Bar"
16
+ },
17
+ {
18
+ id: "baz",
19
+ value: "baz",
20
+ labelText: "Baz"
21
+ }
22
+ ];
23
+
24
+ export const radioGroup = () => (
25
+ <RadioGroup
26
+ headingText="Radio Group Title"
27
+ config={config}
28
+ groupName="radio-button-group"
29
+ field={{
30
+ rawValue: "Hello World",
31
+ dirty: false
32
+ }}
33
+ fieldActions={{
34
+ set: () => noop()
35
+ }}
36
+ />
37
+ );
38
+
39
+ const story = page({
40
+ title: "Components|Molecules/RadioGroup",
41
+ Component: RadioGroup
42
+ });
43
+
44
+ export default story;
@@ -0,0 +1,3 @@
1
+ import RadioGroup from "./RadioGroup";
2
+
3
+ export default RadioGroup;
@@ -3,7 +3,7 @@ import styled from "styled-components";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./RadioSection.theme";
5
5
  import { AnimatePresence } from "framer-motion";
6
- import RadioButton from "../../atoms/radio-button";
6
+ import RadioButton from "./radio-button/RadioButton";
7
7
  import { Box, Cluster, Stack, Motion } from "../../atoms/layouts";
8
8
  import { noop } from "../../../util/general";
9
9
  import Text from "../../atoms/text";
@@ -5,7 +5,7 @@ import RadioSection from "./RadioSection";
5
5
  import page from "../../../../.storybook/page";
6
6
 
7
7
  const story = page({
8
- title: "Components|Atoms/RadioSection",
8
+ title: "Components|Molecules/RadioSection",
9
9
  Component: RadioSection
10
10
  });
11
11
  export default story;
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { themeComponent } from "../../../util/themeUtils";
3
2
  import { fallbackValues } from "./RadioButton.theme";
4
- import { Motion } from "../layouts";
3
+ import { Motion } from "../../../atoms/layouts";
5
4
  import styled from "styled-components";
5
+ import { themeComponent } from "../../../../util/themeUtils";
6
6
 
7
7
  const HiddenRadioButton = styled.input`
8
8
  opacity: 0;
@@ -1,4 +1,4 @@
1
- import { MATISSE_BLUE, GREY_CHATEAU } from "../../../constants/colors";
1
+ import { MATISSE_BLUE, GREY_CHATEAU } from "../../../../constants/colors";
2
2
 
3
3
  const activeColor = `${MATISSE_BLUE}`;
4
4
  const inactiveColor = `${GREY_CHATEAU}`;
package/src/.DS_Store DELETED
Binary file
@@ -1,34 +0,0 @@
1
- import React, { useState } from "react";
2
- import { boolean } from "@storybook/addon-knobs";
3
- import RadioButton from "./RadioButton";
4
- import { Box } from "../layouts";
5
- import page from "../../../../.storybook/page";
6
-
7
- export const radioButtonsDefault = () => {
8
- const [selected, setSelected] = useState(null);
9
- const [focused, setFocused] = useState(null);
10
-
11
- return (
12
- <Box
13
- onFocus={() => setFocused(name)}
14
- onBlur={() => setFocused(null)}
15
- extraStyles="outline: none;"
16
- tabIndex="0"
17
- >
18
- <RadioButton
19
- name="demo"
20
- radioOn={selected === name}
21
- radioFocused={focused === name}
22
- toggleRadio={() => setSelected(name)}
23
- disabled={boolean("disabled", false, "props")}
24
- />
25
- </Box>
26
- );
27
- };
28
-
29
- const story = page({
30
- title: "Components|Atoms/RadioButton",
31
- Component: RadioButton
32
- });
33
-
34
- export default story;
@@ -1,3 +0,0 @@
1
- import RadioButton from "./RadioButton";
2
-
3
- export default RadioButton;