From 3727f5da48d54d39f686ff8958c5ae210d61d5ed Mon Sep 17 00:00:00 2001 From: Harel M Date: Wed, 21 Feb 2024 07:17:28 +0200 Subject: [PATCH] Improve inspect hover UI (#879) Fixes #868 - #868 It solves all the block within blocks and all kind of controls that are not required which creates gaps. I use a simple table, so the width is dynamic but it is always aligned for all the properties and the features. ![image](https://github.com/maplibre/maputnik/assets/3269297/75138b00-ec7b-4e8d-b51b-f8ff6abcd5cb) Vary basic stuff. There's still the layer popup, which I'm not sure I know what it is and might need to be fixed as well. CC: @zstadler --- .../MapMaplibreGlFeaturePropertyPopup.tsx | 43 ++++++++----------- src/styles/_popup.scss | 9 ++++ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/components/MapMaplibreGlFeaturePropertyPopup.tsx b/src/components/MapMaplibreGlFeaturePropertyPopup.tsx index c2337475..e1d0a28e 100644 --- a/src/components/MapMaplibreGlFeaturePropertyPopup.tsx +++ b/src/components/MapMaplibreGlFeaturePropertyPopup.tsx @@ -1,6 +1,4 @@ import React from 'react' -import Block from './Block' -import FieldString from './FieldString' export type InspectFeature = { id: string @@ -21,30 +19,25 @@ function displayValue(value: string | number | Date | object) { return value; } -function renderProperties(feature: InspectFeature) { - return Object.keys(feature.properties).map(propertyName => { - const property = feature.properties[propertyName] - return - - - }) -} - -function renderFeatureId(feature: InspectFeature) { - return - - +function renderKeyValueTableRow(key: string, value: string) { + return + {key} + {value} + } function renderFeature(feature: InspectFeature, idx: number) { - return
-
{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && × {feature.inspectModeCounter}}
- - - - {renderFeatureId(feature)} - {renderProperties(feature)} -
+ return <> + + {feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && × {feature.inspectModeCounter}} + + {renderKeyValueTableRow("$type", feature.geometry.type)} + {renderKeyValueTableRow("Feature ID", displayValue(feature.id))} + {Object.keys(feature.properties).map(propertyName => { + const property = feature.properties[propertyName]; + return renderKeyValueTableRow(propertyName, displayValue(property)) + })} + } function removeDuplicatedFeatures(features: InspectFeature[]) { @@ -78,7 +71,9 @@ class FeaturePropertyPopup extends React.Component { render() { const features = removeDuplicatedFeatures(this.props.features) return
- {features.map(renderFeature)} + + {features.map(renderFeature)} +
} } diff --git a/src/styles/_popup.scss b/src/styles/_popup.scss index f9aab490..a500efb5 100644 --- a/src/styles/_popup.scss +++ b/src/styles/_popup.scss @@ -36,3 +36,12 @@ margin-top: $margin-2; } } + +.maputnik-popup-table { + width: 100%; +} + +.maputnik-popup-table-cell { + color: $color-lowgray; + padding-left: $margin-2; +}