UNPKG

2.52 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';
6/* eslint-disable jsx-a11y/alt-text */
7
8import classNames from 'classnames';
9import React from 'react';
10import PropTypes from 'prop-types';
11
12import SafeAnchor from './SafeAnchor';
13import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
14
15var propTypes = {
16 /**
17 * src property that is passed down to the image inside this component
18 */
19 src: PropTypes.string,
20 /**
21 * alt property that is passed down to the image inside this component
22 */
23 alt: PropTypes.string,
24 /**
25 * href property that is passed down to the image inside this component
26 */
27 href: PropTypes.string,
28 /**
29 * onError callback that is passed down to the image inside this component
30 */
31 onError: PropTypes.func,
32 /**
33 * onLoad callback that is passed down to the image inside this component
34 */
35 onLoad: PropTypes.func
36};
37
38var 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
79Thumbnail.propTypes = propTypes;
80
81export default bsClass('thumbnail', Thumbnail);
\No newline at end of file