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

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.3",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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";
@@ -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;