Skip to content

Commit

Permalink
Merge pull request #139 from mapbox/profile-switcher
Browse files Browse the repository at this point in the history
Toggle or disable profile switcher.
  • Loading branch information
willwhite authored Jul 30, 2017
2 parents e76955f + 5e182b7 commit c7d8449
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/controls/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ let tmpl = template(fs.readFileSync(__dirname + '/../templates/inputs.html', 'ut
*/
export default class Inputs {
constructor(el, store, actions, map) {
const { originQuery, destinationQuery, profile } = store.getState();
const { originQuery, destinationQuery, profile, controls } = store.getState();

el.innerHTML = tmpl({
originQuery,
destinationQuery,
profile
profile,
controls
});

this.container = el;
Expand Down
1 change: 1 addition & 0 deletions src/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Instructions from './controls/instructions';
* @param {Object} [options.controls]
* @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control.
* @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control.
* @param {Boolean} [options.controls.profileSwitcher=true] Hide or display the default profile switch with options for traffic, driving, walking and cycling.
* @example
* var MapboxDirections = require('../src/index');
* var directions = new MapboxDirections({
Expand Down
1 change: 1 addition & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const initialState = {

// UI controls
controls: {
profileSwitcher: true,
inputs: true,
instructions: true
},
Expand Down
2 changes: 2 additions & 0 deletions src/templates/inputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</div>
</div>

<% if (controls.profileSwitcher) { %>
<div class='mapbox-directions-profile mapbox-directions-component-keyline mapbox-directions-clearfix'><input
id='mapbox-directions-profile-driving-traffic'
type='radio'
Expand Down Expand Up @@ -53,4 +54,5 @@
/>
<label for='mapbox-directions-profile-cycling'>Cycling</label>
</div>
<% } %>
</div>

0 comments on commit c7d8449

Please sign in to comment.