ThreeCard.tsx
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import Link from 'next/link';
import Image from 'next/image';
// 假设这是从 somewhere 引入的 hook 或者 store
// import { useCategoryStore, useProductListStore } from 'somewhere';
const MATERIALS = [
{ name: 'Energy materials', imageUrl: '/imgs/pc/home/materials/1.jpg', href: '/products' },
{
name: 'Laboratory consumables',
imageUrl: '/imgs/pc/home/materials/2.png',
href: '/products'
},
{
name: 'Low-dimensional materials',
imageUrl: '/imgs/pc/home/materials/3.png',
href: '/products'
}
]
const ThreeCard = async ({ title, desc }) => {
// const categoryStore = useCategoryStore();
// const productStore = useProductListStore();
// 模拟更新类别和子类别的逻辑
const updateCategory = (item) => {
// categoryStore.updateCategory(item.name);
// const find = categoryStore.list.find(c => c.categoryDisplayName === item.name);
// categoryStore.updateSubCategory(find.list[0].id);
// productStore.updatePageNo(1);
// 路由逻辑
};
return (
<div>
<div className='text-primary-blue text-center mb-4 font-bold text-6xl'>
{title}
</div>
<div className="text-body-1 max-w-[600px] mx-auto mb-8">
<span className="mb-16 max-w-[600px] mx-auto text-gray ">{desc}</span>
</div>
<div className="grid grid-cols-3 lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 gap-4">
{(MATERIALS || []).map((item, index) => (
// onClick={() => updateCategory(item)}
<div key={index} className="cursor-pointer">
<div className="shadow-lg hover:shadow-2xl transition-shadow duration-300 ease-in-out text-center ">
{item.imageUrl && (
<Image src={item.imageUrl} alt={item.name} width={200} height={200} />
)}
<div className="text-center bg-primary-blue text-white w-full h-9 leading-9">
{item.name}
</div>
</div>
</div>
))}
</div>
</div>
);
}
export default ThreeCard;