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