UNPKG

semantic-ui-react

Version:
60 lines (49 loc) 1.36 kB
import cx from 'classnames' import _ from 'lodash' import PropTypes from 'prop-types' import React from 'react' import { childrenUtils, customPropTypes, getElementType, getUnhandledProps, META, SUI, useTextAlignProp, } from '../../lib' /** * A card can contain a description with one or more paragraphs. */ function CardDescription(props) { const { children, className, content, textAlign } = props const classes = cx( useTextAlignProp(textAlign), 'description', className, ) const rest = getUnhandledProps(CardDescription, props) const ElementType = getElementType(CardDescription, props) return ( <ElementType {...rest} className={classes}> {childrenUtils.isNil(children) ? content : children} </ElementType> ) } CardDescription._meta = { name: 'CardDescription', parent: 'Card', type: META.TYPES.VIEW, } CardDescription.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, /** A card content can adjust its text alignment. */ textAlign: PropTypes.oneOf(_.without(SUI.TEXT_ALIGNMENTS, 'justified')), } export default CardDescription