@thecb/components 9.3.2-beta.1 → 9.3.2

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 (54) hide show
  1. package/dist/index.cjs.js +346 -245
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.esm.js +346 -246
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/atoms/button-with-action/ButtonWithAction.js +76 -70
  8. package/src/components/atoms/checkbox/Checkbox.js +10 -2
  9. package/src/components/atoms/checkbox/Checkbox.stories.js +1 -0
  10. package/src/components/atoms/country-dropdown/CountryDropdown.js +2 -0
  11. package/src/components/atoms/dropdown/Dropdown.js +11 -8
  12. package/src/components/atoms/form-layouts/FormInput.js +3 -0
  13. package/src/components/atoms/form-select/FormSelect.js +3 -1
  14. package/src/components/atoms/icons/AccountNumberImage.js +2 -0
  15. package/src/components/atoms/icons/BankIcon.js +2 -0
  16. package/src/components/atoms/icons/CheckmarkIcon.js +2 -0
  17. package/src/components/atoms/icons/GenericCard.js +2 -0
  18. package/src/components/atoms/icons/GenericCardLarge.js +2 -0
  19. package/src/components/atoms/icons/KebabMenuIcon.d.ts +1 -0
  20. package/src/components/atoms/icons/KebabMenuIcon.js +38 -0
  21. package/src/components/atoms/icons/RoutingNumberImage.js +2 -0
  22. package/src/components/atoms/icons/TrashIcon.js +42 -40
  23. package/src/components/atoms/icons/icons.stories.js +3 -1
  24. package/src/components/atoms/icons/index.d.ts +1 -0
  25. package/src/components/atoms/icons/index.js +3 -1
  26. package/src/components/atoms/layouts/Motion.js +7 -10
  27. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +3 -1
  28. package/src/components/atoms/toggle-switch/ToggleSwitch.js +2 -1
  29. package/src/components/molecules/address-form/AddressForm.js +5 -0
  30. package/src/components/molecules/collapsible-section/CollapsibleSection.js +2 -1
  31. package/src/components/molecules/email-form/EmailForm.js +3 -1
  32. package/src/components/molecules/modal/Modal.js +2 -1
  33. package/src/components/molecules/obligation/modules/AutopayModalModule.js +3 -13
  34. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +6 -0
  35. package/src/components/molecules/payment-form-card/PaymentFormCard.js +5 -0
  36. package/src/components/molecules/phone-form/PhoneForm.js +3 -1
  37. package/src/components/molecules/popover/Popover.js +2 -1
  38. package/src/components/molecules/popup-menu/PopupMenu.js +152 -0
  39. package/src/components/molecules/popup-menu/PopupMenu.stories.js +40 -0
  40. package/src/components/molecules/popup-menu/PopupMenu.styled.js +20 -0
  41. package/src/components/molecules/popup-menu/PopupMenu.theme.js +11 -0
  42. package/src/components/molecules/popup-menu/index.d.ts +25 -0
  43. package/src/components/molecules/popup-menu/index.js +3 -0
  44. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.js +79 -0
  45. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.styled.js +27 -0
  46. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.theme.js +23 -0
  47. package/src/components/molecules/radio-section/RadioSection.js +62 -13
  48. package/src/components/molecules/radio-section/RadioSection.stories.js +4 -2
  49. package/src/components/molecules/radio-section/radio-button/RadioButton.js +4 -2
  50. package/src/components/molecules/terms-and-conditions/TermsAndConditions.stories.js +3 -1
  51. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +4 -0
  52. package/src/constants/keyboard.js +7 -0
  53. package/src/util/general.js +10 -0
  54. /package/src/components/atoms/icons/{ExternalLinkIcon.js → ExternalLinkicon.js} +0 -0
@@ -7,6 +7,7 @@ import Heading from "../heading";
7
7
  import { Box, Center, Cover, Cluster } from "../layouts";
8
8
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
9
9
  import { CHARADE_GREY } from "../../../constants/colors";
