Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

make spinner-modal component

Benjamin King53ecb8f1fddb
diff --git a/web/js/components/util/spinner-modal.js b/web/js/components/util/spinner-modal.js
new file mode 100644
index 000000000..5e5d2f3cf
--- /dev/null
+++ b/web/js/components/util/spinner-modal.js
@@ -0,0 +1,52 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import Spinner from 'react-loader';
+import { Modal, ModalBody, ModalHeader } from 'reactstrap';
+
+/*
+ * A react component, Builds a rather specific
+ * interactive widget
+ *
+ * @class AnimationWidget
+ * @extends React.Component
+ */
+export default class SpinnerModal extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ metDelay: false
+ };
+ if (props.delay) {
+ setTimeout(() => {
+ this.setState({ metDelay: true });
+ }, props.delay);
+ }
+ }
+ render() {
+ const { headerText, onClose, delay } = this.props;
+ if (delay && !this.state.metDelay) return '';
+ return (
+ <Modal isOpen={true} toggle={onClose}>
+ <ModalHeader toggle={onClose}>{headerText}</ModalHeader>
+ <ModalBody>
+ <div style={{ minHeight: 50 }}>
+ <Spinner color={'#fff'} loaded={false}>
+ loading
+ </Spinner>
+ </div>
+ </ModalBody>
+ </Modal>
+ );
+ }
+}
+
+SpinnerModal.defaultProps = {
+ headerText: 'Loading',
+ valid: true,
+ id: '',
+ style: null
+};
+SpinnerModal.propTypes = {
+ onClose: PropTypes.func,
+ headerText: PropTypes.string
+};