Added a guest haptics preference and surfaced it in both the settings sheet and /settings, with safe device detection
and a reduced‑motion guard. Haptics now honor the toggle and still fall back gracefully on iOS (switch disabled when
navigator.vibrate isn’t available).
What changed
- Haptics preference storage + gating: resources/js/guest/lib/haptics.ts
- Preference hook: resources/js/guest/hooks/useHapticsPreference.ts
- Settings UI toggle in sheet + page: resources/js/guest/components/settings-sheet.tsx, resources/js/guest/pages/
SettingsPage.tsx
- i18n labels: resources/js/guest/i18n/messages.ts
- Tests: resources/js/guest/lib/__tests__/haptics.test.ts
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
import { getDeviceId } from '../lib/device';
|
||||
import { FADE_SCALE, FADE_UP, STAGGER_FAST, getMotionContainerProps, getMotionItemProps, prefersReducedMotion } from '../lib/motion';
|
||||
import PullToRefresh from '../components/PullToRefresh';
|
||||
import { triggerHaptic } from '../lib/haptics';
|
||||
|
||||
interface Task {
|
||||
id: number;
|
||||
@@ -226,10 +227,12 @@ export default function TaskPickerPage() {
|
||||
|
||||
const handleNewTask = React.useCallback(() => {
|
||||
selectRandomTask(filteredTasks);
|
||||
triggerHaptic('selection');
|
||||
}, [filteredTasks, selectRandomTask]);
|
||||
|
||||
const handleStartUpload = () => {
|
||||
if (!currentTask || !eventKey) return;
|
||||
triggerHaptic('light');
|
||||
navigate(`/e/${encodeURIComponent(eventKey)}/upload?task=${currentTask.id}&emotion=${currentTask.emotion?.slug || ''}`);
|
||||
};
|
||||
|
||||
@@ -240,6 +243,7 @@ export default function TaskPickerPage() {
|
||||
|
||||
const handleSelectTask = React.useCallback((task: Task) => {
|
||||
setCurrentTask(task);
|
||||
triggerHaptic('selection');
|
||||
}, []);
|
||||
|
||||
const handleRetryFetch = () => {
|
||||
|
||||
Reference in New Issue
Block a user