Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

layer row button tweaks

Jason Kent4529bcba17ca
diff --git a/web/css/sidebar-panel.css b/web/css/sidebar-panel.css
index f521d59aa..54d5b1cea 100644
--- a/web/css/sidebar-panel.css
+++ b/web/css/sidebar-panel.css
@@ -139,8 +139,8 @@ a.atexpand {
.sidebar-panel li.item h4,
.inmotion h4 {
- font-size: 0.9em;
- line-height: 14px;
+ font-size: 12px;
+ line-height: 16px;
padding: 3px 3px 0;
}
@@ -234,7 +234,7 @@ li.item.productsitem.inmotion,
-webkit-box-sizing: border-box;
-o-box-sizing: border-box;
position: relative;
- border: 1px solid transparent;
+ border: 1px solid #333;
overflow: hidden;
}
@@ -249,6 +249,7 @@ li.item.productsitem.inmotion,
top: 0;
bottom: 0;
cursor: pointer;
+ border-right: 1px solid #333;
}
.productsitem.layer-visible a.hdanchor:hover {
@@ -371,7 +372,7 @@ li.item.productsitem.inmotion,
}
.productsitem div.zot {
- margin-left: 31px;
+ margin-left: 30px;
position: absolute;
top: 0;
bottom: 0;
@@ -450,10 +451,26 @@ li.item.productsitem.inmotion,
& .layer-info {
background-color: #ccc;
min-height: 40px;
+ & .layer-buttons {
+ position: absolute;
+ right: 0;
+ background: #ccc;
+ background: linear-gradient(90deg, rgba(0,0,0,0) 0%, #ccc 30%);
+ width: 100px;
+ }
+ }
+ &.layer-hidden {
+ .layer-info {
+ background-color: #666;
+ }
+ .layer-buttons {
+ background: #666;
+ background: linear-gradient(90deg, rgba(0,0,0,0) 0%, #666 30%);
+ }
}
& .layer-main {
width: auto;
- margin-left: 31px;
+ margin-left: 30px;
cursor: default;
min-height: 40px;
overflow: hidden;
@@ -461,12 +478,11 @@ li.item.productsitem.inmotion,
}
.productsitem.zotted .layer-main {
- margin-left: 42px;
+ margin-left: 41px;
}
-.productsitem.layer-hidden .layer-info,
.productsitem.layer-hidden a.hdanchor {
- background: rgba(255, 255, 255, 0.2);
+ background: #666;
}
.productsitem.layer-hidden a.hdanchor:hover {
@@ -533,13 +549,25 @@ li.item.productsitem.inmotion,
}
.layer-info {
min-height: 44px;
+ .layer-buttons {
+ height: 26px;
+ width: 40px;
+ .wv-layers-close {
+ height: 20px;
+ width: 25px;
+ svg.svg-inline--fa {
+ font-size: 20px;
+ }
+ }
+ }
}
.layer-eye-icon {
- top: 18px;
+ top: 50%;
font-size: 26px;
+ margin-top: -13px;
}
a.hdanchor.hideReg {
- width: 44px;
+ width: 45px;
}
}
}
diff --git a/web/css/sidebar.css b/web/css/sidebar.css
index ed57ad4e8..329e7dab1 100644
--- a/web/css/sidebar.css
+++ b/web/css/sidebar.css
@@ -161,11 +161,14 @@ footer .compare-toggle-button {
background: #333;
margin-top: 4px;
border: 1px solid #444;
+ &:hover {
+ border-color: #aaa;
+ }
}
.layer-group-title {
display: inline-block;
margin: 4px 0;
- font-size: 13px;
+ font-size: 12px;
max-width: 232px;
line-height: 15px;
}
diff --git a/web/js/containers/sidebar/layer-list.js b/web/js/containers/sidebar/layer-list.js
index 981126c03..5d26d7454 100644
--- a/web/js/containers/sidebar/layer-list.js
+++ b/web/js/containers/sidebar/layer-list.js
@@ -45,6 +45,7 @@ function LayerList(props) {
removeLayers,
toggleVisibility,
toggleCollapse,
+ isMobile,
} = props;
const groupLayerIds = layers.map(({ id }) => id);
const [showDropdown, toggleDropdown] = useState(false);
@@ -124,8 +125,6 @@ function LayerList(props) {
<div
id={`${compareState}-${groupId}`}
className="layer-group-case"
- onMouseEnter={mouseEnter}
- onMouseLeave={mouseLeave}
>
<div
className="layer-group-header"
@@ -137,7 +136,7 @@ function LayerList(props) {
{collapsed ? ` (${layers.length})` : ''}
</h3>
<div className="layer-group-icons">
- {showDropdown ? renderDropdownMenu() : null}
+ {showDropdown || isMobile ? renderDropdownMenu() : null}
<FontAwesomeIcon
className="layer-group-collapse"
icon={!collapsed ? 'caret-down' : 'caret-left'}
@@ -174,9 +173,11 @@ LayerList.propTypes = {
activeLayers: PropTypes.array,
available: PropTypes.func,
collapsed: PropTypes.bool,
+ compareState: PropTypes.string,
getNames: PropTypes.func,
groupId: PropTypes.string,
- compareState: PropTypes.string,
+ isMobile: PropTypes.bool,
+ launchOpacityModal: PropTypes.func,
layers: PropTypes.array,
layerSplit: PropTypes.number,
projId: PropTypes.string,
@@ -185,7 +186,6 @@ LayerList.propTypes = {
removeLayers: PropTypes.func,
toggleCollapse: PropTypes.func,
toggleVisibility: PropTypes.func,
- launchOpacityModal: PropTypes.func,
title: PropTypes.string,
zots: PropTypes.object,
};
@@ -197,6 +197,7 @@ const mapStateToProps = (state, ownProps) => {
: {};
return {
zots,
+ isMobile: state.browser.lessThan.medium,
activeLayers: getActiveLayers(state),
projId: proj.id,
getNames: (layerId) => getTitles(config, layerId, proj.id),
diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.js
index 60a8456cd..c6906cb88 100644
--- a/web/js/containers/sidebar/layer-row.js
+++ b/web/js/containers/sidebar/layer-row.js
@@ -1,14 +1,16 @@
/* eslint-disable react/jsx-props-no-spreading */
/* eslint-disable react/no-danger */
/* eslint-disable no-nested-ternary */
-import React from 'react';
+import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Draggable } from 'react-beautiful-dnd';
import { isEmpty as lodashIsEmpty, get as lodashGet } from 'lodash';
import googleTagManager from 'googleTagManager';
import { connect } from 'react-redux';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { UncontrolledTooltip } from 'reactstrap';
+import {
+ UncontrolledTooltip,
+} from 'reactstrap';
import PaletteLegend from '../../components/sidebar/paletteLegend';
import util from '../../util/util';
import {
@@ -41,23 +43,43 @@ const getItemStyle = (isDragging, draggableStyle) => ({
left: null,
});
-class LayerRow extends React.Component {
- getPaletteLegend = () => {
- const {
- compare,
- layer,
- compareState,
- runningObject,
- paletteLegends,
- getPalette,
- palette,
- renderedPalette,
- requestPalette,
- isCustomPalette,
- isLoading,
- isMobile,
- zot,
- } = this.props;
+function LayerRow (props) {
+ const {
+ compare,
+ layer,
+ compareState,
+ runningObject,
+ paletteLegends,
+ getPalette,
+ palette,
+ renderedPalette,
+ requestPalette,
+ isCustomPalette,
+ isLoading,
+ isMobile,
+ zot,
+ names,
+ onRemoveClick,
+ onInfoClick,
+ onOptionsClick,
+ hasClickableFeature,
+ openVectorAlertModal,
+ toggleVisibility,
+ hover,
+ isDisabled,
+ isVisible,
+ layerClasses,
+ index,
+ hasPalette,
+ isInProjection,
+ tracksForLayer,
+ isVectorLayer,
+ } = props;
+
+ const encodedLayerId = util.encodeId(layer.id);
+ const [showButtons, toggleShowButtons] = useState(isMobile);
+
+ const getPaletteLegend = () => {
if (!lodashIsEmpty(renderedPalette)) {
const isRunningData = compare.active
? compare.activeString === compareState && !!runningObject
@@ -80,9 +102,9 @@ class LayerRow extends React.Component {
} if (!isLoading) {
requestPalette(layer.id);
}
- }
+ };
- getDisabledTitle = (layer) => {
+ const getDisabledTitle = (layer) => {
const {
endDate,
period,
@@ -106,33 +128,24 @@ class LayerRow extends React.Component {
return `Data available between ${layerStartDate} - Present`;
}
return 'No data on selected date for this layer';
- }
+ };
- stopPropagation = (e) => {
+ const stopPropagation = (e) => {
e.nativeEvent.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
- }
+ };
- renderControls() {
- const {
- layer,
- compareState,
- names,
- isMobile,
- onRemoveClick,
- onInfoClick,
- onOptionsClick,
- } = this.props;
+ const renderControls = () => {
const { title } = names;
- const removeLayerBtnId = `close${compareState}${util.encodeId(layer.id)}`;
+ const removeLayerBtnId = `close-${compareState}${encodedLayerId}`;
const removeLayerBtnTitle = 'Remove Layer';
- const layerOptionsBtnId = `layer-options-btn-${util.encodeId(layer.id)}`;
- const layerOptionsBtnTitle = 'View layer options';
+ const layerOptionsBtnId = `layer-options-btn-${encodedLayerId}`;
+ const layerOptionsBtnTitle = 'View Options';
- const layerInfoBtnId = `layer-info-btn-${util.encodeId(layer.id)}`;
- const layerInfoBtnTitle = 'View layer description';
+ const layerInfoBtnId = `layer-info-btn-${encodedLayerId}`;
+ const layerInfoBtnTitle = 'View Description';
return (
<>
@@ -151,7 +164,7 @@ class LayerRow extends React.Component {
id={layerOptionsBtnId}
aria-label={layerOptionsBtnTitle}
className={isMobile ? 'hidden wv-layers-options' : 'wv-layers-options'}
- onMouseDown={this.stopPropagation}
+ onMouseDown={stopPropagation}
onClick={() => onOptionsClick(layer, title)}
>
<UncontrolledTooltip placement="top" target={layerOptionsBtnId}>
@@ -163,7 +176,7 @@ class LayerRow extends React.Component {
id={layerInfoBtnId}
aria-label={layerInfoBtnTitle}
className={isMobile ? 'hidden wv-layers-info' : 'wv-layers-info'}
- onMouseDown={this.stopPropagation}
+ onMouseDown={stopPropagation}
onClick={() => onInfoClick(layer, title)}
>
<UncontrolledTooltip placement="top" target={layerInfoBtnId}>
@@ -173,12 +186,9 @@ class LayerRow extends React.Component {
</a>
</>
);
- }
+ };
- renderVectorIcon() {
- const {
- hasClickableFeature, openVectorAlertModal, runningObject,
- } = this.props;
+ const renderVectorIcon = () => {
const clasNames = hasClickableFeature
? 'layer-pointer-icon'
: 'layer-pointer-icon disabled';
@@ -194,96 +204,91 @@ class LayerRow extends React.Component {
/>
</div>
);
- }
+ };
- render() {
- const {
- compareState,
- isMobile,
- toggleVisibility,
- hover,
- layer,
- isDisabled,
- isVisible,
- layerClasses,
- names,
- index,
- hasPalette,
- zot,
- isInProjection,
- tracksForLayer,
- isVectorLayer,
- } = this.props;
+ const mouseEnter = () => {
+ if (isMobile) return;
+ hover(layer.id, true);
+ toggleShowButtons(true);
+ };
+
+ const mouseLeave = () => {
+ if (isMobile) return;
+ hover(layer.id, false);
+ toggleShowButtons(false);
+ };
- const containerClass = isDisabled
- ? `${layerClasses} disabled layer-hidden`
- : !isVisible
- ? `${layerClasses} layer-hidden`
- : zot
- ? `${layerClasses} layer-enabled layer-visible zotted`
- : `${layerClasses} layer-enabled layer-visible`;
- const visibilityToggleClass = isDisabled
+ const containerClass = isDisabled
+ ? `${layerClasses} disabled layer-hidden`
+ : !isVisible
+ ? `${layerClasses} layer-hidden`
+ : zot
+ ? `${layerClasses} layer-enabled layer-visible zotted`
+ : `${layerClasses} layer-enabled layer-visible`;
+ const visibilityToggleClass = isDisabled
+ ? `${visibilityButtonClasses} layer-hidden`
+ : !isVisible
? `${visibilityButtonClasses} layer-hidden`
- : !isVisible
- ? `${visibilityButtonClasses} layer-hidden`
- : `${visibilityButtonClasses} layer-enabled layer-visible`;
- const visibilityTitle = !isVisible && !isDisabled
- ? 'Show Layer'
- : isDisabled
- ? this.getDisabledTitle(layer)
- : 'Hide Layer';
- const visibilityIconClass = isDisabled
- ? 'ban'
- : !isVisible
- ? ['far', 'eye-slash']
- : ['far', 'eye'];
+ : `${visibilityButtonClasses} layer-enabled layer-visible`;
+ const visibilityTitle = !isVisible && !isDisabled
+ ? 'Show Layer'
+ : isDisabled
+ ? getDisabledTitle(layer)
+ : 'Hide Layer';
+ const visibilityIconClass = isDisabled
+ ? 'ban'
+ : !isVisible
+ ? ['far', 'eye-slash']
+ : ['far', 'eye'];
- return (
- <Draggable
- draggableId={`${util.encodeId(layer.id)}-${compareState}`}
- index={index}
- direction="vertical"
- >
- {(provided, snapshot) => (isInProjection ? (
- <li
- id={`${compareState}-${util.encodeId(layer.id)}`}
- className={containerClass}
- style={getItemStyle(
- snapshot.isDragging,
- provided.draggableProps.style,
- )}
- ref={provided.innerRef}
- {...provided.draggableProps}
- {...provided.dragHandleProps}
- onMouseEnter={() => hover(layer.id, true)}
- onMouseLeave={() => hover(layer.id, false)}
+ return (
+ <Draggable
+ draggableId={`${encodedLayerId}-${compareState}`}
+ index={index}
+ direction="vertical"
+ >
+ {(provided, snapshot) => (isInProjection ? (
+ <li
+ id={`${compareState}-${encodedLayerId}`}
+ className={containerClass}
+ style={getItemStyle(
+ snapshot.isDragging,
+ provided.draggableProps.style,
+ )}
+ ref={provided.innerRef}
+ {...provided.draggableProps}
+ {...provided.dragHandleProps}
+ onMouseEnter={mouseEnter}
+ onMouseLeave={mouseLeave}
+ >
+ <a
+ id={`hide${encodedLayerId}`}
+ className={visibilityToggleClass}
+ aria-label={visibilityTitle}
+ onClick={() => toggleVisibility(layer.id, !isVisible)}
>
- <a
- id={`hide${util.encodeId(layer.id)}`}
- className={visibilityToggleClass}
- aria-label={visibilityTitle}
- onClick={() => toggleVisibility(layer.id, !isVisible)}
+ <UncontrolledTooltip
+ placement="right"
+ target={`hide${encodedLayerId}`}
>
- <UncontrolledTooltip
- placement="right"
- target={`hide${util.encodeId(layer.id)}`}
- >
- {visibilityTitle}
- </UncontrolledTooltip>
- <FontAwesomeIcon icon={visibilityIconClass} className="layer-eye-icon" />
- </a>
+ {visibilityTitle}
+ </UncontrolledTooltip>
+ <FontAwesomeIcon icon={visibilityIconClass} className="layer-eye-icon" />
+ </a>
- <Zot zot={zot} layer={layer.id} isMobile={isMobile} />
+ <Zot zot={zot} layer={layer.id} isMobile={isMobile} />
- <div className="layer-main">
- <div className="layer-info">
- {this.renderControls()}
- <h4 title={names.title}>{names.title}</h4>
- <p dangerouslySetInnerHTML={{ __html: names.subtitle }} />
- {hasPalette ? this.getPaletteLegend() : ''}
+ <div className="layer-main">
+ <div className="layer-info">
+ <div className="layer-buttons">
+ {showButtons && renderControls()}
</div>
- {isVectorLayer && isVisible ? this.renderVectorIcon() : null}
- {tracksForLayer.length > 0 && (
+ <h4 title={names.title}>{names.title}</h4>
+ <p dangerouslySetInnerHTML={{ __html: names.subtitle }} />
+ {hasPalette ? getPaletteLegend() : ''}
+ </div>
+ {isVectorLayer && isVisible ? renderVectorIcon() : null}
+ {tracksForLayer.length > 0 && (
<div className="layer-tracks">
{tracksForLayer.map((track) => (
<OrbitTrack
@@ -293,20 +298,19 @@ class LayerRow extends React.Component {
/>
))}
</div>
- )}
- </div>
- </li>
- ) : (
- <li
- className="layer-list-placeholder"
- ref={provided.innerRef}
- {...provided.draggableProps}
- {...provided.dragHandleProps}
- />
- ))}
- </Draggable>
- );
- }
+ )}
+ </div>
+ </li>
+ ) : (
+ <li
+ className="layer-list-placeholder"
+ ref={provided.innerRef}
+ {...provided.draggableProps}
+ {...provided.dragHandleProps}
+ />
+ ))}
+ </Draggable>
+ );
}
const mapStateToProps = (state, ownProps) => {