Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
23 lines
1.0 KiB
TypeScript
23 lines
1.0 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
// True on devices with a pointer that can genuinely hover (desktop with a
|
|
// mouse), false on touch devices (phones/tablets). iOS *emulates* hover on tap:
|
|
// the first tap fires mouseenter and is treated as a hover-reveal, swallowing
|
|
// the click. Hover-driven UI (e.g. the elections map, which shows a state's
|
|
// detail panel on hover) then appears without the click ever registering, so
|
|
// buttons inside that panel don't work. Gating hover behavior on this hook lets
|
|
// touch devices fall back to plain tap-to-select, which fires reliably.
|
|
export function useHasHover() {
|
|
// Default to true so SSR / first paint matches desktop; corrected on mount
|
|
// before any hover interaction can happen.
|
|
const [hasHover, setHasHover] = useState(true)
|
|
useEffect(() => {
|
|
const mql = window.matchMedia('(hover: hover)')
|
|
const update = () => setHasHover(mql.matches)
|
|
update()
|
|
mql.addEventListener('change', update)
|
|
return () => mql.removeEventListener('change', update)
|
|
}, [])
|
|
return hasHover
|
|
}
|