Changed position of theme button, hiding tooltip after set time. (#735)

* fix: changed position of theme button, hiding tooltip after set time.

* feat: added usevisibility hook

* updating paths
This commit is contained in:
Dan Ditomaso
2025-07-25 12:48:57 -04:00
committed by GitHub
parent 50ca75da0e
commit 3c1399b44a
3 changed files with 53 additions and 11 deletions
@@ -0,0 +1,32 @@
import { useCallback, useEffect, useRef, useState } from "react";
export function useToggleVisibility({ timeout }: { timeout?: number } = {}) {
const [isVisible, setIsVisible] = useState(false);
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const show = useCallback(() => {
setIsVisible(true);
if (timeout) {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
timeoutRef.current = setTimeout(() => {
setIsVisible(false);
timeoutRef.current = null;
}, timeout);
}
}, [timeout]);
// Clear timeout on unmount
useEffect(() => {
return () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
};
}, []);
return [isVisible, show] as const;
}