From ab79c632b009ca8cbbc0a5bc5f1c9549df44b6a2 Mon Sep 17 00:00:00 2001 From: lukasmartinelli Date: Sat, 10 Sep 2016 14:17:49 +0200 Subject: [PATCH] Settings supports immutable map --- src/settings.jsx | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/settings.jsx b/src/settings.jsx index 85986ca5..c1d6ab20 100644 --- a/src/settings.jsx +++ b/src/settings.jsx @@ -1,25 +1,18 @@ import React from 'react' import theme from './theme.js' import { Heading, Container, Input, Toolbar, NavItem, Space } from 'rebass' +import Immutable from 'immutable' /** Edit global settings within a style such as the name */ export class SettingsEditor extends React.Component { static propTypes = { - mapStyle: React.PropTypes.object.isRequired + mapStyle: React.PropTypes.instanceOf(Immutable.Map).isRequired, + onStyleChanged: React.PropTypes.func.isRequired } - constructor(props) { - super(props) - this.state = { - settings: this.props.styleManager.settings() - } - } - onChange(property, e) { - let settings = this.state.settings - settings[property] = e.target.value - this.props.styleManager[property] = settings[property] - this.setState(settings) + const changedStyle = this.props.mapStyle.set(property, e.target.value) + this.props.onStyleChanged(changedStyle) } render() { @@ -33,25 +26,25 @@ export class SettingsEditor extends React.Component {