From 53cb3171551ac8a591049a3ac6bee4d4a77cf543 Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 25 Jan 2018 08:30:23 +0000 Subject: [PATCH 01/32] Fix for safari modal appearing below the overlay. Fixes #225 --- src/styles/_modal.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/_modal.scss b/src/styles/_modal.scss index 56740608..6ec51097 100644 --- a/src/styles/_modal.scss +++ b/src/styles/_modal.scss @@ -6,6 +6,7 @@ background-color: $color-black; box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.3); z-index: 3; + position: relative; } .maputnik-modal-section { From 9d96525f12ca5d5247eab3483a9f20defd8470ce Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 25 Jan 2018 19:12:04 +0000 Subject: [PATCH 02/32] Added support for mapbox:// urls. --- config/webpack.loaders.js | 11 +++++++++++ package.json | 1 + src/components/App.jsx | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/webpack.loaders.js b/config/webpack.loaders.js index f931b7bf..f4004e9f 100644 --- a/config/webpack.loaders.js +++ b/config/webpack.loaders.js @@ -4,6 +4,17 @@ module.exports = [ exclude: /(node_modules|bower_components|public)/, loaders: ['react-hot-loader/webpack'] }, + // HACK: This is a massive hack and reaches into the mapbox-gl private API. + // We have to include this for access to `normalizeSourceURL`. We should + // remove this ASAP, see + { + test: /.*node_modules[\/\\]mapbox-gl[\/\\]src[\///]util[\/\\].*\.js/, + loader: 'babel-loader', + query: { + presets: ['env', 'react', 'flow'], + plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'], + } + }, { test: /\.jsx?$/, exclude: /(.*node_modules(?![\/\\]@mapbox[\/\\]mapbox-gl-style-spec)|bower_components|public)/, diff --git a/package.json b/package.json index b0742a9f..819fd7f8 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.1", + "babel-preset-flow": "^6.23.0", "babel-preset-react": "^6.24.1", "babel-runtime": "^6.26.0", "base64-loader": "^1.0.0", diff --git a/src/components/App.jsx b/src/components/App.jsx index d90415aa..b9935ffc 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -21,6 +21,10 @@ import LayerWatcher from '../libs/layerwatcher' import tokens from '../config/tokens.json' import isEqual from 'lodash.isequal' +import MapboxGl from 'mapbox-gl' +import mapboxUtil from 'mapbox-gl/src/util/mapbox' + + function updateRootSpec(spec, fieldName, newValues) { return { ...spec, @@ -199,7 +203,8 @@ export default class App extends React.Component { }; if(!this.state.sources.hasOwnProperty(key) && val.type === "vector") { - const url = val.url; + const url = mapboxUtil.normalizeSourceURL(val.url, MapboxGl.accessToken); + fetch(url) .then((response) => { return response.json(); From 0ebb299fd0e653fea579aa7ca74b7c7bf2cab10a Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 25 Jan 2018 19:40:54 +0000 Subject: [PATCH 03/32] Added try/catch around mapboxUtil.normalizeSourceURL --- src/components/App.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index b9935ffc..c76bf706 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -203,7 +203,12 @@ export default class App extends React.Component { }; if(!this.state.sources.hasOwnProperty(key) && val.type === "vector") { - const url = mapboxUtil.normalizeSourceURL(val.url, MapboxGl.accessToken); + let url = val.url; + try { + url = mapboxUtil.normalizeSourceURL(url, MapboxGl.accessToken); + } catch(err) { + console.warn("Failed to normalizeSourceURL: ", err); + } fetch(url) .then((response) => { From f0f6130272217d38db873142060973bea63113f0 Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 25 Jan 2018 19:58:01 +0000 Subject: [PATCH 04/32] Fixed typo. --- config/webpack.loaders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/webpack.loaders.js b/config/webpack.loaders.js index f4004e9f..fa6c4cca 100644 --- a/config/webpack.loaders.js +++ b/config/webpack.loaders.js @@ -8,7 +8,7 @@ module.exports = [ // We have to include this for access to `normalizeSourceURL`. We should // remove this ASAP, see { - test: /.*node_modules[\/\\]mapbox-gl[\/\\]src[\///]util[\/\\].*\.js/, + test: /.*node_modules[\/\\]mapbox-gl[\/\\]src[\/\\]util[\/\\].*\.js/, loader: 'babel-loader', query: { presets: ['env', 'react', 'flow'], From 7e510a258279d14068c0c74eef2907f691227b3b Mon Sep 17 00:00:00 2001 From: orangemug Date: Fri, 26 Jan 2018 15:31:33 +0000 Subject: [PATCH 05/32] v1.1.0-beta4 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 115ce19e..043151a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "maputnik", - "version": "1.1.0-beta3", + "version": "1.1.0-beta4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b0742a9f..c325f3ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "maputnik", - "version": "1.1.0-beta3", + "version": "1.1.0-beta4", "description": "A MapboxGL visual style editor", "main": "''", "scripts": { From 89c38991b997be66ffb7f205099e20a916bd1e2c Mon Sep 17 00:00:00 2001 From: orangemug Date: Mon, 29 Jan 2018 17:17:55 +0000 Subject: [PATCH 06/32] Added guard to sourceLayerIds --- src/components/layers/LayerEditor.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/layers/LayerEditor.jsx b/src/components/layers/LayerEditor.jsx index 1d43bffe..47ebe20a 100644 --- a/src/components/layers/LayerEditor.jsx +++ b/src/components/layers/LayerEditor.jsx @@ -117,6 +117,11 @@ export default class LayerEditor extends React.Component { comment = this.props.layer.metadata['maputnik:comment'] } + let sourceLayerIds; + if(this.props.sources.hasOwnProperty(this.props.layer.source)) { + sourceLayerIds = this.props.sources[this.props.layer.source].layers; + } + switch(type) { case 'layer': return
} {this.props.layer.type !== 'raster' && this.props.layer.type !== 'background' && this.changeProperty(null, 'source-layer', v)} /> From ed85b838ec4ae59deeb1cbec3b49716517e91f7b Mon Sep 17 00:00:00 2001 From: orangemug Date: Tue, 30 Jan 2018 20:57:24 +0000 Subject: [PATCH 07/32] v1.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 043151a4..a7b93bee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "maputnik", - "version": "1.1.0-beta4", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e7aa9e66..f144a4da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "maputnik", - "version": "1.1.0-beta4", + "version": "1.1.0", "description": "A MapboxGL visual style editor", "main": "''", "scripts": { From d9b6f28bb59e20d02c56c67db6afa1aa8700d9bb Mon Sep 17 00:00:00 2001 From: jPalmer Date: Wed, 31 Jan 2018 11:26:10 -0800 Subject: [PATCH 08/32] added missing glyphs property check on styleChanged - addresses #229 --- src/components/App.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/App.jsx b/src/components/App.jsx index c76bf706..919e1516 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -111,6 +111,16 @@ export default class App extends React.Component { } onStyleChanged(newStyle, save=true) { + + if(newStyle.glyphs === undefined){ + let error = "Failed because no glyphs property found in style"; + this.setState({ + errors:[error] + }) + console.error(error) + return + } + if(newStyle.glyphs !== this.state.mapStyle.glyphs) { this.updateFonts(newStyle.glyphs) } From 844abd38cead642e6b375e00532070f7134e69ec Mon Sep 17 00:00:00 2001 From: jPalmer Date: Wed, 31 Jan 2018 11:28:09 -0800 Subject: [PATCH 09/32] added missing glyphs property check on styleChanged - addresses #229 --- src/components/App.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 919e1516..51992d8d 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -117,10 +117,9 @@ export default class App extends React.Component { this.setState({ errors:[error] }) - console.error(error) return } - + if(newStyle.glyphs !== this.state.mapStyle.glyphs) { this.updateFonts(newStyle.glyphs) } From 02c854284844aefe9d4309c74ec1c5af1b87792b Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 31 Jan 2018 21:04:49 +0000 Subject: [PATCH 10/32] Added version number to the UI. Fixes #232 --- src/components/Toolbar.jsx | 5 ++++- src/styles/_modal.scss | 1 + src/styles/_toolbar.scss | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index 6b30fb51..5dfadf5d 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -22,6 +22,7 @@ import SettingsModal from './modals/SettingsModal' import ExportModal from './modals/ExportModal' import SourcesModal from './modals/SourcesModal' import OpenModal from './modals/OpenModal' +import pkgJson from '../../package.json' import style from '../libs/style' @@ -136,7 +137,9 @@ export default class Toolbar extends React.Component { className="maputnik-toolbar-logo" > Maputnik -

Maputnik

+

Maputnik + v{pkgJson.version} +

diff --git a/src/styles/_modal.scss b/src/styles/_modal.scss index 6ec51097..6bd315c9 100644 --- a/src/styles/_modal.scss +++ b/src/styles/_modal.scss @@ -76,6 +76,7 @@ position: fixed; align-items: center; justify-content: center; + z-index: 9; @include flex-row; } diff --git a/src/styles/_toolbar.scss b/src/styles/_toolbar.scss index 3e4ed2ca..ab6bc9f5 100644 --- a/src/styles/_toolbar.scss +++ b/src/styles/_toolbar.scss @@ -37,11 +37,22 @@ color: $color-white; text-decoration: none; + h1 { + position: relative; + } + &:hover { background-color: $color-midgray; } } +.maputnik-toolbar-version { + position: absolute; + font-size: 10px; + bottom: 0; + margin-left: 4px; +} + .maputnik-toolbar-action { @extend .maputnik-toolbar-link; } @@ -56,7 +67,7 @@ } .maputnik-toolbar-logo { - flex: 0 0 140px; + flex: 0 0 170px; } .maputnik-toolbar__inner { From 41bd91fcd2a3b6fffa616d4b93a08cd5e2e9d7eb Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 31 Jan 2018 21:22:12 +0000 Subject: [PATCH 11/32] Center the toolbar button text. --- src/styles/_toolbar.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/_toolbar.scss b/src/styles/_toolbar.scss index ab6bc9f5..8d76da54 100644 --- a/src/styles/_toolbar.scss +++ b/src/styles/_toolbar.scss @@ -36,6 +36,7 @@ cursor: pointer; color: $color-white; text-decoration: none; + line-height: 20px; h1 { position: relative; From ee3def492a4d836f423b75d493c2198d1c16b6fc Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 31 Jan 2018 21:36:47 +0000 Subject: [PATCH 12/32] Fixed toolbar version position. --- src/styles/_toolbar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/_toolbar.scss b/src/styles/_toolbar.scss index 8d76da54..cf71aa31 100644 --- a/src/styles/_toolbar.scss +++ b/src/styles/_toolbar.scss @@ -50,7 +50,7 @@ .maputnik-toolbar-version { position: absolute; font-size: 10px; - bottom: 0; + bottom: -2px; margin-left: 4px; } From 1c134d757cfb23ffbac4a3041ec71e5d2611a16a Mon Sep 17 00:00:00 2001 From: orangemug Date: Thu, 1 Feb 2018 19:54:44 +0000 Subject: [PATCH 13/32] Fixes for export to add in mapbox access token. --- src/components/modals/ExportModal.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/modals/ExportModal.jsx b/src/components/modals/ExportModal.jsx index d093f381..56a64817 100644 --- a/src/components/modals/ExportModal.jsx +++ b/src/components/modals/ExportModal.jsx @@ -43,7 +43,10 @@ class Gist extends React.Component { ...this.state, saving: true }); - const preview = this.state.preview && (this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']; + + const preview = this.state.preview; + + const mapboxToken = (this.props.mapStyle.metadata || {})['maputnik:mapbox_access_token']; const mapStyleStr = preview ? styleSpec.format(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) : @@ -66,6 +69,7 @@ class Gist extends React.Component {
+ +