-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Comment.js
65 lines (54 loc) · 1.74 KB
/
Comment.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
import cx from 'clsx'
import PropTypes from 'prop-types'
import * as React from 'react'
import {
childrenUtils,
customPropTypes,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'
import CommentAction from './CommentAction'
import CommentActions from './CommentActions'
import CommentAuthor from './CommentAuthor'
import CommentAvatar from './CommentAvatar'
import CommentContent from './CommentContent'
import CommentGroup from './CommentGroup'
import CommentMetadata from './CommentMetadata'
import CommentText from './CommentText'
/**
* A comment displays user feedback to site content.
*/
const Comment = React.forwardRef(function (props, ref) {
const { className, children, collapsed, content } = props
const classes = cx(useKeyOnly(collapsed, 'collapsed'), 'comment', className)
const rest = getUnhandledProps(Comment, props)
const ElementType = getComponentType(props)
return (
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
})
Comment.displayName = 'Comment'
Comment.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Comment can be collapsed, or hidden from view. */
collapsed: PropTypes.bool,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
}
Comment.Author = CommentAuthor
Comment.Action = CommentAction
Comment.Actions = CommentActions
Comment.Avatar = CommentAvatar
Comment.Content = CommentContent
Comment.Group = CommentGroup
Comment.Metadata = CommentMetadata
Comment.Text = CommentText
export default Comment