- useApiFetch: typed fetch wrapper with network/http error discrimination - useMotion: reactive localStorage override for rich-animation toggle, respects OS prefers-reduced-motion - useHaptics: label/discard/skip/undo vibration patterns, gated on rich mode - useKonamiCode + useHackerMode: 10-key Konami sequence → hacker theme, persisted in localStorage - test-setup.ts: jsdom matchMedia stub so useMotion imports cleanly in Vitest - smoke.test.ts: import smoke tests for all 4 composables (12 tests, all passing)
18 lines
446 B
TypeScript
18 lines
446 B
TypeScript
import { useMotion } from './useMotion'
|
|
|
|
export function useHaptics() {
|
|
const { rich } = useMotion()
|
|
|
|
function vibrate(pattern: number | number[]) {
|
|
if (rich.value && typeof navigator !== 'undefined' && 'vibrate' in navigator) {
|
|
navigator.vibrate(pattern)
|
|
}
|
|
}
|
|
|
|
return {
|
|
label: () => vibrate(40),
|
|
discard: () => vibrate([40, 30, 40]),
|
|
skip: () => vibrate(15),
|
|
undo: () => vibrate([20, 20, 60]),
|
|
}
|
|
}
|