mirror of
https://github.com/maputnik/editor.git
synced 2025-12-25 23:50:02 +00:00
Switch away from Immutable JS for layer editor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user