Switch away from Immutable JS for layer editor

This commit is contained in:
Lukas Martinelli
2016-12-20 14:50:38 +01:00
parent 28b61e7dcb
commit ed87425f01
4 changed files with 41 additions and 25 deletions

View File

@@ -15,7 +15,6 @@ class ColorField extends React.Component {
onChange: React.PropTypes.func.isRequired,
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string,
default: React.PropTypes.number,
doc: React.PropTypes.string,
style: React.PropTypes.object,
}
@@ -31,14 +30,19 @@ class ColorField extends React.Component {
this.setState({ pickerOpened: !this.state.pickerOpened })
}
get color() {
return Color(this.props.value || '#fff')
}
render() {
console.log(Color(this.props.value))
const picker = <div style={{
position: 'absolute',
left: 163,
top: 0,
}}>
<ChromePicker
color={this.props.value ? Color(this.props.value).object() : null}
color={this.color.object()}
onChange={c => this.props.onChange(formatColor(c))}
/>
<div

View File

@@ -25,20 +25,24 @@ function getGroupName(layerType, fieldName) {
export default class PropertyGroup extends React.Component {
static propTypes = {
layer: React.PropTypes.instanceOf(Immutable.Map).isRequired,
layer: React.PropTypes.object.isRequired,
groupFields: React.PropTypes.instanceOf(Immutable.OrderedSet).isRequired,
onChange: React.PropTypes.func.isRequired,
}
onPropertyChange(property, newValue) {
const group = getGroupName(this.props.layer.get('type'), property)
const group = getGroupName(this.props.layer.type, property)
this.props.onChange(group , property ,newValue)
}
render() {
const fields = this.props.groupFields.map(fieldName => {
const fieldSpec = getFieldSpec(this.props.layer.get('type'), fieldName)
const fieldValue = this.props.layer.getIn(['paint', fieldName], this.props.layer.getIn(['layout', fieldName]))
const fieldSpec = getFieldSpec(this.props.layer.type, fieldName)
const paint = this.props.layer.paint || {}
const layout = this.props.layer.layout || {}
const fieldValue = paint[fieldName] || layout[fieldName]
return <ZoomSpecField
onChange={this.onPropertyChange.bind(this)}
key={fieldName}