Articles.js 1.73 KB
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2 3
import React from 'react';
import { List, Icon, Avatar, Tag } from 'antd';
import moment from 'moment';
xiaohu's avatar
xiaohu committed
4
import stylesArticles from '../../List/Search/Articles.less';
ddcat1115's avatar
ddcat1115 committed
5 6
import styles from './Articles.less';

jim's avatar
jim committed
7
export default props => {
ddcat1115's avatar
ddcat1115 committed
8 9 10 11 12 13 14 15 16 17 18
  const { list } = props;
  const IconText = ({ type, text }) => (
    <span>
      <Icon type={type} style={{ marginRight: 8 }} />
      {text}
    </span>
  );
  const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => (
    <div className={stylesArticles.listContent}>
      <div className={stylesArticles.description}>{content}</div>
      <div className={stylesArticles.extra}>
jim's avatar
jim committed
19 20
        <Avatar src={avatar} size="small" />
        <a href={href}>{owner}</a> 发布在 <a href={href}>{href}</a>
ddcat1115's avatar
ddcat1115 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        <em>{moment(updatedAt).format('YYYY-MM-DD HH:mm')}</em>
      </div>
    </div>
  );
  return (
    <List
      size="large"
      className={styles.articleList}
      rowKey="id"
      itemLayout="vertical"
      dataSource={list}
      renderItem={item => (
        <List.Item
          key={item.id}
          actions={[
            <IconText type="star-o" text={item.star} />,
            <IconText type="like-o" text={item.like} />,
            <IconText type="message" text={item.message} />,
          ]}
        >
          <List.Item.Meta
jim's avatar
jim committed
42 43 44 45 46
            title={
              <a className={stylesArticles.listItemMetaTitle} href={item.href}>
                {item.title}
              </a>
            }
ddcat1115's avatar
ddcat1115 committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60
            description={
              <span>
                <Tag>Ant Design</Tag>
                <Tag>设计语言</Tag>
                <Tag>蚂蚁金服</Tag>
              </span>
            }
          />
          <ListContent data={item} />
        </List.Item>
      )}
    />
  );
};