mirror of
https://github.com/maputnik/editor.git
synced 2026-06-27 09:37:26 +00:00
Simplify code
This commit is contained in:
@@ -15,8 +15,8 @@ function displayValue(value: string | number | Date | object | undefined) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderKeyValueTableRow(key: string, value: string | undefined, idx: number) {
|
function renderKeyValueTableRow(key: string, value: string | undefined) {
|
||||||
return <tr key={`${key}-${value}-${idx}`}>
|
return <tr key={key}>
|
||||||
<td className="maputnik-popup-table-cell">{key}</td>
|
<td className="maputnik-popup-table-cell">{key}</td>
|
||||||
<td className="maputnik-popup-table-cell">{value}</td>
|
<td className="maputnik-popup-table-cell">{value}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -24,14 +24,14 @@ function renderKeyValueTableRow(key: string, value: string | undefined, idx: num
|
|||||||
|
|
||||||
function renderFeature(feature: InspectFeature, idx: number) {
|
function renderFeature(feature: InspectFeature, idx: number) {
|
||||||
return <React.Fragment key={idx}>
|
return <React.Fragment key={idx}>
|
||||||
<tr key={`counter-${idx}`}>
|
<tr>
|
||||||
<td colSpan={2} className="maputnik-popup-layer-id">{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</td>
|
<td colSpan={2} className="maputnik-popup-layer-id">{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{renderKeyValueTableRow("$type", feature.geometry.type, idx)}
|
{renderKeyValueTableRow("$type", feature.geometry.type)}
|
||||||
{renderKeyValueTableRow("Feature ID", displayValue(feature.id), idx)}
|
{renderKeyValueTableRow("Feature ID", displayValue(feature.id))}
|
||||||
{Object.keys(feature.properties).map(propertyName => {
|
{Object.keys(feature.properties).map(propertyName => {
|
||||||
const property = feature.properties[propertyName];
|
const property = feature.properties[propertyName];
|
||||||
return renderKeyValueTableRow(propertyName, displayValue(property), idx)
|
return renderKeyValueTableRow(propertyName, displayValue(property))
|
||||||
})}
|
})}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user