Spaces:
Sleeping
Sleeping
Download components/SearchFilters.jsx from ryeisi/anycoder-6b75aad4: direct link, hf CLI and curl.
- Browser
- Download file 3.19 kB
-
https://huggingface.co/spaces/ryeisi/anycoder-6b75aad4/resolve/main/components/SearchFilters.jsx
- Command line
-
hf download hf://spaces/ryeisi/anycoder-6b75aad4/components/SearchFilters.jsx
-
curl -L -o SearchFilters.jsx https://huggingface.co/spaces/ryeisi/anycoder-6b75aad4/resolve/main/components/SearchFilters.jsx
3.19 kB
| import { useState } from 'react'; | |
| import { Search, Filter } from 'lucide-react'; | |
| export default function SearchFilters({ onFilterChange }) { | |
| const [filters, setFilters] = useState({ | |
| type: 'all', | |
| minPrice: '', | |
| maxPrice: '', | |
| bedrooms: 'all' | |
| }); | |
| const handleFilterChange = (key, value) => { | |
| const newFilters = { ...filters, [key]: value }; | |
| setFilters(newFilters); | |
| onFilterChange(newFilters); | |
| }; | |
| return ( | |
| <div className="bg-white rounded-xl shadow-lg p-6 -mt-8 relative z-10"> | |
| <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4"> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Property Type</label> | |
| <select | |
| className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" | |
| value={filters.type} | |
| onChange={(e) => handleFilterChange('type', e.target.value)} | |
| > | |
| <option value="all">All Types</option> | |
| <option value="apartment">Apartment</option> | |
| <option value="house">House</option> | |
| <option value="condo">Condo</option> | |
| <option value="villa">Villa</option> | |
| <option value="studio">Studio</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Min Price</label> | |
| <input | |
| type="number" | |
| placeholder="No minimum" | |
| className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" | |
| value={filters.minPrice} | |
| onChange={(e) => handleFilterChange('minPrice', e.target.value)} | |
| /> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Max Price</label> | |
| <input | |
| type="number" | |
| placeholder="No maximum" | |
| className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" | |
| value={filters.maxPrice} | |
| onChange={(e) => handleFilterChange('maxPrice', e.target.value)} | |
| /> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Bedrooms</label> | |
| <select | |
| className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" | |
| value={filters.bedrooms} | |
| onChange={(e) => handleFilterChange('bedrooms', e.target.value)} | |
| > | |
| <option value="all">Any</option> | |
| <option value="1">1+</option> | |
| <option value="2">2+</option> | |
| <option value="3">3+</option> | |
| <option value="4">4+</option> | |
| <option value="5">5+</option> | |
| </select> | |
| </div> | |
| <div className="flex items-end"> | |
| <button className="w-full btn-primary flex items-center justify-center gap-2"> | |
| <Search className="w-5 h-5" /> | |
| Search | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } |