Appearance
Smoke Test
Quick sanity check to verify intent-click works in your project.
1. Create a Vite project
bash
npm create vite@latest test-intent-click -- --template react-ts
cd test-intent-click
npm install
npm install intent-click2. Add test component
typescript
// src/App.tsx
import { useState } from 'react';
import { useIntentClick } from 'intent-click/react';
function App() {
const [clickCount, setClickCount] = useState(0);
const [cancelReason, setCancelReason] = useState<string | null>(null);
const handleClick = (event: PointerEvent) => {
setClickCount((c) => c + 1);
setCancelReason(null);
console.log('Intent click!', event.clientX, event.clientY);
};
const ref = useIntentClick<HTMLButtonElement>(handleClick, {
threshold: 'auto',
longPressDelay: 500,
onLongPress: () => {
console.log('Long press!');
setCancelReason('long-press');
},
onIntentCancel: (reason) => {
setCancelReason(reason);
console.log('Cancelled:', reason);
},
});
return (
<div style={{ padding: '2rem' }}>
<h1>intent-click Smoke Test</h1>
<button
ref={ref}
style={{
padding: '1rem 2rem',
fontSize: '1.5rem',
background: '#007bff',
color: 'white',
border: 'none',
borderRadius: '8px',
}}
>
Click Me
</button>
<p>Intent clicks: {clickCount}</p>
{cancelReason && <p style={{ color: 'red' }}>Last cancel: {cancelReason}</p>}
<p style={{ color: '#666' }}>
Try: scroll-drag over button, long press, multi-touch
</p>
</div>
);
}
export default App;3. Run
bash
npm run dev4. Verify
- Normal click: Counter increments
- Drag while clicking: Cancelled with "drag"
- Scroll over button: Cancelled with "scroll"
- Long press (>500ms): "long-press" message
- Multi-touch: Cancelled with "concurrent-pointer"
5. Check bundle size
bash
npm run build
npx vite-bundle-visualizerVerify intent-click is < 1KB gzip.