Spaces:
Running
Running
Upload components/CategorySidebar.jsx with huggingface_hub
Browse files- components/CategorySidebar.jsx +107 -0
components/CategorySidebar.jsx
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import {
|
| 3 |
+
Grid,
|
| 4 |
+
Sandwich,
|
| 5 |
+
Coffee,
|
| 6 |
+
Pizza,
|
| 7 |
+
IceCream,
|
| 8 |
+
Salad,
|
| 9 |
+
Dessert,
|
| 10 |
+
Juice,
|
| 11 |
+
MoreHorizontal
|
| 12 |
+
} from 'lucide-react';
|
| 13 |
+
|
| 14 |
+
const CategorySidebar = ({
|
| 15 |
+
activeCategory,
|
| 16 |
+
onCategorySelect,
|
| 17 |
+
isOpen,
|
| 18 |
+
onClose
|
| 19 |
+
}) => {
|
| 20 |
+
const categories = [
|
| 21 |
+
{ id: 'all', name: 'ทั้งหมด', icon: Grid },
|
| 22 |
+
{ id: 'food', name: 'อาหาร', icon: Sandwich },
|
| 23 |
+
{ id: 'drink', name: 'เครื่องดื่ม', icon: Coffee },
|
| 24 |
+
{ id: 'fastfood', name: 'ฟาสต์ฟู้ด', icon: Pizza },
|
| 25 |
+
{ id: 'dessert', name: 'ของหวาน', icon: Dessert },
|
| 26 |
+
{ id: 'healthy', name: 'สุขภาพ', icon: Salad },
|
| 27 |
+
{ id: 'icecream', name: 'ไอศกรีม', icon: IceCream },
|
| 28 |
+
{ id: 'juice', name: 'น้ำผลไม้', icon: Juice },
|
| 29 |
+
];
|
| 30 |
+
|
| 31 |
+
return (
|
| 32 |
+
<>
|
| 33 |
+
{/* Overlay for mobile */}
|
| 34 |
+
{isOpen && (
|
| 35 |
+
<div
|
| 36 |
+
className="fixed inset-0 bg-black/50 z-40 md:hidden"
|
| 37 |
+
onClick={onClose}
|
| 38 |
+
/>
|
| 39 |
+
)}
|
| 40 |
+
|
| 41 |
+
<aside
|
| 42 |
+
className={`
|
| 43 |
+
fixed md:static left-0 top-0 h-full bg-white border-r border-pos-border
|
| 44 |
+
w-64 transform transition-transform duration-300 ease-in-out z-50
|
| 45 |
+
${isOpen ? 'translate-x-0' : '-translate-x-full md:translate-x-0'}
|
| 46 |
+
`}
|
| 47 |
+
>
|
| 48 |
+
<div className="flex flex-col h-full">
|
| 49 |
+
<div className="p-4 border-b border-pos-border flex justify-between items-center">
|
| 50 |
+
<h2 className="text-lg font-bold text-pos-text">หมวดหมู่สินค้า</h2>
|
| 51 |
+
<button onClick={onClose} className="md:hidden p-2 hover:bg-pos-bg rounded-lg">
|
| 52 |
+
<MoreHorizontal className="w-5 h-5 text-pos-text-secondary" />
|
| 53 |
+
</button>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
<div className="flex-1 overflow-y-auto p-2">
|
| 57 |
+
<div className="space-y-1">
|
| 58 |
+
{categories.map((category) => {
|
| 59 |
+
const Icon = category.icon;
|
| 60 |
+
const isActive = activeCategory === category.id;
|
| 61 |
+
|
| 62 |
+
return (
|
| 63 |
+
<button
|
| 64 |
+
key={category.id}
|
| 65 |
+
onClick={() => {
|
| 66 |
+
onCategorySelect(category.id);
|
| 67 |
+
if (window.innerWidth < 768) onClose();
|
| 68 |
+
|
| 69 |
+
className={`
|
| 70 |
+
w-full flex items-center gap-3 px-4 py-3 rounded-xl transition-all duration-200
|
| 71 |
+
${isActive
|
| 72 |
+
? 'bg-primary-600 text-white shadow-lg shadow-primary-200'
|
| 73 |
+
: 'hover:bg-pos-bg text-pos-text'
|
| 74 |
+
}
|
| 75 |
+
`}
|
| 76 |
+
>
|
| 77 |
+
<Icon className={`w-5 h-5 ${isActive ? 'text-white' : 'text-pos-text-secondary'}`} />
|
| 78 |
+
<span className="font-medium">{category.name}</span>
|
| 79 |
+
</button>
|
| 80 |
+
);
|
| 81 |
+
})}
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<div className="mt-6 px-4">
|
| 85 |
+
<div className="bg-primary-50 p-4 rounded-xl">
|
| 86 |
+
<h3 className="text-sm font-semibold text-primary-800 mb-2">โปรโมชั่นพิเศษ</h3>
|
| 87 |
+
<p className="text-xs text-primary-600 mb-3">ซื้อ 2 ชิ้ง ลด 10%</p>
|
| 88 |
+
<div className="w-full bg-primary-200 rounded-full h-1.5 mb-2">
|
| 89 |
+
<div className="bg-primary-600 rounded-full h-1.5 w-3/4"></div>
|
| 90 |
+
</div>
|
| 91 |
+
<p className="text-xs text-primary-600">90% ของสินค้ามีส่วนลด</p>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<div className="p-4 border-t border-pos-border">
|
| 97 |
+
<button className="w-full py-3 rounded-xl border border-primary-600 text-primary-600 font-medium hover:bg-primary-50 transition-colors">
|
| 98 |
+
จัดการหมวดหมู่
|
| 99 |
+
</button>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</aside>
|
| 103 |
+
</>
|
| 104 |
+
);
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
export default CategorySidebar;
|