@sisu-llc/pki-suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
46 lines (36 loc) • 2.37 kB
JavaScript
var _class, _temp;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React from 'react';
import DisappearingImage from './DisappearingImage';
import StringUtils from '../util/StringUtils';
/**
* A component to display the thumbnail for a document. If the
* thumbnail isn't set, then no image is displayed. If the URI
* isn't valid, then the image is hidden rather than showing a
* broken image in the browser.
*/
var DocumentThumbnail = (_temp = _class = function (_React$Component) {
_inherits(DocumentThumbnail, _React$Component);
function DocumentThumbnail() {
_classCallCheck(this, DocumentThumbnail);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
DocumentThumbnail.prototype.render = function render() {
var haveImage = StringUtils.notEmpty(this.props.uri);
if (haveImage) {
var _uri = this.props.uri;
if (_uri && _uri.startsWith('/')) {
_uri = _uri.substring(1);
}
var className = haveImage ? 'attivio-search-result-preview img-responsive' : 'attivio-search-result-preview img-responsive attivio-search-result-preview-placeholder';
return React.createElement(DisappearingImage, { src: _uri, className: className, style: { maxHeight: '100px' }, alt: 'Thumbnail' });
}
return null; // No thumbnail for this document
};
return DocumentThumbnail;
}(React.Component), _class.defaultProps = {
uri: null
}, _class.displayName = 'DocumentThumbnail', _temp);
export { DocumentThumbnail as default };