-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathItemContent.js
92 lines (76 loc) · 2.02 KB
/
ItemContent.js
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import {
childrenUtils,
customPropTypes,
getElementType,
getUnhandledProps,
META,
SUI,
useVerticalAlignProp,
} from '../../lib'
import ItemHeader from './ItemHeader'
import ItemDescription from './ItemDescription'
import ItemExtra from './ItemExtra'
import ItemMeta from './ItemMeta'
/**
* An item can contain content.
*/
function ItemContent(props) {
const {
children,
className,
content,
description,
extra,
header,
meta,
verticalAlign,
} = props
const classes = cx(
useVerticalAlignProp(verticalAlign),
'content',
className,
)
const rest = getUnhandledProps(ItemContent, props)
const ElementType = getElementType(ItemContent, props)
if (!childrenUtils.isNil(children)) {
return <ElementType {...rest} className={classes}>{children}</ElementType>
}
return (
<ElementType {...rest} className={classes}>
{ItemHeader.create(header)}
{ItemMeta.create(meta)}
{ItemDescription.create(description)}
{ItemExtra.create(extra)}
{content}
</ElementType>
)
}
ItemContent._meta = {
name: 'ItemContent',
parent: 'Item',
type: META.TYPES.VIEW,
}
ItemContent.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
/** Shorthand for ItemDescription component. */
description: customPropTypes.itemShorthand,
/** Shorthand for ItemExtra component. */
extra: customPropTypes.itemShorthand,
/** Shorthand for ItemHeader component. */
header: customPropTypes.itemShorthand,
/** Shorthand for ItemMeta component. */
meta: customPropTypes.itemShorthand,
/** Content can specify its vertical alignment. */
verticalAlign: PropTypes.oneOf(SUI.VERTICAL_ALIGNMENTS),
}
export default ItemContent