mirror of
https://github.com/maputnik/editor.git
synced 2026-01-06 21:40:01 +00:00
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.  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
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Block from './Block'
|
|
||||||
import FieldString from './FieldString'
|
|
||||||
|
|
||||||
export type InspectFeature = {
|
export type InspectFeature = {
|
||||||
id: string
|
id: string
|
||||||
@@ -21,30 +19,25 @@ function displayValue(value: string | number | Date | object) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderProperties(feature: InspectFeature) {
|
function renderKeyValueTableRow(key: string, value: string) {
|
||||||
return Object.keys(feature.properties).map(propertyName => {
|
return <tr key={key}>
|
||||||
const property = feature.properties[propertyName]
|
<td className="maputnik-popup-table-cell">{key}</td>
|
||||||
return <Block key={propertyName} label={propertyName}>
|
<td className="maputnik-popup-table-cell">{value}</td>
|
||||||
<FieldString value={displayValue(property)} style={{backgroundColor: 'transparent'}}/>
|
</tr>
|
||||||
</Block>
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderFeatureId(feature: InspectFeature) {
|
|
||||||
return <Block key={"feature-id"} label={"feature_id"}>
|
|
||||||
<FieldString value={displayValue(feature.id)} style={{backgroundColor: 'transparent'}} />
|
|
||||||
</Block>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderFeature(feature: InspectFeature, idx: number) {
|
function renderFeature(feature: InspectFeature, idx: number) {
|
||||||
return <div key={`${feature.sourceLayer}-${idx}`}>
|
return <>
|
||||||
<div className="maputnik-popup-layer-id">{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</div>
|
<tr key={`${feature.sourceLayer}-${idx}`}>
|
||||||
<Block key={"property-type"} label={"$type"}>
|
<td colSpan={2} className="maputnik-popup-layer-id">{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</td>
|
||||||
<FieldString value={feature.geometry.type} style={{backgroundColor: 'transparent'}} />
|
</tr>
|
||||||
</Block>
|
{renderKeyValueTableRow("$type", feature.geometry.type)}
|
||||||
{renderFeatureId(feature)}
|
{renderKeyValueTableRow("Feature ID", displayValue(feature.id))}
|
||||||
{renderProperties(feature)}
|
{Object.keys(feature.properties).map(propertyName => {
|
||||||
</div>
|
const property = feature.properties[propertyName];
|
||||||
|
return renderKeyValueTableRow(propertyName, displayValue(property))
|
||||||
|
})}
|
||||||
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeDuplicatedFeatures(features: InspectFeature[]) {
|
function removeDuplicatedFeatures(features: InspectFeature[]) {
|
||||||
@@ -78,7 +71,9 @@ class FeaturePropertyPopup extends React.Component<FeaturePropertyPopupProps> {
|
|||||||
render() {
|
render() {
|
||||||
const features = removeDuplicatedFeatures(this.props.features)
|
const features = removeDuplicatedFeatures(this.props.features)
|
||||||
return <div className="maputnik-feature-property-popup">
|
return <div className="maputnik-feature-property-popup">
|
||||||
{features.map(renderFeature)}
|
<table className="maputnik-popup-table">
|
||||||
|
{features.map(renderFeature)}
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,3 +36,12 @@
|
|||||||
margin-top: $margin-2;
|
margin-top: $margin-2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-popup-table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maputnik-popup-table-cell {
|
||||||
|
color: $color-lowgray;
|
||||||
|
padding-left: $margin-2;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user