@thecb/components 11.11.0-beta.0 → 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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { createThemeValues
|
|
2
|
+
import { createThemeValues } from "../../../util/themeUtils";
|
|
3
3
|
import { ThemeContext } from "styled-components";
|
|
4
4
|
import Text from "../../atoms/text";
|
|
5
5
|
import { Box } from "../../atoms/layouts";
|
|
6
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
7
|
import { noop, arrowBorder } from "../../../util/general";
|
|
8
|
-
import { fallbackValues } from "./Tooltip.theme";
|
|
8
|
+
import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
|
|
9
9
|
|
|
10
10
|
const Tooltip = ({
|
|
11
11
|
tooltipID,
|
|
@@ -19,19 +19,18 @@ const Tooltip = ({
|
|
|
19
19
|
minWidth = "250px",
|
|
20
20
|
maxWidth = "100%",
|
|
21
21
|
height = "auto",
|
|
22
|
-
arrowDirection = "down",
|
|
23
22
|
contentPosition = {
|
|
24
|
-
top: "
|
|
23
|
+
top: "-110px",
|
|
25
24
|
right: "auto",
|
|
26
|
-
bottom: "
|
|
27
|
-
left: "
|
|
28
|
-
transform: "translateX(-50%)" // shifts left by half tooltip's own width → centered
|
|
25
|
+
bottom: "auto",
|
|
26
|
+
left: "-225px"
|
|
29
27
|
},
|
|
28
|
+
arrowDirection = "down",
|
|
30
29
|
arrowPosition = {
|
|
31
30
|
arrowTop: "auto",
|
|
32
|
-
arrowRight: "
|
|
31
|
+
arrowRight: "10px",
|
|
33
32
|
arrowBottom: "-8px",
|
|
34
|
-
arrowLeft: "
|
|
33
|
+
arrowLeft: "auto"
|
|
35
34
|
},
|
|
36
35
|
arrowColor
|
|
37
36
|
}) => {
|
|
@@ -41,7 +40,7 @@ const Tooltip = ({
|
|
|
41
40
|
const themeValues = createThemeValues(
|
|
42
41
|
themeContext,
|
|
43
42
|
fallbackValues,
|
|
44
|
-
|
|
43
|
+
TOOLTIP_THEME_SOURCE
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
const { top, right, bottom, left } = contentPosition;
|
|
@@ -83,21 +82,12 @@ const Tooltip = ({
|
|
|
83
82
|
|
|
84
83
|
const renderTrigger = () => {
|
|
85
84
|
if (hasCustomTrigger && children) {
|
|
86
|
-
return (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
data-qa={`tooltip-trigger-${tooltipID}`}
|
|
93
|
-
aria-describedby={tooltipID}
|
|
94
|
-
onFocus={() => handleToggleTooltip(true)}
|
|
95
|
-
onBlur={() => handleToggleTooltip(false)}
|
|
96
|
-
onKeyDown={handleKeyDown}
|
|
97
|
-
>
|
|
98
|
-
{children}
|
|
99
|
-
</Box>
|
|
100
|
-
);
|
|
85
|
+
return React.cloneElement(React.Children.only(children), {
|
|
86
|
+
"aria-describedby": tooltipID,
|
|
87
|
+
onFocus: () => handleToggleTooltip(true),
|
|
88
|
+
onBlur: () => handleToggleTooltip(false),
|
|
89
|
+
onKeyDown: handleKeyDown
|
|
90
|
+
});
|
|
101
91
|
}
|
|
102
92
|
|
|
103
93
|
return (
|
|
@@ -113,10 +103,9 @@ const Tooltip = ({
|
|
|
113
103
|
text={triggerText}
|
|
114
104
|
extraStyles={`
|
|
115
105
|
color: ${themeValues.linkColor};
|
|
116
|
-
|
|
117
|
-
&:
|
|
118
|
-
|
|
119
|
-
button, span, &:hover span { text-decoration: none; }
|
|
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; }
|
|
120
109
|
`}
|
|
121
110
|
/>
|
|
122
111
|
);
|
|
@@ -182,4 +171,4 @@ const Tooltip = ({
|
|
|
182
171
|
);
|
|
183
172
|
};
|
|
184
173
|
|
|
185
|
-
export default
|
|
174
|
+
export default Tooltip;
|