@thecb/components 11.10.1-beta.1 → 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.
@@ -1,9 +1,6 @@
1
1
  import React from "react";
2
2
  import Tooltip from "./Tooltip";
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";
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
- content: "This is the tooltip content.",
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
- contentExtraStyles: "",
44
- contentBackgroundColor: ""
43
+ triggerExtraStyles: "",
44
+ triggerButtonVariant: "smallGhost",
45
+ contentBackgroundColor: "",
46
+ contentExtraStyles: ""
45
47
  },
46
48
  argTypes: {
47
- children: {
49
+ tooltipID: {
48
50
  description:
49
- "Optional trigger element. When provided, it replaces the default ButtonWithAction trigger. The child element will receive aria-describedby, focus, blur, and keydown handlers.",
51
+ "Unique ID linking the trigger to the tooltip content for accessibility",
50
52
  table: {
51
- type: { summary: "React.ReactNode" },
53
+ type: { summary: "string" },
52
54
  defaultValue: { summary: undefined }
53
55
  }
54
56
  },
55
- content: {
57
+ hasIconTrigger: {
56
58
  description:
57
- "The content displayed inside the tooltip. Can be a string or a React node/element.",
59
+ "When true, renders an icon as the tooltip trigger instead of text",
60
+ control: { type: "boolean" },
58
61
  table: {
59
- type: { summary: "string | React.ReactNode" },
60
- defaultValue: { summary: '""' }
62
+ type: { summary: "boolean" },
63
+ defaultValue: { summary: false }
61
64
  }
62
65
  },
63
- tooltipID: {
66
+ IconTrigger: {
64
67
  description:
65
- "Unique ID for the tooltip content element. Used as the aria-describedby value on the trigger.",
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: undefined }
78
+ defaultValue: { summary: "Open the tooltip" }
69
79
  }
70
80
  },
71
81
  triggerText: {
72
82
  description:
73
- "Text shown in the default ButtonWithAction trigger. Not needed when children are provided.",
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
- contentExtraStyles: {
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
- contentBackgroundColor: {
149
- description: "Background color of the tooltip content box.",
161
+ triggerButtonVariant: {
162
+ description:
163
+ "Button variant applied to the trigger ButtonWithAction element",
150
164
  table: {
151
165
  type: { summary: "string" },
152
- defaultValue: { summary: "white" }
166
+ defaultValue: { summary: "smallGhost" }
153
167
  }
154
168
  }
155
169
  }
@@ -160,66 +174,15 @@ export default meta;
160
174
  export const Basic = {
161
175
  args: {
162
176
  tooltipID: "tooltip-basic",
163
- triggerText: "What is this?",
164
- content:
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
- 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
-
218
183
  export const TooltipBelow = {
219
184
  args: {
220
185
  tooltipID: "tooltip-below",
221
- triggerText: "Hover for info",
222
- content: "This tooltip appears below the trigger.",
223
186
  contentPosition: {
224
187
  top: "50px",
225
188
  right: "auto",
@@ -239,8 +202,6 @@ export const TooltipBelow = {
239
202
  export const TooltipRight = {
240
203
  args: {
241
204
  tooltipID: "tooltip-right",
242
- triggerText: "Hover for info",
243
- content: "This tooltip appears to the right.",
244
205
  contentPosition: {
245
206
  top: "-40px",
246
207
  right: "auto",
@@ -256,3 +217,21 @@ export const TooltipRight = {
256
217
  }
257
218
  }
258
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
- 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";
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
- triggerText?: string;
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
  }