Spaces:
Sleeping
Sleeping
Upload components/SearchBar.jsx with huggingface_hub
Browse files- components/SearchBar.jsx +35 -0
components/SearchBar.jsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { FiSearch, FiMapPin } from 'react-icons/fi';
|
| 3 |
+
|
| 4 |
+
export default function SearchBar({ onSearch }) {
|
| 5 |
+
const [city, setCity] = useState('');
|
| 6 |
+
|
| 7 |
+
const handleSubmit = (e) => {
|
| 8 |
+
e.preventDefault();
|
| 9 |
+
onSearch(city);
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
return (
|
| 13 |
+
<form onSubmit={handleSubmit} className="w-full max-w-2xl mx-auto">
|
| 14 |
+
<div className="relative">
|
| 15 |
+
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
| 16 |
+
<FiMapPin className="text-gray-400" />
|
| 17 |
+
</div>
|
| 18 |
+
<input
|
| 19 |
+
type="text"
|
| 20 |
+
value={city}
|
| 21 |
+
onChange={(e) => setCity(e.target.value)}
|
| 22 |
+
placeholder="Enter your city..."
|
| 23 |
+
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"
|
| 24 |
+
/>
|
| 25 |
+
<button
|
| 26 |
+
type="submit"
|
| 27 |
+
className="absolute inset-y-0 right-0 px-4 flex items-center bg-primary text-white rounded-r-lg hover:bg-primary-dark transition"
|
| 28 |
+
>
|
| 29 |
+
<FiSearch className="mr-2" />
|
| 30 |
+
Search
|
| 31 |
+
</button>
|
| 32 |
+
</div>
|
| 33 |
+
</form>
|
| 34 |
+
);
|
| 35 |
+
}
|