@thecb/components 11.10.1-beta.2 → 11.11.0-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.
- package/dist/index.cjs.js +82 -78
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +82 -78
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- 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/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
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@ import "core-js/proposals/relative-indexing-method";
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
ERROR_COLOR,
|
|
16
|
-
GREY_CHATEAU,
|
|
17
16
|
MINESHAFT_GREY,
|
|
18
17
|
STORM_GREY,
|
|
19
18
|
WHITE
|
|
@@ -35,7 +34,7 @@ const IconWrapper = styled.div`
|
|
|
35
34
|
|
|
36
35
|
const DropdownContentWrapper = styled.div`
|
|
37
36
|
transform-origin: 0 0;
|
|
38
|
-
border: 1px solid ${
|
|
37
|
+
border: 1px solid ${STORM_GREY};
|
|
39
38
|
border-radius: 2px;
|
|
40
39
|
background-color: ${WHITE};
|
|
41
40
|
padding: 8px 0 8px;
|
|
@@ -349,7 +348,7 @@ const Dropdown = ({
|
|
|
349
348
|
? ERROR_COLOR
|
|
350
349
|
: isOpen
|
|
351
350
|
? themeValues.selectedColor
|
|
352
|
-
:
|
|
351
|
+
: STORM_GREY
|
|
353
352
|
}
|
|
354
353
|
dataQa={placeholder}
|
|
355
354
|
extraStyles={
|
|
@@ -148,7 +148,7 @@ const FormInput = ({
|
|
|
148
148
|
<Stack childGap="0.25rem">
|
|
149
149
|
<Box padding="0">
|
|
150
150
|
{helperModal ? (
|
|
151
|
-
<Cluster justify="space-between" align="center">
|
|
151
|
+
<Cluster justify="space-between" align="center" overflow>
|
|
152
152
|
{labelDisplayOverride ? (
|
|
153
153
|
labelDisplayOverride
|
|
154
154
|
) : (
|
|
@@ -2,23 +2,34 @@ import React, { useContext, useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import { createThemeValues } from "../../../util/themeUtils";
|
|
3
3
|
import { ThemeContext } from "styled-components";
|
|
4
4
|
import Text from "../../atoms/text";
|
|
5
|
+
import Paragraph from "../../atoms/paragraph";
|
|
5
6
|
import { Box } from "../../atoms/layouts";
|
|
6
7
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
8
|
import { noop, arrowBorder } from "../../../util/general";
|
|
8
|
-
import
|
|
9
|
+
import WarningIconXS from "../../atoms/icons/WarningIconXS";
|
|
10
|
+
import {
|
|
11
|
+
MATISSE_BLUE,
|
|
12
|
+
PEACOCK_BLUE,
|
|
13
|
+
SAPPHIRE_BLUE,
|
|
14
|
+
WHITE
|
|
15
|
+
} from "../../../constants/colors";
|
|
16
|
+
|
|
17
|
+
const TOOLTIP_THEME_SOURCE = "Popover";
|
|
18
|
+
|
|
19
|
+
const fallbackValues = {
|
|
20
|
+
hoverColor: SAPPHIRE_BLUE,
|
|
21
|
+
activeColor: PEACOCK_BLUE,
|
|
22
|
+
popoverTriggerColor: MATISSE_BLUE,
|
|
23
|
+
borderColor: `rgba(255, 255, 255, 0.85)`
|
|
24
|
+
};
|
|
9
25
|
|
|
10
26
|
const Tooltip = ({
|
|
11
27
|
tooltipID,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
content = "",
|
|
18
|
-
contentExtraStyles = "",
|
|
19
|
-
minWidth = "250px",
|
|
20
|
-
maxWidth = "100%",
|
|
21
|
-
height = "auto",
|
|
28
|
+
hasIconTrigger = false,
|
|
29
|
+
IconTrigger = WarningIconXS,
|
|
30
|
+
iconHelpText = "Open the tooltip",
|
|
31
|
+
triggerText = "Open the tooltip",
|
|
32
|
+
tooltipContent = "The contents of the tooltip go here.",
|
|
22
33
|
contentPosition = {
|
|
23
34
|
top: "-110px",
|
|
24
35
|
right: "auto",
|
|
@@ -32,7 +43,14 @@ const Tooltip = ({
|
|
|
32
43
|
arrowBottom: "-8px",
|
|
33
44
|
arrowLeft: "auto"
|
|
34
45
|
},
|
|
35
|
-
|
|
46
|
+
minWidth = "250px",
|
|
47
|
+
maxWidth = "300px",
|
|
48
|
+
height = "auto",
|
|
49
|
+
containerExtraStyles = "",
|
|
50
|
+
triggerExtraStyles = "",
|
|
51
|
+
triggerButtonVariant = "smallGhost",
|
|
52
|
+
contentExtraStyles = "",
|
|
53
|
+
contentBackgroundColor = WHITE
|
|
36
54
|
}) => {
|
|
37
55
|
const closeTimeoutRef = useRef(null);
|
|
38
56
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
@@ -43,16 +61,23 @@ const Tooltip = ({
|
|
|
43
61
|
TOOLTIP_THEME_SOURCE
|
|
44
62
|
);
|
|
45
63
|
|
|
64
|
+
const {
|
|
65
|
+
borderColor,
|
|
66
|
+
popoverTriggerColor: tooltipTriggerColor,
|
|
67
|
+
hoverColor,
|
|
68
|
+
activeColor
|
|
69
|
+
} = themeValues;
|
|
70
|
+
|
|
46
71
|
const { top, right, bottom, left } = contentPosition;
|
|
47
72
|
const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition;
|
|
48
73
|
|
|
49
|
-
const handleToggleTooltip =
|
|
50
|
-
if (tooltipOpen !==
|
|
51
|
-
setTooltipOpen(
|
|
74
|
+
const handleToggleTooltip = desiredTooltipState => {
|
|
75
|
+
if (tooltipOpen !== desiredTooltipState) {
|
|
76
|
+
setTooltipOpen(desiredTooltipState);
|
|
52
77
|
}
|
|
53
78
|
};
|
|
54
79
|
|
|
55
|
-
const
|
|
80
|
+
const handleKeyboardEvent = e => {
|
|
56
81
|
if (e.key === "Escape") {
|
|
57
82
|
handleToggleTooltip(false);
|
|
58
83
|
}
|
|
@@ -80,73 +105,80 @@ const Tooltip = ({
|
|
|
80
105
|
};
|
|
81
106
|
}, []);
|
|
82
107
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return (
|
|
108
|
+
return (
|
|
109
|
+
<Box
|
|
110
|
+
ref={closeTimeoutRef}
|
|
111
|
+
padding="0"
|
|
112
|
+
extraStyles={`position: relative; ${containerExtraStyles}`}
|
|
113
|
+
onMouseEnter={() => handleMouseEnter(true)}
|
|
114
|
+
onMouseLeave={() => handleMouseLeave(false)}
|
|
115
|
+
data-qa="tooltip-container"
|
|
116
|
+
>
|
|
94
117
|
<ButtonWithAction
|
|
95
|
-
action={noop}
|
|
96
118
|
aria-describedby={tooltipID}
|
|
97
|
-
onKeyDown={
|
|
119
|
+
onKeyDown={handleKeyboardEvent}
|
|
98
120
|
variant={triggerButtonVariant}
|
|
99
121
|
onFocus={() => handleToggleTooltip(true)}
|
|
100
122
|
onBlur={() => handleToggleTooltip(false)}
|
|
101
123
|
onTouchStart={() => handleToggleTooltip(true)}
|
|
102
|
-
data-qa=
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
data-qa="tooltip-trigger"
|
|
125
|
+
contentOverride={true}
|
|
126
|
+
>
|
|
127
|
+
{hasIconTrigger === true && (
|
|
128
|
+
<>
|
|
129
|
+
<Box aria-label="Open tooltip">
|
|
130
|
+
<IconTrigger color={tooltipTriggerColor} />
|
|
131
|
+
</Box>
|
|
132
|
+
<Box padding="0" srOnly>
|
|
133
|
+
<Text>{iconHelpText}</Text>
|
|
134
|
+
</Box>
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
{hasIconTrigger === false && (
|
|
138
|
+
<Text
|
|
139
|
+
color={tooltipTriggerColor}
|
|
140
|
+
extraStyles={`
|
|
141
|
+
color: ${tooltipTriggerColor};
|
|
142
|
+
&:visited {
|
|
143
|
+
color: ${tooltipTriggerColor};
|
|
144
|
+
}
|
|
145
|
+
&:hover {
|
|
146
|
+
color: ${hoverColor};
|
|
147
|
+
}
|
|
148
|
+
&:active,
|
|
149
|
+
&:focus {
|
|
150
|
+
color: ${activeColor};
|
|
151
|
+
}
|
|
152
|
+
${triggerExtraStyles};
|
|
153
|
+
`}
|
|
154
|
+
>
|
|
155
|
+
{triggerText}
|
|
156
|
+
</Text>
|
|
157
|
+
)}
|
|
158
|
+
</ButtonWithAction>
|
|
123
159
|
<Box
|
|
124
160
|
role="tooltip"
|
|
125
161
|
id={tooltipID}
|
|
126
162
|
aria-hidden={!tooltipOpen}
|
|
127
|
-
background={
|
|
163
|
+
background={contentBackgroundColor}
|
|
128
164
|
data-qa="tooltip-contents"
|
|
129
165
|
extraStyles={`
|
|
130
166
|
position: absolute;
|
|
131
167
|
display: ${tooltipOpen ? "block" : "none"};
|
|
132
|
-
top: ${top};
|
|
168
|
+
top: ${top};
|
|
133
169
|
right: ${right};
|
|
134
170
|
bottom: ${bottom};
|
|
135
171
|
left: ${left};
|
|
136
172
|
height: ${height};
|
|
137
173
|
${contentExtraStyles}
|
|
138
|
-
|
|
139
|
-
boxShadow=
|
|
140
|
-
border=
|
|
174
|
+
`}
|
|
175
|
+
boxShadow={`0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)`}
|
|
176
|
+
border={`1px solid transparent`}
|
|
141
177
|
borderRadius="4px"
|
|
142
178
|
minWidth={minWidth}
|
|
143
179
|
maxWidth={maxWidth}
|
|
144
180
|
>
|
|
145
|
-
{
|
|
146
|
-
<Text color={themeValues.linkColor}>{content}</Text>
|
|
147
|
-
) : (
|
|
148
|
-
content
|
|
149
|
-
)}
|
|
181
|
+
<Paragraph>{tooltipContent}</Paragraph>
|
|
150
182
|
<Box
|
|
151
183
|
padding="0"
|
|
152
184
|
extraStyles={`
|
|
@@ -154,11 +186,7 @@ const Tooltip = ({
|
|
|
154
186
|
content: "";
|
|
155
187
|
width: 0;
|
|
156
188
|
height: 0;
|
|
157
|
-
${arrowBorder(
|
|
158
|
-
arrowColor || themeValues.borderColor,
|
|
159
|
-
arrowDirection,
|
|
160
|
-
"8px"
|
|
161
|
-
)};
|
|
189
|
+
${arrowBorder(borderColor, arrowDirection, "8px")};
|
|
162
190
|
filter: drop-shadow(2px 8px 14px black);
|
|
163
191
|
bottom: ${arrowBottom};
|
|
164
192
|
right: ${arrowRight};
|
|
@@ -6,19 +6,9 @@ import * as TooltipStories from './Tooltip.stories.js';
|
|
|
6
6
|
|
|
7
7
|
<Title />
|
|
8
8
|
|
|
9
|
-
Tooltip is
|
|
9
|
+
The Tooltip is a fully accessible tooltip widget that displays additional information when a user hovers over or focuses on a specified trigger element. The trigger can either be text supplied using the `triggerText` prop, or a custom Icon component supplied using the `IconTrigger` prop. The trigger is rendered as a `ButtonWithAction` with the `smallGhost` variant.
|
|
10
10
|
|
|
11
|
-
The
|
|
12
|
-
- **Custom children**: Pass any single React element as `children`. It will receive `aria-describedby`, focus, blur, and keyboard handlers automatically.
|
|
13
|
-
- **Default button**: When no `children` are provided, a `ButtonWithAction` is rendered using the `triggerText` prop.
|
|
14
|
-
|
|
15
|
-
The tooltip content (`content` prop) accepts a plain string or a React node for rich content. It is styled similarly to the Popover component, including an arrow pointing toward the trigger.
|
|
16
|
-
|
|
17
|
-
### Accessibility
|
|
18
|
-
- The trigger element has `aria-describedby` referencing the tooltip.
|
|
19
|
-
- The tooltip container has `role="tooltip"`.
|
|
20
|
-
- Pressing **Escape** dismisses the tooltip.
|
|
21
|
-
- Focus stays on the trigger while the tooltip is displayed.
|
|
11
|
+
The Tooltip uses the WAI-ARIA tooltip pattern (`role="tooltip"` and `aria-describedby`) for accessibility. It can be positioned anywhere around the trigger element using the position props. Content and style of the tooltip are customizable.
|
|
22
12
|
|
|
23
13
|
<Controls />
|
|
24
14
|
|
|
@@ -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
|
}
|