import React, { useState, useEffect } from 'react'; import { Box, Search, Card, Tag, Divider, Typography, Icon, Loading, Button, Pagination } from '@alifd/next'; import styles from './index.module.scss'; const { Group: TagGroup, Selectable: SelectableTag } = Tag; export interface ICardItem { title?: string; content?: string; subContent?: string; } export interface DataSource { cards: ICardItem[]; tagsA: string[]; tagA: string; tagsB: string[]; tagB: string; } const DEFAULT_DATA: DataSource = { tagsA: ['类目一', '类目二', '类目三', '类目四', '类目五', '类目六', '类目七', '类目八', '类目九', '类目十'], tagA: '类目一', tagsB: ['不到一年', '一年以上三年以下', '三年以上五年以下', '五年以上'], tagB: '一年以上三年以下', cards: new Array(5).fill({ title: '构建一套产品化设计系统', content: '随着互联网行业的聚变式发展,在电商业务从“信息透出” 到 “在线交易” 的过程中,网站 UI 构建也经历了“体验一致性”、“设计效率”、“UI系统构建/应用效率”、“多端适配” …', subContent: '谢瑶 3 小时前更新', }), }; const BasicList: React.FunctionComponent = (props: BasicListProps): JSX.Element => { const { dataSource = DEFAULT_DATA, onSearch = (): void => { }, } = props; const [tagAValue, setTagAValue] = useState(dataSource.tagA); const [tagBValue, setTagBValue] = useState(dataSource.tagB); const [loading, setLoading] = useState(true); useEffect(() => { setTimeout(() => { setLoading(false); }, 2000); }); const onTagAValueChange = (v: string) => { setLoading(true); setTagAValue(v); }; const onTagBValueChange = (v: string) => { setLoading(true); setTagBValue(v); }; const onSearchClick = () => { setLoading(true); onSearch(); }; const onPaginationChange = () => { setLoading(true); }; const renderTagListA = () => { return dataSource.tagsA.map((name: string) => ( onTagAValueChange(name)} {...props} >{name} )); }; const renderTagListB = () => { return dataSource.tagsB.map((name: string) => ( onTagBValueChange(name)} {...props} >{name} )); }; const renderCards = () => { return dataSource.cards.map((c: ICardItem, i: number) => (
img
{c.title}
{c.content}
{c.subContent}
)); }; return ( <>
内容分类 {renderTagListA()}
时间 {renderTagListB()}
添加内容
{renderCards()}
200条需求
); }; export default BasicList;