@thecb/components 3.5.12-beta.2 → 3.5.15

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/.storybook/main.js +1 -1
  2. package/.storybook/page.js +0 -2
  3. package/.tool-versions +1 -0
  4. package/dist/index.cjs.js +426 -370
  5. package/package.json +3 -3
  6. package/src/components/atoms/alert/Alert.js +50 -34
  7. package/src/components/atoms/breadcrumb/Breadcrumb.js +1 -4
  8. package/src/components/atoms/button-with-action/ButtonWithAction.js +1 -1
  9. package/src/components/atoms/checkbox/Checkbox.js +0 -1
  10. package/src/components/atoms/checkbox-list/CheckboxList.js +1 -3
  11. package/src/components/atoms/display-card/DisplayCard.js +4 -2
  12. package/src/components/atoms/dropdown/Dropdown.js +3 -3
  13. package/src/components/atoms/dropdown/Dropdown.stories.js +33 -10
  14. package/src/components/atoms/form-layouts/FormInput.js +23 -10
  15. package/src/components/atoms/form-layouts/FormLayouts.stories.js +5 -5
  16. package/src/components/atoms/hamburger-button/HamburgerButton.js +3 -4
  17. package/src/components/atoms/icons/AccountsIconSmall.js +13 -6
  18. package/src/components/atoms/icons/icons.stories.js +1 -1
  19. package/src/components/atoms/layouts/Box.styled.js +0 -1
  20. package/src/components/atoms/layouts/Cluster.styled.js +1 -5
  21. package/src/components/atoms/layouts/Sidebar.styled.js +1 -7
  22. package/src/components/atoms/radio-button/RadioButton.js +0 -1
  23. package/src/components/atoms/radio-button/RadioButton.stories.js +61 -26
  24. package/src/components/atoms/toggle-switch/ToggleSwitch.js +0 -1
  25. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +51 -10
  26. package/src/components/molecules/editable-list/EditableList.js +8 -11
  27. package/src/components/molecules/nav-menu/NavMenuDesktop.js +1 -2
  28. package/src/components/molecules/nav-menu/NavMenuMobile.js +1 -7
  29. package/src/components/molecules/radio-section/RadioSection.js +7 -3
  30. package/src/deprecated/components/radio-button/radio-button.js +1 -5
  31. package/src/deprecated/icons/IconInvalid.js +31 -7
  32. package/src/deprecated/icons/IconNeutral.js +4 -5
  33. package/src/deprecated/icons/IconValid.js +33 -8
  34. package/src/util/general.js +1 -10
@@ -1,34 +1,69 @@
1
1
  import React, { useState } from "react";
2
- import { boolean } from "@storybook/addon-knobs";
2
+ import { withKnobs, text, radios } from "@storybook/addon-knobs";
3
3
  import RadioButton from "./RadioButton";
4
- import { Box } from "../layouts";
5
- import page from "../../../../.storybook/page";
4
+ import { Box, Cover, Center } from "../layouts";
5
+ import { ThemeProvider } from "styled-components";
6
+
7
+ const fakeTheme = {
8
+ RadioButton: {
9
+ activeColor: "#15749D",
10
+ inactiveColor: "#959CA8"
11
+ }
12
+ };
13
+
14
+ export default {
15
+ title: "Radio Button",
16
+ component: RadioButton,
17
+ decorators: [
18
+ withKnobs,
19
+ storyFn => (
20
+ <ThemeProvider
21
+ theme={{
22
+ name: text("Theme Name", "default"),
23
+ values: fakeTheme
24
+ }}
25
+ >
26
+ <Cover>
27
+ <div />
28
+ <Center>{storyFn()}</Center>
29
+ <div />
30
+ </Cover>
31
+ </ThemeProvider>
32
+ )
33
+ ]
34
+ };
6
35
 
