semantic-ui-react
Version:
The official Semantic-UI-React integration.
73 lines (59 loc) • 1.89 kB
JavaScript
import _extends from 'babel-runtime/helpers/extends';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { childrenUtils, createShorthand, customPropTypes, getElementType, getUnhandledProps, META } from '../../lib';
import FeedDate from './FeedDate';
import FeedUser from './FeedUser';
/**
* A feed can contain a summary.
*/
function FeedSummary(props) {
var children = props.children,
className = props.className,
content = props.content,
date = props.date,
user = props.user;
var classes = cx('summary', className);
var rest = getUnhandledProps(FeedSummary, props);
var ElementType = getElementType(FeedSummary, props);
if (!childrenUtils.isNil(children)) {
return React.createElement(
ElementType,
_extends({}, rest, { className: classes }),
children
);
}
return React.createElement(
ElementType,
_extends({}, rest, { className: classes }),
createShorthand(FeedUser, function (val) {
return { content: val };
}, user),
content,
createShorthand(FeedDate, function (val) {
return { content: val };
}, date)
);
}
FeedSummary.handledProps = ['as', 'children', 'className', 'content', 'date', 'user'];
FeedSummary._meta = {
name: 'FeedSummary',
parent: 'Feed',
type: META.TYPES.VIEW
};
FeedSummary.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,
/** Shorthand for FeedDate. */
date: customPropTypes.itemShorthand,
/** Shorthand for FeedUser. */
user: customPropTypes.itemShorthand
} : {};
export default FeedSummary;