@thecb/components 11.10.1-beta.2 → 11.10.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/README.md +8 -4
- package/dist/index.cjs.js +115 -94
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +115 -94
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/card-type/CardType.js +10 -2
- package/src/components/atoms/dropdown/Dropdown.js +2 -3
- package/src/components/atoms/dropdown/DropdownIcon.js +1 -0
- package/src/components/atoms/dropdown/DropdownIconV2.js +1 -0
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +10 -7
- package/src/components/atoms/icons/AmExSmallIcon.js +2 -0
- package/src/components/atoms/icons/DiscoverSmallIcon.js +2 -0
- package/src/components/atoms/icons/GenericCardLarge.js +1 -1
- package/src/components/atoms/icons/GenericSmallIcon.js +2 -0
- package/src/components/atoms/icons/MasterCardSmallIcon.js +2 -0
- package/src/components/atoms/icons/VisaSmallIcon.js +2 -0
- package/src/components/molecules/radio-section/InnerRadioSection.js +2 -2
- package/src/components/molecules/tooltip/Tooltip.js +93 -65
- package/src/components/molecules/tooltip/Tooltip.mdx +2 -12
- package/src/components/molecules/tooltip/Tooltip.stories.js +71 -93
- package/src/components/molecules/tooltip/Tooltip.theme.js +5 -15
- package/src/components/molecules/tooltip/index.d.ts +7 -4
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Tooltip from "./Tooltip";
|
|
3
|
-
import
|
|
4
|
-
import AutopayOnIcon from "../../atoms/icons/AutopayOnIcon";
|
|
5
|
-
import Box from "../../atoms/layouts/Box";
|
|
6
|
-
import { SEA_GREEN } from "../../../constants/colors";
|
|
3
|
+
import WarningIconXS from "../../atoms/icons/WarningIconXS";
|
|
7
4
|
|
|
8
5
|
const meta = {
|
|
9
6
|
title: "Molecules/Tooltip",
|
|
@@ -21,8 +18,11 @@ const meta = {
|
|
|
21
18
|
],
|
|
22
19
|
args: {
|
|
23
20
|
tooltipID: "tooltip-id",
|
|
21
|
+
hasIconTrigger: false,
|
|
22
|
+
IconTrigger: WarningIconXS,
|
|
23
|
+
iconHelpText: "Open the tooltip",
|
|
24
24
|
triggerText: "Hover me",
|
|
25
|
-
|
|
25
|
+
tooltipContent: "The contents of the tooltip go here.",
|
|
26
26
|
contentPosition: {
|
|
27
27
|
top: "-110px",
|
|
28
28
|
right: "auto",
|
|
@@ -40,56 +40,71 @@ const meta = {
|
|
|
40
40
|
maxWidth: "300px",
|
|
41
41
|
height: "auto",
|
|
42
42
|
containerExtraStyles: "",
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
triggerExtraStyles: "",
|
|
44
|
+
triggerButtonVariant: "smallGhost",
|
|
45
|
+
contentBackgroundColor: "",
|
|
46
|
+
contentExtraStyles: ""
|
|
45
47
|
},
|
|
46
48
|
argTypes: {
|
|
47
|
-
|
|
49
|
+
tooltipID: {
|
|
48
50
|
description:
|
|
49
|
-
"
|
|
51
|
+
"Unique ID linking the trigger to the tooltip content for accessibility",
|
|
50
52
|
table: {
|
|
51
|
-
type: { summary: "
|
|
53
|
+
type: { summary: "string" },
|
|
52
54
|
defaultValue: { summary: undefined }
|
|
53
55
|
}
|
|
54
56
|
},
|
|
55
|
-
|
|
57
|
+
hasIconTrigger: {
|
|
56
58
|
description:
|
|
57
|
-
"
|
|
59
|
+
"When true, renders an icon as the tooltip trigger instead of text",
|
|
60
|
+
control: { type: "boolean" },
|
|
58
61
|
table: {
|
|
59
|
-
type: { summary: "
|
|
60
|
-
defaultValue: { summary:
|
|
62
|
+
type: { summary: "boolean" },
|
|
63
|
+
defaultValue: { summary: false }
|
|
61
64
|
}
|
|
62
65
|
},
|
|
63
|
-
|
|
66
|
+
IconTrigger: {
|
|
64
67
|
description:
|
|
65
|
-
"
|
|
68
|
+
"Icon component rendered as the trigger when hasIconTrigger is true",
|
|
69
|
+
table: {
|
|
70
|
+
type: { summary: "React Component" },
|
|
71
|
+
defaultValue: { summary: "WarningIconXS" }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
iconHelpText: {
|
|
75
|
+
description: "Screen reader text for the icon trigger",
|
|
66
76
|
table: {
|
|
67
77
|
type: { summary: "string" },
|
|
68
|
-
defaultValue: { summary:
|
|
78
|
+
defaultValue: { summary: "Open the tooltip" }
|
|
69
79
|
}
|
|
70
80
|
},
|
|
71
81
|
triggerText: {
|
|
72
82
|
description:
|
|
73
|
-
"Text
|
|
83
|
+
"Text rendered as the tooltip trigger when hasIconTrigger is false",
|
|
84
|
+
table: {
|
|
85
|
+
type: { summary: "string | JSX.Element" },
|
|
86
|
+
defaultValue: { summary: "Open the tooltip" }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
tooltipContent: {
|
|
90
|
+
description: "The content displayed inside the tooltip",
|
|
74
91
|
table: {
|
|
75
92
|
type: { summary: "string" },
|
|
76
|
-
defaultValue: { summary:
|
|
93
|
+
defaultValue: { summary: "The contents of the tooltip go here." }
|
|
77
94
|
}
|
|
78
95
|
},
|
|
79
96
|
contentPosition: {
|
|
80
97
|
description:
|
|
81
|
-
"CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger
|
|
98
|
+
"CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger",
|
|
82
99
|
table: {
|
|
83
100
|
type: { summary: "object" },
|
|
84
101
|
defaultValue: {
|
|
85
|
-
summary:
|
|
86
|
-
'{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }'
|
|
102
|
+
summary: `{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }`
|
|
87
103
|
}
|
|
88
104
|
}
|
|
89
105
|
},
|
|
90
106
|
arrowDirection: {
|
|
91
|
-
description:
|
|
92
|
-
"Direction the tooltip arrow points (up, down, left, right).",
|
|
107
|
+
description: "Direction the tooltip arrow points (up, down, left, right)",
|
|
93
108
|
control: { type: "select" },
|
|
94
109
|
options: ["up", "down", "left", "right"],
|
|
95
110
|
table: {
|
|
@@ -99,31 +114,30 @@ const meta = {
|
|
|
99
114
|
},
|
|
100
115
|
arrowPosition: {
|
|
101
116
|
description:
|
|
102
|
-
"CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element
|
|
117
|
+
"CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element",
|
|
103
118
|
table: {
|
|
104
119
|
type: { summary: "object" },
|
|
105
120
|
defaultValue: {
|
|
106
|
-
summary:
|
|
107
|
-
'{ arrowTop: "auto", arrowRight: "10px", arrowBottom: "-8px", arrowLeft: "auto" }'
|
|
121
|
+
summary: `{ arrowTop: "auto", arrowRight: "10px", arrowBottom: "-8px", arrowLeft: "auto" }`
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
},
|
|
111
125
|
minWidth: {
|
|
112
|
-
description: "Minimum width of the tooltip content box
|
|
126
|
+
description: "Minimum width of the tooltip content box",
|
|
113
127
|
table: {
|
|
114
128
|
type: { summary: "string" },
|
|
115
129
|
defaultValue: { summary: "250px" }
|
|
116
130
|
}
|
|
117
131
|
},
|
|
118
132
|
maxWidth: {
|
|
119
|
-
description: "Maximum width of the tooltip content box
|
|
133
|
+
description: "Maximum width of the tooltip content box",
|
|
120
134
|
table: {
|
|
121
135
|
type: { summary: "string" },
|
|
122
136
|
defaultValue: { summary: "300px" }
|
|
123
137
|
}
|
|
124
138
|
},
|
|
125
139
|
height: {
|
|
126
|
-
description: "Height of the tooltip content box
|
|
140
|
+
description: "Height of the tooltip content box",
|
|
127
141
|
table: {
|
|
128
142
|
type: { summary: "string" },
|
|
129
143
|
defaultValue: { summary: "auto" }
|
|
@@ -131,25 +145,25 @@ const meta = {
|
|
|
131
145
|
},
|
|
132
146
|
containerExtraStyles: {
|
|
133
147
|
description:
|
|
134
|
-
"Additional CSS string applied to the tooltip container element
|
|
148
|
+
"Additional CSS string applied to the tooltip container element",
|
|
135
149
|
table: {
|
|
136
150
|
type: { summary: "string" },
|
|
137
151
|
defaultValue: { summary: '""' }
|
|
138
152
|
}
|
|
139
153
|
},
|
|
140
|
-
|
|
141
|
-
description:
|
|
142
|
-
"Additional CSS string applied to the tooltip content element.",
|
|
154
|
+
triggerExtraStyles: {
|
|
155
|
+
description: "Additional CSS string applied to the text trigger element",
|
|
143
156
|
table: {
|
|
144
157
|
type: { summary: "string" },
|
|
145
158
|
defaultValue: { summary: '""' }
|
|
146
159
|
}
|
|
147
160
|
},
|
|
148
|
-
|
|
149
|
-
description:
|
|
161
|
+
triggerButtonVariant: {
|
|
162
|
+
description:
|
|
163
|
+
"Button variant applied to the trigger ButtonWithAction element",
|
|
150
164
|
table: {
|
|
151
165
|
type: { summary: "string" },
|
|
152
|
-
defaultValue: { summary: "
|
|
166
|
+
defaultValue: { summary: "smallGhost" }
|
|
153
167
|
}
|
|
154
168
|
}
|
|
155
169
|
}
|
|
@@ -160,67 +174,15 @@ export default meta;
|
|
|
160
174
|
export const Basic = {
|
|
161
175
|
args: {
|
|
162
176
|
tooltipID: "tooltip-basic",
|
|
163
|
-
triggerText: "
|
|
164
|
-
|
|
177
|
+
triggerText: "How basic is this?",
|
|
178
|
+
tooltipContent:
|
|
165
179
|
"This is a detailed explanation of a feature or term that the user may need more context about."
|
|
166
180
|
}
|
|
167
181
|
};
|
|
168
182
|
|
|
169
|
-
export const WithChildren = {
|
|
170
|
-
args: {
|
|
171
|
-
tooltipID: "tooltip-children",
|
|
172
|
-
hasCustomTrigger: true,
|
|
173
|
-
content: "Extra information about this label.",
|
|
174
|
-
contentPosition: {
|
|
175
|
-
top: "-84px",
|
|
176
|
-
right: "auto",
|
|
177
|
-
bottom: "auto",
|
|
178
|
-
left: "-225px"
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
render: args => (
|
|
182
|
-
<Tooltip {...args}>
|
|
183
|
-
<Box padding="0" extraStyles="white-space: nowrap;">
|
|
184
|
-
<AutopayOnIcon />
|
|
185
|
-
<Text
|
|
186
|
-
color={SEA_GREEN}
|
|
187
|
-
extraStyles="margin-left: 5px; white-space: nowrap;"
|
|
188
|
-
>
|
|
189
|
-
Custom trigger
|
|
190
|
-
</Text>
|
|
191
|
-
</Box>
|
|
192
|
-
</Tooltip>
|
|
193
|
-
)
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
export const RichTooltipContent = {
|
|
197
|
-
args: {
|
|
198
|
-
tooltipID: "tooltip-node-content",
|
|
199
|
-
contentExtraStyles: "background-color: #000000; color: #ffffff;",
|
|
200
|
-
triggerText: "Rich content",
|
|
201
|
-
arrowColor: "black",
|
|
202
|
-
contentPosition: {
|
|
203
|
-
top: "-126px",
|
|
204
|
-
right: "auto",
|
|
205
|
-
bottom: "auto",
|
|
206
|
-
left: "-225px"
|
|
207
|
-
},
|
|
208
|
-
content: (
|
|
209
|
-
<div style={{ padding: "8px" }}>
|
|
210
|
-
<strong>Bold title</strong>
|
|
211
|
-
<p>
|
|
212
|
-
With <em>an italic text detail</em> below.
|
|
213
|
-
</p>
|
|
214
|
-
</div>
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
183
|
export const TooltipBelow = {
|
|
220
184
|
args: {
|
|
221
185
|
tooltipID: "tooltip-below",
|
|
222
|
-
triggerText: "Hover for info",
|
|
223
|
-
content: "This tooltip appears below the trigger.",
|
|
224
186
|
contentPosition: {
|
|
225
187
|
top: "50px",
|
|
226
188
|
right: "auto",
|
|
@@ -240,8 +202,6 @@ export const TooltipBelow = {
|
|
|
240
202
|
export const TooltipRight = {
|
|
241
203
|
args: {
|
|
242
204
|
tooltipID: "tooltip-right",
|
|
243
|
-
triggerText: "Hover for info",
|
|
244
|
-
content: "This tooltip appears to the right.",
|
|
245
205
|
contentPosition: {
|
|
246
206
|
top: "-40px",
|
|
247
207
|
right: "auto",
|
|
@@ -257,3 +217,21 @@ export const TooltipRight = {
|
|
|
257
217
|
}
|
|
258
218
|
}
|
|
259
219
|
};
|
|
220
|
+
|
|
221
|
+
export const CustomContent = {
|
|
222
|
+
args: {
|
|
223
|
+
tooltipID: "tooltip-custom-content",
|
|
224
|
+
triggerText: "What is this?",
|
|
225
|
+
tooltipContent:
|
|
226
|
+
"This is a detailed explanation of a feature or term that the user may need more context about."
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const CustomWidth = {
|
|
231
|
+
args: {
|
|
232
|
+
tooltipID: "tooltip-custom-width",
|
|
233
|
+
minWidth: "150px",
|
|
234
|
+
maxWidth: "200px",
|
|
235
|
+
tooltipContent: "A narrower tooltip."
|
|
236
|
+
}
|
|
237
|
+
};
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
SAPPHIRE_BLUE
|
|
5
|
-
} from "../../../constants/colors";
|
|
6
|
-
|
|
7
|
-
const hoverColor = SAPPHIRE_BLUE;
|
|
8
|
-
const activeColor = PEACOCK_BLUE;
|
|
9
|
-
const linkColor = MATISSE_BLUE;
|
|
10
|
-
const borderColor = "rgba(255, 255, 255, 0.85)";
|
|
11
|
-
|
|
12
|
-
export const TOOLTIP_THEME_SOURCE = "Button";
|
|
1
|
+
const hoverColor = "#116285";
|
|
2
|
+
const activeColor = "#0E506D";
|
|
3
|
+
const tooltipTriggerColor = "#15749D";
|
|
13
4
|
|
|
14
5
|
export const fallbackValues = {
|
|
15
|
-
borderColor,
|
|
16
|
-
linkColor,
|
|
17
6
|
hoverColor,
|
|
18
|
-
activeColor
|
|
7
|
+
activeColor,
|
|
8
|
+
tooltipTriggerColor
|
|
19
9
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Expand from "../../../util/expand";
|
|
3
|
-
|
|
4
3
|
export interface TooltipProps {
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
content: string | React.ReactNode;
|
|
7
4
|
tooltipID: string;
|
|
8
|
-
|
|
5
|
+
hasIconTrigger?: boolean;
|
|
6
|
+
IconTrigger?: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
7
|
+
iconHelpText?: string;
|
|
8
|
+
triggerText?: string | JSX.Element;
|
|
9
|
+
tooltipContent: string;
|
|
9
10
|
contentPosition?: {
|
|
10
11
|
top: string;
|
|
11
12
|
right: string;
|
|
@@ -23,6 +24,8 @@ export interface TooltipProps {
|
|
|
23
24
|
maxWidth?: string;
|
|
24
25
|
height?: string;
|
|
25
26
|
containerExtraStyles?: string;
|
|
27
|
+
triggerExtraStyles?: string;
|
|
28
|
+
triggerButtonVariant?: string;
|
|
26
29
|
contentExtraStyles?: string;
|
|
27
30
|
contentBackgroundColor?: string;
|
|
28
31
|
}
|