semantic-ui-react
Version:
The official Semantic-UI-React integration.
53 lines (42 loc) • 1.24 kB
JavaScript
import cx from 'classnames'
import _ from 'lodash'
import PropTypes from 'prop-types'
import React from 'react'
import {
createShorthandFactory,
customPropTypes,
getElementType,
getUnhandledProps,
META,
} from '../../lib'
/**
* An item can contain a description with a single or multiple paragraphs.
*/
function ItemDescription(props) {
const { children, className, content } = props
const classes = cx('description', className)
const rest = getUnhandledProps(ItemDescription, props)
const ElementType = getElementType(ItemDescription, props)
return (
<ElementType {...rest} className={classes}>
{_.isNil(children) ? content : children}
</ElementType>
)
}
ItemDescription._meta = {
name: 'ItemDescription',
parent: 'Item',
type: META.TYPES.VIEW,
}
ItemDescription.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,
}
ItemDescription.create = createShorthandFactory(ItemDescription, content => ({ content }))
export default ItemDescription