UNPKG

semantic-ui-react

Version:
54 lines (42 loc) 1.54 kB
import _extends from 'babel-runtime/helpers/extends'; import _without from 'lodash/without'; import cx from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import { childrenUtils, customPropTypes, getElementType, getUnhandledProps, META, SUI, useTextAlignProp } from '../../lib'; /** * A card can contain a header. */ function CardHeader(props) { var children = props.children, className = props.className, content = props.content, textAlign = props.textAlign; var classes = cx(useTextAlignProp(textAlign), 'header', className); var rest = getUnhandledProps(CardHeader, props); var ElementType = getElementType(CardHeader, props); return React.createElement( ElementType, _extends({}, rest, { className: classes }), childrenUtils.isNil(children) ? content : children ); } CardHeader.handledProps = ['as', 'children', 'className', 'content', 'textAlign']; CardHeader._meta = { name: 'CardHeader', parent: 'Card', type: META.TYPES.VIEW }; CardHeader.propTypes = process.env.NODE_ENV !== "production" ? { /** 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 header can adjust its text alignment. */ textAlign: PropTypes.oneOf(_without(SUI.TEXT_ALIGNMENTS, 'justified')) } : {}; export default CardHeader;