UNPKG

1.19 kBJavaScriptView Raw
1import React, { PureComponent } from 'react'
2import PropTypes from 'prop-types'
3import classnames from 'classnames'
4import List from '../List'
5import { cardClass } from '../styles'
6
7const CollapseList = List(['collapse'], 'fast')
8
9class 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
43Body.propTypes = {
44}
45
46export default Body
47
\No newline at end of file