@thecb/components 11.10.0-beta.2 → 11.10.1-beta.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.
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  import Tooltip from "./Tooltip";
3
- import WarningIconXS from "../../atoms/icons/WarningIconXS";
3
+ import Text from "../../atoms/text/Text";
4
+ import AutopayOnIcon from "../../atoms/icons/AutopayOnIcon";
5
+ import Box from "../../atoms/layouts/Box";
6
+ import { SEA_GREEN } from "../../../constants/colors";
4
7
 
5
8
  const meta = {
6
9
  title: "Molecules/Tooltip",
@@ -18,11 +21,8 @@ const meta = {
18
21
  ],
19
22
  args: {
20
23
  tooltipID: "tooltip-id",
21
- hasIconTrigger: false,
22
- IconTrigger: WarningIconXS,
23
- iconHelpText: "Open the tooltip",
24
24
  triggerText: "Hover me",
25
- tooltipContent: "The contents of the tooltip go here.",
25
+ content: "This is the tooltip content.",
26
26
  contentPosition: {
27
27
  top: "-110px",
28
28
  right: "auto",
@@ -40,71 +40,56 @@ const meta = {
40
40
  maxWidth: "300px",
41
41
  height: "auto",
42
42
  containerExtraStyles: "",
43
- triggerExtraStyles: "",
44
- triggerButtonVariant: "smallGhost",
45
- contentBackgroundColor: "",
46
- contentExtraStyles: ""
43
+ contentExtraStyles: "",
44
+ contentBackgroundColor: ""
47
45
  },
48
46
  argTypes: {
49
- tooltipID: {
47
+ children: {
50
48
  description:
51
- "Unique ID linking the trigger to the tooltip content for accessibility",
49
+ "Optional trigger element. When provided, it replaces the default ButtonWithAction trigger. The child element will receive aria-describedby, focus, blur, and keydown handlers.",
52
50
  table: {
53
- type: { summary: "string" },
51
+ type: { summary: "React.ReactNode" },
54
52
  defaultValue: { summary: undefined }
55
53
  }
56
54
  },
57
- hasIconTrigger: {
55
+ content: {
58
56
  description:
59
- "When true, renders an icon as the tooltip trigger instead of text",
60
- control: { type: "boolean" },
57
+ "The content displayed inside the tooltip. Can be a string or a React node/element.",
61
58
  table: {
62
- type: { summary: "boolean" },
63
- defaultValue: { summary: false }
59
+ type: { summary: "string | React.ReactNode" },
60
+ defaultValue: { summary: '""' }
64
61
  }
65
62
  },
66
- IconTrigger: {
63
+ tooltipID: {
67
64
  description:
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",
65
+ "Unique ID for the tooltip content element. Used as the aria-describedby value on the trigger.",
76
66
  table: {
77
67
  type: { summary: "string" },
78
- defaultValue: { summary: "Open the tooltip" }
68
+ defaultValue: { summary: undefined }
79
69
  }
80
70
  },
81
71
  triggerText: {
82
72
  description:
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",
73
+ "Text shown in the default ButtonWithAction trigger. Not needed when children are provided.",
91
74
  table: {
92
75
  type: { summary: "string" },
93
- defaultValue: { summary: "The contents of the tooltip go here." }
76
+ defaultValue: { summary: '""' }
94
77
  }
95
78
  },
96
79
  contentPosition: {
97
80
  description:
98
- "CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger",
81
+ "CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger.",
99
82
  table: {
100
83
  type: { summary: "object" },
101
84
  defaultValue: {
102
- summary: `{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }`
85
+ summary:
86
+ '{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }'
103
87
  }
104
88
  }
105
89
  },
106
90
  arrowDirection: {
107
- description: "Direction the tooltip arrow points (up, down, left, right)",
91
+ description:
92
+ "Direction the tooltip arrow points (up, down, left, right).",
108
93
  control: { type: "select" },
109
94
  options: ["up", "down", "left", "right"],
110
95
  table: {
@@ -114,30 +99,31 @@ const meta = {
114
99
  },
115
100
  arrowPosition: {
116
101
  description:
117
- "CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element",
102
+ "CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element.",
118
103
  table: {
119
104
  type: { summary: "object" },
120
105
  defaultValue: {
121
- summary: `{ arrowTop: "auto", arrowRight: "10px", arrowBottom: "-8px", arrowLeft: "auto" }`
106
+ summary:
107
+ '{ arrowTop: "auto", arrowRight: "10px", arrowBottom: "-8px", arrowLeft: "auto" }'
122
108
  }
123
109
  }
124
110
  },
125
111
  minWidth: {
126
- description: "Minimum width of the tooltip content box",
112
+ description: "Minimum width of the tooltip content box.",
127
113
  table: {
128
114
  type: { summary: "string" },
129
115
  defaultValue: { summary: "250px" }
130
116
  }
131
117
  },
132
118
  maxWidth: {
133
- description: "Maximum width of the tooltip content box",
119
+ description: "Maximum width of the tooltip content box.",
134
120
  table: {
135
121
  type: { summary: "string" },
136
122
  defaultValue: { summary: "300px" }
137
123
  }
138
124
  },
139
125
  height: {
140
- description: "Height of the tooltip content box",
126
+ description: "Height of the tooltip content box.",
141
127
  table: {
142
128
  type: { summary: "string" },
143
129
  defaultValue: { summary: "auto" }
@@ -145,25 +131,25 @@ const meta = {
145
131
  },
146
132
  containerExtraStyles: {
147
133
  description:
148
- "Additional CSS string applied to the tooltip container element",
134
+ "Additional CSS string applied to the tooltip container element.",
149
135
  table: {
150
136
  type: { summary: "string" },
151
137
  defaultValue: { summary: '""' }
152
138
  }
153
139
  },
154
- triggerExtraStyles: {
155
- description: "Additional CSS string applied to the text trigger element",
140
+ contentExtraStyles: {
141
+ description:
142
+ "Additional CSS string applied to the tooltip content element.",
156
143
  table: {
157
144
  type: { summary: "string" },
158
145
  defaultValue: { summary: '""' }
159
146
  }
160
147
  },
161
- triggerButtonVariant: {
162
- description:
163
- "Button variant applied to the trigger ButtonWithAction element",
148
+ contentBackgroundColor: {
149
+ description: "Background color of the tooltip content box.",
164
150
  table: {
165
151
  type: { summary: "string" },
166
- defaultValue: { summary: "smallGhost" }
152
+ defaultValue: { summary: "white" }
167
153
  }
168
154
  }
169
155
  }
@@ -174,15 +160,66 @@ export default meta;
174
160
  export const Basic = {
175
161
  args: {
176
162
  tooltipID: "tooltip-basic",
177
- triggerText: "How basic is this?",
178
- tooltipContent:
163
+ triggerText: "What is this?",
164
+ content:
179
165
  "This is a detailed explanation of a feature or term that the user may need more context about."
180
166
  }
181
167
  };
182
168
 
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
+ contentBackgroundColor: "#ffffff",
200
+ triggerText: "Rich content",
201
+ contentPosition: {
202
+ top: "-126px",
203
+ right: "auto",
204
+ bottom: "auto",
205
+ left: "-225px"
206
+ },
207
+ content: (
208
+ <div style={{ padding: "8px" }}>
209
+ <strong>Bold title</strong>
210
+ <p>
211
+ With <em>an italic text detail</em> below.
212
+ </p>
213
+ </div>
214
+ )
215
+ }
216
+ };
217
+
183
218
  export const TooltipBelow = {
184
219
  args: {
185
220
  tooltipID: "tooltip-below",
221
+ triggerText: "Hover for info",
222
+ content: "This tooltip appears below the trigger.",
186
223
  contentPosition: {
187
224
  top: "50px",
188
225
  right: "auto",
@@ -202,6 +239,8 @@ export const TooltipBelow = {
202
239
  export const TooltipRight = {
203
240
  args: {
204
241
  tooltipID: "tooltip-right",
242
+ triggerText: "Hover for info",
243
+ content: "This tooltip appears to the right.",
205
244
  contentPosition: {
206
245
  top: "-40px",
207
246
  right: "auto",
@@ -217,21 +256,3 @@ export const TooltipRight = {
217
256
  }
218
257
  }
219
258
  };
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,9 +1,19 @@
1
- const hoverColor = "#116285";
2
- const activeColor = "#0E506D";
3
- const tooltipTriggerColor = "#15749D";
1
+ import {
2
+ MATISSE_BLUE,
3
+ PEACOCK_BLUE,
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";
4
13
 
5
14
  export const fallbackValues = {
15
+ borderColor,
16
+ linkColor,
6
17
  hoverColor,
7
- activeColor,
8
- tooltipTriggerColor
18
+ activeColor
9
19
  };
@@ -1,12 +1,11 @@
1
1
  import React from "react";
2
2
  import Expand from "../../../util/expand";
3
+
3
4
  export interface TooltipProps {
5
+ children?: React.ReactNode;
6
+ content: string | React.ReactNode;
4
7
  tooltipID: string;
5
- hasIconTrigger?: boolean;
6
- IconTrigger?: React.FC<React.SVGProps<SVGSVGElement>>;
7
- iconHelpText?: string;
8
- triggerText?: string | JSX.Element;
9
- tooltipContent: string;
8
+ triggerText?: string;
10
9
  contentPosition?: {
11
10
  top: string;
12
11
  right: string;
@@ -24,8 +23,6 @@ export interface TooltipProps {
24
23
  maxWidth?: string;
25
24
  height?: string;
26
25
  containerExtraStyles?: string;
27
- triggerExtraStyles?: string;
28
- triggerButtonVariant?: string;
29
26
  contentExtraStyles?: string;
30
27
  contentBackgroundColor?: string;
31
28
  }