From bf5131caddbede57762083cc298f861db859c6c4 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Thu, 29 Dec 2016 14:44:46 +0100 Subject: [PATCH] Restructure layer settings for add modal --- src/components/App.jsx | 1 + src/components/Toolbar.jsx | 11 ++++ src/components/layers/LayerEditor.jsx | 41 +++++++----- src/components/layers/LayerIdBlock.jsx | 22 +++++++ src/components/layers/LayerSettings.jsx | 50 -------------- src/components/layers/LayerSourceBlock.jsx | 25 +++++++ .../layers/LayerSourceLayerBlock.jsx | 25 +++++++ src/components/layers/LayerTypeBlock.jsx | 31 +++++++++ src/components/layers/SourceEditor.jsx | 54 --------------- src/components/modals/AddModal.jsx | 65 +++++++++++++++++++ 10 files changed, 205 insertions(+), 120 deletions(-) create mode 100644 src/components/layers/LayerIdBlock.jsx delete mode 100644 src/components/layers/LayerSettings.jsx create mode 100644 src/components/layers/LayerSourceBlock.jsx create mode 100644 src/components/layers/LayerSourceLayerBlock.jsx create mode 100644 src/components/layers/LayerTypeBlock.jsx delete mode 100644 src/components/layers/SourceEditor.jsx create mode 100644 src/components/modals/AddModal.jsx diff --git a/src/components/App.jsx b/src/components/App.jsx index f2b401b..8747acb 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -164,6 +164,7 @@ export default class App extends React.Component { const toolbar = + this.onPropertyChange(null, 'type', v)} - onIdChange={newId => this.props.onLayerIdChange(this.props.layer.id, newId)} - /> + case 'settings': return
+ this.props.onLayerIdChange(this.props.layer.id, newId)} + /> + this.changeProperty(null, 'type', v)} + /> +
case 'source': return
{this.props.layer.filter && this.onFilterChange(f)} /> } - this.changeProperty(null, 'source', v)} + /> + this.changeProperty(null, 'source-layer', v)} /> case 'jsoneditor': return + + + } +} + +export default LayerIdBlock diff --git a/src/components/layers/LayerSettings.jsx b/src/components/layers/LayerSettings.jsx deleted file mode 100644 index 43c6904..0000000 --- a/src/components/layers/LayerSettings.jsx +++ /dev/null @@ -1,50 +0,0 @@ -import React from 'react' -import GlSpec from 'mapbox-gl-style-spec/reference/latest.min.js' -import InputBlock from '../inputs/InputBlock' -import StringInput from '../inputs/StringInput' -import SelectInput from '../inputs/SelectInput' - -import colors from '../../config/colors' -import { margins } from '../../config/scales' - - -class LayerSettings extends React.Component { - static propTypes = { - id: React.PropTypes.string.isRequired, - type: React.PropTypes.oneOf(Object.keys(GlSpec.layer.type.values)).isRequired, - onIdChange: React.PropTypes.func.isRequired, - onTypeChange: React.PropTypes.func.isRequired, - } - - render() { - return
- - - - - - -
- } -} - -export default LayerSettings diff --git a/src/components/layers/LayerSourceBlock.jsx b/src/components/layers/LayerSourceBlock.jsx new file mode 100644 index 0000000..226b57c --- /dev/null +++ b/src/components/layers/LayerSourceBlock.jsx @@ -0,0 +1,25 @@ +import React from 'react' + +import InputBlock from '../inputs/InputBlock' +import StringInput from '../inputs/StringInput' +import SelectInput from '../inputs/SelectInput' + +class LayerSourceBlock extends React.Component { + static propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, + sourceIds: React.PropTypes.array.isRequired, + } + + render() { + return + [s, s])} + /> + + } +} + +export default LayerSourceBlock diff --git a/src/components/layers/LayerSourceLayerBlock.jsx b/src/components/layers/LayerSourceLayerBlock.jsx new file mode 100644 index 0000000..5e4775f --- /dev/null +++ b/src/components/layers/LayerSourceLayerBlock.jsx @@ -0,0 +1,25 @@ +import React from 'react' + +import InputBlock from '../inputs/InputBlock' +import StringInput from '../inputs/StringInput' +import SelectInput from '../inputs/SelectInput' + +class LayerSourceLayer extends React.Component { + static propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, + sourceLayerIds: React.PropTypes.array.isRequired, + } + + render() { + return + [l, l])} + /> + + } +} + +export default LayerSourceLayer diff --git a/src/components/layers/LayerTypeBlock.jsx b/src/components/layers/LayerTypeBlock.jsx new file mode 100644 index 0000000..87ad151 --- /dev/null +++ b/src/components/layers/LayerTypeBlock.jsx @@ -0,0 +1,31 @@ +import React from 'react' + +import InputBlock from '../inputs/InputBlock' +import SelectInput from '../inputs/SelectInput' + +class LayerTypeBlock extends React.Component { + static propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, + } + + render() { + return + + + } +} + +export default LayerTypeBlock diff --git a/src/components/layers/SourceEditor.jsx b/src/components/layers/SourceEditor.jsx deleted file mode 100644 index 4c6165c..0000000 --- a/src/components/layers/SourceEditor.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from 'react' - -import PropertyGroup from '../fields/PropertyGroup' -import input from '../../config/input.js' - -/** Choose tileset (source) and the source layer */ -export default class SourceEditor extends React.Component { - static propTypes = { - source: React.PropTypes.string.isRequired, - sourceLayer: React.PropTypes.string.isRequired, - - onSourceChange: React.PropTypes.func.isRequired, - onSourceLayerChange: React.PropTypes.func.isRequired, - - /** List of available sources in the style - * https://www.mapbox.com/mapbox-gl-style-spec/#root-sources */ - sources: React.PropTypes.object.isRequired, - } - - render() { - const options = Object.keys(this.props.sources).map(sourceId => { - return - }) - - const layerOptions = this.props.sources[this.props.source].map(vectorLayerId => { - const id = vectorLayerId - return - }) - - return
-
- - -
-
- - -
-
- - } -} diff --git a/src/components/modals/AddModal.jsx b/src/components/modals/AddModal.jsx new file mode 100644 index 0000000..02b6931 --- /dev/null +++ b/src/components/modals/AddModal.jsx @@ -0,0 +1,65 @@ +import React from 'react' + +import InputBlock from '../inputs/InputBlock' +import StringInput from '../inputs/StringInput' +import SelectInput from '../inputs/SelectInput' +import Modal from './Modal' +import colors from '../../config/colors' + +import LayerTypeBlock from '../layers/LayerTypeBlock' +import LayerIdBlock from '../layers/LayerIdBlock' +import LayerSourceBlock from '../layers/LayerSourceBlock' +import LayerSourceLayerBlock from '../layers/LayerSourceLayerBlock' + +class AddModal extends React.Component { + static propTypes = { + mapStyle: React.PropTypes.object.isRequired, + onStyleChanged: React.PropTypes.func.isRequired, + isOpen: React.PropTypes.bool.isRequired, + onOpenToggle: React.PropTypes.func.isRequired, + + // A dict of source id's and the available source layers + sources: React.PropTypes.object.isRequired, + } + + constructor(props) { + super(props) + + console.log('sources', this.props.sources) + this.state = { + type: 'fill', + id: '', + //source: Object.keys(this.props.sources)[0], + //'source-layer': this.props.sources[0][0] + } + } + + render() { + return + this.setState({ id: v })} + /> + this.setState({ type: v })} + /> + this.setState({ source: v })} + /> + this.setState({ 'source-layer': v })} + /> + + } +} + +export default AddModal