import React from 'react'
import Modal from './Modal'
import Heading from '../Heading'
import Button from '../Button'
import Paragraph from '../Paragraph'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
import SourceTypeEditor from '../sources/SourceTypeEditor'
import style from '../../libs/style'
import publicSources from '../../config/tilesets.json'
import colors from '../../config/colors'
import { margins, fontSizes } from '../../config/scales'
import AddIcon from 'react-icons/lib/md/add-circle-outline'
import DeleteIcon from 'react-icons/lib/md/delete'
class PublicSource extends React.Component {
static propTypes = {
id: React.PropTypes.string.isRequired,
type: React.PropTypes.string.isRequired,
title: React.PropTypes.string.isRequired,
onSelect: React.PropTypes.func.isRequired,
}
render() {
return
}
}
function editorMode(source) {
if(source.type === 'geojson') return ' geojson'
if(source.type === 'vector' && source.tiles) {
return 'tilexyz'
}
return 'tilejson'
}
class ActiveSourceTypeEditor 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() {
const inputProps = { }
return
#{this.props.sourceId}
}
}
class AddSource extends React.Component {
static propTypes = {
onSourceAdd: React.PropTypes.func.isRequired,
}
constructor(props) {
super(props)
this.state = {
mode: 'tilejson',
source: {
id: style.generateId(),
}
}
}
onSourceIdChange(newId) {
this.setState({
source: {
...this.state.source,
id: newId,
}
})
}
onSourceChange(source) {
this.setState({
source: source
})
}
render() {
return
this.setState({mode: v})}
value={this.state.mode}
/>
}
}
class SourcesModal extends React.Component {
static propTypes = {
mapStyle: React.PropTypes.object.isRequired,
isOpen: React.PropTypes.bool.isRequired,
onOpenToggle: React.PropTypes.func.isRequired,
onStyleChanged: React.PropTypes.func.isRequired,
}
onSourceAdd(source) {
const changedSources = {
...this.props.mapStyle.sources,
[source.id]: source
}
const changedStyle = {
...this.props.mapStyle,
sources: changedSources
}
this.props.onStyleChanged(changedStyle)
}
deleteSource(sourceId) {
const remainingSources = { ...this.props.mapStyle.sources}
delete remainingSources[sourceId]
const changedStyle = {
...this.props.mapStyle,
sources: remainingSources
}
this.props.onStyleChanged(changedStyle)
}
render() {
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
const source = this.props.mapStyle.sources[sourceId]
return
})
const tilesetOptions = publicSources.filter(source => !(source.id in this.props.mapStyle.sources)).map(source => {
return this.onSourceAdd(source)}
/>
})
const inputProps = { }
return
Active Sources
{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.
{tilesetOptions}
}
}
export default SourcesModal