2016-12-24 15:24:22 +01:00
|
|
|
import React from 'react'
|
2016-12-24 17:24:24 +01:00
|
|
|
import InputBlock from '../inputs/InputBlock'
|
|
|
|
import StringInput from '../inputs/StringInput'
|
|
|
|
|
|
|
|
import colors from '../../config/colors'
|
|
|
|
import { margins, fontSizes } from '../../config/scales'
|
|
|
|
|
|
|
|
function renderProperties(feature) {
|
|
|
|
return Object.keys(feature.properties).map(propertyName => {
|
|
|
|
const property = feature.properties[propertyName]
|
|
|
|
return <InputBlock label={propertyName} style={{marginTop: 0, marginBottom: 0}}>
|
|
|
|
<StringInput value={property} style={{backgroundColor: 'transparent'}}/>
|
|
|
|
</InputBlock>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const Panel = (props) => {
|
|
|
|
return <div style={{
|
|
|
|
backgroundColor: colors.gray,
|
|
|
|
padding: margins[0],
|
|
|
|
fontSize: fontSizes[5],
|
|
|
|
lineHeight: 1.2,
|
|
|
|
}}>{props.children}</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderFeature(feature) {
|
|
|
|
return <div>
|
|
|
|
<Panel>Source</Panel>
|
|
|
|
<InputBlock label={feature.layer['source-layer']} style={{marginTop: 0, marginBottom: 0}}>
|
|
|
|
</InputBlock>
|
|
|
|
<Panel>Layers</Panel>
|
|
|
|
<InputBlock label={feature.layer.id} style={{marginTop: 0, marginBottom: 0}}>
|
|
|
|
</InputBlock>
|
|
|
|
<Panel>Properties</Panel>
|
|
|
|
{renderProperties(feature)}
|
|
|
|
</div>
|
|
|
|
}
|
2016-12-24 15:24:22 +01:00
|
|
|
|
|
|
|
class FeatureLayerTable extends React.Component {
|
2016-12-24 17:24:24 +01:00
|
|
|
|
2016-12-24 15:24:22 +01:00
|
|
|
render() {
|
2016-12-24 17:24:24 +01:00
|
|
|
const features = this.props.features
|
|
|
|
return <div>
|
|
|
|
{features.map(renderFeature)}
|
|
|
|
</div>
|
2016-12-24 15:24:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default FeatureLayerTable
|