* Add comprehensive mobile support with responsive navigation

- Add hamburger drawer navigation for mobile (< 768px)
  - Create useIsMobile hook for responsive breakpoint detection
  - Create useLongPress hook for touch gesture context menus
  - Update Button component with 44px min-height for WCAG touch compliance
  - Update Toggle component with larger mobile size (44x28px)
  - Add responsive padding (p-4 md:p-8) to all pages
  - Update ArchivesPage with mobile menu button and horizontal scroll filters
  - Update SettingsPage with stacked column layout on mobile
  - Increase drag handle sizes for touch-friendly reordering
  - Add CSS utilities for touch-manipulation and safe-area insets
This commit is contained in:
maziggy
2025-12-09 12:55:59 +00:00
parent b4007c9594
commit 42cdfdbd74
20 changed files with 8857 additions and 8682 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useState, useEffect } from 'react';
const MOBILE_BREAKPOINT = 768; // md breakpoint
export function useIsMobile(): boolean {
const [isMobile, setIsMobile] = useState(() =>
typeof window !== 'undefined' ? window.innerWidth < MOBILE_BREAKPOINT : false
);
useEffect(() => {
const mediaQuery = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const handleChange = (e: MediaQueryListEvent) => {
setIsMobile(e.matches);
};
// Set initial value
setIsMobile(mediaQuery.matches);
// Modern browsers support addEventListener
mediaQuery.addEventListener('change', handleChange);
return () => mediaQuery.removeEventListener('change', handleChange);
}, []);
return isMobile;
}
+46
View File
@@ -0,0 +1,46 @@
import { useCallback, useRef } from 'react';
interface LongPressOptions {
onLongPress: (e: React.TouchEvent | React.MouseEvent) => void;
onClick?: () => void;
delay?: number;
}
export function useLongPress({ onLongPress, onClick, delay = 500 }: LongPressOptions) {
const timeoutRef = useRef<number | null>(null);
const targetRef = useRef<EventTarget | null>(null);
const longPressTriggered = useRef(false);
const start = useCallback(
(e: React.TouchEvent | React.MouseEvent) => {
longPressTriggered.current = false;
targetRef.current = e.target;
timeoutRef.current = window.setTimeout(() => {
longPressTriggered.current = true;
onLongPress(e);
}, delay);
},
[onLongPress, delay]
);
const clear = useCallback(
(e: React.TouchEvent | React.MouseEvent, shouldTriggerClick = true) => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
if (shouldTriggerClick && !longPressTriggered.current && onClick && targetRef.current === e.target) {
onClick();
}
},
[onClick]
);
return {
onMouseDown: start,
onMouseUp: (e: React.MouseEvent) => clear(e, true),
onMouseLeave: (e: React.MouseEvent) => clear(e, false),
onTouchStart: start,
onTouchEnd: (e: React.TouchEvent) => clear(e, true),
};
}