diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index cccab74..2d5715e 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -113,8 +113,7 @@ export default class Toolbar extends React.Component { this.toggleSources.bind(this)} /> -
- {this.props.title}
+ {this.props.title} +
#{this.props.id}
- - Add - -
+ + } } +function editorMode(source) { + if(source.type === 'geojson') return ' geojson' + if(source.type === 'vector' && source.tiles) { + return 'tilexyz' + } + return 'tilejson' +} + class SourceEditorLayout extends React.Component { static propTypes = { sourceId: React.PropTypes.string.isRequired, source: React.PropTypes.object.isRequired, + onSourceDelete: React.PropTypes.func.isRequired, + onSourceChange: React.PropTypes.func.isRequired, } render() { @@ -74,17 +79,14 @@ class SourceEditorLayout extends React.Component { fontSize: fontSizes[4], flexDirection: 'row', }}> - #{this.props.sourceId} + #{this.props.sourceId} - - Remove - +
- +
} @@ -100,6 +106,21 @@ class SourceEditorLayout extends React.Component { class AddSource extends React.Component { static propTypes = { + onSourceAdd: React.PropTypes.func.isRequired, + } + + constructor(props) { + super(props) + this.state = { + mode: 'tilejson', + source: {} + } + } + + onSourceChange(source) { + this.setState({ + source: source + }) } render() { @@ -114,21 +135,20 @@ class AddSource extends React.Component { options={[ ['geojson', 'GeoJSON'], ['tilejson', 'Vector (TileJSON URL)'], - ['tileurls', 'Vector (Direct URLs)'], + ['tilexyz', 'Vector (XYZ URLs)'], ]} - value={'geojson'} + onChange={v => this.setState({mode: v})} + value={this.state.mode} /> - + + } } @@ -165,7 +185,10 @@ class SourcesModal extends React.Component { {activeSources} Add New Source - +
+

Add a new source to your style. You can only choose the source type and id at creation time!

+ +
Choose Public Source

Add one of the publicly availble sources to your style.

diff --git a/src/components/sources/SourceTypeEditor.jsx b/src/components/sources/SourceTypeEditor.jsx index dfd508a..ab49c83 100644 --- a/src/components/sources/SourceTypeEditor.jsx +++ b/src/components/sources/SourceTypeEditor.jsx @@ -5,12 +5,14 @@ import StringInput from '../inputs/StringInput' class TileJSONSourceEditor extends React.Component { static propTypes = { url: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, } render() { return } @@ -21,26 +23,24 @@ class TileURLSourceEditor extends React.Component { tiles: React.PropTypes.array.isRequired, minZoom: React.PropTypes.number.isRequired, maxZoom: React.PropTypes.number.isRequired, + onChange: React.PropTypes.func.isRequired, } renderTileUrls() { + const prefix = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th'] return this.props.tiles.map((tileUrl, tileIndex) => { - + return }) } render() { + console.log(this.props.tiles) return
{this.renderTileUrls()} - - - } @@ -72,22 +74,19 @@ class GeoJSONSourceEditor extends React.Component { class SourceTypeEditor extends React.Component { static propTypes = { + mode: React.PropTypes.string.isRequired, source: React.PropTypes.object.isRequired, + onChange: React.PropTypes.func.isRequired, } render() { const source = this.props.source - if(source.type === "geojson") { - return + switch(this.props.mode) { + case 'geojson': return + case 'tilejson': return + case 'tilexyz': return + default: return null } - if(source.type === "vector") { - if(source.url) { - return - } else { - return - } - } - return null } }