diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx
index 46ae067..bcb60f8 100644
--- a/src/components/Toolbar.jsx
+++ b/src/components/Toolbar.jsx
@@ -91,6 +91,7 @@ export default class Toolbar extends React.Component {
/>
diff --git a/src/components/inputs/CheckboxInput.jsx b/src/components/inputs/CheckboxInput.jsx
index e5d661a..cfe5b3d 100644
--- a/src/components/inputs/CheckboxInput.jsx
+++ b/src/components/inputs/CheckboxInput.jsx
@@ -17,7 +17,9 @@ class CheckboxInput extends React.Component {
checked={this.props.value}
/>
diff --git a/src/components/inputs/StringInput.jsx b/src/components/inputs/StringInput.jsx
index f9fb56e..34a550a 100644
--- a/src/components/inputs/StringInput.jsx
+++ b/src/components/inputs/StringInput.jsx
@@ -27,7 +27,7 @@ class StringInput extends React.Component {
placeholder={this.props.default}
onChange={e => this.setState({ value: e.target.value })}
onBlur={() => {
- if(this.state.value) this.props.onChange(this.state.value)
+ if(this.state.value!==this.props.value) this.props.onChange(this.state.value)
}}
/>
}
diff --git a/src/components/modals/ExportModal.jsx b/src/components/modals/ExportModal.jsx
index 17dec43..86b75d8 100644
--- a/src/components/modals/ExportModal.jsx
+++ b/src/components/modals/ExportModal.jsx
@@ -5,9 +5,11 @@ import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
+import CheckboxInput from '../inputs/CheckboxInput'
import Button from '../Button'
import Modal from './Modal'
import MdFileDownload from 'react-icons/lib/md/file-download'
+import style from '../../libs/style.js'
import formatStyle from 'mapbox-gl-style-spec/lib/format'
import GitHub from 'github-api'
@@ -15,18 +17,35 @@ import GitHub from 'github-api'
class Gist extends React.Component {
static propTypes = {
mapStyle: React.PropTypes.object.isRequired,
+ onStyleChanged: React.PropTypes.func.isRequired,
}
constructor(props) {
super(props);
- this.state = {}
+ this.state = {
+ preview: false,
+ saving: false,
+ latestGist: null,
+ }
+ }
+
+ componentWillReceiveProps(nextProps) {
+ this.setState({
+ ...this.state,
+ preview: !!nextProps.mapStyle.metadata['maputnik:openmaptiles_access_token']
+ })
}
onSave() {
this.setState({
+ ...this.state,
saving: true
});
- const mapStyleStr = formatStyle(this.props.mapStyle);
+ const preview = this.state.preview && this.props.mapStyle.metadata['maputnik:openmaptiles_access_token'];
+
+ const mapStyleStr = preview ?
+ formatStyle(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) :
+ formatStyle(stripAccessTokens(this.props.mapStyle));
const styleTitle = this.props.mapStyle.name || 'Style';
const htmlStr = `
@@ -56,49 +75,100 @@ class Gist extends React.Component {