Spaces:
Build error
Build error
Download components/CategorySection.js from mouris030/anycoder-044de774: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/spaces/mouris030/anycoder-044de774/resolve/main/components/CategorySection.js
- Command line
-
hf download hf://spaces/mouris030/anycoder-044de774/components/CategorySection.js
-
curl -L -o CategorySection.js https://huggingface.co/spaces/mouris030/anycoder-044de774/resolve/main/components/CategorySection.js
2.46 kB
| export default function CategorySection({ title, products, onAddToCart }) { | |
| return ( | |
| <section className="py-8"> | |
| <div className="max-w-7xl mx-auto px-4"> | |
| <div className="flex items-center justify-between mb-6"> | |
| <h2 className="text-2xl font-bold text-gray-800">{title}</h2> | |
| <a href="#" className="text-sm text-blue-500 hover:underline">See more</a> | |
| </div> | |
| <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6"> | |
| {products.slice(0, 4).map((product) => ( | |
| <div key={product.id} className="bg-white rounded-lg shadow-md p-4 hover:shadow-lg transition-shadow"> | |
| <div className="h-40 bg-gray-100 rounded-lg mb-4 flex items-center justify-center"> | |
| <img | |
| src={product.image} | |
| alt={product.name} | |
| className="max-h-full max-w-full object-contain" | |
| /> | |
| </div> | |
| <h3 className="text-sm font-medium text-gray-800 line-clamp-2 mb-2">{product.name}</h3> | |
| <div className="flex items-center space-x-1 mb-2"> | |
| {[...Array(5)].map((_, i) => ( | |
| <svg | |
| key={i} | |
| className={`w-4 h-4 ${i < Math.floor(product.rating) ? 'text-yellow-400' : 'text-gray-300'}`} | |
| fill="currentColor" | |
| viewBox="0 0 20 20" | |
| > | |
| <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/> | |
| </svg> | |
| ))} | |
| </div> | |
| <div className="flex items-baseline space-x-1"> | |
| <span className="text-xs text-gray-500">$</span> | |
| <span className="text-xl font-bold">{product.price}</span> | |
| </div> | |
| <button | |
| onClick={() => onAddToCart(product)} | |
| className="w-full mt-3 bg-amazon-yellow hover:bg-yellow-500 text-gray-900 font-medium py-2 rounded text-sm transition-colors" | |
| > | |
| Add to Cart | |
| </button> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| </section> | |
| ); | |
| } |