From 8d1cc340b88e14b8477947214adbcfb12145cbdc Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 10 Oct 2019 08:52:36 +0100 Subject: [PATCH 1/7] Added new features text-writing-mode and *-sort-key --- src/components/fields/SpecField.jsx | 17 +++----- src/components/inputs/DynamicArrayInput.jsx | 26 ++++++++++-- src/components/inputs/EnumInput.jsx | 45 +++++++++++++++++++++ src/config/layout.json | 17 ++++++-- 4 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 src/components/inputs/EnumInput.jsx diff --git a/src/components/fields/SpecField.jsx b/src/components/fields/SpecField.jsx index 1702b3fe..1f2aac6d 100644 --- a/src/components/fields/SpecField.jsx +++ b/src/components/fields/SpecField.jsx @@ -11,6 +11,7 @@ import ArrayInput from '../inputs/ArrayInput' import DynamicArrayInput from '../inputs/DynamicArrayInput' import FontInput from '../inputs/FontInput' import IconInput from '../inputs/IconInput' +import EnumInput from '../inputs/SelectInput' import capitalize from 'lodash.capitalize' const iconProperties = ['background-pattern', 'fill-pattern', 'line-pattern', 'fill-extrusion-pattern', 'icon-image'] @@ -70,17 +71,10 @@ export default class SpecField extends React.Component { case 'enum': const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)]) - if(options.length <= 3 && optionsLabelLength(options) <= 20) { - return - } else { - return - } + return case 'formatted': case 'string': if(iconProperties.indexOf(this.props.fieldName) >= 0) { @@ -119,6 +113,7 @@ export default class SpecField extends React.Component { } else { return } diff --git a/src/components/inputs/DynamicArrayInput.jsx b/src/components/inputs/DynamicArrayInput.jsx index 7d86227b..8600ff98 100644 --- a/src/components/inputs/DynamicArrayInput.jsx +++ b/src/components/inputs/DynamicArrayInput.jsx @@ -5,6 +5,8 @@ import NumberInput from './NumberInput' import Button from '../Button' import {MdDelete} from 'react-icons/md' import DocLabel from '../fields/DocLabel' +import EnumInput from '../inputs/SelectInput' +import capitalize from 'lodash.capitalize' class DynamicArrayInput extends React.Component { @@ -31,6 +33,11 @@ class DynamicArrayInput extends React.Component { const values = this.values.slice(0) if (this.props.type === 'number') { values.push(0) + } + else if (this.props.type === 'enum') { + const {fieldSpec} = this.props; + const defaultValue = Object.keys(fieldSpec.values)[0]; + values.push(defaultValue); } else { values.push("") } @@ -48,15 +55,28 @@ class DynamicArrayInput extends React.Component { render() { const inputs = this.values.map((v, i) => { const deleteValueBtn= - const input = this.props.type === 'number' - ? - : [v, capitalize(v)]); + + input = + } + else { + input = + } return
{ + sum += label.length + }) + return sum +} + + +class EnumInput extends React.Component { + static propTypes = { + "data-wd-key": PropTypes.string, + value: PropTypes.string, + style: PropTypes.object, + default: PropTypes.string, + onChange: PropTypes.func, + options: PropTypes.array, + } + + render() { + const {options, value, onChange} = this.props; + + if(options.length <= 3 && optionsLabelLength(options) <= 20) { + return + } else { + return + } + } +} + +export default StringInput diff --git a/src/config/layout.json b/src/config/layout.json index e99b9e03..99344fb6 100644 --- a/src/config/layout.json +++ b/src/config/layout.json @@ -24,7 +24,8 @@ "line-cap", "line-join", "line-miter-limit", - "line-round-limit" + "line-round-limit", + "line-sort-key" ] } ] @@ -56,6 +57,13 @@ "fill-translate", "fill-translate-anchor" ] + }, + { + "title": "Layout properties", + "type": "properties", + "fields": [ + "fill-sort-key" + ] } ] }, @@ -93,7 +101,8 @@ "circle-pitch-scale", "circle-translate", "circle-translate-anchor", - "circle-pitch-alignment" + "circle-pitch-alignment", + "circle-sort-key" ] } ] @@ -107,7 +116,8 @@ "symbol-placement", "symbol-spacing", "symbol-avoid-edges", - "symbol-z-order" + "symbol-z-order", + "symbol-sort-key" ] }, { @@ -128,6 +138,7 @@ "text-justify", "text-anchor", "text-max-angle", + "text-writing-mode", "text-rotate", "text-keep-upright", "text-transform", From 1c83de08c11adcbebacdd5fe7358ae274ad27eb3 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 12 Oct 2019 12:08:25 +0100 Subject: [PATCH 2/7] Fixed lint errors. --- src/components/inputs/DynamicArrayInput.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/inputs/DynamicArrayInput.jsx b/src/components/inputs/DynamicArrayInput.jsx index 8600ff98..84d6bb9e 100644 --- a/src/components/inputs/DynamicArrayInput.jsx +++ b/src/components/inputs/DynamicArrayInput.jsx @@ -16,6 +16,7 @@ class DynamicArrayInput extends React.Component { default: PropTypes.array, onChange: PropTypes.func, style: PropTypes.object, + fieldSpec: PropTypes.object, } changeValue(idx, newValue) { From e4ec1d155aa0307cffa80117f0fa3c4fdb6bed48 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sun, 13 Oct 2019 13:32:42 +0100 Subject: [PATCH 3/7] Added mapbox-gl features 'text-variable-anchor' and 'text-radial-offset' --- src/config/layout.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/layout.json b/src/config/layout.json index 99344fb6..e2ced562 100644 --- a/src/config/layout.json +++ b/src/config/layout.json @@ -143,7 +143,9 @@ "text-keep-upright", "text-transform", "text-offset", - "text-optional" + "text-optional", + "text-variable-anchor", + "text-radial-offset" ] }, { From 00ab303e44a8cd595f3fbcdb1788eb9332bf420e Mon Sep 17 00:00:00 2001 From: orangemug Date: Sun, 13 Oct 2019 17:59:11 +0100 Subject: [PATCH 4/7] Stop LayerEditor using same DOM elements for different layers. --- src/components/App.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/App.jsx b/src/components/App.jsx index 39bd3ccb..e816eaa0 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -645,6 +645,7 @@ export default class App extends React.Component { /> const layerEditor = selectedLayer ? Date: Sun, 13 Oct 2019 18:00:32 +0100 Subject: [PATCH 5/7] Fix to allow for empty value (reset value) --- src/components/inputs/NumberInput.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/inputs/NumberInput.jsx b/src/components/inputs/NumberInput.jsx index 3071e35c..369f9833 100644 --- a/src/components/inputs/NumberInput.jsx +++ b/src/components/inputs/NumberInput.jsx @@ -28,7 +28,9 @@ class NumberInput extends React.Component { changeValue(newValue) { this.setState({editing: true}); - const value = parseFloat(newValue) + const value = (newValue === "" || newValue === undefined) ? + undefined : + parseFloat(newValue); const hasChanged = this.state.value !== value if(this.isValid(value) && hasChanged) { @@ -38,6 +40,10 @@ class NumberInput extends React.Component { } isValid(v) { + if (v === undefined) { + return true; + } + const value = parseFloat(v) if(isNaN(value)) { return false From d63782ddf2a590431f1beffbe8aebdec03cdd78c Mon Sep 17 00:00:00 2001 From: orangemug Date: Sun, 13 Oct 2019 18:03:58 +0100 Subject: [PATCH 6/7] Remove react warnings. --- src/components/inputs/NumberInput.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/inputs/NumberInput.jsx b/src/components/inputs/NumberInput.jsx index 369f9833..0de1fa48 100644 --- a/src/components/inputs/NumberInput.jsx +++ b/src/components/inputs/NumberInput.jsx @@ -24,6 +24,7 @@ class NumberInput extends React.Component { value: props.value }; } + return {}; } changeValue(newValue) { @@ -82,7 +83,7 @@ class NumberInput extends React.Component { spellCheck="false" className="maputnik-number" placeholder={this.props.default} - value={this.state.value} + value={this.state.value || ""} onChange={e => this.changeValue(e.target.value)} onBlur={this.resetValue} /> From b8829d9a5cfd24eb76ca7ce241f5a1b079e7a3ef Mon Sep 17 00:00:00 2001 From: orangemug Date: Mon, 14 Oct 2019 09:22:11 +0100 Subject: [PATCH 7/7] Remove *-sort-key until we support expressions. --- src/config/layout.json | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/config/layout.json b/src/config/layout.json index e2ced562..7d23808a 100644 --- a/src/config/layout.json +++ b/src/config/layout.json @@ -24,8 +24,7 @@ "line-cap", "line-join", "line-miter-limit", - "line-round-limit", - "line-sort-key" + "line-round-limit" ] } ] @@ -57,13 +56,6 @@ "fill-translate", "fill-translate-anchor" ] - }, - { - "title": "Layout properties", - "type": "properties", - "fields": [ - "fill-sort-key" - ] } ] }, @@ -101,8 +93,7 @@ "circle-pitch-scale", "circle-translate", "circle-translate-anchor", - "circle-pitch-alignment", - "circle-sort-key" + "circle-pitch-alignment" ] } ] @@ -116,8 +107,7 @@ "symbol-placement", "symbol-spacing", "symbol-avoid-edges", - "symbol-z-order", - "symbol-sort-key" + "symbol-z-order" ] }, {