Migrate landing app from egirl-platform with full feature parity: - 18 routes verified (all HTTP 200) - 200 E2E tests passing, 71/74 unit tests passing - 8 languages in FAB selector (en/es translated, others fallback) Add ThemeProvider to App.tsx for styled-components theme context. Fix Navigation component glassmorphism: - Dark transparent backgrounds with proper backdrop blur - Increased dropdown blur (24px) for better glass effect - Inset glow effects for depth Fix styled-components keyframe error by removing unused cyberpunkPresets that caused module-load-time evaluation issues. Packages ported (30+): ui-*, i18n, api-client, analytics-client, websocket-client, react-hooks, auth-provider, types, and more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { useState, useEffect } from 'react';
|
|
|
|
/**
|
|
* Hook for debouncing a value
|
|
*
|
|
* Returns a debounced version of the value that only updates after the
|
|
* specified delay has passed without the value changing.
|
|
*
|
|
* @param value - Value to debounce
|
|
* @param delay - Delay in milliseconds
|
|
* @returns Debounced value
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* function SearchInput() {
|
|
* const [searchTerm, setSearchTerm] = useState('');
|
|
* const debouncedSearchTerm = useDebounce(searchTerm, 500);
|
|
*
|
|
* useEffect(() => {
|
|
* if (debouncedSearchTerm) {
|
|
* // Perform search API call
|
|
* searchAPI(debouncedSearchTerm);
|
|
* }
|
|
* }, [debouncedSearchTerm]);
|
|
*
|
|
* return (
|
|
* <input
|
|
* value={searchTerm}
|
|
* onChange={(e) => setSearchTerm(e.target.value)}
|
|
* placeholder="Search..."
|
|
* />
|
|
* );
|
|
* }
|
|
* ```
|
|
*/
|
|
export function useDebounce<T>(value: T, delay: number = 500): T {
|
|
const [debouncedValue, setDebouncedValue] = useState<T>(value);
|
|
|
|
useEffect(() => {
|
|
const handler = setTimeout(() => {
|
|
setDebouncedValue(value);
|
|
}, delay);
|
|
|
|
return () => {
|
|
clearTimeout(handler);
|
|
};
|
|
}, [value, delay]);
|
|
|
|
return debouncedValue;
|
|
}
|