mouris030 commited on
Commit
67d85f3
·
verified ·
1 Parent(s): 07e8b1e

Upload components/CategorySection.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/CategorySection.js +48 -0
components/CategorySection.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function CategorySection({ title, products, onAddToCart }) {
2
+ return (
3
+ <section className="py-8">
4
+ <div className="max-w-7xl mx-auto px-4">
5
+ <div className="flex items-center justify-between mb-6">
6
+ <h2 className="text-2xl font-bold text-gray-800">{title}</h2>
7
+ <a href="#" className="text-sm text-blue-500 hover:underline">See more</a>
8
+ </div>
9
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
10
+ {products.slice(0, 4).map((product) => (
11
+ <div key={product.id} className="bg-white rounded-lg shadow-md p-4 hover:shadow-lg transition-shadow">
12
+ <div className="h-40 bg-gray-100 rounded-lg mb-4 flex items-center justify-center">
13
+ <img
14
+ src={product.image}
15
+ alt={product.name}
16
+ className="max-h-full max-w-full object-contain"
17
+ />
18
+ </div>
19
+ <h3 className="text-sm font-medium text-gray-800 line-clamp-2 mb-2">{product.name}</h3>
20
+ <div className="flex items-center space-x-1 mb-2">
21
+ {[...Array(5)].map((_, i) => (
22
+ <svg
23
+ key={i}
24
+ className={`w-4 h-4 ${i < Math.floor(product.rating) ? 'text-yellow-400' : 'text-gray-300'}`}
25
+ fill="currentColor"
26
+ viewBox="0 0 20 20"
27
+ >
28
+ <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"/>
29
+ </svg>
30
+ ))}
31
+ </div>
32
+ <div className="flex items-baseline space-x-1">
33
+ <span className="text-xs text-gray-500">$</span>
34
+ <span className="text-xl font-bold">{product.price}</span>
35
+ </div>
36
+ <button
37
+ onClick={() => onAddToCart(product)}
38
+ className="w-full mt-3 bg-amazon-yellow hover:bg-yellow-500 text-gray-900 font-medium py-2 rounded text-sm transition-colors"
39
+ >
40
+ Add to Cart
41
+ </button>
42
+ </div>
43
+ ))}
44
+ </div>
45
+ </div>
46
+ </section>
47
+ );
48
+ }