Spaces:
Sleeping
Sleeping
Download components/SearchBar.jsx from ryeisi/anycoder-7491f760: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/ryeisi/anycoder-7491f760/resolve/main/components/SearchBar.jsx
- Command line
-
hf download hf://spaces/ryeisi/anycoder-7491f760/components/SearchBar.jsx
-
curl -L -o SearchBar.jsx https://huggingface.co/spaces/ryeisi/anycoder-7491f760/resolve/main/components/SearchBar.jsx
1.15 kB
| import { useState } from 'react'; | |
| import { FiSearch, FiMapPin } from 'react-icons/fi'; | |
| export default function SearchBar({ onSearch }) { | |
| const [city, setCity] = useState(''); | |
| const handleSubmit = (e) => { | |
| e.preventDefault(); | |
| onSearch(city); | |
| }; | |
| return ( | |
| <form onSubmit={handleSubmit} className="w-full max-w-2xl mx-auto"> | |
| <div className="relative"> | |
| <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> | |
| <FiMapPin className="text-gray-400" /> | |
| </div> | |
| <input | |
| type="text" | |
| value={city} | |
| onChange={(e) => setCity(e.target.value)} | |
| placeholder="Enter your city..." | |
| className="block w-full pl-10 pr-12 py-3 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-primary focus:border-primary" | |
| /> | |
| <button | |
| type="submit" | |
| className="absolute inset-y-0 right-0 px-4 flex items-center bg-primary text-white rounded-r-lg hover:bg-primary-dark transition" | |
| > | |
| <FiSearch className="mr-2" /> | |
| Search | |
| </button> | |
| </div> | |
| </form> | |
| ); | |
| } |