import { Avatar, List } from 'antd'; import React from 'react'; import classNames from 'classnames'; import { NoticeIconData } from './index'; import styles from './NoticeList.less'; export interface NoticeIconTabProps { count?: number; name?: string; showClear?: boolean; showViewMore?: boolean; style?: React.CSSProperties; title: string; tabKey: string; data?: NoticeIconData[]; onClick?: (item: NoticeIconData) => void; onClear?: () => void; emptyText?: string; clearText?: string; viewMoreText?: string; onViewMore?: (e: any) => void; } const NoticeList: React.SFC = ({ data = [], onClick, onClear, title, onViewMore, emptyText, showClear = true, clearText, viewMoreText, showViewMore = false, }) => { if (data.length === 0) { return (
not found
{emptyText}
); } return (
className={styles.list} dataSource={data} renderItem={(item, i) => { const itemCls = classNames(styles.item, { [styles.read]: item.read, }); // eslint-disable-next-line no-nested-ternary const leftIcon = item.avatar ? ( typeof item.avatar === 'string' ? ( ) : ( {item.avatar} ) ) : null; return ( onClick && onClick(item)} > {item.title}
{item.extra}
} description={
{item.description}
{item.datetime}
} /> ); }} />
{showClear ? (
{clearText} {title}
) : null} {showViewMore ? (
{ if (onViewMore) { onViewMore(e); } }} > {viewMoreText}
) : null}
); }; export default NoticeList;