From 6a6595d971a1d669d7e2fec5f607cc04f21f7ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Wolan=CC=81ski?= Date: Mon, 8 Jan 2018 22:18:30 +0100 Subject: [PATCH 1/7] Clickable layer tooltips (#60) --- package.json | 2 +- src/components/App.jsx | 3 ++- src/components/layers/LayerList.jsx | 5 +++-- src/components/map/FeatureLayerPopup.jsx | 4 ++++ src/components/map/MapboxGlMap.jsx | 12 +++++------- src/styles/_popup.scss | 1 + 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index c358b4b..0bc256d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "lodash.isequal": "^4.5.0", "lodash.throttle": "^4.1.1", "mapbox-gl": "^0.41.0", - "mapbox-gl-inspect": "^1.2.4", + "mapbox-gl-inspect": "^1.2.5", "maputnik-design": "github:maputnik/design", "mousetrap": "^1.6.1", "ol-mapbox-style": "^1.0.1", diff --git a/src/components/App.jsx b/src/components/App.jsx index d51f724..d90415a 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -249,7 +249,8 @@ export default class App extends React.Component { } else { return + highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]} + onLayerSelect={this.onLayerSelect.bind(this)} /> } } diff --git a/src/components/layers/LayerList.jsx b/src/components/layers/LayerList.jsx index c30c647..a27807e 100644 --- a/src/components/layers/LayerList.jsx +++ b/src/components/layers/LayerList.jsx @@ -164,7 +164,7 @@ class LayerListContainer extends React.Component { const grp = listItems.push(grp) @@ -172,9 +172,10 @@ class LayerListContainer extends React.Component { layers.forEach((layer, idxInGroup) => { const groupIdx = findClosestCommonPrefix(this.props.layers, idx) + const listItem = 1 && this.isCollapsed(groupPrefix, groupIdx), + 'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx) && idx !== this.props.selectedLayerIndex, 'maputnik-layer-list-item-group-last': idxInGroup == layers.length - 1 && layers.length > 1 })} index={idx} diff --git a/src/components/map/FeatureLayerPopup.jsx b/src/components/map/FeatureLayerPopup.jsx index ca67de5..2b905aa 100644 --- a/src/components/map/FeatureLayerPopup.jsx +++ b/src/components/map/FeatureLayerPopup.jsx @@ -16,6 +16,7 @@ function groupFeaturesBySourceLayer(features) { class FeatureLayerPopup extends React.Component { static propTypes = { + onLayerSelect: PropTypes.func.isRequired, features: PropTypes.array } @@ -27,6 +28,9 @@ class FeatureLayerPopup extends React.Component { return