Spaces:
Sleeping
Sleeping
Upload index.tsx
Browse files
aworld/cmd/web/webui/src/pages/components/BubbleItem/cardLinkList/index.tsx
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import './index.less';
|
3 |
+
import type { ToolCardData } from '../utils';
|
4 |
+
import { Card, Flex } from 'antd';
|
5 |
+
import { CheckOutlined } from '@ant-design/icons';
|
6 |
+
|
7 |
+
const MAX_DISPLAY_ITEMS = 3;
|
8 |
+
|
9 |
+
interface Props {
|
10 |
+
data: ToolCardData;
|
11 |
+
}
|
12 |
+
|
13 |
+
interface ItemInterface {
|
14 |
+
title: string;
|
15 |
+
snippet: string;
|
16 |
+
link?: string;
|
17 |
+
isViewMore?: boolean;
|
18 |
+
}
|
19 |
+
|
20 |
+
const cardLinkList: React.FC<Props> = ({ data }) => {
|
21 |
+
const items = data?.card_data?.search_items || [];
|
22 |
+
const remainingCount = Math.max(0, items.length - MAX_DISPLAY_ITEMS);
|
23 |
+
const cardItems = [
|
24 |
+
...items.slice(0, MAX_DISPLAY_ITEMS),
|
25 |
+
...(remainingCount > 0
|
26 |
+
? [
|
27 |
+
{
|
28 |
+
title: `View ${remainingCount} more`,
|
29 |
+
snippet: '',
|
30 |
+
link: 'https://www.baidu.com',
|
31 |
+
isViewMore: true
|
32 |
+
}
|
33 |
+
]
|
34 |
+
: [])
|
35 |
+
];
|
36 |
+
|
37 |
+
return (
|
38 |
+
<div className="cardwrap">
|
39 |
+
{items.length > 0 && (
|
40 |
+
<div className="card-length">
|
41 |
+
<CheckOutlined className="check-icon" />
|
42 |
+
{items.length} results
|
43 |
+
</div>
|
44 |
+
)}
|
45 |
+
<Flex className="cardbox" justify="space-between">
|
46 |
+
{cardItems.map((item: ItemInterface, index: number) => (
|
47 |
+
<Card key={index} className={`card-item ${item.isViewMore ? 'view-more' : ''}`} onClick={() => item.link && (window.location.href = item.link)}>
|
48 |
+
<Card.Meta title={item.title} description={item.snippet} />
|
49 |
+
</Card>
|
50 |
+
))}
|
51 |
+
</Flex>
|
52 |
+
</div>
|
53 |
+
);
|
54 |
+
};
|
55 |
+
|
56 |
+
export default cardLinkList;
|