Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

make modal updates #1576

Benjamin King17e2cb631f99
diff --git a/web/css/modal.css b/web/css/modal.css
new file mode 100644
index 000000000..eda5ff745
--- /dev/null
+++ b/web/css/modal.css
@@ -0,0 +1,22 @@
+/* universal/default modal styles */
+.modal-dialog .default-modal,
+.modal-dialog .modal-content {
+ background: #282828;
+ color: #eee;
+}
+.modal-dialog .close {
+ color: #fff;
+}
+
+/* toolbar modal list styles */
+.toolbar-list-modal,
+.toolbar-list-modal .modal-content {
+ width: 150px;
+}
+.toolbar-list-modal.modal-dialog {
+ position: absolute;
+ top: 33px;
+}
+.toolbar-list-modal .modal-body {
+ padding: 0;
+};
\ No newline at end of file
diff --git a/web/js/components/util/detect-outer-click.js b/web/js/components/util/detect-outer-click.js
new file mode 100644
index 000000000..06def48fc
--- /dev/null
+++ b/web/js/components/util/detect-outer-click.js
@@ -0,0 +1,55 @@
+// Take from https://stackoverflow.com/a/42234988
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+/**
+ * Component that alerts if you click outside of it
+ */
+export default class OutsideAlerter extends Component {
+ constructor(props) {
+ super(props);
+
+ this.setWrapperRef = this.setWrapperRef.bind(this);
+ this.handleClickOutside = this.handleClickOutside.bind(this);
+ }
+
+ componentDidMount() {
+ document.addEventListener('mousedown', this.handleClickOutside);
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('mousedown', this.handleClickOutside);
+ }
+
+ /**
+ * Set the wrapper ref
+ */
+ setWrapperRef(node) {
+ this.wrapperRef = node;
+ }
+
+ /**
+ * Alert if clicked on outside of element
+ */
+ handleClickOutside(event) {
+ if (
+ this.wrapperRef &&
+ !this.wrapperRef.contains(event.target) &&
+ !this.props.disabled
+ ) {
+ this.props.onClick();
+ }
+ }
+
+ render() {
+ return <div ref={this.setWrapperRef}>{this.props.children}</div>;
+ }
+}
+OutsideAlerter.defaultProps = {
+ disabled: false
+};
+OutsideAlerter.propTypes = {
+ children: PropTypes.element.isRequired,
+ onClick: PropTypes.func.isRequired,
+ disabled: PropTypes.bool
+};