@thecb/components 10.6.0-beta.0 → 10.6.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.6.0-beta.0",
3
+ "version": "10.6.0-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -2,21 +2,21 @@ import React, { Fragment, useContext } from "react";
2
2
  import { Box } from "../layouts";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import ButtonWithAction from "../button-with-action";
5
- import { noop } from "../../../util/general";
6
5
  import Text from "../text/Text";
7
6
  import { ThemeContext } from "styled-components";
8
7
  import { fallbackValues } from "./WalletName.theme";
9
8
  import Module from "../../molecules/module/Module";
10
9
 
11
10
  const WalletName = ({
12
- mainText = "",
13
- action = noop,
14
- text = "Not you?",
15
- actionText = "Check out as a guest",
16
- themeValues
11
+ mainText,
12
+ action,
13
+ text,
14
+ actionText,
15
+ themeValues,
16
+ disableAction = false,
17
+ buttonExtraStyles = ""
17
18
  }) => {
18
- const themeContext = useContext(ThemeContext);
19
- const { isMobile } = themeContext;
19
+ const { isMobile } = useContext(ThemeContext);
20
20
 
21
21
  return (
22
22
  <Fragment>
@@ -28,7 +28,7 @@ const WalletName = ({
28
28
  margin="0 0 0 0"
29
29
  extraStyles={
30
30
  isMobile
31
- ? `display: flex; flex-direction: column; flex-wrap: wrap; span {text - align: right;}`
31
+ ? `display: flex; flex-direction: column; flex-wrap: wrap; span {text-align: right;}`
32
32
  : `display: flex; justify-content: space-between; align-items: center;`
33
33
  }
34
34
  >
@@ -37,17 +37,22 @@ const WalletName = ({
37
37
  </Box>
38
38
  {!isMobile && (
39
39
  <Box padding="0">
40
- <Text variant="pXS">{text}</Text>
41
- &nbsp;
42
- <ButtonWithAction
43
- text={actionText}
44
- action={action}
45
- variant="smallGhost"
46
- extraStyles="
47
- margin-left: 0;
40
+ {text && <Text variant="pXS">{text}</Text>}
41
+ {text && actionText && <>&nbsp;</>}
42
+ {action && actionText && (
43
+ <ButtonWithAction
44
+ disabled={disableAction}
45
+ text={actionText}
46
+ action={action}
47
+ variant="smallGhost"
48
+ extraStyles={`
49
+ margin: 0;
50
+ min-width: 0;
48
51
  span {font-size: 0.75rem;}
49
- "
50
- />
52
+ ${buttonExtraStyles}
53
+ `}
54
+ />
55
+ )}
51
56
  </Box>
52
57
  )}
53
58
  </Box>
@@ -57,13 +62,21 @@ const WalletName = ({
57
62
  padding="0 0 24px"
58
63
  extraStyles="display: flex; align-items: center; justify-content: flex-end;"
59
64
  >
60
- <Text extraStyles="font-size: 12px">{text}</Text>
61
- <ButtonWithAction
62
- text={actionText}
63
- action={action}
64
- variant="smallGhost"
65
- extraStyles="span {font-size: 12px;}"
66
- />
65
+ {text && <Text extraStyles="font-size: 12px">{text}</Text>}
66
+ {action && actionText && (
67
+ <ButtonWithAction
68
+ text={actionText}
69
+ action={action}
70
+ variant="smallGhost"
71
+ disabled={disableAction}
72
+ extraStyles={`
73
+ margin: 0;
74
+ min-width: 0;
75
+ span {font-size: 0.75rem;}
76
+ ${buttonExtraStyles}
77
+ `}
78
+ />
79
+ )}
67
80
  </Box>
68
81
  )}
69
82
  </Fragment>
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import WalletName from "./WalletName";
3
- import { text, object } from "@storybook/addon-knobs";
3
+ import { text, object, boolean } from "@storybook/addon-knobs";
4
4
  import page from "../../../../.storybook/page";
5
5
 
6
6
  export const walletName = () => {
@@ -10,6 +10,7 @@ export const walletName = () => {
10
10
  action={object("action", () => window.alert("action fired!"), "props")}
11
11
  actionText={text("actionText", "Check out as a guest", "props")}
12
12
  text={text("text", "Not you?", "props")}
13
+ disableAction={boolean("disableAction", false, "props")}
13
14
  />
14
15
  );
15
16
  };
@@ -1,9 +1,13 @@
1
- import { CHARADE_GREY, WHITE } from "../../../constants/colors";
1
+ import { CHARADE_GREY, ROYAL_BLUE, WHITE } from "../../../constants/colors";
2
2
 
3
3
  const backgroundColor = {
4
4
  primary: WHITE
5
5
  };
6
6
 
7
+ const color = {
8
+ primary: ROYAL_BLUE
9
+ };
10
+
7
11
  const boxShadow = {
8
12
  primary: `box-shadow: 0px 1px 2px 0px rgba(${CHARADE_GREY}, 0.1);
9
13
  box-shadow: 0px 2px 6px 0px rgba(${CHARADE_GREY}, 0.2);
@@ -12,5 +16,6 @@ const boxShadow = {
12
16
 
13
17
  export const fallbackValues = {
14
18
  backgroundColor,
19
+ color,
15
20
  boxShadow
16
21
  };
@@ -3,9 +3,11 @@ import Expand from "../../../util/expand";
3
3
 
4
4
  export interface WalletNameProps {
5
5
  action?: () => void;
6
- text?: string;
7
- actionText?: string;
8
- mainText?: string;
6
+ text: string;
7
+ actionText: string;
8
+ mainText: string;
9
+ disableAction?: boolean;
10
+ buttonExtraStyles?: string;
9
11
  }
10
12
 
11
13
  export const WalletName: React.FC<Expand<WalletNameProps> &
@@ -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,39 @@
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
+
6
+ export const CloseIconButton = ({
7
+ buttonExtraStyles = "",
8
+ hideModal = noop,
9
+ iconWidth = "24",
10
+ iconHeight = "24",
11
+ ariaLabel = "Close Modal"
12
+ }) => {
13
+ return (
14
+ <ButtonWithAction
15
+ action={hideModal}
16
+ aria-label={ariaLabel}
17
+ contentOverride
18
+ extraStyles={`
19
+ min-height: auto;
20
+ min-width: auto;
21
+ height: 1.5rem;
22
+ margin: 0 0 0 0.5rem;
23
+ &:focus {
24
+ outline-offset: -3px;
25
+ }
26
+ `}
27
+ variant="smallGhost"
28
+ >
29
+ <CloseIcon
30
+ role="img"
31
+ aria-hidden="true"
32
+ iconWidth={iconWidth}
33
+ iconHeight={iconHeight}
34
+ />
35
+ </ButtonWithAction>
36
+ );
37
+ };
38
+
39
+ 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";
@@ -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";