1 | import React, { PureComponent } from 'react'
|
2 | import PropTypes from 'prop-types'
|
3 | import classnames from 'classnames'
|
4 | import List from '../List'
|
5 | import { cardClass } from '../styles'
|
6 |
|
7 | const CollapseList = List(['collapse'], 'fast')
|
8 |
|
9 | class Body extends PureComponent {
|
10 | static propTypes = {
|
11 | children: PropTypes.any,
|
12 | className: PropTypes.string,
|
13 | collapsed: PropTypes.bool,
|
14 | collapsible: PropTypes.bool,
|
15 | style: PropTypes.object,
|
16 | onCollapse: PropTypes.func,
|
17 | }
|
18 |
|
19 | render() {
|
20 | const {
|
21 | className, collapsed, collapsible, onCollapse, ...other
|
22 | } = this.props
|
23 | const newClassName = classnames(cardClass('body'), className)
|
24 |
|
25 | if (!collapsible) return <div {...other} className={newClassName} />
|
26 |
|
27 | const onClick = typeof collapsed === 'boolean' ? onCollapse : undefined
|
28 | return (
|
29 | <CollapseList show={!collapsed}>
|
30 | <div {...other} className={newClassName}>
|
31 | {other.children}
|
32 | {collapsible === 'bottom' && (
|
33 | <div className={cardClass('foldup')} onClick={onClick}>
|
34 | <span />
|
35 | </div>
|
36 | )}
|
37 | </div>
|
38 | </CollapseList>
|
39 | )
|
40 | }
|
41 | }
|
42 |
|
43 | Body.propTypes = {
|
44 | }
|
45 |
|
46 | export default Body
|
47 |
|
\ | No newline at end of file |