kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
60 lines (59 loc) • 10.2 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _loadingSpinner = _interopRequireDefault(require("./loading-spinner"));
var _templateObject; // SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
var StyledImagePreview = _styledComponents["default"].div.attrs({
className: 'image-preview'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n align-items: center;\n display: flex;\n flex-direction: column;\n flex: 1;\n justify-content: center;\n padding: 30px;\n\n .dimension,\n .instruction {\n padding: 8px 0px;\n }\n\n .preview-image {\n background: #e2e2e2;\n border-radius: 4px;\n box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.18);\n width: 100%;\n position: relative;\n }\n\n .preview-image-placeholder {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n\n .preview-image-spinner {\n position: absolute;\n left: calc(50% - 25px);\n top: calc(50% - 25px);\n }\n\n .preview-image--error {\n font-size: 12px;\n padding: 12px;\n color: ", ";\n text-align: center;\n }\n"])), function (props) {
return props.theme.errorColor;
});
/**
* @param {object} props
* @param {ExportImage} [props.exportImage]
* @param {number} [props.width]
* @param {boolean} [props.showDimension]
*/
var ImagePreview = function ImagePreview(_ref) {
var exportImage = _ref.exportImage,
_ref$width = _ref.width,
width = _ref$width === void 0 ? 400 : _ref$width,
_ref$showDimension = _ref.showDimension,
showDimension = _ref$showDimension === void 0 ? false : _ref$showDimension;
var _ref2 = exportImage || {},
error = _ref2.error,
imageDataUri = _ref2.imageDataUri,
processing = _ref2.processing,
_ref2$imageSize = _ref2.imageSize,
_ref2$imageSize2 = _ref2$imageSize === void 0 ? {} : _ref2$imageSize,
_ref2$imageSize2$imag = _ref2$imageSize2.imageW,
imageW = _ref2$imageSize2$imag === void 0 ? 0 : _ref2$imageSize2$imag,
_ref2$imageSize2$imag2 = _ref2$imageSize2.imageH,
imageH = _ref2$imageSize2$imag2 === void 0 ? 0 : _ref2$imageSize2$imag2;
var imageStyle = {
width: "".concat(width, "px"),
height: "".concat(imageH / (imageW || 1) * width, "px")
};
return /*#__PURE__*/_react["default"].createElement(StyledImagePreview, null, showDimension ? /*#__PURE__*/_react["default"].createElement("div", {
className: "dimension"
}, imageW, " pixel x ", imageH, " pixel") : null, /*#__PURE__*/_react["default"].createElement("div", {
className: "preview-image",
style: imageStyle
}, processing ? /*#__PURE__*/_react["default"].createElement("div", {
className: "preview-image-spinner"
}, /*#__PURE__*/_react["default"].createElement(_loadingSpinner["default"], null)) : error ? /*#__PURE__*/_react["default"].createElement("div", {
className: "preview-image--error"
}, /*#__PURE__*/_react["default"].createElement("span", null, error.message || 'Generate map image failed!')) : /*#__PURE__*/_react["default"].createElement("img", {
className: "preview-image-placeholder",
src: imageDataUri
})));
};
var _default = exports["default"] = ImagePreview;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwicmVxdWlyZSIsIl9zdHlsZWRDb21wb25lbnRzIiwiX2xvYWRpbmdTcGlubmVyIiwiX3RlbXBsYXRlT2JqZWN0IiwiU3R5bGVkSW1hZ2VQcmV2aWV3Iiwic3R5bGVkIiwiZGl2IiwiYXR0cnMiLCJjbGFzc05hbWUiLCJfdGFnZ2VkVGVtcGxhdGVMaXRlcmFsMiIsInByb3BzIiwidGhlbWUiLCJlcnJvckNvbG9yIiwiSW1hZ2VQcmV2aWV3IiwiX3JlZiIsImV4cG9ydEltYWdlIiwiX3JlZiR3aWR0aCIsIndpZHRoIiwiX3JlZiRzaG93RGltZW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