7
36
  export const radioButtonsDefault = () => {
37
+ const buttons = 3;
38
+
8
39
  const [selected, setSelected] = useState(null);
9
40
  const [focused, setFocused] = useState(null);
10
41
 
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
- );
42
+ return [...Array(buttons).keys()].map(i => {
43
+ const name = `radio-button-${i}`;
44
+ return (
45
+ <Box
46
+ key={name}
47
+ onFocus={() => setFocused(name)}
48
+ onBlur={() => setFocused(null)}
49
+ extraStyles="outline: none;"
50
+ tabIndex="0"
51
+ >
52
+ <RadioButton
53
+ name={name}
54
+ radioOn={selected === name}
55
+ radioFocused={focused === name}
56
+ toggleRadio={() => setSelected(name)}
57
+ disabled={
58
+ radios(
59
+ "Disable Radio Buttons",
60
+ { Enabled: "enabled", Disabled: "disabled" },
61
+ "enabled",
62
+ "RADIO-GROUP-1"
63
+ ) === "disabled"
64
+ }
65
+ />
66
+ </Box>
67
+ );
68
+ });
27
69
  };
28
-
29
- const story = page({
30
- title: "Components|Atoms/RadioButton",
31
- Component: RadioButton
32
- });
33
-
34
- export default story;
@@ -171,7 +171,6 @@ const ToggleSwitch = ({
171
171
  dataQa={dataQa}
172
172
  >
173
173
  <HiddenToggleSwitchBox
174
- aria-label={name}
175
174
  checked={isOn}
176
175
  onChange={disabled ? noop : onToggle}
177
176
  disabled={disabled}
@@ -1,12 +1,60 @@
1
1
  import React, { useState, Fragment } from "react";
2
- import { boolean } from "@storybook/addon-knobs";
2
+ import { withKnobs, text, radios } from "@storybook/addon-knobs";
3
3
  import ToggleSwitch from "./ToggleSwitch";
4
- import page from "../../../../.storybook/page";
4
+ import { Cover, Center, Stack } from "../layouts";
5
+ import { ThemeProvider } from "styled-components";
6
+
7
+ const fakeTheme = {
8
+ ToggleSwitch: {
9
+ onBackground: "#15749D",
10
+ disabledBackground: "#D5D8DC",
11
+ white: "white",
12
+ offBackground: "#959EA7",
13
+ rightLabelStyles: `display: flex;
14
+ justify-content: flex-start;
15
+ align-items: center;
16
+ flex-direction: row;`,
17
+ leftLabelStyles: `display: flex;
18
+ justify-content: flex-start;
19
+ align-items: center;
20
+ flex-direction: row-reverse;`
21
+ }
22
+ };
23
+
24
+ export default {
25
+ title: "Toggle Switch",
26
+ component: ToggleSwitch,
27
+ decorators: [
28
+ withKnobs,
29
+ storyFn => (
30
+ <ThemeProvider
31
+ theme={{
32
+ name: text("Theme Name", "default"),
33
+ values: fakeTheme
34
+ }}
35
+ >
36
+ <Cover>
37
+ <div />
38
+ <Center>
39
+ <Stack>{storyFn()}</Stack>
40
+ </Center>
41
+ <div />
42
+ </Cover>
43
+ </ThemeProvider>
44
+ )
45
+ ]
46
+ };
5
47
 
6
48
  export const toggleSwitchDefault = () => {
7
49
  const [isOn, onToggle] = useState(false);
8
50
 
9
- const disabled = boolean("disabled", false, "props");
51
+ const disabled =
52
+ radios(
53
+ "Disable Toggle Switch",
54
+ { Enabled: "enabled", Disabled: "disabled" },
55
+ "enabled",
56
+ "RADIO-GROUP-1"
57
+ ) === "disabled";
10
58
 
11
59
  return (
12
60
  <Fragment>
@@ -20,10 +68,3 @@ export const toggleSwitchDefault = () => {
20
68
  </Fragment>
21
69
  );
22
70
  };
23
-
24
- const story = page({
25
- title: "Components|Atoms/ToggleSwitch",
26
- Component: ToggleSwitch
27
- });
28
-
29
- export default story;
@@ -55,25 +55,24 @@ const EditableList = ({
55
55
  extraStyles={`box-shadow: 0px 2px 14px 0px rgb(246, 246, 249),
56
56
  0px 3px 8px 0px rgb(202, 206, 216);`}
57
57
  >
58
- {items.map(item => {
58
+ {items.map(props => {
59
59
  const [modalOpen, toggleModal] = useState(false);
60
60
  return (
61
61
  <EditableListItem
62
62
  listItemSize={
63
- !!item.id && item.id === autoPayMethod ? "big" : listItemSize
63
+ !!props.id && props.id === autoPayMethod ? "big" : listItemSize
64
64
  }
65
- key={item.id || item}
65
+ key={props.id}
66
66
  >
67
67
  <Text variant="p" color={CHARADE_GREY}>
68
- {renderItem(item)}
68
+ {renderItem(props)}
69
69
  </Text>
70
70
  <EditableListItemControls>
71
- {item.isPrimary && (
71
+ {props.isPrimary && (
72
72
  <Text
73
73
  variant="p"
74
74
  color={STORM_GREY}
75
75
  extraStyles={`font-style: italic;`}
76
- key={`Default ${itemName}`}
77
76
  >
78
77
  Default {itemName}
79
78
  </Text>
@@ -84,11 +83,10 @@ const EditableList = ({
84
83
  border="2px solid transparent"
85
84
  extraStyles={`:not(:first-child) { border-left: 2px solid ${BOSTON_BLUE};}`}
86
85
  dataQa={qaPrefix + " Remove"}
87
- key={`Remove ${item.id}`}
88
86
  >
89
87
  {useModal ? (
90
88
  <Modal
91
- item={{ ...item }}
89
+ item={{ ...props }}
92
90
  {...modalProps}
93
91
  modalOpen={modalOpen}
94
92
  toggleModal={toggleModal}
@@ -97,7 +95,7 @@ const EditableList = ({
97
95
  <ButtonWithAction
98
96
  variant="smallGhost"
99
97
  text="Remove"
100
- action={() => removeItem(item.id)}
98
+ action={() => removeItem(props.id)}
101
99
  extraStyles={`min-width: 0;`}
102
100
  />
103
101
  )}
@@ -109,12 +107,11 @@ const EditableList = ({
109
107
  border="2px solid transparent"
110
108
  extraStyles={`:not(:first-child) { border-left: 2px solid ${BOSTON_BLUE};}`}
111
109
  dataQa={qaPrefix + " Edit"}
112
- key={`Edit ${item.id}`}
113
110
  >
114
111
  <ButtonWithAction
115
112
  variant="smallGhost"
116
113
  text="Edit"
117
- action={() => editItem(item.id)}
114
+ action={() => editItem(props.id)}
118
115
  extraStyles={`min-width: 0;`}
119
116
  />
120
117
  </Box>
@@ -4,7 +4,6 @@ import { fallbackValues } from "./NavMenu.theme.js";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
5
 
6
6
  const NavMenuDesktop = ({
7
- id,
8
7
  top = "125%",
9
8
  left = "-100%",
10
9
  menuContent = [],
@@ -18,7 +17,7 @@ const NavMenuDesktop = ({
18
17
  const menuCarat = `&:after { bottom: 100%; right: 10px; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-color: ${themeValues.backgroundColor}00; border-bottom-color: ${themeValues.backgroundColor}; border-width: 10px; margin-left: -10px; }`;
19
18
 
20
19
  return (
21
- <Imposter id={id} breakout top={top} left={left} visible={visible}>
20
+ <Imposter breakout top={top} left={left} visible={visible}>
22
21
  <Box
23
22
  minWidth="240px"
24
23
  padding="1rem 0.5rem"
@@ -42,15 +42,9 @@ const ImposterMenu = styled(menu)`
42
42
  top: 72px;
43
43
  `;
44
44
 
45
- const NavMenuMobile = ({
46
- id,
47
- menuContent = [],
48
- visible = false,
49
- themeValues
50
- }) => {
45
+ const NavMenuMobile = ({ menuContent = [], visible = false, themeValues }) => {
51
46
  return (
52
47
  <ImposterMenu
53
- id={id}
54
48
  initialPose="invisible"
55
49
  pose={visible ? "visible" : "invisible"}
56
50
  >
@@ -122,12 +122,12 @@ const RadioSection = ({
122
122
  : themeValues.headingBackgroundColor
123
123
  }
124
124
  onClick={
125
- isMobile && supportsTouch
125
+ (isMobile && supportsTouch) || section.disabled
126
126
  ? noop
127
127
  : () => toggleOpenSection(section.id)
128
128
  }
129
129
  onTouchEnd={
130
- isMobile && supportsTouch
130
+ (isMobile && supportsTouch) || !section.disabled
131
131
  ? () => toggleOpenSection(section.id)
132
132
  : noop
133
133
  }
@@ -155,7 +155,11 @@ const RadioSection = ({
155
155
  name={section.id}
156
156
  radioOn={openSection === section.id}
157
157
  radioFocused={focused === section.id}
158
- toggleRadio={() => toggleOpenSection(section.id)}
158
+ toggleRadio={
159
+ section.disabled
160
+ ? noop
161
+ : () => toggleOpenSection(section.id)
162
+ }
159
163
  tabIndex="-1"
160
164
  />
161
165
  </Box>
@@ -36,11 +36,7 @@ const RadioButtonCenter = styled.div`
36
36
  RadioButtonCenter.defaultProps = defaultTheme;
37
37
 
38
38
  const RadioButton = ({ isSelected, name }) => (
39
- <RadioButtonBorder
40
- isSelected={isSelected}
41
- name={name}
42
- aria-checked={isSelected}
43
- >
39
+ <RadioButtonBorder isSelected={isSelected} name={name}>
44
40
  {isSelected && <RadioButtonCenter />}
45
41
  </RadioButtonBorder>
46
42
  );
@@ -16,23 +16,47 @@ export const IconInvalid = ({
16
16
  xmlns="http://www.w3.org/2000/svg"
17
17
  xmlnsXlink="http://www.w3.org/1999/xlink"
18
18
  style={{ margin }}
19
- aria-label="Invalid"
20
19
  >
21
- <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
22
- <g transform="translate(-538.000000, -1064.000000)" fillRule="nonzero">
23
- <g transform="translate(457.000000, 938.000000)">
24
- <g transform="translate(81.000000, 20.000000)">
25
- <g transform="translate(0.000000, 106.000000)">
20
+ <g
21
+ id="icon-invalid-Authentication"
22
+ stroke="none"
23
+ strokeWidth="1"
24
+ fill="none"
25
+ fillRule="evenodd"
26
+ >
27
+ <g
28
+ id="icon-invalid-00.1.0.1---HSS---Register---Already-Exists-Error"
29
+ transform="translate(-538.000000, -1064.000000)"
30
+ fillRule="nonzero"
31
+ >
32
+ <g
33
+ id="icon-invalid-Password-Requirements"
34
+ transform="translate(457.000000, 938.000000)"
35
+ >
36
+ <g
37
+ id="icon-invalid-Group-2"
38
+ transform="translate(81.000000, 20.000000)"
39
+ >
40
+ <g
41
+ id="icon-invalid-PasswordVerification-Error"
42
+ transform="translate(0.000000, 106.000000)"
43
+ >
26
44
  <circle
45
+ id="icon-invalid-Oval"
27
46
  stroke={bgFill}
28
47
  fill={bgFill}
29
48
  cx="9"
30
49
  cy="9"
31
50
  r="8.5"
32
51
  ></circle>
33
- <g transform="translate(2.000000, 2.000000)" fill={iconFill}>
52
+ <g
53
+ id="icon-invalid-Icon/Close"
54
+ transform="translate(2.000000, 2.000000)"
55
+ fill={iconFill}
56
+ >
34
57
  <path
35
58
  d="M7.58333333,7.58333333 L7.58333333,11.6666667 L6.41666667,11.6666667 L6.41666667,7.58333333 L2.33333333,7.58333333 L2.33333333,6.41666667 L6.41666667,6.41666667 L6.41666667,2.33333333 L7.58333333,2.33333333 L7.58333333,6.41666667 L11.6666667,6.41666667 L11.6666667,7.58333333 L7.58333333,7.58333333 Z"
59
+ id="icon-invalid-x"
36
60
  transform="translate(7.000000, 7.000000) rotate(45.000000) translate(-7.000000, -7.000000) "
37
61
  ></path>
38
62
  </g>
@@ -15,12 +15,11 @@ export const IconNeutral = ({
15
15
  xmlns="http://www.w3.org/2000/svg"
16
16
  xmlnsXlink="http://www.w3.org/1999/xlink"
17
17
  style={{ margin }}
18
- aria-label="Neutral"
19
18
  >
20
- <g fill={fill} fillRule="nonzero" stroke={fill}>
21
- <g>
22
- <g>
23
- <circle cx="9" cy="9" r="8.5"></circle>
19
+ <g id="icon-neutral-group" fill={fill} fillRule="nonzero" stroke={fill}>
20
+ <g id="icon-neutral-Group-2">
21
+ <g id="icon-neutral-PasswordVerification-Empty">
22
+ <circle id="icon-neutral-Oval" cx="9" cy="9" r="8.5"></circle>
24
23
  </g>
25
24
  </g>
26
25
  </g>
@@ -16,14 +16,32 @@ export const IconValid = ({
16
16
  xmlns="http://www.w3.org/2000/svg"
17
17
  xmlnsXlink="http://www.w3.org/1999/xlink"
18
18
  style={{ margin }}
19
- aria-label="Valid"
20
19
  >
21
- <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
22
- <g transform="translate(-538.000000, -996.000000)">
23
- <g transform="translate(457.000000, 938.000000)">
24
- <g transform="translate(81.000000, 20.000000)">
25
- <g transform="translate(0.000000, 38.000000)">
20
+ <g
21
+ id="icon-valid-Authentication"
22
+ stroke="none"
23
+ strokeWidth="1"
24
+ fill="none"
25
+ fillRule="evenodd"
26
+ >
27
+ <g
28
+ id="icon-valid-00.1.0.1---HSS---Register---Already-Exists-Error"
29
+ transform="translate(-538.000000, -996.000000)"
30
+ >
31
+ <g
32
+ id="icon-valid-Password-Requirements"
33
+ transform="translate(457.000000, 938.000000)"
34
+ >
35
+ <g
36
+ id="icon-valid-Group-2"
37
+ transform="translate(81.000000, 20.000000)"
38
+ >
39
+ <g
40
+ id="icon-valid-PasswordVerification-Sucess"
41
+ transform="translate(0.000000, 38.000000)"
42
+ >
26
43
  <circle
44
+ id="icon-valid-Oval"
27
45
  stroke={bgFill}
28
46
  fill={bgFill}
29
47
  fillRule="nonzero"
@@ -31,9 +49,16 @@ export const IconValid = ({
31
49
  cy="9"
32
50
  r="8.5"
33
51
  ></circle>
34
- <g transform="translate(2.000000, 2.000000)">
35
- <polygon points="0 0 14 0 14 14 0 14"></polygon>
52
+ <g
53
+ id="icon-valid-baseline-check-24px"
54
+ transform="translate(2.000000, 2.000000)"
55
+ >
36
56
  <polygon
57
+ id="icon-valid-Path"
58
+ points="0 0 14 0 14 14 0 14"
59
+ ></polygon>
60
+ <polygon
61
+ id="icon-valid-Path-2"
37
62
  fill={iconFill}
38
63
  points="5.25 9.4325 2.8175 7 1.98916667 7.8225 5.25 11.0833333 12.25 4.08333333 11.4275 3.26083333"
39
64
  ></polygon>
@@ -1,4 +1,3 @@
1
- import React, { Fragment } from "react";
2
1
  import numeral from "numeral";
3
2
 
4
3
  export const noop = () => {};
@@ -10,17 +9,9 @@ export const displayCurrency = cents =>
10
9
 
11
10
  export const convertCentsToMoneyInt = n => (n / 100).toFixed(0);
12
11
 
13
- const createUniqueId = () =>
14
- "_" +
15
- Math.random()
16
- .toString(36)
17
- .substr(2, 9);
18
-
19
12
  export const safeChildren = (children, replacement = []) => {
20
13
  if (children && children instanceof Array) {
21
- return children.map(child =>
22
- !child ? <Fragment key={createUniqueId()}>{replacement}</Fragment> : child
23
- );
14
+ return children.map(child => (!child ? replacement : child));
24
15
  }
25
16
  return !children ? replacement : children;
26
17
  };