forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.jsx
76 lines (70 loc) · 2.01 KB
/
item.jsx
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
75
76
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { polyfill } from 'react-lifecycles-compat';
import ConfigProvider from '../config-provider';
/**
* List.Item
*/
class ListItem extends Component {
static propTypes = {
prefix: PropTypes.string,
/**
* 列表元素的标题
*/
title: PropTypes.node,
/**
* 列表元素的描述内容
*/
description: PropTypes.node,
/**
* 列表元素的头像 / 图标 / 图片内容
*/
media: PropTypes.node,
/**
* 额外内容
*/
extra: PropTypes.node,
className: PropTypes.any,
};
static defaultProps = {
prefix: 'next-',
};
render() {
const {
prefix,
title,
description,
media,
extra,
className,
children,
...others
} = this.props;
const classes = classNames(`${prefix}list-item`, className);
return (
<li {...others} className={classes}>
{media ? (
<div className={`${prefix}list-item-media`}>{media}</div>
) : null}
<div className={`${prefix}list-item-content`}>
{title ? (
<div className={`${prefix}list-item-title`}>
{title}
</div>
) : null}
{description ? (
<div className={`${prefix}list-item-description`}>
{description}
</div>
) : null}
{children}
</div>
{extra ? (
<div className={`${prefix}list-item-extra`}>{extra}</div>
) : null}
</li>
);
}
}
export default ConfigProvider.config(polyfill(ListItem));