1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 |
|
7 |
|
8 | import classNames from 'classnames';
|
9 | import React from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 |
|
12 | import SafeAnchor from './SafeAnchor';
|
13 | import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
|
14 |
|
15 | var propTypes = {
|
16 | |
17 |
|
18 |
|
19 | src: PropTypes.string,
|
20 | |
21 |
|
22 |
|
23 | alt: PropTypes.string,
|
24 | |
25 |
|
26 |
|
27 | href: PropTypes.string,
|
28 | |
29 |
|
30 |
|
31 | onError: PropTypes.func,
|
32 | |
33 |
|
34 |
|
35 | onLoad: PropTypes.func
|
36 | };
|
37 |
|
38 | var Thumbnail = function (_React$Component) {
|
39 | _inherits(Thumbnail, _React$Component);
|
40 |
|
41 | function Thumbnail() {
|
42 | _classCallCheck(this, Thumbnail);
|
43 |
|
44 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
45 | }
|
46 |
|
47 | Thumbnail.prototype.render = function render() {
|
48 | var _props = this.props,
|
49 | src = _props.src,
|
50 | alt = _props.alt,
|
51 | onError = _props.onError,
|
52 | onLoad = _props.onLoad,
|
53 | className = _props.className,
|
54 | children = _props.children,
|
55 | props = _objectWithoutProperties(_props, ['src', 'alt', 'onError', 'onLoad', 'className', 'children']);
|
56 |
|
57 | var _splitBsProps = splitBsProps(props),
|
58 | bsProps = _splitBsProps[0],
|
59 | elementProps = _splitBsProps[1];
|
60 |
|
61 | var Component = elementProps.href ? SafeAnchor : 'div';
|
62 | var classes = getClassSet(bsProps);
|
63 |
|
64 | return React.createElement(
|
65 | Component,
|
66 | _extends({}, elementProps, { className: classNames(className, classes) }),
|
67 | React.createElement('img', { src: src, alt: alt, onError: onError, onLoad: onLoad }),
|
68 | children && React.createElement(
|
69 | 'div',
|
70 | { className: 'caption' },
|
71 | children
|
72 | )
|
73 | );
|
74 | };
|
75 |
|
76 | return Thumbnail;
|
77 | }(React.Component);
|
78 |
|
79 | Thumbnail.propTypes = propTypes;
|
80 |
|
81 | export default bsClass('thumbnail', Thumbnail); |
\ | No newline at end of file |