From 2910efde6e9462d7d1bb9c5d44427a48f3ace1d7 Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 16 Oct 2019 21:58:24 +0100 Subject: [PATCH] Allow removal of light/transition properties. --- src/components/modals/SettingsModal.jsx | 42 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index 2b9fdee..aaa714d 100644 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -21,25 +21,39 @@ class SettingsModal extends React.Component { } changeTransitionProperty(property, value) { - const changedStyle = { - ...this.props.mapStyle, - transition: { - ...this.props.mapStyle.transition, - [property]: value - } + const transition = { + ...this.props.mapStyle.transition, } - this.props.onStyleChanged(changedStyle) + + if (value === undefined) { + delete transition[property]; + } + else { + transition[property] = value; + } + + this.props.onStyleChanged({ + ...this.props.mapStyle, + transition, + }); } changeLightProperty(property, value) { - const changedStyle = { - ...this.props.mapStyle, - light: { - ...this.props.mapStyle.light, - [property]: value - } + const light = { + ...this.props.mapStyle.light, } - this.props.onStyleChanged(changedStyle) + + if (value === undefined) { + delete light[property]; + } + else { + light[property] = value; + } + + this.props.onStyleChanged({ + ...this.props.mapStyle, + light, + }); } changeStyleProperty(property, value) {