@thecb/components 11.8.0-beta.2 → 11.8.0-beta.4

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": "11.8.0-beta.2",
3
+ "version": "11.8.0-beta.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  APRICOT_ORANGE,
3
+ INFO_BLUE,
3
4
  BLUSH_RED,
4
5
  HINT_GREEN,
5
6
  ZEST_ORANGE,
7
+ MATISSE_BLUE,
6
8
  RAZZMATAZZ_RED,
7
9
  EMERALD_GREEN,
8
10
  MUSTARD_YELLOW,
@@ -14,20 +16,18 @@ import {
14
16
  THUNDERBIRD_RED,
15
17
  HAZE_GREEN,
16
18
  ZODIAC_BLUE,
17
- SCIENCE_BLUE,
18
- LUCKY_POINT,
19
- HAWKES_BLUE
19
+ SCIENCE_BLUE
20
20
  } from "../../../constants/colors";
21
21
 
22
22
  const background = {
23
- info: `${HAWKES_BLUE}`,
23
+ info: `${INFO_BLUE}`,
24
24
  warn: `${APRICOT_ORANGE}`,
25
25
  error: `${BLUSH_RED}`,
26
26
  success: `${HINT_GREEN}`
27
27
  };
28
28
 
29
29
  const border = {
30
- info: `${LUCKY_POINT}`,
30
+ info: `${MATISSE_BLUE}`,
31
31
  warn: `${ZEST_ORANGE}`,
32
32
  error: `${RAZZMATAZZ_RED}`,
33
33
  success: `${EMERALD_GREEN}`
@@ -13,7 +13,6 @@ export { default as SortableTableHeading } from "./sortable-table-heading";
13
13
  export { default as CountryDropdown } from "./country-dropdown";
14
14
  export { default as Detail } from "./detail";
15
15
  export { default as DisplayBox } from "./display-box";
16
- export { default as DisplayCard } from "./display-card";
17
16
  export { default as Dropdown } from "./dropdown";
18
17
  export * from "./form-layouts";
19
18
  export { default as FormSelect } from "./form-select";
@@ -31,15 +31,20 @@ const PaymentButtonBar = ({
31
31
  }) => {
32
32
  const { isMobile } = useContext(ThemeContext);
33
33
 
34
+ // cancel URLs are external (back to client system)
35
+ const handleCancel = () => {
36
+ window.location.href = cancelURL;
37
+ };
38
+
34
39
  const backButton =
35
40
  !!cancelURL && !!cancelText ? (
36
- <ButtonWithLink
41
+ <ButtonWithAction
37
42
  text={cancelText}
38
- url={cancelURL}
43
+ action={handleCancel}
39
44
  variant={backButtonVariant}
40
45
  extraStyles={isMobile && "flex-grow: 1"}
41
46
  dataQa={backButtonTestId || cancelText}
42
- aria-labelledby={`${kebabCaseString(cancelText)}-button`}
47
+ aria-label={`${cancelText}, navigate back to previous site`}
43
48
  role="link"
44
49
  />
45
50
  ) : (
@@ -50,7 +55,7 @@ const PaymentButtonBar = ({
50
55
  action={backButtonAction}
51
56
  extraStyles={isMobile && "flex-grow: 1"}
52
57
  dataQa="Back"
53
- aria-labelledby="back-button"
58
+ aria-label={"Back, navigate to previous page"}
54
59
  role="link"
55
60
  />
56
61
  )
@@ -7,8 +7,8 @@ import ButtonWithAction from "../../atoms/button-with-action";
7
7
  import { noop } from "../../../util/general";
8
8
  import { ESCAPE } from "../../../constants/keyboard";
9
9
  import { fallbackValues } from "./Tooltip.theme";
10
- import IconAdd from "../../atoms/icons/IconAdd";
11
- import { BLACK } from "../../../constants/colors";
10
+ import WarningIconXS from "../../atoms/icons/WarningIconXS";
11
+ import { SELECTIVE_YELLOW } from "../../../constants/colors";
12
12
 
13
13
  const arrowBorder = (borderColor, direction, width = "8px") => {
14
14
  const angle = `${width} solid transparent`;
@@ -29,32 +29,36 @@ const Tooltip = ({
29
29
  triggerText = "",
30
30
  content = "",
31
31
  hasIconTrigger = false,
32
- IconTrigger = IconAdd,
32
+ IconTrigger = WarningIconXS,
33
33
  iconHelpText = "",
34
- tooltipID = 0,
35
- extraStyles,
34
+ tooltipID = "tooltip-content",
35
+ extraStyles = "",
36
36
  textExtraStyles = "",
37
37
  minWidth = "250px",
38
38
  maxWidth = "300px",
39
39
  height = "auto",
40
- position,
41
- arrowPosition,
42
40
  arrowDirection = "down",
43
- transform = "none",
41
+ arrowPosition = {
42
+ arrowTop: "auto",
43
+ arrowRight: "10px",
44
+ arrowBottom: "-8px",
45
+ arrowLeft: "auto"
46
+ },
47
+ position = {
48
+ top: "-110px",
49
+ right: "auto",
50
+ bottom: "auto",
51
+ left: "-225px"
52
+ },
53
+ iconColor = SELECTIVE_YELLOW,
44
54
  buttonExtraStyles,
45
55
  backgroundColor = "white",
46
56
  borderColor = "rgba(255, 255, 255, 0.85)",
47
- tooltipExtraStyles
57
+ tooltipContentExtraStyles
48
58
  }) => {
49
59
  const { hoverColor, activeColor, tooltipTriggerColor } = themeValues;
50
- const { top = "-110px", right = "auto", bottom = "auto", left = "-225px" } =
51
- position ?? {};
52
- const {
53
- arrowTop = "auto",
54
- arrowRight = "10px",
55
- arrowBottom = "-8px",
56
- arrowLeft = "auto"
57
- } = arrowPosition ?? {};
60
+ const { top, right, bottom, left } = position ?? {};
61
+ const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition ?? {};
58
62
 
59
63
  const [tooltipOpen, setTooltipOpen] = useState(false);
60
64
 
@@ -89,8 +93,10 @@ const Tooltip = ({
89
93
  >
90
94
  {hasIconTrigger && (
91
95
  <>
92
- <IconTrigger stroke={BLACK} />
93
- <Box padding="0" srOnly>
96
+ <Box aria-label="Trigger Popover">
97
+ <IconTrigger color={iconColor} />
98
+ </Box>
99
+ <Box padding="0" srOnly aria-hidden="true">
94
100
  <Text>{iconHelpText}</Text>
95
101
  </Box>
96
102
  </>
@@ -107,6 +113,7 @@ const Tooltip = ({
107
113
  role="tooltip"
108
114
  minWidth={minWidth}
109
115
  maxWidth={maxWidth}
116
+ aria-hidden={!tooltipOpen}
110
117
  extraStyles={`
111
118
  display: ${tooltipOpen ? "block" : "none"};
112
119
  position: absolute;
@@ -115,8 +122,7 @@ const Tooltip = ({
115
122
  bottom: ${bottom};
116
123
  left: ${left};
117
124
  height: ${height};
118
- transform: ${transform};
119
- ${tooltipExtraStyles};
125
+ ${tooltipContentExtraStyles};
120
126
  `}
121
127
  >
122
128
  <Paragraph>{content}</Paragraph>
@@ -1,6 +1,5 @@
1
1
  import Tooltip from "./Tooltip";
2
- import IconAdd from "../../atoms/icons/IconAdd";
3
-
2
+ import WarningIconXS from "../../atoms/icons/WarningIconXS";
4
3
  export default {
5
4
  title: "Molecules/Tooltip",
6
5
  component: Tooltip,
@@ -13,7 +12,7 @@ export default {
13
12
  triggerText: "",
14
13
  content: "",
15
14
  hasIconTrigger: false,
16
- IconTrigger: IconAdd,
15
+ IconTrigger: WarningIconXS,
17
16
  iconHelpText: "",
18
17
  tooltipID: 0,
19
18
  extraStyles: undefined,
@@ -59,7 +58,7 @@ export default {
59
58
  "The icon component to display. Requires hasIcon to be true.",
60
59
  table: {
61
60
  type: { summary: "React Component" },
62
- defaultValue: { summary: "IconAdd" }
61
+ defaultValue: { summary: "WarningIconXS" }
63
62
  }
64
63
  },
65
64
  iconHelpText: {
@@ -186,7 +185,7 @@ export const BasicTooltip = {
186
185
  export const IconTooltip = {
187
186
  args: {
188
187
  hasIconTrigger: true,
189
- IconTrigger: IconAdd,
188
+ IconTrigger: WarningIconXS,
190
189
  content:
191
190
  "Contact support at 1-800-CTY-VILL for help with your account balance."
192
191
  }
@@ -31,7 +31,7 @@ export const AlertInfoIcon = () => (
31
31
  </mask>
32
32
  <use
33
33
  id="background-2"
34
- fill="#281978"
34
+ fill="#15749d"
35
35
  fillRule="nonzero"
36
36
  xlinkHref="#path-1"
37
37
  ></use>
@@ -1,127 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import Stack from "../layouts/Stack";
3
- import Box from "../layouts/Box";
4
- import Text from "../text";
5
- import Paragraph from "../paragraph";
6
- import Cluster from "../layouts/Cluster";
7
- import ButtonWithAction from "../button-with-action";
8
- import ButtonWithLink from "../button-with-link";
9
- import { WHITE, CHARADE_GREY, STORM_GREY } from "../../../constants/colors";
10
- import Popover from "../../molecules/popover";
11
- import Tooltip from "../../molecules/tooltip";
12
- import { Link } from "react-router-dom";
13
-
14
- const DisplayCard = ({
15
- title,
16
- item,
17
- buttonText,
18
- buttonAction,
19
- url,
20
- link = false,
21
- linkText,
22
- linkURL,
23
- linkExtraStyles = "",
24
- helpText,
25
- hasTooltip = false,
26
- tooltipTriggerText = "",
27
- tooltipContent = "",
28
- tooltipPosition = {
29
- top: "auto",
30
- bottom: "calc(100% + 0.25rem)",
31
- left: "auto",
32
- right: "0"
33
- },
34
- tooltipArrowPosition = {
35
- arrowBottom: "-0.5rem",
36
- arrowRight: "0.625rem",
37
- arrowTop: "auto",
38
- arrowLeft: "auto"
39
- },
40
- tooltipArrowDirection,
41
- tooltipExtraStyles,
42
- tooltipTextExtraStyles = `max-width: 300px;`,
43
- hasPopover = false,
44
- popoverTriggerText = "",
45
- popoverContent = "",
46
- popoverExtraStyles,
47
- popoverTextExtraStyles
48
- }) => (
49
- <Box padding="0 0 16px">
50
- <Stack childGap="0rem">
51
- <Box padding="0 0 8px 0">
52
- <Cluster justify="space-between" align="center" overflow>
53
- <Paragraph
54
- variant="pL"
55
- color={CHARADE_GREY}
56
- extraStyles={`letter-spacing: 0.29px`}
57
- >
58
- {title}
59
- </Paragraph>
60
- {hasPopover && (
61
- <Popover
62
- triggerText={popoverTriggerText}
63
- content={popoverContent}
64
- popoverExtraStyles={popoverExtraStyles}
65
- popoverTextExtraStyles={popoverTextExtraStyles}
66
- />
67
- )}
68
- {hasTooltip && (
69
- <Tooltip
70
- triggerText={tooltipTriggerText}
71
- content={tooltipContent}
72
- textExtraStyles={tooltipTextExtraStyles}
73
- position={tooltipPosition}
74
- arrowPosition={tooltipArrowPosition}
75
- arrowDirection={tooltipArrowDirection}
76
- tooltipExtraStyles={tooltipExtraStyles}
77
- />
78
- )}
79
- </Cluster>
80
- </Box>
81
- <Box padding="0">
82
- <Box
83
- padding="24px"
84
- borderSize="1px"
85
- borderRadius="4px"
86
- background={WHITE}
87
- boxShadow="0px 2px 14px 0px rgb(246, 246, 249),
88
- 0px 3px 8px 0px rgb(202, 206, 216)"
89
- >
90
- <Cluster justify="space-between" align="center">
91
- <Text color={CHARADE_GREY}>{item}</Text>
92
- {linkText && linkURL && (
93
- <Link to={linkURL} extraStyles={linkExtraStyles}>
94
- {linkText}
95
- </Link>
96
- )}
97
- {link ? (
98
- <ButtonWithLink
99
- text={buttonText}
100
- url={url}
101
- variant="smallGhost"
102
- dataQa={buttonText}
103
- extraStyles={`min-width: 0;`}
104
- />
105
- ) : buttonAction ? (
106
- <ButtonWithAction
107
- text={buttonText}
108
- action={buttonAction}
109
- variant="smallGhost"
110
- dataQa={buttonText}
111
- extraStyles={`min-width: 0;`}
112
- />
113
- ) : helpText ? (
114
- <Text color={STORM_GREY} extraStyles={`font-style: italic;`}>
115
- {helpText}
116
- </Text>
117
- ) : (
118
- <Fragment />
119
- )}
120
- </Cluster>
121
- </Box>
122
- </Box>
123
- </Stack>
124
- </Box>
125
- );
126
-
127
- export default DisplayCard;
@@ -1,13 +0,0 @@
1
- import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
2
-
3
- import * as DisplayCardStories from './DisplayCard.stories.js';
4
-
5
- <Meta of={DisplayCardStories} />
6
-
7
- <Title />
8
-
9
- The DisplayCard component offers a consistent box style for text content. A link, button, or "help" text is also supported, which will be displayed with the text in a flexbox with any extra space rendered in-between. DisplayCard also supports an optional tooltip with the Popover molecule, and a title.
10
-
11
- Note: DisplyCard is _not_ themeable or styleable except for the Popover box.
12
-
13
- <Story />
@@ -1,274 +0,0 @@
1
- import DisplayCard from "./DisplayCard";
2
- import React from "react";
3
- import { fn } from "@storybook/test";
4
-
5
- const meta = {
6
- title: "Atoms/DisplayCard",
7
- component: DisplayCard,
8
- parameters: {
9
- layout: "centered",
10
- controls: { expanded: true }
11
- },
12
- tags: ["!autodocs"],
13
- args: {
14
- title: "Display Card",
15
- item: "Item text",
16
- buttonText: undefined,
17
- buttonAction: undefined,
18
- url: undefined,
19
- link: false,
20
- linkText: undefined,
21
- linkURL: undefined,
22
- linkExtraStyles: "",
23
- helpText: undefined,
24
- hasTooltip: false,
25
- tooltipTriggerText: "",
26
- tooltipContent: "",
27
- tooltipPosition: undefined,
28
- tooltipArrowPosition: undefined,
29
- tooltipArrowDirection: undefined,
30
- tooltipExtraStyles: undefined,
31
- tooltipTextExtraStyles: undefined,
32
- hasPopover: false,
33
- popoverTriggerText: "",
34
- popoverContent: "",
35
- popoverExtraStyles: undefined,
36
- popoverTextExtraStyles: undefined
37
- },
38
- argTypes: {
39
- title: {
40
- description: "Text that appears above the box",
41
- table: {
42
- type: { summary: "string" },
43
- defaultValue: { summary: undefined }
44
- }
45
- },
46
- item: {
47
- description: "Text that appears in the box",
48
- table: {
49
- type: { summary: "string" },
50
- defaultValue: { summary: undefined }
51
- }
52
- },
53
- buttonText: {
54
- description: "Text for the button or link",
55
- table: {
56
- type: { summary: "string" },
57
- defaultValue: { summary: undefined }
58
- }
59
- },
60
- buttonAction: {
61
- description: "Callback function for the button",
62
- table: {
63
- type: { summary: "function" },
64
- defaultValue: { summary: undefined }
65
- }
66
- },
67
- url: {
68
- description: "URL for the link",
69
- table: {
70
- type: { summary: "string" },
71
- defaultValue: { summary: undefined }
72
- }
73
- },
74
- link: {
75
- description:
76
- "Whether or not to display a link, uses the `url` and `buttonText` props",
77
- table: {
78
- type: { summary: "boolean" },
79
- defaultValue: { summary: false }
80
- }
81
- },
82
- linkText: {
83
- description:
84
- "Text for the inline react-router Link rendered next to the item",
85
- table: {
86
- type: { summary: "string" },
87
- defaultValue: { summary: undefined }
88
- }
89
- },
90
- linkURL: {
91
- description: "Route path for the inline react-router Link",
92
- table: {
93
- type: { summary: "string" },
94
- defaultValue: { summary: undefined }
95
- }
96
- },
97
- linkExtraStyles: {
98
- description: "Extra CSS styles to apply to the link",
99
- table: {
100
- type: { summary: "string" },
101
- defaultValue: { summary: "" }
102
- }
103
- },
104
- helpText: {
105
- description:
106
- "Text rendered to the right of the `item` text and styled as italic.",
107
- table: {
108
- type: { summary: "string" },
109
- defaultValue: { summary: undefined }
110
- }
111
- },
112
- hasTooltip: {
113
- description: "Whether or not to render Tooltip component",
114
- table: {
115
- type: { summary: "boolean" },
116
- defaultValue: { summary: false }
117
- }
118
- },
119
- tooltipTriggerText: {
120
- description: "Text that triggers the tooltip",
121
- table: {
122
- type: { summary: "string" },
123
- defaultValue: { summary: "" }
124
- }
125
- },
126
- tooltipContent: {
127
- description: "Content displayed inside the tooltip",
128
- table: {
129
- type: { summary: "string" },
130
- defaultValue: { summary: "" }
131
- }
132
- },
133
- tooltipPosition: {
134
- description:
135
- "Object with top/right/bottom/left values for tooltip position relative to trigger",
136
- table: {
137
- type: { summary: "Object" },
138
- defaultValue: { summary: undefined }
139
- }
140
- },
141
- tooltipArrowPosition: {
142
- description:
143
- "Object with arrowTop/arrowRight/arrowBottom/arrowLeft values for the tooltip arrow",
144
- table: {
145
- type: { summary: "Object" },
146
- defaultValue: { summary: undefined }
147
- }
148
- },
149
- tooltipArrowDirection: {
150
- description: "Direction the tooltip arrow points",
151
- table: {
152
- type: { summary: "string" },
153
- defaultValue: { summary: undefined }
154
- }
155
- },
156
- tooltipExtraStyles: {
157
- description: "Extra CSS styles to apply to the tooltip",
158
- table: {
159
- type: { summary: "string" },
160
- defaultValue: { summary: undefined }
161
- }
162
- },
163
- tooltipTextExtraStyles: {
164
- description: "Extra CSS styles for the tooltip trigger text",
165
- table: {
166
- type: { summary: "string" },
167
- defaultValue: { summary: "max-width: 300px;" }
168
- }
169
- },
170
- hasPopover: {
171
- description: "Whether or not to render Popover component",
172
- table: {
173
- type: { summary: "boolean" },
174
- defaultValue: { summary: false }
175
- }
176
- },
177
- popoverTriggerText: {
178
- table: {
179
- type: { summary: "string" },
180
- defaultValue: { summary: "" }
181
- }
182
- },
183
- popoverContent: {
184
- table: {
185
- type: { summary: "string" },
186
- defaultValue: { summary: "" }
187
- }
188
- },
189
- popoverExtraStyles: {
190
- description: "Styles for the Box that wraps the Popover content.",
191
- table: {
192
- type: { summary: "string" },
193
- defaultValue: { summary: undefined }
194
- }
195
- },
196
- popoverTextExtraStyles: {
197
- description: "Prop passed to the Popover component, but is not used.",
198
- table: {
199
- type: { summary: "string" },
200
- defaultValue: { summary: undefined }
201
- }
202
- }
203
- }
204
- };
205
-
206
- export default meta;
207
-
208
- export const Basic = {
209
- render: args => <DisplayCard {...args} />
210
- };
211
-
212
- export const WithExternalLink = {
213
- args: {
214
- buttonText: "Link",
215
- url: "https://example.com",
216
- link: true
217
- },
218
- render: args => <DisplayCard {...args} />
219
- };
220
-
221
- export const WithRouterLink = {
222
- args: {
223
- linkText: "View details",
224
- linkURL: "#",
225
- linkExtraStyles: "text-decoration: none;"
226
- },
227
- render: args => <DisplayCard {...args} />
228
- };
229
-
230
- export const WithButtonAction = {
231
- args: {
232
- buttonText: "Button",
233
- buttonAction: fn()
234
- },
235
- render: args => <DisplayCard {...args} />
236
- };
237
-
238
- export const WithHelpText = {
239
- parameters: {
240
- layout: "padded"
241
- },
242
- args: {
243
- helpText: "Help!"
244
- },
245
- render: args => <DisplayCard {...args} />
246
- };
247
-
248
- export const WithPopover = {
249
- args: {
250
- hasPopover: true,
251
- popoverTriggerText: "Popover",
252
- popoverContent: "This is example popover content!"
253
- },
254
- render: args => <DisplayCard {...args} />
255
- };
256
-
257
- export const WithTooltip = {
258
- args: {
259
- hasTooltip: true,
260
- tooltipTriggerText: "What's this?",
261
- tooltipContent: "This is example tooltip content!"
262
- },
263
- render: args => <DisplayCard {...args} />
264
- };
265
-
266
- export const WithPopoverAndExtraStyles = {
267
- args: {
268
- hasPopover: true,
269
- popoverTriggerText: "Popover",
270
- popoverContent: "This is example popover content!",
271
- popoverExtraStyles: "padding: 4px 8px"
272
- },
273
- render: args => <DisplayCard {...args} />
274
- };
@@ -1,3 +0,0 @@
1
- import DisplayCard from "./DisplayCard";
2
-
3
- export default DisplayCard;