Skip to content

Commit

Permalink
docs(user-location): autogenerated docs based on lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 10, 2020
1 parent 54c8bf3 commit 1f5494d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
6 changes: 3 additions & 3 deletions docs/UserLocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
| Prop | Type | Default | Required | Description |
| ---- | :--: | :-----: | :------: | :----------: |
| animated | `bool` | `true` | `false` | Wheather location icon is animated between updates |
| renderMode | `enum` | `"normal"` | `false` | Rendermode of user location icon.<br/>One of `"normal"`, `"custom"`.<br/>"custom" must be of type mapbox-gl-native components |
| renderMode | `enum` | `'normal'` | `false` | Rendermode of user location icon.<br/>One of `"normal"`, `"custom"`.<br/>"custom" must be of type mapbox-gl-native components |
| visible | `bool` | `true` | `false` | Wheather location icon is visible |
| onPress | `func` | `none` | `false` | Callback that is triggered on location icon press |
| onUpdate | `func` | `none` | `false` | Callback that is triggered on location update |
| minDisplacement | `number` | `0` | `false` | FIX ME NO DESCRIPTION |
| children | `any` | `none` | `false` | Custom location icon of type mapbox-gl-native components |

### methods
#### setLocationManager({ running })
#### setLocationManager({running})

Wheather to start or stop the locationManager<br/>Notice, that locationManager will start automatically when<br/>either `onUpdate` or `visible` are set

##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `{ running }` | `n/a` | `Yes` | undefined |
| `{running}` | `n/a` | `Yes` | undefined |


#### needsLocationManagerRunning()
Expand Down
4 changes: 2 additions & 2 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4831,7 +4831,7 @@
],
"params": [
{
"name": "{ running }"
"name": "{running}"
}
],
"returns": {
Expand Down Expand Up @@ -4870,7 +4870,7 @@
"name": "renderMode",
"required": false,
"type": "enum",
"default": "\"normal\"",
"default": "'normal'",
"description": "Rendermode of user location icon.\nOne of `\"normal\"`, `\"custom\"`.\n\"custom\" must be of type mapbox-gl-native components"
},
{
Expand Down
50 changes: 25 additions & 25 deletions javascript/components/UserLocation.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import React from "react";
import PropTypes from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';

import locationManager from "../modules/location/locationManager";
import locationManager from '../modules/location/locationManager';

import Annotation from "./annotations/Annotation"; // eslint-disable-line import/no-cycle
import CircleLayer from "./CircleLayer";
import Annotation from './annotations/Annotation'; // eslint-disable-line import/no-cycle
import CircleLayer from './CircleLayer';

const mapboxBlue = "rgba(51, 181, 229, 100)";
const mapboxBlue = 'rgba(51, 181, 229, 100)';

const layerStyles = {
normal: {
pluse: {
circleRadius: 15,
circleColor: mapboxBlue,
circleOpacity: 0.2,
circlePitchAlignment: "map"
circlePitchAlignment: 'map',
},
background: {
circleRadius: 9,
circleColor: "#fff",
circlePitchAlignment: "map"
circleColor: '#fff',
circlePitchAlignment: 'map',
},
foreground: {
circleRadius: 6,
circleColor: mapboxBlue,
circlePitchAlignment: "map"
}
}
circlePitchAlignment: 'map',
},
},
};

const normalIcon = [
Expand All @@ -45,7 +45,7 @@ const normalIcon = [
id="mapboxUserLocationBlueCicle"
aboveLayerID="mapboxUserLocationWhiteCircle"
style={layerStyles.normal.foreground}
/>
/>,
];

class UserLocation extends React.Component {
Expand All @@ -60,7 +60,7 @@ class UserLocation extends React.Component {
* One of `"normal"`, `"custom"`.
* "custom" must be of type mapbox-gl-native components
*/
renderMode: PropTypes.oneOf(["normal", "custom"]),
renderMode: PropTypes.oneOf(['normal', 'custom']),

/**
* Wheather location icon is visible
Expand All @@ -82,27 +82,27 @@ class UserLocation extends React.Component {
/**
* Custom location icon of type mapbox-gl-native components
*/
children: PropTypes.any
children: PropTypes.any,
};

static defaultProps = {
animated: true,
visible: true,
minDisplacement: 0,
renderMode: "normal"
renderMode: 'normal',
};

static RenderMode = {
Normal: "normal",
Custom: "custom"
Normal: 'normal',
Custom: 'custom',
};

constructor(props) {
super(props);

this.state = {
shouldShowUserLocation: false,
coordinates: null
coordinates: null,
};

this._onLocationUpdate = this._onLocationUpdate.bind(this);
Expand All @@ -111,7 +111,7 @@ class UserLocation extends React.Component {
async componentDidMount() {
locationManager.addListener(this._onLocationUpdate);
await this.setLocationManager({
running: this.needsLocationManagerRunning()
running: this.needsLocationManagerRunning(),
});
}

Expand All @@ -125,7 +125,7 @@ class UserLocation extends React.Component {
* @param {Object} running - Object with key `running` and `boolean` value
* @return {void}
*/
setLocationManager = async ({ running }) => {
setLocationManager = async ({running}) => {
if (this.locationManagerRunning !== running) {
this.locationManagerRunning = running;
if (running) {
Expand All @@ -135,7 +135,7 @@ class UserLocation extends React.Component {

if (lastKnownLocation) {
this.setState({
coordinates: this._getCoordinatesFromLocation(lastKnownLocation)
coordinates: this._getCoordinatesFromLocation(lastKnownLocation),
});
}
}
Expand All @@ -154,12 +154,12 @@ class UserLocation extends React.Component {

async componentWillUnmount() {
locationManager.removeListener(this._onLocationUpdate);
await this.setLocationManager({ running: false });
await this.setLocationManager({running: false});
}

_onLocationUpdate(location) {
this.setState({
coordinates: this._getCoordinatesFromLocation(location)
coordinates: this._getCoordinatesFromLocation(location),
});

if (this.props.onUpdate) {
Expand All @@ -185,7 +185,7 @@ class UserLocation extends React.Component {

async componentDidUpdate(prevProps) {
await this.setLocationManager({
running: this.needsLocationManagerRunning()
running: this.needsLocationManagerRunning(),
});

if (this.props.minDisplacement !== prevProps.minDisplacement) {
Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,8 @@
}
},
"lint-staged": {
"linters": {
"*.js": [
"yarn lint",
"git add"
"*.js": [
"yarn lint"
]
},
"ignore": [
"**/scripts/**/*.js"
]
}
}

0 comments on commit 1f5494d

Please sign in to comment.