2016-09-10 14:10:25 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { Input } from 'rebass'
|
|
|
|
|
|
|
|
export default class BackgroundLayer extends React.Component {
|
|
|
|
static propTypes = {
|
2016-09-10 15:15:17 +02:00
|
|
|
layer: React.PropTypes.object.isRequired,
|
|
|
|
onPaintChanged: React.PropTypes.func.isRequired
|
|
|
|
}
|
2016-09-10 14:10:25 +02:00
|
|
|
|
|
|
|
onPaintChanged(property, e) {
|
|
|
|
let value = e.target.value
|
|
|
|
if (property == "background-opacity" && !isNaN(parseFloat(value))) {
|
|
|
|
value = parseFloat(value)
|
|
|
|
}
|
|
|
|
this.props.onPaintChanged(property, value)
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const paint = this.props.layer.get('paint')
|
|
|
|
return <div>
|
|
|
|
<Input name="background-color" label="Background color" onChange={this.onPaintChanged.bind(this, "background-color")} value={paint.get("background-color")} />
|
|
|
|
<Input name="background-opacity" label="Background opacity" onChange={this.onPaintChanged.bind(this, "background-opacity")} value={paint.get("background-opacity")} />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|