10
+ import { ENTER } from "../../../constants/keyboard";
10
11
  import { noop } from "../../../util/general";
11
12
 
12
13
  const HiddenToggleSwitchBox = styled.input`
@@ -149,7 +150,7 @@ const ToggleSwitch = ({
149
150
  });
150
151
 
151
152
  const handleKeyDown = e => {
152
- if (e.keyCode === 13) {
153
+ if (e.keyCode === ENTER) {
153
154
  onToggle();
154
155
  }
155
156
  };
@@ -71,6 +71,7 @@ const AddressForm = ({
71
71
  }}
72
72
  showErrors={showErrors}
73
73
  dataQa="Country"
74
+ isRequired={true}
74
75
  />
75
76
  <FormInput
76
77
  labelTextWhenNoError="Address"
@@ -81,6 +82,7 @@ const AddressForm = ({
81
82
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
82
83
  autocompleteValue="address-line1"
83
84
  dataQa="Address"
85
+ isRequired={true}
84
86
  />
85
87
  <FormInput
86
88
  labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
@@ -100,6 +102,7 @@ const AddressForm = ({
100
102
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
103
  autocompleteValue="address-level2"
102
104
  dataQa="City"
105
+ isRequired={true}
103
106
  />
104
107
  <StateProvinceDropdown
105
108
  labelTextWhenNoError={isUS ? "State" : "State or Province"}
@@ -110,6 +113,7 @@ const AddressForm = ({
110
113
  showErrors={showErrors}
111
114
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
112
115
  dataQa="State or Province"
116
+ isRequired={true}
113
117
  />
114
118
  <FormInput
115
119
  isNum={isUS}
@@ -122,6 +126,7 @@ const AddressForm = ({
122
126
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
123
127
  autocompleteValue="postal-code"
124
128
  dataQa="Zip code"
129
+ isRequired={true}
125
130
  />
126
131
  {showWalletCheckbox && (
127
132
  <Checkbox
@@ -4,6 +4,7 @@ import { AnimatePresence } from "framer-motion";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
5
  import Title from "../../atoms/title";
6
6
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
7
+ import { ENTER } from "../../../constants/keyboard";
7
8
  import { Box, Cluster, Stack, Motion } from "../../atoms/layouts";
8
9
  import { ChevronIcon } from "../../atoms/icons";
9
10
  import { noop } from "../../../util/general";
@@ -28,7 +29,7 @@ const CollapsibleSection = ({
28
29
  extraStyles = ""
29
30
  }) => {
30
31
  const handleKeyDown = e => {
31
- if (e.keyCode === 13) {
32
+ if (e.keyCode === ENTER) {
32
33
  toggleSection();
33
34
  }
34
35
  };
@@ -19,7 +19,8 @@ const EmailForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked
22
+ walletCheckboxMarked,
23
+ isRequired = false
23
24
  }) => {
24
25
  if (clearOnDismount) {
25
26
  useEffect(() => () => actions.form.clear(), []);
@@ -48,6 +49,7 @@ const EmailForm = ({
48
49
  isEmail
49
50
  autocompleteValue="email"
50
51
  dataQa="Email address"
52
+ isRequired={isRequired}
51
53
  />
52
54
  {showWalletCheckbox && (
53
55
  <Checkbox
@@ -67,7 +67,8 @@ const Modal = ({
67
67
  alignItems: "center"
68
68
  }}
69
69
  dialogStyle={{
70
- width: customWidth || "615px"
70
+ width: customWidth || "615px",
71
+ overflow: "auto"
71
72
  }}
72
73
  underlayClickExits={underlayClickExits}
73
74
  >
@@ -70,19 +70,9 @@ const AutopayModal = ({
70
70
  : navigateToSettings
71
71
  };
72
72
 
73
- const hoverStyles = `
74
- &:hover {
75
- .autopayIcon { fill: ${themeValues.hoverColor}; text-decoration: underline; cursor: pointer; }
76
- }`;
73
+ const hoverStyles = "text-decoration: underline;";
74
+ const activeStyles = "text-decoration: underline;";
77
75
 
78
- const activeStyles = `
79
- &:active {
80
- .autopayIcon { fill: ${themeValues.activeColor}; text-decoration: underline; }
81
- }`;
82
-
83
- const defaultStyles = `
84
- .autopayIcon { fill: ${themeValues.color}; text-decoration: underline; }
85
- `;
86
76
  const renderAutoPayControl = () => {
87
77
  switch (controlType) {
88
78
  case "secondary": {
@@ -126,7 +116,7 @@ const AutopayModal = ({
126
116
  }}
127
117
  hoverStyles={hoverStyles}
128
118
  activeStyles={activeStyles}
129
- extraStyles={defaultStyles}
119
+ extraStyles={"cursor: pointer;"}
130
120
  >
131
121
  <Cluster
132
122
  justify={isMobile ? "flex-start" : "flex-end"}
@@ -76,6 +76,7 @@ const PaymentFormACH = ({
76
76
  showErrors={showErrors}
77
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
78
78
  autocompleteValue="name"
79
+ isRequired={true}
79
80
  />
80
81
  <FormInput
81
82
  labelTextWhenNoError="Routing number"
@@ -97,6 +98,7 @@ const PaymentFormACH = ({
97
98
  />
98
99
  )}
99
100
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
+ isRequired={true}
100
102
  />
101
103
  <FormInput
102
104
  labelTextWhenNoError="Confirm routing number"
@@ -107,6 +109,7 @@ const PaymentFormACH = ({
107
109
  showErrors={showErrors}
108
110
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
109
111
  isNum
112
+ isRequired={true}
110
113
  />
111
114
  <FormInput
112
115
  labelTextWhenNoError="Account number"
@@ -128,6 +131,7 @@ const PaymentFormACH = ({
128
131
  />
129
132
  )}
130
133
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
134
+ isRequired={true}
131
135
  />
132
136
  <FormInput
133
137
  labelTextWhenNoError="Confirm account number"
@@ -137,6 +141,7 @@ const PaymentFormACH = ({
137
141
  fieldActions={actions.fields.confirmAccountNumber}
138
142
  showErrors={showErrors}
139
143
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
144
+ isRequired={true}
140
145
  isNum
141
146
  />
142
147
  {allowBankAccountType && (
@@ -152,6 +157,7 @@ const PaymentFormACH = ({
152
157
  showErrors={showErrors}
153
158
  errorMessages={accountTypeErrors}
154
159
  field={fields.accountType}
160
+ isRequired={true}
155
161
  />
156
162
  )}
157
163
  {!hideDefaultPayment && (
@@ -121,6 +121,7 @@ const PaymentFormCard = ({
121
121
  showErrors={showErrors}
122
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
123
123
  autocompleteValue="cc-name"
124
+ isRequired={true}
124
125
  />
125
126
  <FormInput
126
127
  labelTextWhenNoError="Credit card number"
@@ -133,6 +134,7 @@ const PaymentFormCard = ({
133
134
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
134
135
  isNum
135
136
  autocompleteValue="cc-number"
137
+ isRequired={true}
136
138
  />
137
139
  <FormInputRow
138
140
  breakpoint={isMobile ? "1000rem" : "21rem"}
@@ -150,6 +152,7 @@ const PaymentFormCard = ({
150
152
  isNum
151
153
  removeFromValue={/\//} // removes "/" from browser autofill
152
154
  autocompleteValue="cc-exp"
155
+ isRequired={true}
153
156
  />
154
157
  <FormInput
155
158
  labelTextWhenNoError="CVV"
@@ -166,6 +169,7 @@ const PaymentFormCard = ({
166
169
  }
167
170
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
168
171
  autocompleteValue="cc-csc"
172
+ isRequired={true}
169
173
  />
170
174
  </FormInputRow>
171
175
  {!hideZipCode && (
@@ -184,6 +188,7 @@ const PaymentFormCard = ({
184
188
  showErrors={showErrors}
185
189
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
186
190
  autocompleteValue="billing postal-code"
191
+ isRequired={true}
187
192
  />
188
193
  </Box>
189
194
  )}
@@ -19,7 +19,8 @@ const PhoneForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked
22
+ walletCheckboxMarked,
23
+ isRequired = false
23
24
  }) => {
24
25
  if (clearOnDismount) {
25
26
  useEffect(() => () => actions.form.clear(), []);
@@ -43,6 +44,7 @@ const PhoneForm = ({
43
44
  autocompleteValue="tel-national"
44
45
  dataQa="Phone number"
45
46
  isNum={true}
47
+ isRequired={isRequired}
46
48
  />
47
49
  {showWalletCheckbox && (
48
50
  <Checkbox
@@ -6,6 +6,7 @@ import { Box } from "../../atoms/layouts";
6
6
  import ButtonWithAction from "../../atoms/button-with-action";
7
7
  import { useOutsideClick } from "../../../hooks";
8
8
  import { noop } from "../../../util/general";
9
+ import { ESCAPE } from "../../../constants/keyboard";
9
10
  import { fallbackValues } from "./Popover.theme";
10
11
 
11
12
  const arrowBorder = (borderColor, direction, width = "8px") => {
@@ -76,7 +77,7 @@ const Popover = ({
76
77
  handleTogglePopover(false);
77
78
  }}
78
79
  onKeyDown={e => {
79
- if (e.keyCode === 27) {
80
+ if (e.keyCode === ESCAPE) {
80
81
  handleTogglePopover(false);
81
82
  }
82
83
  }}
@@ -0,0 +1,152 @@
1
+ import React, { useState, useRef, useEffect } from "react";
2
+ import { themeComponent } from "../../../util/themeUtils";
3
+ import Text from "../../atoms/text";
4
+ import { Box } from "../../atoms/layouts";
5
+ import PopupMenuItem from "./popup-menu-item/PopupMenuItem";
6
+ import { fallbackValues } from "./PopupMenu.theme";
7
+ import { PopupMenuContainer, PopupMenuTriggerButton } from "./PopupMenu.styled";
8
+
9
+ const PopupMenu = ({
10
+ menuId = "popup-menu",
11
+ menuItems = [],
12
+ themeValues,
13
+ triggerText = "trigger text",
14
+ hasIcon = false,
15
+ icon: Icon,
16
+ iconHelpText = "", // for screen-readers, required if using an icon for trigger
17
+ menuFocus,
18
+ containerExtraStyles,
19
+ textExtraStyles,
20
+ minWidth = "250px",
21
+ maxWidth = "300px",
22
+ height = "auto",
23
+ position,
24
+ transform = "none",
25
+ buttonExtraStyles,
26
+ popupExtraStyles
27
+ }) => {
28
+ const {
29
+ hoverColor,
30
+ activeColor,
31
+ menuTriggerColor,
32
+ backgroundColor
33
+ } = themeValues;
34
+ const { top = `${height}px`, right = "auto", bottom = "auto", left = "0" } =
35
+ position ?? {};
36
+ const [isMenuOpen, setIsMenuOpen] = useState(false);
37
+ const menuRef = useRef();
38
+ const triggerRef = useRef();
39
+ const toggleMenu = menuState => setIsMenuOpen(menuState);
40
+
41
+ useEffect(() => {
42
+ const checkIfClickedOutside = e => {
43
+ // If the menu is open and the clicked target is not within the menu or the trigger
44
+ if (
45
+ isMenuOpen &&
46
+ menuRef.current &&
47
+ !menuRef.current.contains(e.target) &&
48
+ triggerRef.current &&
49
+ !triggerRef.current.contains(e.target)
50
+ ) {
51
+ toggleMenu(false);
52
+ }
53
+ };
54
+
55
+ document.addEventListener("click", checkIfClickedOutside);
56
+
57
+ return () => {
58
+ document.removeEventListener("click", checkIfClickedOutside);
59
+ };
60
+ }, [isMenuOpen]);
61
+
62
+ return (
63
+ <PopupMenuContainer extraStyles={containerExtraStyles}>
64
+ <PopupMenuTriggerButton
65
+ ref={triggerRef}
66
+ action={() => {
67
+ toggleMenu(!isMenuOpen);
68
+ }}
69
+ onKeyDown={e => {
70
+ if (e.key === "Escape") {
71
+ toggleMenu(false);
72
+ }
73
+ }}
74
+ contentOverride
75
+ variant="smallGhost"
76
+ tabIndex="0"
77
+ id={menuId}
78
+ borderRadius="8px"
79
+ aria-haspopup="true"
80
+ aria-expanded={isMenuOpen}
81
+ aria-controls={`${menuId}-container`}
82
+ extraStyles={buttonExtraStyles}
83
+ >
84
+ {hasIcon && (
85
+ <>
86
+ <Icon />
87
+ <Box padding="0" srOnly>
88
+ <Text id={`btn${menuId}_info`}>{iconHelpText}</Text>
89
+ </Box>
90
+ </>
91
+ )}
92
+ {!hasIcon && (
93
+ <Text
94
+ color={menuTriggerColor}
95
+ extraStyles={`&:active { color: ${activeColor}; } &:hover { color: ${hoverColor} }; ${textExtraStyles}`}
96
+ >
97
+ {triggerText}
98
+ </Text>
99
+ )}
100
+ </PopupMenuTriggerButton>
101
+ <Box
102
+ as="div"
103
+ id={`${menuId}-container`}
104
+ ref={menuRef}
105
+ onKeyDown={e => {
106
+ if (e.key === "Escape") {
107
+ toggleMenu(false);
108
+ }
109
+ }}
110
+ background={backgroundColor}
111
+ borderRadius="8px"
112
+ boxShadow={`
113
+ 0px 7px 32px 0px rgba(41, 42, 51, 0.2),
114
+ 0px 1px 4px 0px rgba(41, 42, 51, 0.2),
115
+ 0px 1px 8px -1px rgba(41, 42, 51, 0.3);
116
+ `}
117
+ role="menu"
118
+ aria-labelledby={menuId}
119
+ tabIndex={menuFocus && isMenuOpen ? "0" : "-1"}
120
+ minWidth={minWidth}
121
+ maxWidth={maxWidth}
122
+ extraStyles={`
123
+ display: ${isMenuOpen ? "block" : "none"};
124
+ position: absolute;
125
+ padding: 8px 8px 3px 8px;
126
+ top: ${top};
127
+ left: ${left};
128
+ right: ${right};
129
+ bottom: ${bottom};
130
+ height: ${height};
131
+ transform: ${transform};
132
+ ${popupExtraStyles};
133
+ `}
134
+ >
135
+ {menuItems.map((item, index) => (
136
+ <PopupMenuItem
137
+ key={index}
138
+ id={`${menuId}-item-${index}`}
139
+ closeMenuCallback={() => {
140
+ toggleMenu(false);
141
+ // focus back to trigger button when menu closes
142
+ triggerRef.current.focus();
143
+ }}
144
+ {...item}
145
+ />
146
+ ))}
147
+ </Box>
148
+ </PopupMenuContainer>
149
+ );
150
+ };
151
+
152
+ export default themeComponent(PopupMenu, "PopupMenu", fallbackValues);
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import { KebabMenuIcon, TrashIcon } from "../../atoms";
3
+ import PopupMenu from "./PopupMenu";
4
+ import page from "../../../../.storybook/page";
5
+ import { noop } from "../../../util/general";
6
+
7
+ const menuItems = [
8
+ {
9
+ text: "Account Details",
10
+ action: noop
11
+ },
12
+ {
13
+ text: "Remove",
14
+ action: noop,
15
+ isDeleteAction: true,
16
+ hasIcon: true,
17
+ icon: TrashIcon
18
+ }
19
+ ];
20
+
21
+ const story = page({
22
+ title: "Components|Molecules/PopupMenu",
23
+ Component: PopupMenu
24
+ });
25
+
26
+ export const popupMenu = () => (
27
+ <PopupMenu
28
+ hasIcon="true"
29
+ menuItems={menuItems}
30
+ icon={KebabMenuIcon}
31
+ minWidth={"50px"}
32
+ maxWidth={"208px"}
33
+ position={{ top: "0", left: "auto", right: "63px" }}
34
+ menuId={"menuId"}
35
+ containerExtraStyles={`margin-bottom: 100px;`}
36
+ buttonExtraStyles={`margin: 0 0 0 auto;`}
37
+ popupExtraStyles={`padding: 8px 8px 3px 8px;`}
38
+ />
39
+ );
40
+ export default story;
@@ -0,0 +1,20 @@
1
+ import styled from "styled-components";
2
+ import { ButtonWithAction } from "../../atoms";
3
+ import { Box } from "../../atoms";
4
+
5
+ export const PopupMenuContainer = styled(Box)`
6
+ display: flex;
7
+ position: relative;
8
+ padding: 0;
9
+ `;
10
+
11
+ export const PopupMenuTriggerButton = styled(ButtonWithAction)`
12
+ padding: 10px 15px;
13
+ min-width: auto;
14
+ &:active,
15
+ &:focus {
16
+ outline: none;
17
+ border: 1px solid rgba(196, 206, 244, 1);
18
+ background-color: rgba(235, 239, 251, 1);
19
+ }
20
+ `;
@@ -0,0 +1,11 @@
1
+ const hoverColor = "#116285";
2
+ const activeColor = "#0E506D";
3
+ const menuTriggerColor = "#15749D";
4
+ const backgroundColor = "white";
5
+
6
+ export const fallbackValues = {
7
+ hoverColor,
8
+ activeColor,
9
+ menuTriggerColor,
10
+ backgroundColor
11
+ };
@@ -0,0 +1,25 @@
1
+ import React, { ReactNode } from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface PopupMenuProps {
5
+ menuId?: string;
6
+ children?: ReactNode;
7
+ triggerText?: string | JSX.Element;
8
+ hasIcon?: boolean;
9
+ iconHelpText?: string; // for screen-readers, required if using an icon for trigger
10
+ menuFocus?: boolean;
11
+ containerExtraStyles?: string;
12
+ textExtraStyles?: string;
13
+ minWidth?: string;
14
+ maxWidth?: string;
15
+ height?: string;
16
+ position?: { top: string; right: string; bottom: string; left: string };
17
+ transform?: string;
18
+ disclosedExtraStyles?: string;
19
+ borderColor?: string;
20
+ backgroundColor?: string;
21
+ popupExtraStyles?: string;
22
+ }
23
+
24
+ export const PopupMenu: React.FC<Expand<PopupMenuProps> &
25
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,3 @@
1
+ import PopupMenu from "./PopupMenu";
2
+
3
+ export default PopupMenu;
@@ -0,0 +1,79 @@
1
+ import React from "react";
2
+ import { themeComponent } from "../../../../util/themeUtils";
3
+ import { Box, Text } from "../../../atoms";
4
+ import { fallbackValues } from "./PopupMenuItem.theme";
5
+ import { FONT_WEIGHT_SEMIBOLD } from "../../../../constants/style_constants";
6
+ import { PopupMenuItemContainer } from "./PopupMenuItem.styled";
7
+
8
+ const PopupMenuItem = ({
9
+ id,
10
+ closeMenuCallback,
11
+ action,
12
+ themeValues,
13
+ text,
14
+ hasIcon = false,
15
+ isDeleteAction = false,
16
+ icon: Icon,
17
+ textExtraStyles,
18
+ hoverStyles,
19
+ activeStyles,
20
+ extraStyles,
21
+ ...rest
22
+ }) => {
23
+ return (
24
+ <PopupMenuItemContainer
25
+ id={id}
26
+ role="menuItem"
27
+ text={text}
28
+ action={() => {
29
+ action();
30
+ closeMenuCallback();
31
+ }}
32
+ variant="smallGhost"
33
+ isDeleteAction={isDeleteAction}
34
+ theme={themeValues}
35
+ contentOverride
36
+ textExtraStyles={textExtraStyles}
37
+ hoverStyles={hoverStyles}
38
+ extraStyles={extraStyles}
39
+ activeStyles={`outline: none; ${activeStyles}`}
40
+ {...rest}
41
+ >
42
+ <Box
43
+ extraStyles={`
44
+ display: flex;
45
+ gap: 8px;
46
+ justify-content: center;
47
+ padding: 0;
48
+ `}
49
+ >
50
+ {hasIcon && (
51
+ <Icon
52
+ iconFill={
53
+ isDeleteAction
54
+ ? themeValues.menuItemColorDelete
55
+ : themeValues.menuItemColor
56
+ }
57
+ />
58
+ )}
59
+ {text && (
60
+ <Text
61
+ variant="pS"
62
+ weight={FONT_WEIGHT_SEMIBOLD}
63
+ fontFamily="Public Sans, sans-serif"
64
+ color={
65
+ isDeleteAction
66
+ ? themeValues.menuItemColorDelete
67
+ : themeValues.menuItemColor
68
+ }
69
+ extraStyles={textExtraStyles}
70
+ >
71
+ {text}
72
+ </Text>
73
+ )}
74
+ </Box>
75
+ </PopupMenuItemContainer>
76
+ );
77
+ };
78
+
79
+ export default themeComponent(PopupMenuItem, "PopupMenuItem", fallbackValues);
@@ -0,0 +1,27 @@
1
+ import styled from "styled-components";
2
+ import ButtonWithAction from "../../../atoms/button-with-action/ButtonWithAction";
3
+
4
+ export const PopupMenuItemContainer = styled(ButtonWithAction)`
5
+ width: 100%;
6
+ margin: 0;
7
+ padding: 17px 11px;
8
+ margin-bottom: 5px;
9
+ border: 0;
10
+ cursor: pointer;
11
+ text-decoration: none;
12
+ ${({ theme, isDeleteAction }) => `
13
+ background-color: ${theme.menuItemBackgroundColor};
14
+ color: ${isDeleteAction ? theme.menuItemColorDelete : theme.menuItemColor};
15
+ `}
16
+ &:hover,
17
+ &:active {
18
+ text-decoration: none;
19
+ ${({ theme, isDeleteAction }) => `
20
+ background-color: ${
21
+ isDeleteAction
22
+ ? theme.menuItemHoverBackgroundColorDelete
23
+ : theme.menuItemHoverBackgroundColor
24
+ };
25
+ `}
26
+ }
27
+ `;
@@ -0,0 +1,23 @@
1
+ import {
2
+ ROYAL_BLUE_VIVID,
3
+ CORNFLOWER_BLUE,
4
+ RAZZMATAZZ_RED,
5
+ BLUSH_RED,
6
+ WHITE
7
+ } from "../../../../constants/colors";
8
+
9
+ const menuItemBackgroundColor = WHITE;
10
+ const menuItemColor = ROYAL_BLUE_VIVID;
11
+ const menuItemColorDelete = RAZZMATAZZ_RED;
12
+ const menuItemHoverBackgroundColor = CORNFLOWER_BLUE;
13
+ const menuItemHoverBackgroundColorDelete = BLUSH_RED;
14
+ const menuItemHoverColor = ROYAL_BLUE_VIVID;
15
+
16
+ export const fallbackValues = {
17
+ menuItemBackgroundColor,
18
+ menuItemColor,
19
+ menuItemColorDelete,
20
+ menuItemHoverBackgroundColor,
21
+ menuItemHoverBackgroundColorDelete,
22
+ menuItemHoverColor
23
+ };