UNPKG

2.43 kBJavaScriptView Raw
1import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
3import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
4
5/* eslint-disable jsx-a11y/alt-text */
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9import SafeAnchor from './SafeAnchor';
10import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
11var propTypes = {
12 /**
13 * src property that is passed down to the image inside this component
14 */
15 src: PropTypes.string,
16
17 /**
18 * alt property that is passed down to the image inside this component
19 */
20 alt: PropTypes.string,
21
22 /**
23 * href property that is passed down to the image inside this component
24 */
25 href: PropTypes.string,
26
27 /**
28 * onError callback that is passed down to the image inside this component
29 */
30 onError: PropTypes.func,
31
32 /**
33 * onLoad callback that is passed down to the image inside this component
34 */
35 onLoad: PropTypes.func
36};
37
38var Thumbnail =
39/*#__PURE__*/
40function (_React$Component) {
41 _inheritsLoose(Thumbnail, _React$Component);
42
43 function Thumbnail() {
44 return _React$Component.apply(this, arguments) || this;
45 }
46
47 var _proto = Thumbnail.prototype;
48
49 _proto.render = function render() {
50 var _this$props = this.props,
51 src = _this$props.src,
52 alt = _this$props.alt,
53 onError = _this$props.onError,
54 onLoad = _this$props.onLoad,
55 className = _this$props.className,
56 children = _this$props.children,
57 props = _objectWithoutPropertiesLoose(_this$props, ["src", "alt", "onError", "onLoad", "className", "children"]);
58
59 var _splitBsProps = splitBsProps(props),
60 bsProps = _splitBsProps[0],
61 elementProps = _splitBsProps[1];
62
63 var Component = elementProps.href ? SafeAnchor : 'div';
64 var classes = getClassSet(bsProps);
65 return React.createElement(Component, _extends({}, elementProps, {
66 className: classNames(className, classes)
67 }), React.createElement("img", {
68 src: src,
69 alt: alt,
70 onError: onError,
71 onLoad: onLoad
72 }), children && React.createElement("div", {
73 className: "caption"
74 }, children));
75 };
76
77 return Thumbnail;
78}(React.Component);
79
80Thumbnail.propTypes = propTypes;
81export default bsClass('thumbnail', Thumbnail);
\No newline at end of file