Spaces:
Running
Running
Download components/SearchBar.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/SearchBar.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/components/SearchBar.js
-
curl -L -o SearchBar.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/SearchBar.js
1.63 kB
| import { useState } from 'react' | |
| import { useDebounce } from '../hooks/useDebounce' | |
| export default function SearchBar({ onSearch, isSearching }) { | |
| const [value, setValue] = useState('') | |
| const debouncedValue = useDebounce(value, 300) | |
| useState(() => { | |
| onSearch(debouncedValue) | |
| }, [debouncedValue, onSearch]) | |
| return ( | |
| <div className="relative max-w-3xl mx-auto"> | |
| <div className="relative"> | |
| <input | |
| type="text" | |
| value={value} | |
| onChange={(e) => setValue(e.target.value)} | |
| 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> | |
| ) | |
| } |