create-ekka-desktop-app 0.4.7 → 0.4.8
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,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Info Tooltip Component
|
|
3
3
|
* Shows an info icon that displays tooltip text on hover.
|
|
4
|
+
* Uses position: fixed to avoid being clipped by parent overflow.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
import { useState, type CSSProperties, type ReactElement } from 'react';
|
|
7
|
+
import { useState, useRef, type CSSProperties, type ReactElement } from 'react';
|
|
7
8
|
|
|
8
9
|
interface InfoTooltipProps {
|
|
9
10
|
text: string;
|
|
@@ -12,6 +13,8 @@ interface InfoTooltipProps {
|
|
|
12
13
|
|
|
13
14
|
export function InfoTooltip({ text, darkMode = false }: InfoTooltipProps): ReactElement {
|
|
14
15
|
const [isVisible, setIsVisible] = useState(false);
|
|
16
|
+
const [pos, setPos] = useState({ top: 0, left: 0 });
|
|
17
|
+
const iconRef = useRef<HTMLSpanElement>(null);
|
|
15
18
|
|
|
16
19
|
const colors = {
|
|
17
20
|
icon: darkMode ? '#98989d' : '#86868b',
|
|
@@ -20,6 +23,14 @@ export function InfoTooltip({ text, darkMode = false }: InfoTooltipProps): React
|
|
|
20
23
|
tooltipText: '#ffffff',
|
|
21
24
|
};
|
|
22
25
|
|
|
26
|
+
function handleEnter() {
|
|
27
|
+
if (iconRef.current) {
|
|
28
|
+
const rect = iconRef.current.getBoundingClientRect();
|
|
29
|
+
setPos({ top: rect.top - 8, left: rect.left + rect.width / 2 });
|
|
30
|
+
}
|
|
31
|
+
setIsVisible(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
const styles: Record<string, CSSProperties> = {
|
|
24
35
|
container: {
|
|
25
36
|
position: 'relative',
|
|
@@ -34,11 +45,10 @@ export function InfoTooltip({ text, darkMode = false }: InfoTooltipProps): React
|
|
|
34
45
|
transition: 'color 0.15s ease',
|
|
35
46
|
},
|
|
36
47
|
tooltip: {
|
|
37
|
-
position: '
|
|
38
|
-
|
|
39
|
-
left:
|
|
40
|
-
transform: '
|
|
41
|
-
marginBottom: '8px',
|
|
48
|
+
position: 'fixed',
|
|
49
|
+
top: pos.top,
|
|
50
|
+
left: pos.left,
|
|
51
|
+
transform: 'translate(-50%, -100%)',
|
|
42
52
|
padding: '8px 12px',
|
|
43
53
|
background: colors.tooltipBg,
|
|
44
54
|
color: colors.tooltipText,
|
|
@@ -48,18 +58,20 @@ export function InfoTooltip({ text, darkMode = false }: InfoTooltipProps): React
|
|
|
48
58
|
whiteSpace: 'normal',
|
|
49
59
|
maxWidth: '320px',
|
|
50
60
|
width: 'max-content',
|
|
51
|
-
zIndex:
|
|
61
|
+
zIndex: 10000,
|
|
52
62
|
opacity: isVisible ? 1 : 0,
|
|
53
63
|
visibility: isVisible ? 'visible' : 'hidden',
|
|
54
64
|
transition: 'opacity 0.15s ease, visibility 0.15s ease',
|
|
55
65
|
pointerEvents: 'none',
|
|
66
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.25)',
|
|
56
67
|
},
|
|
57
68
|
};
|
|
58
69
|
|
|
59
70
|
return (
|
|
60
71
|
<span
|
|
72
|
+
ref={iconRef}
|
|
61
73
|
style={styles.container}
|
|
62
|
-
onMouseEnter={
|
|
74
|
+
onMouseEnter={handleEnter}
|
|
63
75
|
onMouseLeave={() => setIsVisible(false)}
|
|
64
76
|
>
|
|
65
77
|
<svg style={styles.icon} viewBox="0 0 16 16" fill="none">
|