@thecb/components 11.11.0-beta.1 → 11.11.0-beta.2
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 +77 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +77 -80
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +3 -2
- package/src/components/atoms/dropdown/DropdownIcon.js +0 -1
- package/src/components/atoms/dropdown/DropdownIconV2.js +0 -1
- package/src/components/molecules/tooltip/Tooltip.js +65 -93
- package/src/components/molecules/tooltip/Tooltip.mdx +12 -2
- package/src/components/molecules/tooltip/Tooltip.stories.js +93 -71
- package/src/components/molecules/tooltip/Tooltip.theme.js +15 -5
- package/src/components/molecules/tooltip/index.d.ts +4 -7
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import "core-js/proposals/relative-indexing-method";
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
ERROR_COLOR,
|
|
16
|
+
GREY_CHATEAU,
|
|
16
17
|
MINESHAFT_GREY,
|
|
17
18
|
STORM_GREY,
|
|
18
19
|
WHITE
|
|
@@ -34,7 +35,7 @@ const IconWrapper = styled.div`
|
|
|
34
35
|
|
|
35
36
|
const DropdownContentWrapper = styled.div`
|
|
36
37
|
transform-origin: 0 0;
|
|
37
|
-
border: 1px solid ${
|
|
38
|
+
border: 1px solid ${GREY_CHATEAU};
|
|
38
39
|
border-radius: 2px;
|
|
39
40
|
background-color: ${WHITE};
|
|
40
41
|
padding: 8px 0 8px;
|
|
@@ -348,7 +349,7 @@ const Dropdown = ({
|
|
|
348
349
|
? ERROR_COLOR
|
|
349
350
|
: isOpen
|
|
350
351
|
? themeValues.selectedColor
|
|
351
|
-
:
|
|
352
|
+
: GREY_CHATEAU
|
|
352
353
|
}
|
|
353
354
|
dataQa={placeholder}
|
|
354
355
|
extraStyles={
|
|
@@ -2,34 +2,23 @@ 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";
|
|
6
5
|
import { Box } from "../../atoms/layouts";
|
|
7
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
8
7
|
import { noop, arrowBorder } from "../../../util/general";
|
|
9
|
-
import
|
|
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
|
-
};
|
|
8
|
+
import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
|
|
25
9
|
|
|
26
10
|
const Tooltip = ({
|
|
27
11
|
tooltipID,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
children,
|
|
13
|
+
hasCustomTrigger = false,
|
|
14
|
+
triggerText = "",
|
|
15
|
+
containerExtraStyles = "",
|
|
16
|
+
triggerButtonVariant = "smallGhost",
|
|
17
|
+
content = "",
|
|
18
|
+
contentExtraStyles = "",
|
|
19
|
+
minWidth = "250px",
|
|
20
|
+
maxWidth = "100%",
|
|
21
|
+
height = "auto",
|
|
33
22
|
contentPosition = {
|
|
34
23
|
top: "-110px",
|
|
35
24
|
right: "auto",
|
|
@@ -43,14 +32,7 @@ const Tooltip = ({
|
|
|
43
32
|
arrowBottom: "-8px",
|
|
44
33
|
arrowLeft: "auto"
|
|
45
34
|
},
|
|
46
|
-
|
|
47
|
-
maxWidth = "300px",
|
|
48
|
-
height = "auto",
|
|
49
|
-
containerExtraStyles = "",
|
|
50
|
-
triggerExtraStyles = "",
|
|
51
|
-
triggerButtonVariant = "smallGhost",
|
|
52
|
-
contentExtraStyles = "",
|
|
53
|
-
contentBackgroundColor = WHITE
|
|
35
|
+
arrowColor
|
|
54
36
|
}) => {
|
|
55
37
|
const closeTimeoutRef = useRef(null);
|
|
56
38
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
@@ -61,23 +43,16 @@ const Tooltip = ({
|
|
|
61
43
|
TOOLTIP_THEME_SOURCE
|
|
62
44
|
);
|
|
63
45
|
|
|
64
|
-
const {
|
|
65
|
-
borderColor,
|
|
66
|
-
popoverTriggerColor: tooltipTriggerColor,
|
|
67
|
-
hoverColor,
|
|
68
|
-
activeColor
|
|
69
|
-
} = themeValues;
|
|
70
|
-
|
|
71
46
|
const { top, right, bottom, left } = contentPosition;
|
|
72
47
|
const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition;
|
|
73
48
|
|
|
74
|
-
const handleToggleTooltip =
|
|
75
|
-
if (tooltipOpen !==
|
|
76
|
-
setTooltipOpen(
|
|
49
|
+
const handleToggleTooltip = desiredState => {
|
|
50
|
+
if (tooltipOpen !== desiredState) {
|
|
51
|
+
setTooltipOpen(desiredState);
|
|
77
52
|
}
|
|
78
53
|
};
|
|
79
54
|
|
|
80
|
-
const
|
|
55
|
+
const handleKeyDown = e => {
|
|
81
56
|
if (e.key === "Escape") {
|
|
82
57
|
handleToggleTooltip(false);
|
|
83
58
|
}
|
|
@@ -105,80 +80,73 @@ const Tooltip = ({
|
|
|
105
80
|
};
|
|
106
81
|
}, []);
|
|
107
82
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
83
|
+
const renderTrigger = () => {
|
|
84
|
+
if (hasCustomTrigger && children) {
|
|
85
|
+
return React.cloneElement(React.Children.only(children), {
|
|
86
|
+
"aria-describedby": tooltipID,
|
|
87
|
+
onFocus: () => handleToggleTooltip(true),
|
|
88
|
+
onBlur: () => handleToggleTooltip(false),
|
|
89
|
+
onKeyDown: handleKeyDown
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
117
94
|
<ButtonWithAction
|
|
95
|
+
action={noop}
|
|
118
96
|
aria-describedby={tooltipID}
|
|
119
|
-
onKeyDown={
|
|
97
|
+
onKeyDown={handleKeyDown}
|
|
120
98
|
variant={triggerButtonVariant}
|
|
121
99
|
onFocus={() => handleToggleTooltip(true)}
|
|
122
100
|
onBlur={() => handleToggleTooltip(false)}
|
|
123
101
|
onTouchStart={() => handleToggleTooltip(true)}
|
|
124
|
-
data-qa=
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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>
|
|
102
|
+
data-qa={`tooltip-trigger-${tooltipID}`}
|
|
103
|
+
text={triggerText}
|
|
104
|
+
extraStyles={`
|
|
105
|
+
color: ${themeValues.linkColor};
|
|
106
|
+
&:hover { color: ${themeValues.hoverColor}; text-decoration: none;}
|
|
107
|
+
&:active, &:focus { color: ${themeValues.activeColor};text-decoration: none;}
|
|
108
|
+
button, span, &:hover span { text-decoration: none; }
|
|
109
|
+
`}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Box
|
|
116
|
+
padding="0"
|
|
117
|
+
extraStyles={`position: relative; ${containerExtraStyles}`}
|
|
118
|
+
onMouseEnter={handleMouseEnter}
|
|
119
|
+
onMouseLeave={handleMouseLeave}
|
|
120
|
+
data-qa={`${tooltipID}-container`}
|
|
121
|
+
>
|
|
122
|
+
{renderTrigger()}
|
|
159
123
|
<Box
|
|
160
124
|
role="tooltip"
|
|
161
125
|
id={tooltipID}
|
|
162
126
|
aria-hidden={!tooltipOpen}
|
|
163
|
-
background={
|
|
127
|
+
background={themeValues.borderColor}
|
|
164
128
|
data-qa="tooltip-contents"
|
|
165
129
|
extraStyles={`
|
|
166
130
|
position: absolute;
|
|
167
131
|
display: ${tooltipOpen ? "block" : "none"};
|
|
168
|
-
top: ${top};
|
|
132
|
+
top: ${top};
|
|
169
133
|
right: ${right};
|
|
170
134
|
bottom: ${bottom};
|
|
171
135
|
left: ${left};
|
|
172
136
|
height: ${height};
|
|
173
137
|
${contentExtraStyles}
|
|
174
|
-
|
|
175
|
-
boxShadow=
|
|
176
|
-
border=
|
|
138
|
+
`}
|
|
139
|
+
boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
|
|
140
|
+
border="1px solid transparent"
|
|
177
141
|
borderRadius="4px"
|
|
178
142
|
minWidth={minWidth}
|
|
179
143
|
maxWidth={maxWidth}
|
|
180
144
|
>
|
|
181
|
-
|
|
145
|
+
{typeof content === "string" ? (
|
|
146
|
+
<Text color={themeValues.linkColor}>{content}</Text>
|
|
147
|
+
) : (
|
|
148
|
+
content
|
|
149
|
+
)}
|
|
182
150
|
<Box
|
|
183
151
|
padding="0"
|
|
184
152
|
extraStyles={`
|
|
@@ -186,7 +154,11 @@ const Tooltip = ({
|
|
|
186
154
|
content: "";
|
|
187
155
|
width: 0;
|
|
188
156
|
height: 0;
|
|
189
|
-
${arrowBorder(
|
|
157
|
+
${arrowBorder(
|
|
158
|
+
arrowColor || themeValues.borderColor,
|
|
159
|
+
arrowDirection,
|
|
160
|
+
"8px"
|
|
161
|
+
)};
|
|
190
162
|
filter: drop-shadow(2px 8px 14px black);
|
|
191
163
|
bottom: ${arrowBottom};
|
|
192
164
|
right: ${arrowRight};
|
|
@@ -6,9 +6,19 @@ import * as TooltipStories from './Tooltip.stories.js';
|
|
|
6
6
|
|
|
7
7
|
<Title />
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Tooltip is an accessible tooltip component implementing the [WAI-ARIA Tooltip Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/). It displays supplemental information when the user hovers over or focuses on a trigger element.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The trigger can be either:
|
|
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.
|
|
12
22
|
|
|
13
23
|
<Controls />
|
|
14
24
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Tooltip from "./Tooltip";
|
|
3
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
contentBackgroundColor: "",
|
|
46
|
-
contentExtraStyles: ""
|
|
43
|
+
contentExtraStyles: "",
|
|
44
|
+
contentBackgroundColor: ""
|
|
47
45
|
},
|
|
48
46
|
argTypes: {
|
|
49
|
-
|
|
47
|
+
children: {
|
|
50
48
|
description:
|
|
51
|
-
"
|
|
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: "
|
|
51
|
+
type: { summary: "React.ReactNode" },
|
|
54
52
|
defaultValue: { summary: undefined }
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
|
-
|
|
55
|
+
content: {
|
|
58
56
|
description:
|
|
59
|
-
"
|
|
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: "
|
|
63
|
-
defaultValue: { summary:
|
|
59
|
+
type: { summary: "string | React.ReactNode" },
|
|
60
|
+
defaultValue: { summary: '""' }
|
|
64
61
|
}
|
|
65
62
|
},
|
|
66
|
-
|
|
63
|
+
tooltipID: {
|
|
67
64
|
description:
|
|
68
|
-
"
|
|
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:
|
|
68
|
+
defaultValue: { summary: undefined }
|
|
79
69
|
}
|
|
80
70
|
},
|
|
81
71
|
triggerText: {
|
|
82
72
|
description:
|
|
83
|
-
"Text
|
|
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: "
|
|
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:
|
|
85
|
+
summary:
|
|
86
|
+
'{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }'
|
|
103
87
|
}
|
|
104
88
|
}
|
|
105
89
|
},
|
|
106
90
|
arrowDirection: {
|
|
107
|
-
description:
|
|
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:
|
|
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
|
-
|
|
155
|
-
description:
|
|
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
|
-
|
|
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: "
|
|
152
|
+
defaultValue: { summary: "white" }
|
|
167
153
|
}
|
|
168
154
|
}
|
|
169
155
|
}
|
|
@@ -174,15 +160,67 @@ export default meta;
|
|
|
174
160
|
export const Basic = {
|
|
175
161
|
args: {
|
|
176
162
|
tooltipID: "tooltip-basic",
|
|
177
|
-
triggerText: "
|
|
178
|
-
|
|
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
|
+
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
|
+
|
|
183
219
|
export const TooltipBelow = {
|
|
184
220
|
args: {
|
|
185
221
|
tooltipID: "tooltip-below",
|
|
222
|
+
triggerText: "Hover for info",
|
|
223
|
+
content: "This tooltip appears below the trigger.",
|
|
186
224
|
contentPosition: {
|
|
187
225
|
top: "50px",
|
|
188
226
|
right: "auto",
|
|
@@ -202,6 +240,8 @@ export const TooltipBelow = {
|
|
|
202
240
|
export const TooltipRight = {
|
|
203
241
|
args: {
|
|
204
242
|
tooltipID: "tooltip-right",
|
|
243
|
+
triggerText: "Hover for info",
|
|
244
|
+
content: "This tooltip appears to the right.",
|
|
205
245
|
contentPosition: {
|
|
206
246
|
top: "-40px",
|
|
207
247
|
right: "auto",
|
|
@@ -217,21 +257,3 @@ export const TooltipRight = {
|
|
|
217
257
|
}
|
|
218
258
|
}
|
|
219
259
|
};
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
}
|