Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Mar 13, 2024
1 parent 8e587b7 commit 3a809cb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/MapMaplibreGlFeaturePropertyPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ function displayValue(value: string | number | Date | object | undefined) {
return value;
}

function renderKeyValueTableRow(key: string, value: string | undefined, idx: number) {
return <tr key={`${key}-${value}-${idx}`}>
function renderKeyValueTableRow(key: string, value: string | undefined) {
return <tr key={key}>
<td className="maputnik-popup-table-cell">{key}</td>
<td className="maputnik-popup-table-cell">{value}</td>
</tr>
}

function renderFeature(feature: InspectFeature, idx: number) {
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>
</tr>
{renderKeyValueTableRow("$type", feature.geometry.type, idx)}
{renderKeyValueTableRow("Feature ID", displayValue(feature.id), idx)}
{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), idx)
return renderKeyValueTableRow(propertyName, displayValue(property))
})}
</React.Fragment>
}
Expand Down

0 comments on commit 3a809cb

Please sign in to comment.