diff --git a/frontend/src/components/Tooltip.jsx b/frontend/src/components/Tooltip.jsx index 787097d..2e9a1ce 100644 --- a/frontend/src/components/Tooltip.jsx +++ b/frontend/src/components/Tooltip.jsx @@ -1,8 +1,8 @@ import { useState, useRef, useEffect } from 'react' /** - * Tooltip компонент для отображения подсказок - * Поддерживает keyboard shortcuts и различные позиции + * Tooltip компонент в стиле Tabler UI + * Использует position: absolute относительно trigger элемента */ function Tooltip({ children, @@ -13,43 +13,14 @@ function Tooltip({ className = '' }) { const [isVisible, setIsVisible] = useState(false) - const [coords, setCoords] = useState({ x: 0, y: 0 }) const timeoutRef = useRef(null) const triggerRef = useRef(null) - const showTooltip = (e) => { + const showTooltip = () => { if (timeoutRef.current) clearTimeout(timeoutRef.current) timeoutRef.current = setTimeout(() => { - if (triggerRef.current) { - const rect = triggerRef.current.getBoundingClientRect() - let x = 0, y = 0 - - switch (position) { - case 'top': - x = rect.left + rect.width / 2 - y = rect.top - break - case 'bottom': - x = rect.left + rect.width / 2 - y = rect.bottom - break - case 'left': - x = rect.left - y = rect.top + rect.height / 2 - break - case 'right': - x = rect.right - y = rect.top + rect.height / 2 - break - default: - x = rect.left + rect.width / 2 - y = rect.top - } - - setCoords({ x, y }) - setIsVisible(true) - } + setIsVisible(true) }, delay) } @@ -69,129 +40,94 @@ function Tooltip({ }, []) return ( - <> - - {children} - + + {children} {isVisible && (
+
{ + const styles = { + position: 'absolute', + width: '8px', + height: '8px', + background: 'inherit' + } + if (position === 'top') { + styles.bottom = '0' + styles.left = '50%' + styles.transform = 'translateX(-50%) translateY(50%) rotate(45deg)' + } else if (position === 'bottom') { + styles.top = '0' + styles.left = '50%' + styles.transform = 'translateX(-50%) translateY(-50%) rotate(45deg)' + } else if (position === 'left') { + styles.right = '0' + styles.top = '50%' + styles.transform = 'translateX(50%) translateY(-50%) rotate(45deg)' + } else if (position === 'right') { + styles.left = '0' + styles.top = '50%' + styles.transform = 'translateX(-50%) translateY(-50%) rotate(45deg)' + } + return styles + })()}>
-
{content}
+ {content} {shortcut && ( - {shortcut} + {shortcut} )}
)} - - - +
) }