Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add invisible color to single custom palette #2727

Benjamin Kingbf97eb994419
diff --git a/config/default/common/config/palettes-custom.json/single.json b/config/default/common/config/palettes-custom.json/single.json
index 21f9004e7..476a4d254 100644
--- a/config/default/common/config/palettes-custom.json/single.json
+++ b/config/default/common/config/palettes-custom.json/single.json
@@ -58,5 +58,10 @@
"id": "brown",
"name": "Brown",
"colors": ["b15928ff"]
+ },
+ "invisible": {
+ "id": "invisible",
+ "name": "Invisible",
+ "colors": ["00000000"]
}
}
diff --git a/config/default/common/config/wv.json/paletteOrder.json b/config/default/common/config/wv.json/paletteOrder.json
index 0dcb1460c..409350335 100644
--- a/config/default/common/config/wv.json/paletteOrder.json
+++ b/config/default/common/config/wv.json/paletteOrder.json
@@ -1,5 +1,6 @@
{
"paletteOrder": [
+ "invisible",
"orange_1",
"red_1",
"red_2",
diff --git a/web/css/util.css b/web/css/util.css
index 4f2214dea..ddc749d37 100644
--- a/web/css/util.css
+++ b/web/css/util.css
@@ -200,7 +200,17 @@ button[data-tooltip] {
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}
-
+/* https://stackoverflow.com/a/35362074/4589331 */
+.checkerbox-bg {
+ background-image:
+ linear-gradient(45deg, rgb(200, 200, 200) 25%, transparent 25%),
+ linear-gradient(-45deg, rgb(200, 200, 200) 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, rgb(200, 200, 200) 75%),
+ linear-gradient(-45deg, transparent 75%, rgb(200, 200, 200) 75%);
+ background-size: 4px 4px;
+ background-color: #fff;
+ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
+}
/* Clearfix classes */
.clearfix::after {
content: "";
diff --git a/web/js/components/layer/settings/palette.js b/web/js/components/layer/settings/palette.js
index 98c64399b..0dfb2f01f 100644
--- a/web/js/components/layer/settings/palette.js
+++ b/web/js/components/layer/settings/palette.js
@@ -144,6 +144,8 @@ class PaletteSelect extends React.Component {
: palette.colors[0];
const caseDefaultClassName = 'wv-palette-selector-row wv-checkbox wv-checkbox-round gray ';
const checkedClassName = isSelected ? 'checked' : '';
+ const isInvisible = color === '00000000';
+
return (
<div key={id} className={caseDefaultClassName + checkedClassName}>
<input
@@ -154,8 +156,8 @@ class PaletteSelect extends React.Component {
/>
<label htmlFor={`wv-palette-radio-${id}`}>
<span
- className="wv-palettes-class"
- style={{ backgroundColor: util.hexToRGB(color) }}
+ className={isInvisible ? 'checkerbox-bg wv-palettes-class' : 'wv-palettes-class'}
+ style={isInvisible ? null : { backgroundColor: util.hexToRGBA(color) }}
>
&nbsp;
</span>
@@ -168,7 +170,6 @@ class PaletteSelect extends React.Component {
render() {
const { index, layer, paletteOrder } = this.props;
const recommended = layer.palette.recommended || [];
-
return (
<div
className="wv-palette-selector settings-component noselect"
diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.js
index f9adf76a6..c8da4d5d2 100644
--- a/web/js/components/sidebar/paletteLegend.js
+++ b/web/js/components/sidebar/paletteLegend.js
@@ -351,22 +351,23 @@ class PaletteLegend extends React.Component {
<div className={legendClass} key={`${legend.id}_${legendIndex}`}>
{legend.colors.map((color, keyIndex) => {
const isActiveKey = activeKeyObj && activeKeyObj.index === keyIndex;
- const palletteClass = isActiveKey ? 'wv-active wv-palettes-class' : 'wv-palettes-class';
+ let palletteClass = isActiveKey ? 'wv-active wv-palettes-class' : 'wv-palettes-class';
const isSubLayer = !!parentLayer;
const parentLayerId = isSubLayer ? `-${parentLayer.id}` : '';
const keyId = `${legend.id}-color${parentLayerId}-${layerGroupName}${keyIndex}`;
const keyLabel = activeKeyObj ? activeKeyObj.label : '';
-
const inActive = palette.disabled && palette.disabled.includes(keyIndex);
const tooltipText = singleKey
? layer.track ? trackLabel : legendTooltip
: keyLabel;
+ const isInvisible = color === '00000000';
+ palletteClass = isInvisible ? `${palletteClass} checkerbox-bg` : palletteClass;
return (
<React.Fragment key={keyId}>
<span
id={keyId}
className={inActive ? `${palletteClass} disabled-classification` : palletteClass}
- style={{ backgroundColor: util.hexToRGBA(color) }}
+ style={isInvisible ? null : { backgroundColor: util.hexToRGBA(color) }}
onMouseMove={this.onMove.bind(this, color)}
onMouseEnter={this.onMouseEnter.bind(this)}
onMouseLeave={this.hideValue.bind(this)}