Interactive interface for browsing global, full-resolution satellite imagery
add new component distraction free time to display minimal date with hover effect for full timeline
Ed Plato1e21a9f1c5dd
diff --git a/web/js/components/timeline/distraction-free-time.js b/web/js/components/timeline/distraction-free-time.jsnew file mode 100644index 000000000..a8da9599b--- /dev/null+++ b/web/js/components/timeline/distraction-free-time.js@@ -0,0 +1,54 @@+import React, { PureComponent } from 'react';+import PropTypes from 'prop-types';+import util from '../../util/util';++class DistractionFreeTimeUI extends PureComponent {+ handleMouseOver = () => {+ this.props.hoverOverDistractionFreeTimeUI(true);+ }++ render() {+ const { date, hasSubdailyLayers, isHoverOverDistractionFreeTimeUI } = this.props;++ // get month as string (e.g., 2 -> 'FEB')+ const monthNumber = new Date(date).getUTCMonth();+ const monthString = util.monthStringArray[monthNumber];++ // split date first YMD and second HR (subdaily)+ const dateSplit = date.split('T');+ const dateFirstHalfYMD = dateSplit[0].split('-');+ const dateSecondHalfHM = dateSplit[1].split(':', 2).join(':');++ // update month to use string+ dateFirstHalfYMD[1] = monthString;++ // display date as '2000-10-28' for default or '2000-10-28 20:28Z' for subdaily+ let displayDate;+ if (hasSubdailyLayers) {+ displayDate = dateFirstHalfYMD.join(' ') + ' ' + dateSecondHalfHM;+ } else {+ displayDate = dateFirstHalfYMD.join(' ');+ }+// TODO: CREATE HEIGHT SPECIFIC CONTAINER FOR HOVER EFFECT SMOOTHER UX+ return (+ <div+ className="distraction-free-date"+ style={{+ opacity: isHoverOverDistractionFreeTimeUI ? '0' : '1'+ }}+ onMouseOver={this.handleMouseOver}+ >+ {displayDate}+ </div>+ );+ }+}++DistractionFreeTimeUI.propTypes = {+ date: PropTypes.string,+ hasSubdailyLayers: PropTypes.bool,+ hoverOverDistractionFreeTimeUI: PropTypes.func,+ isHoverOverDistractionFreeTimeUI: PropTypes.bool+};++export default DistractionFreeTimeUI;