@thecb/components 10.5.1-beta.3 → 10.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.5.1-beta.3",
3
+ "version": "10.5.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -90,6 +90,6 @@
90
90
  "ramda": "^0.27.0",
91
91
  "react-aria-modal": "^4.0.0",
92
92
  "react-pose": "^4.0.10",
93
- "redux-freeform": "^5.9.0"
93
+ "redux-freeform": "^5.8.0"
94
94
  }
95
95
  }
@@ -76,6 +76,7 @@ export const modalV2 = () => (
76
76
  noButtons={boolean("noButtons", false, groupId)}
77
77
  onlyCloseButton={boolean("onlyCloseButton", false, groupId)}
78
78
  onlyContinueButton={boolean("onlyContinueButton", false, groupId)}
79
+ showCloseIconButton={boolean("showCloseIconButton", true, groupId)}
79
80
  useDangerButton={boolean("useDangerButton", false, groupId)}
80
81
  />
81
82
  );
@@ -18,6 +18,7 @@ import {
18
18
  ButtonLayoutWrapper,
19
19
  CancelButton,
20
20
  CloseButton,
21
+ CloseIconButton,
21
22
  ContinueButton
22
23
  } from "./__private__";
23
24
 
@@ -38,10 +39,12 @@ const Modal = ({
38
39
  buttonExtraStyles = "",
39
40
  cancelAction = noop,
40
41
  cancelButtonText = "Cancel",
42
+ cancelButtonVariant = "secondary",
41
43
  children = [],
42
44
  closeButtonText = "Close",
43
45
  continueAction = noop,
44
46
  continueButtonText = "Continue",
47
+ continueButtonVariant = "primary",
45
48
  continueURL = "",
46
49
  customWidth = "",
47
50
  dataQa = null,
@@ -60,6 +63,7 @@ const Modal = ({
60
63
  onExit = hideModal,
61
64
  onlyCloseButton = false,
62
65
  onlyContinueButton = false,
66
+ showCloseIconButton = false,
63
67
  underlayClickExits = true,
64
68
  useDangerButton = false
65
69
  }) => {
@@ -108,7 +112,7 @@ const Modal = ({
108
112
  borderRadius: BORDER_RADIUS.MD,
109
113
  margin: SPACING.XS,
110
114
  overflow: "auto",
111
- width: isMobile ? "" : customWidth || "615px"
115
+ width: isMobile ? "" : customWidth || "576px"
112
116
  }}
113
117
  underlayClickExits={underlayClickExits}
114
118
  aria-modal={true}
@@ -122,7 +126,13 @@ const Modal = ({
122
126
  borderWidthOverride={`0 0 ${BORDER_THIN} 0`}
123
127
  padding={`${SPACING.XS} ${SPACING.MD}`}
124
128
  >
125
- <Cluster justify="flex-start" align="center">
129
+ <Cluster
130
+ justify={showCloseIconButton ? "space-between" : "flex-start"}
131
+ align={
132
+ showCloseIconButton && isMobile ? "flex-start" : "center"
133
+ }
134
+ nowrap
135
+ >
126
136
  <Title
127
137
  as="h2"
128
138
  weight={FONT_WEIGHT_SEMIBOLD}
@@ -130,6 +140,9 @@ const Modal = ({
130
140
  >
131
141
  {modalHeaderText}
132
142
  </Title>
143
+ {showCloseIconButton && (
144
+ <CloseIconButton hideModal={hideModal} />
145
+ )}
133
146
  </Cluster>
134
147
  </Box>
135
148
  <Box background={modalBodyBg || ATHENS_GREY} padding="0">
@@ -161,6 +174,7 @@ const Modal = ({
161
174
  buttonExtraStyles={buttonExtraStyles}
162
175
  cancelAction={cancelAction}
163
176
  cancelButtonText={cancelButtonText}
177
+ cancelButtonVariant={cancelButtonVariant}
164
178
  hideModal={hideModal}
165
179
  isMobile={isMobile}
166
180
  key="cancel"
@@ -172,6 +186,7 @@ const Modal = ({
172
186
  continueAction={continueAction}
173
187
  continueButtonText={continueButtonText}
174
188
  continueURL={continueURL}
189
+ continueButtonVariant={continueButtonVariant}
175
190
  isContinueActionDisabled={isContinueActionDisabled}
176
191
  isLoading={isLoading}
177
192
  isMobile={isMobile}
@@ -10,6 +10,7 @@ export const CancelButton = ({
10
10
  buttonExtraStyles = "",
11
11
  cancelAction = noop,
12
12
  cancelButtonText = "",
13
+ cancelButtonVariant = "secondary",
13
14
  hideModal = noop,
14
15
  isMobile = false
15
16
  }) => {
@@ -27,7 +28,7 @@ export const CancelButton = ({
27
28
  role="button"
28
29
  text={cancelButtonText}
29
30
  textExtraStyles={`${fontSize}`}
30
- variant="secondary"
31
+ variant={cancelButtonVariant}
31
32
  />
32
33
  );
33
34
  };
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import { noop } from "../../../../util/general";
3
+ import ButtonWithAction from "../../../atoms/button-with-action/ButtonWithAction";
4
+ import { CloseIcon } from "../../../atoms/icons/CloseIcon";
5
+ import { button } from "@storybook/addon-knobs";
6
+
7
+ export const CloseIconButton = ({
8
+ buttonExtraStyles = "",
9
+ hideModal = noop,
10
+ iconWidth = "24",
11
+ iconHeight = "24",
12
+ ariaLabel = "Close Modal"
13
+ }) => {
14
+ return (
15
+ <ButtonWithAction
16
+ action={hideModal}
17
+ aria-label={ariaLabel}
18
+ contentOverride
19
+ extraStyles={`
20
+ min-height: auto;
21
+ min-width: auto;
22
+ height: 1.5rem;
23
+ margin: 0 0 0 0.5rem;
24
+ &:focus {
25
+ outline-offset: -3px;
26
+ }
27
+ `}
28
+ variant="smallGhost"
29
+ >
30
+ <CloseIcon
31
+ role="img"
32
+ aria-hidden="true"
33
+ iconWidth={iconWidth}
34
+ iconHeight={iconHeight}
35
+ />
36
+ </ButtonWithAction>
37
+ );
38
+ };
39
+
40
+ export default CloseIconButton;
@@ -12,6 +12,7 @@ export const ContinueButton = ({
12
12
  continueAction = noop,
13
13
  continueButtonText = "",
14
14
  continueURL = "",
15
+ continueButtonVariant = "primary",
15
16
  isContinueActionDisabled = false,
16
17
  isLoading = false,
17
18
  isMobile = false,
@@ -36,7 +37,7 @@ export const ContinueButton = ({
36
37
  text={continueButtonText}
37
38
  textExtraStyles={`${fontSize}`}
38
39
  url={continueURL}
39
- variant={useDangerButton ? "danger" : "primary"}
40
+ variant={useDangerButton ? "danger" : continueButtonVariant}
40
41
  />
41
42
  );
42
43
  };
@@ -14,6 +14,7 @@ export interface CancelButtonProps {
14
14
  buttonExtraStyles?: string;
15
15
  cancelAction?: Function;
16
16
  cancelButtonText?: string;
17
+ cancelButtonVariant?: string;
17
18
  hideModal?: Function;
18
19
  isMobile?: boolean;
19
20
  }
@@ -31,11 +32,23 @@ export interface CloseButtonProps {
31
32
  export declare const CloseButton: React.FC<Expand<CloseButtonProps> &
32
33
  React.HTMLAttributes<HTMLElement>>;
33
34
 
35
+ export interface CloseIconButtonProps {
36
+ buttonExtraStyles?: string;
37
+ hideModal?: action;
38
+ iconWidth?: string;
39
+ iconHeight?: string;
40
+ ariaLabel?: string;
41
+ }
42
+
43
+ export declare const CloseIconButton: React.FC<Expand<CloseIconButtonProps> &
44
+ React.HTMLAttributes<HTMLElement>>;
45
+
34
46
  export interface ContinueButtonProps {
35
47
  buttonExtraStyles?: string;
36
48
  continueAction?: Function;
37
49
  continueButtonText?: string;
38
50
  continueURL?: string;
51
+ continueButtonVariant?: string;
39
52
  isContinueActionDisabled?: boolean;
40
53
  isLoading?: boolean;
41
54
  isMobile?: boolean;
@@ -1,4 +1,5 @@
1
1
  export { default as ButtonLayoutWrapper } from "./ButtonLayoutWrapper";
2
2
  export { default as CancelButton } from "./CancelButton";
3
3
  export { default as CloseButton } from "./CloseButton";
4
+ export { default as CloseIconButton } from "./CloseIconButton";
4
5
  export { default as ContinueButton } from "./ContinueButton";
@@ -7,8 +7,7 @@ import {
7
7
  hasLowercaseLetter,
8
8
  hasUppercaseLetter,
9
9
  hasSpecialCharacter,
10
- isProbablyEmail,
11
- validName
10
+ isProbablyEmail
12
11
  } from "redux-freeform";
13
12
  import PasswordRequirements from "../../atoms/password-requirements";
14
13
  import { Box } from "../../atoms/layouts";
@@ -27,12 +26,10 @@ const RegistrationForm = ({
27
26
  useEffect(() => () => actions.form.clear(), []);
28
27
  }
29
28
  const firstNameErrorMessages = {
30
- [required.error]: "First name is required",
31
- [validName.error]: "First name contains invalid characters"
29
+ [required.error]: "First name is required"
32
30
  };
33
31
  const lastNameErrorMessages = {
34
- [required.error]: "Last name is required",
35
- [validName.error]: "Last name contains invalid characters"
32
+ [required.error]: "Last name is required"
36
33
  };
37
34
  const emailErrorMessages = {
38
35
  [required.error]: "Email is required",
@@ -7,16 +7,15 @@ import {
7
7
  hasLowercaseLetter,
8
8
  hasUppercaseLetter,
9
9
  hasSpecialCharacter,
10
- isProbablyEmail,
11
- validName
10
+ isProbablyEmail
12
11
  } from "redux-freeform";
13
12
 
14
13
  const formConfig = {
15
14
  firstName: {
16
- validators: [required(), validName()]
15
+ validators: [required()]
17
16
  },
18
17
  lastName: {
19
- validators: [required(), validName()]
18
+ validators: [required()]
20
19
  },
21
20
  email: {
22
21
  validators: [required(), isProbablyEmail()]
@@ -8,7 +8,8 @@ export const FONT_SIZE = {
8
8
  XS: "0.750rem", // 12px
9
9
  SM: "0.875rem", // 14px
10
10
  MD: "1.000rem", // 16px
11
- LG: "1.125rem" // 18px
11
+ LG: "1.125rem", // 18px
12
+ XL: "1.250rem" //20px
12
13
  };
13
14
  export const FONT_WEIGHT_REGULAR = "400";
14
15
  export const FONT_WEIGHT_SEMIBOLD = "600";
Binary file