UNPKG

1.75 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';
9
10import Media from './Media';
11import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
12
13var propTypes = {
14 /**
15 * Align the media to the top, middle, or bottom of the media object.
16 */
17 align: PropTypes.oneOf(['top', 'middle', 'bottom'])
18};
19
20var MediaLeft = function (_React$Component) {
21 _inherits(MediaLeft, _React$Component);
22
23 function MediaLeft() {
24 _classCallCheck(this, MediaLeft);
25
26 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
27 }
28
29 MediaLeft.prototype.render = function render() {
30 var _props = this.props,
31 align = _props.align,
32 className = _props.className,
33 props = _objectWithoutProperties(_props, ['align', 'className']);
34
35 var _splitBsProps = splitBsProps(props),
36 bsProps = _splitBsProps[0],
37 elementProps = _splitBsProps[1];
38
39 var classes = getClassSet(bsProps);
40
41 if (align) {
42 // The class is e.g. `media-top`, not `media-left-top`.
43 classes[prefix(Media.defaultProps, align)] = true;
44 }
45
46 return React.createElement('div', _extends({}, elementProps, { className: classNames(className, classes) }));
47 };
48
49 return MediaLeft;
50}(React.Component);
51
52MediaLeft.propTypes = propTypes;
53
54export default bsClass('media-left', MediaLeft);
\No newline at end of file