Interactive interface for browsing global, full-resolution satellite imagery
limit info toolbar to exit distraction mode when active, hide map ui els using parent style, add ESC key to exit, update tests
Ed Plato4a90735376c9
diff --git a/web/css/map.css b/web/css/map.cssindex a03251318..f02835c43 100644--- a/web/css/map.css+++ b/web/css/map.css@@ -199,3 +199,10 @@background: url('../images/map/latlon.png') no-repeat;background-position: -14px;}++.distraction-free-active .wv-map-zoom-in,+.distraction-free-active .wv-map-zoom-out,+.distraction-free-active .wv-map-scale-imperial,+.distraction-free-active .wv-map-scale-metric {+ display: none;+}diff --git a/web/css/toolbar.css b/web/css/toolbar.cssindex 4f9d0d26d..8308da48d 100644--- a/web/css/toolbar.css+++ b/web/css/toolbar.css@@ -79,7 +79,7 @@}.toolbar_info .modal-content {- width: 156px;+ width: 157px;}/* List modal */diff --git a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snapindex 9f3e70497..2a088b2c9 100644--- a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap+++ b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap@@ -3,22 +3,12 @@exports[`clears coordinates when mouse moves off the map 1`] = `<divid="ol-coords-case"- style={- Object {- "display": "block",- }- }/>`;exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `<divid="ol-coords-case"- style={- Object {- "display": "block",- }- }><divclassName="wv-coords-map wv-coords-map-btn"@@ -45,11 +35,6 @@ exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `<divid="ol-coords-case"- style={- Object {- "display": "block",- }- }><divclassName="wv-coords-map wv-coords-map-btn"@@ -76,11 +61,6 @@ exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes formatexports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`] = `<divid="ol-coords-case"- style={- Object {- "display": "block",- }- }><divclassName="wv-coords-map wv-coords-map-btn"@@ -107,11 +87,6 @@ exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`]exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `<divid="ol-coords-case"- style={- Object {- "display": "block",- }- }><divclassName="wv-coords-map wv-coords-map-btn"diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.jsindex e90b7f058..b5b2cd248 100644--- a/web/js/components/map/ol-coordinates.js+++ b/web/js/components/map/ol-coordinates.js@@ -25,6 +25,11 @@ export class OlCoordinates extends React.Component {this.props.mouseEvents.on('mouseout', this.mouseOut);}+ componentWillUnmount() {+ this.props.mouseEvents.off('mousemove', this.mouseMove);+ this.props.mouseEvents.off('mouseout', this.mouseOut);+ }+mouseMove(event, map, crs) {const pixels = map.getEventPixel(event);const coord = map.getCoordinateFromPixel(pixels);@@ -78,14 +83,13 @@ export class OlCoordinates extends React.Component {}render() {- const { isDistractionFreeModeActive } = this.props;// Don't render until a mouse is being usedif (!this.state.hasMouse) {return null;}return (- <div id='ol-coords-case' style={{ display: isDistractionFreeModeActive ? 'none' : 'block' }}>+ <div id='ol-coords-case'><Coordinatesformat={this.state.format}latitude={this.state.latitude}@@ -99,8 +103,5 @@ export class OlCoordinates extends React.Component {}OlCoordinates.propTypes = {- mouseEvents: PropTypes.object.isRequired,- isDistractionFreeModeActive: PropTypes.bool+ mouseEvents: PropTypes.object.isRequired};--export default OlCoordinates;diff --git a/web/js/components/map/ol-coordinates.test.js b/web/js/components/map/ol-coordinates.test.jsindex 44a686910..3cb67ed9d 100644--- a/web/js/components/map/ol-coordinates.test.js+++ b/web/js/components/map/ol-coordinates.test.js@@ -14,7 +14,6 @@ beforeEach(() => {component = renderer.create(<OlCoordinatesmouseEvents={events}- distractionFreeMode={false}/>);map = {diff --git a/web/js/containers/info.js b/web/js/containers/info.jsindex dec96ee54..e86324ce0 100644--- a/web/js/containers/info.js+++ b/web/js/containers/info.js@@ -48,84 +48,92 @@ class InfoList extends Component {notifications,config,startTour,+ isDistractionFreeModeActive,isTourActive,isMobile,toggleDistractionFreeMode} = this.props;- const feedbackAction = isMobile- ? { href: 'mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool' }- : {- onClick: () => {- sendFeedback(feedbackIsInitiated);- }- };- const arr = [- {- text: 'Send feedback',- iconClass: 'ui-icon',- iconName: 'faEnvelope',- id: 'send_feedback_info_item',- ...feedbackAction- },- {- text: 'Source Code',- iconClass: 'ui-icon',- iconName: 'faCode',- id: 'source_code_info_item',- href: 'https://github.com/nasa-gibs/worldview'- },- {- text: 'What\'s new',- iconClass: 'ui-icon',- iconName: 'faFlag',- id: 'whats_new_info_item',- href: 'https://wiki.earthdata.nasa.gov/pages/viewrecentblogposts.action?key=GIBS'- },- {- text: 'About',- iconClass: 'ui-icon',- iconName: 'faFile',- id: 'about_info_item',- onClick: () => {- aboutClick();+ const distractionFreeObj = {+ text: isDistractionFreeModeActive ? 'Exit Distraction Free' : 'Distraction Free',+ iconClass: 'ui-icon',+ iconName: 'faEye',+ id: 'distraction_free_info_item',+ onClick: () => {+ toggleDistractionFreeMode();+ }+ };+ if (!isDistractionFreeModeActive) {+ const feedbackAction = isMobile+ ? { href: 'mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool' }+ : {+ onClick: () => {+ sendFeedback(feedbackIsInitiated);+ }+ };+ const arr = [+ {+ text: 'Send feedback',+ iconClass: 'ui-icon',+ iconName: 'faEnvelope',+ id: 'send_feedback_info_item',+ ...feedbackAction+ },+ {+ text: 'Source Code',+ iconClass: 'ui-icon',+ iconName: 'faCode',+ id: 'source_code_info_item',+ href: 'https://github.com/nasa-gibs/worldview'+ },+ {+ text: 'What\'s new',+ iconClass: 'ui-icon',+ iconName: 'faFlag',+ id: 'whats_new_info_item',+ href: 'https://wiki.earthdata.nasa.gov/pages/viewrecentblogposts.action?key=GIBS'+ },+ {+ text: 'About',+ iconClass: 'ui-icon',+ iconName: 'faFile',+ id: 'about_info_item',+ onClick: () => {+ aboutClick();+ }}- },- {- text: 'Distraction Free',- iconClass: 'ui-icon',- iconName: 'faEye',- id: 'distraction_free_info_item',- onClick: () => {- toggleDistractionFreeMode();+ ];++ // limit explore and distraction free for larger device displays+ if (window.innerWidth >= 740 &&+ window.innerHeight >= 615) {+ if (+ config.features.tour &&+ config.stories &&+ config.storyOrder) {+ const exploreWorlviewObj = {+ text: 'Explore Worldview',+ iconClass: 'ui-icon',+ iconName: 'faTruck',+ id: 'start_tour_info_item',+ onClick: () => {+ startTour(isTourActive);+ googleTagManager.pushEvent({+ event: 'tour_start_button'+ });+ }+ };+ arr.splice(1, 0, exploreWorlviewObj);}+ arr.push(distractionFreeObj);}- ];- if (- config.features.tour &&- config.stories &&- config.storyOrder &&- window.innerWidth >= 740 &&- window.innerHeight >= 615- ) {- const exploreWorlviewObj = {- text: 'Explore Worldview',- iconClass: 'ui-icon',- iconName: 'faTruck',- id: 'start_tour_info_item',- onClick: () => {- startTour(isTourActive);- googleTagManager.pushEvent({- event: 'tour_start_button'- });- }- };- arr.splice(1, 0, exploreWorlviewObj);- }- if (notifications.isActive) {- const obj = this.getNotificationListItem();- arr.splice(4, 0, obj);+ if (notifications.isActive) {+ const obj = this.getNotificationListItem();+ arr.splice(4, 0, obj);+ }+ return arr;+ } else {+ return [distractionFreeObj];}- return arr;}render() {@@ -139,6 +147,7 @@ function mapStateToProps(state) {return {feedbackIsInitiated: isInitiated,+ isDistractionFreeModeActive: state.ui.isDistractionFreeModeActive,isTourActive: state.tour.active,notifications: state.notifications,config: state.config,@@ -205,6 +214,7 @@ InfoList.propTypes = {aboutClick: PropTypes.func,config: PropTypes.object,feedbackIsInitiated: PropTypes.bool,+ isDistractionFreeModeActive: PropTypes.bool,isMobile: PropTypes.bool,isTourActive: PropTypes.bool,models: PropTypes.object,diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.jsindex 6156be792..30eb7ed79 100644--- a/web/js/containers/map-interactions.js+++ b/web/js/containers/map-interactions.js@@ -1,7 +1,7 @@import React from 'react';import { connect } from 'react-redux';import PropTypes from 'prop-types';-import OlCoordinates from '../components/map/ol-coordinates';+import { OlCoordinates } from '../components/map/ol-coordinates';import vectorDialog from './vector-dialog';import { onMapClickGetVectorFeatures } from '../modules/vector-styles/util';import { openCustomContent, onClose } from '../modules/modal/actions';@@ -78,15 +78,20 @@ export class MapInteractions extends React.Component {isShowingClick,mouseEvents} = this.props;- const mapClasses = isShowingClick ? 'wv-map' + ' cursor-pointer' : 'wv-map';+ let mapClasses = isShowingClick+ ? 'wv-map' + ' cursor-pointer'+ : 'wv-map';+ mapClasses = isDistractionFreeModeActive+ ? mapClasses + ' distraction-free-active'+ : mapClasses;return (<React.Fragment><div id="wv-map" className={mapClasses} />- <OlCoordinates+ {!isDistractionFreeModeActive && <OlCoordinatesmouseEvents={mouseEvents}- isDistractionFreeModeActive={isDistractionFreeModeActive}/>+ }</React.Fragment>);}diff --git a/web/js/containers/map-interactions.test.js b/web/js/containers/map-interactions.test.jsindex 7d2d998d3..c72132c99 100644--- a/web/js/containers/map-interactions.test.js+++ b/web/js/containers/map-interactions.test.js@@ -30,7 +30,6 @@ beforeEach(() => {measureIsActive={false}onCloseModal={jest.fn()}modalState={{ id: [], isOpen: false }}- isDistractionFreeModeActive={false}/>,{createNodeMock: (element) => {diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 16ff8b4f2..8cdb4fc48 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -36,7 +36,6 @@ import { measure } from './measure/ui';import { CALCULATE_RESPONSIVE_STATE } from 'redux-responsive';import { LOCATION_POP_ACTION } from '../redux-location-state-customs';import { CHANGE_PROJECTION } from '../modules/projection/constants';-import { TOGGLE_DISTRACTION_FREE_MODE } from '../modules/ui/constants';import { SELECT_DATE } from '../modules/date/constants';import { CHANGE_UNITS } from '../modules/measure/constants';import Cache from 'cachai';@@ -99,26 +98,6 @@ export function mapui(models, config, store, ui) {*/const subscribeToStore = function(action) {switch (action.type) {- case TOGGLE_DISTRACTION_FREE_MODE: {- var map = self.selected;- const isDistractionFreeModeActive = store.getState().ui.isDistractionFreeModeActive;- if (isDistractionFreeModeActive) {- // hide map scale and zoom buttons- map.removeControl(map.wv.scaleImperial);- map.removeControl(map.wv.scaleMetric);- $('#' + map.getTarget() + ' .select-wrapper').hide();- $('.wv-map-zoom-in').hide();- $('.wv-map-zoom-out').hide();- } else {- // show map scale and zoom buttons- map.addControl(map.wv.scaleImperial);- map.addControl(map.wv.scaleMetric);- $('#' + map.getTarget() + ' .select-wrapper').show();- $('.wv-map-zoom-in').show();- $('.wv-map-zoom-out').show();- }- return;- }case layerConstants.ADD_LAYER: {const def = lodashFind(action.layers, { id: action.id });return addLayer(def);@@ -298,8 +277,6 @@ export function mapui(models, config, store, ui) {* @returns {void}*/var onResize = function() {- const state = store.getState();- const isDistractionFreeModeActive = state.ui.isDistractionFreeModeActive;var map = self.selected;if (map.small !== util.browser.small) {if (util.browser.small) {@@ -307,11 +284,9 @@ export function mapui(models, config, store, ui) {map.removeControl(map.wv.scaleMetric);$('#' + map.getTarget() + ' .select-wrapper').hide();} else {- if (!isDistractionFreeModeActive) {- map.addControl(map.wv.scaleImperial);- map.addControl(map.wv.scaleMetric);- $('#' + map.getTarget() + ' .select-wrapper').show();- }+ map.addControl(map.wv.scaleImperial);+ map.addControl(map.wv.scaleMetric);+ $('#' + map.getTarget() + ' .select-wrapper').show();}}};diff --git a/web/js/modules/key-press/actions.js b/web/js/modules/key-press/actions.jsindex eb7785061..8b37e19d6 100644--- a/web/js/modules/key-press/actions.js+++ b/web/js/modules/key-press/actions.js@@ -15,6 +15,7 @@ export function keyPress(keyCode, shiftKey, ctrlOrCmdKey) {return (dispatch, getState) => {const { modal, animation, tour, ui } = getState();const modalIsOpen = modal.isOpen;+ const isDistractionFreeModeActive = ui.isDistractionFreeModeActive;if (animation.isActive && !modalIsOpen) {// can get more specific modal.key !== "LAYER_PICKER_COMPONENT"dispatch({@@ -28,11 +29,13 @@ export function keyPress(keyCode, shiftKey, ctrlOrCmdKey) {});}if (!ctrlOrCmdKey && shiftKey && keyCode === 68) {- const isDistractionFreeModeActive = ui.isDistractionFreeModeActive;dispatch({ type: TOGGLE_DISTRACTION_FREE_MODE });if (!isDistractionFreeModeActive && modalIsOpen) {dispatch({ type: CLOSE_MODAL });}}+ if (isDistractionFreeModeActive && keyCode === 27) {+ dispatch({ type: TOGGLE_DISTRACTION_FREE_MODE });+ }};}