Merge pull request #4340 from urbit/james/hark/usehovering

interface: consistent hover events
This commit is contained in:
Liam Fitzgerald 2021-01-28 10:05:44 +10:00 committed by GitHub
commit 4a90989064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -363,11 +363,19 @@ export function useShowNickname(contact: Contact | null, hide?: boolean): boolea
return !!(contact && contact.nickname && !hideNicknames); return !!(contact && contact.nickname && !hideNicknames);
} }
export function useHovering() { interface useHoveringInterface {
hovering: boolean;
bind: {
onMouseOver: () => void,
onMouseLeave: () => void
}
}
export const useHovering = (): useHoveringInterface => {
const [hovering, setHovering] = useState(false); const [hovering, setHovering] = useState(false);
const bind = { const bind = {
onMouseEnter: () => setHovering(true), onMouseOver: () => setHovering(true),
onMouseLeave: () => setHovering(false) onMouseLeave: () => setHovering(false)
}; };
return { hovering, bind }; return { hovering, bind };
} };