Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

aria labels and tooltips for animation buttons

Jason Kentf873c1829a6f
diff --git a/web/js/components/animation-widget/loop-button.js b/web/js/components/animation-widget/loop-button.js
index b05d7256b..9c8f92d4c 100644
--- a/web/js/components/animation-widget/loop-button.js
+++ b/web/js/components/animation-widget/loop-button.js
@@ -2,24 +2,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { UncontrolledTooltip } from 'reactstrap';
/*
* @class LoopButton
* @extends React.Component
*/
-const LoopButton = (props) => (
- <a
- title={props.looping ? 'Stop Loop' : 'Loop video'}
- className={
- props.looping
- ? 'wv-loop-icon-case wv-icon-case active'
- : 'wv-loop-icon-case wv-icon-case'
- }
- onClick={props.onLoop}
- >
- <FontAwesomeIcon icon="retweet" className="wv-animation-widget-icon" />
- </a>
-);
+const LoopButton = ({ looping, onLoop }) => {
+ const labelText = looping ? 'Disable animation loop' : 'Enable animation loop';
+ const buttonId = 'loop-button';
+ return (
+ <a
+ id={buttonId}
+ aria-label={labelText}
+ className={
+ looping
+ ? 'wv-loop-icon-case wv-icon-case active'
+ : 'wv-loop-icon-case wv-icon-case'
+ }
+ onClick={onLoop}
+ >
+ <UncontrolledTooltip
+ placement="right"
+ target={buttonId}
+ >
+ {labelText}
+ </UncontrolledTooltip>
+ <FontAwesomeIcon icon="retweet" className="wv-animation-widget-icon" />
+ </a>
+ );
+};
LoopButton.propTypes = {
looping: PropTypes.bool,
diff --git a/web/js/components/animation-widget/play-button.js b/web/js/components/animation-widget/play-button.js
index e5a0f72d2..aee8396dc 100644
--- a/web/js/components/animation-widget/play-button.js
+++ b/web/js/components/animation-widget/play-button.js
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { UncontrolledTooltip } from 'reactstrap';
/*
* @class PlayButton
@@ -8,12 +9,21 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
*/
const PlayButton = (props) => {
const { playing, pause, play } = props;
+ const buttonId = 'play-button';
+ const labelText = playing ? 'Pause animation' : 'Play animation';
return (
<a
- title={playing ? 'Pause video' : 'Play video'}
+ id={buttonId}
+ aria-label={labelText}
className="wv-anim-play-case wv-icon-case"
onClick={playing ? pause : play}
>
+ <UncontrolledTooltip
+ target={buttonId}
+ placement="top"
+ >
+ {labelText}
+ </UncontrolledTooltip>
{playing
? <FontAwesomeIcon icon="pause" className="wv-animation-widget-icon" />
: <FontAwesomeIcon icon="play" className="wv-animation-widget-icon" />}
diff --git a/web/js/components/timeline/timeline-controls/animation-button.js b/web/js/components/timeline/timeline-controls/animation-button.js
index 442755c81..7edaf2dbd 100644
--- a/web/js/components/timeline/timeline-controls/animation-button.js
+++ b/web/js/components/timeline/timeline-controls/animation-button.js
@@ -1,17 +1,26 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { UncontrolledTooltip } from 'reactstrap';
class AnimationButton extends PureComponent {
render() {
const className = 'button-action-group animate-button';
- const { disabled, title, clickAnimationButton } = this.props;
+ const { disabled, label, clickAnimationButton } = this.props;
+ const buttonId = 'animate-button';
+ const labelText = label || 'Set up animation';
return (
<div
className={disabled ? `wv-disabled-button ${className}` : className}
- title={title || 'Set up animation'}
+ aria-label={labelText}
>
- <div id="animate-button" onClick={clickAnimationButton}>
+ <div id={buttonId} onClick={clickAnimationButton}>
+ <UncontrolledTooltip
+ placement="right"
+ target={buttonId}
+ >
+ {labelText}
+ </UncontrolledTooltip>
<FontAwesomeIcon icon="video" className="wv-animate" size="3x" />
</div>
</div>
@@ -22,7 +31,7 @@ class AnimationButton extends PureComponent {
AnimationButton.propTypes = {
clickAnimationButton: PropTypes.func,
disabled: PropTypes.bool,
- title: PropTypes.string,
+ label: PropTypes.string,
};
export default AnimationButton;
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index 786cf8bd3..aa4d2f354 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -8,7 +8,7 @@ import {
import googleTagManager from 'googleTagManager';
import PropTypes from 'prop-types';
import Slider, { Handle } from 'rc-slider';
-import { Tooltip } from 'reactstrap';
+import { Button, Tooltip, UncontrolledTooltip } from 'reactstrap';
import Draggable from 'react-draggable';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import util from '../util/util';
@@ -104,7 +104,6 @@ class AnimationWidget extends React.Component {
const halfWidgetWidth = (props.subDailyMode ? subdailyWidgetWidth : widgetWidth) / 2;
this.state = {
speed: props.speed,
- hoverGif: false,
widgetPosition: {
x: (props.screenWidth / 2) - halfWidgetWidth,
y: -10,
@@ -116,8 +115,6 @@ class AnimationWidget extends React.Component {
this.onDateChange = this.onDateChange.bind(this);
this.onIntervalSelect = this.onIntervalSelect.bind(this);
this.onLoop = this.onLoop.bind(this);
- this.openGif = this.openGif.bind(this);
- this.toggleHoverGif = this.toggleHoverGif.bind(this);
this.handleDragStart = this.handleDragStart.bind(this);
this.toggleCollapse = this.toggleCollapse.bind(this);
this.onCollapsedDrag = this.onCollapsedDrag.bind(this);
@@ -198,58 +195,6 @@ class AnimationWidget extends React.Component {
return Promise.resolve(type);
}
- openGif() {
- const {
- toggleGif,
- onUpdateStartAndEndDate,
- hasCustomPalettes,
- isRotated,
- hasGraticule,
- rotation,
- activePalettes,
- numberOfFrames,
- refreshStateAfterGif,
- } = this.props;
- const {
- startDate,
- endDate,
- } = this.zeroDates();
-
- if (numberOfFrames >= maxFrames) {
- return;
- }
- const paletteStore = lodashCloneDeep(activePalettes);
-
- this.getPromise(hasCustomPalettes, 'palette', clearCustoms, 'Notice').then(
- () => {
- this.getPromise(
- isRotated,
- 'rotate',
- clearRotate,
- 'Reset rotation',
- ).then(() => {
- this.getPromise(
- hasGraticule,
- 'graticule',
- clearGraticule,
- 'Remove Graticule?',
- ).then(() => {
- onUpdateStartAndEndDate(startDate, endDate);
- }).then(() => {
- googleTagManager.pushEvent({
- event: 'GIF_create_animated_button',
- });
- this.onCloseGif = () => {
- refreshStateAfterGif(hasCustomPalettes ? paletteStore : undefined, rotation, hasGraticule);
- toggleGif();
- };
- toggleGif();
- });
- });
- },
- );
- }
-
/**
* Sets a new state to say whether or not
* the animation should loop
@@ -387,30 +332,6 @@ class AnimationWidget extends React.Component {
changeCustomInterval(delta, timeScale);
};
- toggleHoverGif() {
- const { hoverGif } = this.state;
- this.setState({ hoverGif: !hoverGif });
- }
-
- renderToolTip() {
- const { numberOfFrames } = this.props;
- const { hoverGif } = this.state;
- const elemExists = document.querySelector('#create-gif-button');
- const showTooltip = elemExists && hoverGif && numberOfFrames >= maxFrames;
- return (
- <Tooltip
- placement="right"
- isOpen={showTooltip}
- target="create-gif-button"
- >
- Too many frames were selected.
- {' '}
- <br />
- Please request less than 40 frames if you would like to generate a GIF.
- </Tooltip>
- );
- }
-
renderCollapsedWidget() {
const {
onClose,
@@ -446,6 +367,74 @@ class AnimationWidget extends React.Component {
);
}
+ renderCreateGifButton() {
+ const {
+ toggleGif,
+ onUpdateStartAndEndDate,
+ hasCustomPalettes,
+ isRotated,
+ hasGraticule,
+ rotation,
+ activePalettes,
+ numberOfFrames,
+ refreshStateAfterGif,
+ } = this.props;
+ const gifDisabled = numberOfFrames >= maxFrames;
+ const elemExists = document.querySelector('#create-gif-button');
+ const showWarning = elemExists && numberOfFrames >= maxFrames;
+ const warningMessage = (
+ <span>
+ Too many frames were selected.
+ <br />
+ Please request less than 40 frames if you would like to generate a GIF.
+ </span>
+ );
+ const labelText = 'Create an animated gif';
+
+ const openGif = async () => {
+ const { startDate, endDate } = this.zeroDates();
+ if (numberOfFrames >= maxFrames) {
+ return;
+ }
+ const paletteStore = lodashCloneDeep(activePalettes);
+ await this.getPromise(hasCustomPalettes, 'palette', clearCustoms, 'Notice');
+ await this.getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');
+ await this.getPromise(hasGraticule, 'graticule', clearGraticule, 'Remove Graticule?');
+ await onUpdateStartAndEndDate(startDate, endDate);
+ googleTagManager.pushEvent({
+ event: 'GIF_create_animated_button',
+ });
+ this.onCloseGif = () => {
+ refreshStateAfterGif(hasCustomPalettes ? paletteStore : undefined, rotation, hasGraticule);
+ toggleGif();
+ };
+ toggleGif();
+ };
+
+ return (
+ <a
+ id="create-gif-button"
+ title={!gifDisabled ? 'Create Animated GIF' : ''}
+ aria-label={labelText}
+ className={gifDisabled ? 'wv-icon-case disabled' : 'wv-icon-case'}
+ onClick={openGif}
+ >
+ <FontAwesomeIcon
+ id="wv-animation-widget-file-video-icon"
+ className="wv-animation-widget-icon"
+ icon="file-video"
+ />
+ <UncontrolledTooltip
+ placement="right"
+ target="create-gif-button"
+ >
+ {showWarning ? warningMessage : labelText}
+ </UncontrolledTooltip>
+ </a>
+
+ );
+ }
+
renderExpandedWidget() {
const {
onClose,
@@ -463,12 +452,11 @@ class AnimationWidget extends React.Component {
customSelected,
customDelta,
customInterval,
- numberOfFrames,
animationCustomModalOpen,
hasSubdailyLayers,
} = this.props;
const { speed, widgetPosition } = this.state;
- const gifDisabled = numberOfFrames >= maxFrames;
+
return (
<Draggable
bounds="body"
@@ -517,17 +505,7 @@ class AnimationWidget extends React.Component {
</div>
{/* Create Gif */}
- <a
- id="create-gif-button"
- title={!gifDisabled ? 'Create Animated GIF' : ''}
- className={gifDisabled ? 'wv-icon-case disabled' : 'wv-icon-case'}
- onClick={this.openGif}
- onMouseEnter={this.toggleHoverGif}
- onMouseLeave={this.toggleHoverGif}
- >
- <FontAwesomeIcon icon="file-video" id="wv-animation-widget-file-video-icon" className="wv-animation-widget-icon" />
- </a>
- {this.renderToolTip()}
+ {this.renderCreateGifButton()}
{/* From/To Date/Time Selection */}
<div className="wv-anim-dates-case">
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 7e299a6ba..82175e59d 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -1159,7 +1159,7 @@ class Timeline extends React.Component {
<AnimationButton
clickAnimationButton={this.clickAnimationButton}
disabled={animationDisabled}
- title={
+ label={
// eslint-disable-next-line no-nested-ternary
isCompareModeActive
? 'Animation feature is deactivated when Compare feature is active'