semantic-ui-react
Version:
The official Semantic-UI-React integration.
65 lines (51 loc) • 1.68 kB
JavaScript
import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import {
childrenUtils,
createShorthandFactory,
customPropTypes,
getElementType,
getUnhandledProps,
META,
} from '../../lib'
import StepDescription from './StepDescription'
import StepTitle from './StepTitle'
/**
* A step can contain a content.
*/
function StepContent(props) {
const { children, className, content, description, title } = props
const classes = cx('content', className)
const rest = getUnhandledProps(StepContent, props)
const ElementType = getElementType(StepContent, props)
if (!childrenUtils.isNil(children)) return <ElementType {...rest} className={classes}>{children}</ElementType>
if (!childrenUtils.isNil(content)) return <ElementType {...rest} className={classes}>{content}</ElementType>
return (
<ElementType {...rest} className={classes}>
{StepTitle.create(title)}
{StepDescription.create(description)}
</ElementType>
)
}
StepContent._meta = {
name: 'StepContent',
parent: 'Step',
type: META.TYPES.ELEMENT,
}
StepContent.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,
/** Shorthand for StepDescription. */
description: customPropTypes.itemShorthand,
/** Shorthand for StepTitle. */
title: customPropTypes.itemShorthand,
}
StepContent.create = createShorthandFactory(StepContent, content => ({ content }))
export default StepContent