From 9103d9560aadd003b56abab62ad1b1ed3c99f42b Mon Sep 17 00:00:00 2001 From: orangemug Date: Tue, 8 Sep 2020 16:50:29 +0100 Subject: [PATCH] Added 'base' to functions. --- src/components/FieldFunction.jsx | 5 +++++ src/components/_DataProperty.jsx | 31 +++++++++++++++++++++++++++++++ src/components/_ZoomProperty.jsx | 25 +++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/components/FieldFunction.jsx b/src/components/FieldFunction.jsx index 0174f93..b90ee3a 100644 --- a/src/components/FieldFunction.jsx +++ b/src/components/FieldFunction.jsx @@ -206,6 +206,7 @@ export default class FieldFunction extends React.Component { if (typeof(value) === "object") { if (value.stops) { zoomFunc = { + base: value.base, stops: value.stops.map(stop => { return [stop[0].zoom, stop[1] || findDefaultFromSpec(this.props.fieldSpec)]; }) @@ -213,6 +214,7 @@ export default class FieldFunction extends React.Component { } else { zoomFunc = { + base: value.base, stops: [ [6, findDefaultFromSpec(this.props.fieldSpec)], [10, findDefaultFromSpec(this.props.fieldSpec)] @@ -289,6 +291,7 @@ export default class FieldFunction extends React.Component { dataFunc = { property: "", type: functionType, + base: value.base, stops: value.stops.map(stop => { return [{zoom: stop[0], value: stopValue}, stop[1] || findDefaultFromSpec(this.props.fieldSpec)]; }) @@ -298,6 +301,7 @@ export default class FieldFunction extends React.Component { dataFunc = { property: "", type: functionType, + base: value.base, stops: [ [{zoom: 6, value: stopValue}, findDefaultFromSpec(this.props.fieldSpec)], [{zoom: 10, value: stopValue}, findDefaultFromSpec(this.props.fieldSpec)] @@ -309,6 +313,7 @@ export default class FieldFunction extends React.Component { dataFunc = { property: "", type: functionType, + base: value.base, stops: [ [{zoom: 6, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)], [{zoom: 10, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)] diff --git a/src/components/_DataProperty.jsx b/src/components/_DataProperty.jsx index 35cbfca..c0382a3 100644 --- a/src/components/_DataProperty.jsx +++ b/src/components/_DataProperty.jsx @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import {mdiFunctionVariant, mdiTableRowPlusAfter} from '@mdi/js'; +import {latest} from '@mapbox/mapbox-gl-style-spec' import InputButton from './InputButton' import InputSpec from './InputSpec' @@ -167,6 +168,18 @@ export default class DataProperty extends React.Component { this.onChange(this.props.fieldName, changedValue) } + changeBase(newValue) { + const changedValue = { + ...this.props.value, + base: newValue + } + + if (changedValue.base === undefined) { + delete changedValue["base"]; + } + this.props.onChange(this.props.fieldName, changedValue) + } + changeDataType(propVal) { if (propVal === "interpolate") { this.props.onChangeToZoomFunction(); @@ -292,6 +305,7 @@ export default class DataProperty extends React.Component {
+ {this.props.value.type !== "identity" && + +
+ this.changeBase(newValue)} + /> +
+
+ }
{ if (type !== "interpolate") { this.props.onChangeToDataFunction(type); @@ -195,6 +208,18 @@ export default class ZoomProperty extends React.Component { />
+ +
+ this.changeBase(newValue)} + /> +
+
Stops