improved tooltips

This commit is contained in:
2026-01-07 09:02:16 -07:00
parent 678727c650
commit fb5ee94b55
5 changed files with 54 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
import { useState, useRef, useCallback } from "react";
export const useTooltip = (delayMs: number = 150) => {
const [visible, setVisible] = useState(false);
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
const targetRef = useRef<HTMLAnchorElement>(null);
const showTooltip = useCallback(() => {
timeoutRef.current = setTimeout(() => {
setVisible(true);
}, delayMs);
}, [delayMs]);
const hideTooltip = useCallback(() => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
setVisible(false);
}, []);
return {
visible,
targetRef,
showTooltip,
hideTooltip,
};
};