Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

make checkbox labels clickable, show pointer

Jason Kent199ebb78df71
diff --git a/web/css/checkbox.css b/web/css/checkbox.css
index 84f246176..a42c314b8 100644
--- a/web/css/checkbox.css
+++ b/web/css/checkbox.css
@@ -13,6 +13,9 @@
width: 24px;
left: 0;
}
+.wv-checkbox label {
+ cursor: pointer;
+}
.wv-checkbox::before {
content: '\00a0';
display: inline-block;
diff --git a/web/css/switch.css b/web/css/switch.css
index 370dd1893..33bbafe43 100644
--- a/web/css/switch.css
+++ b/web/css/switch.css
@@ -61,3 +61,7 @@
height: 17px;
width: 32px;
}
+
+.switch-label-text {
+ cursor: pointer;
+}
diff --git a/web/js/components/layer/settings/orbit-tracks-toggle.js b/web/js/components/layer/settings/orbit-tracks-toggle.js
index ae2d2ab14..225783fef 100644
--- a/web/js/components/layer/settings/orbit-tracks-toggle.js
+++ b/web/js/components/layer/settings/orbit-tracks-toggle.js
@@ -26,6 +26,7 @@ const OrbitTracksToggle = (props) => {
const onCheck = () => (isEnabled ? removeLayer(id) : addLayer(id));
return (
<Checkbox
+ id={id}
key={id}
title="Enable/disable orbit tracks for this layer"
checked={isEnabled}
diff --git a/web/js/components/tour/modal-tour-complete.js b/web/js/components/tour/modal-tour-complete.js
index ad19c2e1f..7b387c83f 100644
--- a/web/js/components/tour/modal-tour-complete.js
+++ b/web/js/components/tour/modal-tour-complete.js
@@ -40,7 +40,7 @@ const ModalComplete = (props) => {
fade={false}
keyboard
>
- <ModalHeader toggle={endTour} charCode="">
+ <ModalHeader toggle={endTour}>
Story Complete
</ModalHeader>
<ModalBody>
diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.js
index 16ed26e60..5d17ac032 100644
--- a/web/js/components/tour/modal-tour-in-progress.js
+++ b/web/js/components/tour/modal-tour-in-progress.js
@@ -38,7 +38,7 @@ class ModalInProgress extends React.Component {
backdrop={false}
keyboard={false}
>
- <ModalHeader toggle={endTour} charCode="">
+ <ModalHeader toggle={endTour}>
{currentStory.title}
<i className="modal-icon" aria-hidden="true" />
</ModalHeader>
diff --git a/web/js/components/tour/modal-tour-start.js b/web/js/components/tour/modal-tour-start.js
index c589bbeeb..ff9ff05f9 100644
--- a/web/js/components/tour/modal-tour-start.js
+++ b/web/js/components/tour/modal-tour-start.js
@@ -8,6 +8,7 @@ import {
InputGroup,
InputGroupText,
Input,
+ Label,
} from 'reactstrap';
import TourIntro from './content-intro';
import TourBoxes from './tour-boxes';
@@ -79,7 +80,7 @@ class ModalStart extends React.Component {
keyboard={false}
innerRef={this.setWrapperRef}
>
- <ModalHeader toggle={endTour} charCode="">
+ <ModalHeader toggle={endTour}>
Welcome to Worldview!
</ModalHeader>
<Scrollbars style={{ maxHeight: `${height - 200}px` }}>
@@ -101,15 +102,16 @@ class ModalStart extends React.Component {
<InputGroupText className="w-100">
<Input
addon
+ id="hide-until-new-checkbox"
type="checkbox"
className="float-right m-0"
defaultChecked={checked}
onChange={this.handleCheck}
- aria-label="Hide this box until a new story has been added."
+ aria-label="Hide this dialog until a new story has been added."
/>
- <span className="ml-2">
+ <Label for="hide-until-new-checkbox" className="ml-2">
Do not show until a new story has been added.
- </span>
+ </Label>
</InputGroupText>
</InputGroup>
</ModalFooter>
diff --git a/web/js/components/util/checkbox.js b/web/js/components/util/checkbox.js
index 160ea054e..e888aa3f4 100644
--- a/web/js/components/util/checkbox.js
+++ b/web/js/components/util/checkbox.js
@@ -12,6 +12,8 @@ export default class Checkbox extends React.Component {
this.state = {
checked: props.checked,
};
+ this.handleChange = this.handleChange.bind(this);
+ this.handleClick = this.handleClick.bind(this);
}
UNSAFE_componentWillReceiveProps(nextProps) {
@@ -23,7 +25,7 @@ export default class Checkbox extends React.Component {
}
}
- onClick(e) {
+ handleClick(e) {
const { onClick } = this.props;
if (onClick) {
e.stopPropagation();
@@ -51,7 +53,10 @@ export default class Checkbox extends React.Component {
const caseClassName = defaultClassName + roundClassName + checkedClassName + color;
return (
- <div className={caseClassName} onClick={this.onClick.bind(this)}>
+ <div
+ className={caseClassName}
+ onClick={this.handleClick}
+ >
<input
type="checkbox"
id={id}
@@ -59,7 +64,7 @@ export default class Checkbox extends React.Component {
name={name}
checked={checked}
className={classNames}
- onChange={this.handleChange.bind(this)}
+ onChange={this.handleChange}
/>
{children}
<label htmlFor={id}>
@@ -81,7 +86,7 @@ Checkbox.propTypes = {
children: PropTypes.node,
classNames: PropTypes.string,
color: PropTypes.string,
- id: PropTypes.string,
+ id: PropTypes.string.isRequired,
isRound: PropTypes.bool,
label: PropTypes.string,
name: PropTypes.string,
diff --git a/web/js/components/util/switch.js b/web/js/components/util/switch.js
index b9765cc18..d65f35322 100644
--- a/web/js/components/util/switch.js
+++ b/web/js/components/util/switch.js
@@ -27,6 +27,12 @@ const Switch = (props) => {
toggleActive(active);
}, [active]);
+ function toggleSwitch () {
+ // wait for css animation to complete before firing action
+ setTimeout(toggle, 200);
+ toggleActive(!isActive);
+ }
+
return (
<div className={containerClass}>
<div className="react-switch-case switch-col">
@@ -35,11 +41,7 @@ const Switch = (props) => {
id={id}
type="checkbox"
checked={isActive}
- onChange={() => {
- // wait for css animation to complete before firing action
- setTimeout(toggle, 200);
- toggleActive(!isActive);
- }}
+ onChange={toggleSwitch}
/>
<label
className="react-switch-label"
@@ -50,7 +52,12 @@ const Switch = (props) => {
</label>
</div>
<div className="react-switch-label-case switch-col">
- {label}
+ <span
+ className="switch-label-text"
+ onClick={toggleSwitch}
+ >
+ {label}
+ </span>
{tooltip
&& (
<>
@@ -78,7 +85,7 @@ Switch.propTypes = {
border: PropTypes.bool,
color: PropTypes.string,
containerClassAddition: PropTypes.string,
- id: PropTypes.string,
+ id: PropTypes.string.isRequired,
label: PropTypes.string,
toggle: PropTypes.func,
tooltip: PropTypes.object,