From d2ffc3a0b10629a01e6f08384dc628b63a5f13d7 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 18 May 2019 18:54:10 +0100 Subject: [PATCH] Added semi-hidden debug modal and removed all this url param awkwardness --- src/components/App.jsx | 31 +++++++++++++++++--- src/components/modals/DebugModal.js | 36 ++++++++++++++++++++++++ src/components/modals/ShortcutsModal.jsx | 4 +++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/components/modals/DebugModal.js diff --git a/src/components/App.jsx b/src/components/App.jsx index 34216c8..8be737f 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -19,6 +19,7 @@ import SourcesModal from './modals/SourcesModal' import OpenModal from './modals/OpenModal' import ShortcutsModal from './modals/ShortcutsModal' import SurveyModal from './modals/SurveyModal' +import DebugModal from './modals/DebugModal' import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata' import {latest, validate} from '@mapbox/mapbox-gl-style-spec' @@ -139,6 +140,12 @@ export default class App extends React.Component { document.querySelector(".mapboxgl-canvas").focus(); } }, + { + key: "!", + handler: () => { + this.toggleModal("debug"); + } + }, ] document.body.addEventListener("keyup", (e) => { @@ -203,12 +210,13 @@ export default class App extends React.Component { open: false, shortcuts: false, export: false, - survey: localStorage.hasOwnProperty('survey') ? false : true + survey: localStorage.hasOwnProperty('survey') ? false : true, + debug: false, }, mapOptions: { - showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries"), - showCollisionBoxes: queryUtil.asBool(queryObj, "show-collision-boxes"), - showOverdrawInspector: queryUtil.asBool(queryObj, "show-overdraw-inspector") + showTileBoundaries: false, + showCollisionBoxes: false, + showOverdrawInspector: false, }, } @@ -524,6 +532,15 @@ export default class App extends React.Component { this.setModal(modalName, !this.state.isOpen[modalName]); } + onChangeDebug = (key, value) => { + this.setState({ + mapOptions: { + ...this.state.mapOptions, + [key]: value, + } + }); + } + render() { const layers = this.state.mapStyle.layers || [] const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null @@ -575,6 +592,12 @@ export default class App extends React.Component { const modals =
+ this.shortcutEl = el} isOpen={this.state.isOpen.shortcuts} diff --git a/src/components/modals/DebugModal.js b/src/components/modals/DebugModal.js new file mode 100644 index 0000000..48697aa --- /dev/null +++ b/src/components/modals/DebugModal.js @@ -0,0 +1,36 @@ +import React from 'react' +import PropTypes from 'prop-types' + +import Modal from './Modal' + + +class DebugModal extends React.Component { + static propTypes = { + isOpen: PropTypes.bool.isRequired, + onOpenToggle: PropTypes.func.isRequired, + debugOptions: PropTypes.object, + } + + render() { + return +
+
    + {Object.entries(this.props.debugOptions).map(([key, val]) => { + return
  • + +
  • + })} +
+
+
+ } +} + +export default DebugModal; diff --git a/src/components/modals/ShortcutsModal.jsx b/src/components/modals/ShortcutsModal.jsx index df8312e..1ec7448 100644 --- a/src/components/modals/ShortcutsModal.jsx +++ b/src/components/modals/ShortcutsModal.jsx @@ -40,6 +40,10 @@ class ShortcutsModal extends React.Component { key: "m", text: "Focus map" }, + { + key: "!", + text: "Debug modal" + }, ]