Spaces:
Running
Running
Upload components/SearchBar.js with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import { useState, useRef, useEffect } from 'react'
export default function SearchBar({ onSearch, isSearching }) { const [value, setValue] = useState('') const timeoutRef = useRef(null)
const handleChange = (e) => { const newValue = e.target.value setValue(newValue) // Debounce search if (timeoutRef.current) clearTimeout(timeoutRef.current) timeoutRef.current = setTimeout(() => { onSearch(newValue) }, 300) }
return ( <div className="relative max-w-3xl mx-auto"> <div className="relative"> <input type="text" value={value} onChange={handleChange} placeholder="Search transcripts, tags, or keywords..." className="input-field pl-12 pr-12 py-4 text-lg shadow-xl" autoFocus /> <div className="absolute left-4 top-1/2 -translate-y-1/2 text-dark-500"> <svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /> </svg> </div> {isSearching && ( <div className="absolute right-4 top-1/2 -translate-y-1/2"> <div className="w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"></div> </div> )} </div> <div className="flex justify-center gap-2 mt-4 text-xs text-dark-500"> <span className="bg-dark-800 px-2 py-1 rounded border border-dark-700">Tip: Use quotes for exact phrases</span> <span className="bg-dark-800 px-2 py-1 rounded border border-dark-700">Tip: Use * for wildcards</span> </div> </div> )}components/SearchBar.jsAdded+48