Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2006: toggle datelines (#3815)

Jason Kent7a566683f221
diff --git a/e2e/features/global-unit/global-unit-test.js b/e2e/features/global-unit/global-unit-test.js
index b38db40fa..5fecdc8cc 100644
--- a/e2e/features/global-unit/global-unit-test.js
+++ b/e2e/features/global-unit/global-unit-test.js
@@ -8,8 +8,8 @@ const {
const TIME_LIMIT = 5000;
const settingsInfoItem = '#settings_info_item';
const globalSettingsModal = '#global_settings_modal';
-const globalSettingsTemperatureButtons = '.temperature-unit-buttons';
-const KelvinSettingsButton = '#global_settings_modal button.temperature-unit-button:nth-child(1)';
+const settingContainer = '.global-setting-container';
+const KelvinSettingsButton = '#global_settings_modal button.setting-button:nth-child(1)';
const SSTQueryString = '?l=GHRSST_L4_MUR_Sea_Surface_Temperature,Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=false&t=2020-09-28-T20%3A40%3A53Z';
const SSTMinPalette = '#GHRSST_L4_MUR_Sea_Surface_Temperature_GHRSST_Sea_Surface_Temperature_0_legend_0 > div.wv-palettes-min';
@@ -31,7 +31,7 @@ module.exports = {
c.pause(500);
c.expect.element(globalSettingsModal).to.be.present;
- c.expect.element(globalSettingsTemperatureButtons).to.be.present;
+ c.expect.element(settingContainer).to.be.present;
},
'Initial temp unit is default value in layer palette legend': (c) => {
diff --git a/web/css/settings.css b/web/css/settings.css
new file mode 100644
index 000000000..a4896e1bd
--- /dev/null
+++ b/web/css/settings.css
@@ -0,0 +1,35 @@
+/* Global Settings Modal */
+.global-settings-modal.modal-dialog {
+ width: 420px;
+}
+.global-settings-modal {
+ .global-setting-container {
+ margin-bottom: 16px;
+ }
+ .settings-component {
+ margin-bottom: 15px;
+ }
+
+ .wv-header {
+ margin-bottom: 12px;
+ }
+ .btn-group button.setting-button {
+ color: #fff;
+ background: #222;
+ &.active {
+ background: #d54e21;
+ border-color: #d54e21;
+ }
+ &:hover {
+ background: #fff;
+ color: #000;
+ }
+ }
+}
+
+@media (max-width: 576px) {
+ .global-settings-modal.modal-dialog {
+ width: 96%;
+ margin: 0;
+ }
+}
diff --git a/web/css/toolbar.css b/web/css/toolbar.css
index 8d7db9214..b892d74be 100644
--- a/web/css/toolbar.css
+++ b/web/css/toolbar.css
@@ -148,44 +148,6 @@
width: 100%;
}
-/* Global Settings Modal */
-.global-settings-modal.modal-dialog {
- width: 420px;
-}
-.global-settings-modal {
- .global-setting-container {
- margin-bottom: 16px;
- }
- .settings-component {
- margin-bottom: 15px;
- }
-
- .wv-header {
- margin-bottom: 12px;
- }
- .temperature-unit-buttons {
- .temperature-unit-button {
- color: #fff;
- background: #222;
- &.active {
- background: #d54e21;
- border-color: #d54e21;
- }
- &:hover {
- background: #fff;
- color: #000;
- }
- }
- }
-}
-
-@media (max-width: 576px) {
- .global-settings-modal.modal-dialog {
- width: 96%;
- margin: 0;
- }
-}
-
@media (min-width: 576px) {
.toolbar-modal:not(.toolbar-snapshot-modal) {
top: 33px;
diff --git a/web/js/app.js b/web/js/app.js
index dbab415d6..f759314f1 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -87,6 +87,7 @@ import '../css/recent-layers.css';
import '../css/location-search.css';
import '../css/embed.css';
import '../css/context-menu.css';
+import '../css/settings.css';
require('@elastic/react-search-ui-views/lib/styles/styles.css');
diff --git a/web/js/components/dateline/datelines.js b/web/js/components/dateline/datelines.js
index 434be2294..07ba5dbec 100644
--- a/web/js/components/dateline/datelines.js
+++ b/web/js/components/dateline/datelines.js
@@ -16,6 +16,7 @@ function DateLines(props) {
const [height, setHeight] = useState(0);
const [startY, setStartY] = useState(0);
const [hideLines, setHideLines] = useState(false);
+ const [textCoords, setTextCoords] = useState([0, 0]);
const updatePosition = () => {
let topY;
@@ -76,6 +77,8 @@ function DateLines(props) {
lineX={-180}
lineY={startY}
date={date}
+ textCoords={textCoords}
+ setTextCoords={setTextCoords}
/>
<Line
id="dateline-right"
@@ -86,6 +89,8 @@ function DateLines(props) {
lineX={180}
lineY={startY}
date={util.dateAdd(date, 'day', -1)}
+ textCoords={textCoords}
+ setTextCoords={setTextCoords}
/>
</>
);
diff --git a/web/js/components/dateline/line.js b/web/js/components/dateline/line.js
index 887c65f2d..bd9292f37 100644
--- a/web/js/components/dateline/line.js
+++ b/web/js/components/dateline/line.js
@@ -22,7 +22,6 @@ class Line extends React.Component {
overlay: '',
hovered: false,
textActive: props.alwaysShow,
- textCoords: [0, 0],
};
this.nodeRef = React.createRef();
}
@@ -38,10 +37,14 @@ class Line extends React.Component {
this.setState({ overlay });
}
- componentDidUpdate() {
- const { lineX, lineY } = this.props;
+ componentDidUpdate(prevProps) {
+ const { lineX, lineY, alwaysShow } = this.props;
const { overlay } = this.state;
overlay.setPosition([lineX, lineY]);
+ if (!alwaysShow && alwaysShow !== prevProps.alwaysShow) {
+ // eslint-disable-next-line react/no-did-update-set-state
+ this.setState({ textActive: false });
+ }
}
mouseOver = () => {
@@ -57,10 +60,10 @@ class Line extends React.Component {
}
mouseOverHidden = (e) => {
- const { map } = this.props;
+ const { map, setTextCoords } = this.props;
+ setTextCoords(map.getCoordinateFromPixel([e.clientX, e.clientY]));
this.setState({
textActive: true,
- textCoords: map.getCoordinateFromPixel([e.clientX, e.clientY]),
});
}
@@ -78,8 +81,9 @@ class Line extends React.Component {
style,
map,
height,
+ textCoords,
} = this.props;
- const { hovered, textCoords, textActive } = this.state;
+ const { hovered, textActive } = this.state;
const {
strokeWidth, dashArray, color, svgStyle, width,
@@ -150,6 +154,8 @@ Line.propTypes = {
lineY: PropTypes.number,
map: PropTypes.object,
style: PropTypes.object,
+ setTextCoords: PropTypes.func,
+ textCoords: PropTypes.array,
};
export default Line;
diff --git a/web/js/components/global-settings/global-settings.js b/web/js/components/global-settings/global-settings.js
index bbff3d34a..1b6558e68 100644
--- a/web/js/components/global-settings/global-settings.js
+++ b/web/js/components/global-settings/global-settings.js
@@ -2,13 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { Button, ButtonGroup } from 'reactstrap';
import HoverTooltip from '../util/hover-tooltip';
import TemperatureUnitButtons from './temperature-unit-buttons';
import {
changeTemperatureUnit,
changeDatelineVisibility,
} from '../../modules/settings/actions';
-import Switch from '../util/switch';
function GlobalSettings(props) {
const {
@@ -29,23 +29,34 @@ function GlobalSettings(props) {
<div className="settings-component">
<h3 className="wv-header">
- Show Datelines
+ Show Antimeridian / Approximate Date Line
{' '}
<span><FontAwesomeIcon id="datelines-toggle" icon="info-circle" /></span>
<HoverTooltip
isMobile={false}
- labelText="Either always show or only on mouse hover"
+ labelText="For many layers, this line represents the transition of daytime imagery from one day to the next."
target="datelines-toggle"
placement="right"
/>
</h3>
- <Switch
- id="dateline-visibility-toggle"
- label={alwaysShowDatelines ? 'Always' : 'On Hover'}
- containerClassAddition="header"
- active={alwaysShowDatelines}
- toggle={() => toggleAlwaysShowDatelines(!alwaysShowDatelines)}
- />
+ <ButtonGroup>
+ <Button
+ outline
+ className="setting-button"
+ active={alwaysShowDatelines}
+ onClick={() => toggleAlwaysShowDatelines(true)}
+ >
+ Always
+ </Button>
+ <Button
+ outline
+ className="setting-button"
+ active={!alwaysShowDatelines}
+ onClick={() => toggleAlwaysShowDatelines(false)}
+ >
+ On Hover
+ </Button>
+ </ButtonGroup>
</div>
</div>
</>
diff --git a/web/js/components/global-settings/temperature-unit-buttons.js b/web/js/components/global-settings/temperature-unit-buttons.js
index 2dda64f6c..426948a7a 100644
--- a/web/js/components/global-settings/temperature-unit-buttons.js
+++ b/web/js/components/global-settings/temperature-unit-buttons.js
@@ -6,7 +6,7 @@ import HoverTooltip from '../util/hover-tooltip';
import { TEMPERATURE_UNITS } from '../../modules/settings/constants';
const TemperatureUnitButtons = ({ changeTemperatureUnit, globalTemperatureUnit }) => (
- <div className="temperature-unit-buttons settings-component">
+ <div className="settings-component">
<h3 className="wv-header">
Temperature Unit
{' '}
@@ -24,7 +24,7 @@ const TemperatureUnitButtons = ({ changeTemperatureUnit, globalTemperatureUnit }
key={`${unit}-button`}
aria-label={`Set ${unit} Unit`}
outline
- className="temperature-unit-button"
+ className="setting-button"
active={globalTemperatureUnit === unit}
onClick={() => changeTemperatureUnit(unit)}
>
@@ -34,7 +34,7 @@ const TemperatureUnitButtons = ({ changeTemperatureUnit, globalTemperatureUnit }
<Button
aria-label="Reset to Default Unit"
outline
- className="temperature-unit-button"
+ className="setting-button"
active={!globalTemperatureUnit}
onClick={() => changeTemperatureUnit('')}
>