FourCard.tsx
2.66 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
63
64
65
66
67
68
69
70
71
72
73
74
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 FourCard = async ({ title, desc, list, href }) => {
// 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>
{href && (
<Link href={href}>
<div className="font-bold underline inline-block text-blue-500 hover:text-blue-800">
detail
<span className="mt-[-4px] ml-1 inline-block align-middle">
{/* 可以使用 SVG 或 Font Awesome 图标 */}
<svg className="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 7l5 5m0 0l-5 5m5-5H6" />
</svg>
</span>
</div>
</Link>
)}
</div>
<div className="grid grid-cols-4 lg:grid-cols-4 md:grid-cols-4 sm:grid-cols-2 gap-4">
{(list || []).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 FourCard;