UNPKG

1.99 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9import elementType from 'prop-types-extra/lib/elementType';
10
11import Media from './Media';
12import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
13
14var propTypes = {
15 /**
16 * Align the media to the top, middle, or bottom of the media object.
17 */
18 align: PropTypes.oneOf(['top', 'middle', 'bottom']),
19
20 componentClass: elementType
21};
22
23var defaultProps = {
24 componentClass: 'div'
25};
26
27var MediaBody = function (_React$Component) {
28 _inherits(MediaBody, _React$Component);
29
30 function MediaBody() {
31 _classCallCheck(this, MediaBody);
32
33 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
34 }
35
36 MediaBody.prototype.render = function render() {
37 var _props = this.props,
38 Component = _props.componentClass,
39 align = _props.align,
40 className = _props.className,
41 props = _objectWithoutProperties(_props, ['componentClass', 'align', 'className']);
42
43 var _splitBsProps = splitBsProps(props),
44 bsProps = _splitBsProps[0],
45 elementProps = _splitBsProps[1];
46
47 var classes = getClassSet(bsProps);
48
49 if (align) {
50 // The class is e.g. `media-top`, not `media-left-top`.
51 classes[prefix(Media.defaultProps, align)] = true;
52 }
53
54 return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) }));
55 };
56
57 return MediaBody;
58}(React.Component);
59
60MediaBody.propTypes = propTypes;
61MediaBody.defaultProps = defaultProps;
62
63export default bsClass('media-body', MediaBody);
\No newline at end of file