diff --git a/package.json b/package.json index 1a918ba..c3204c7 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "plugins": [ "react" ], - "extend": [ + "extends": [ "plugin:react/recommended" ], "env": { diff --git a/src/components/Button.jsx b/src/components/Button.jsx index d3c6ee1..d87b851 100644 --- a/src/components/Button.jsx +++ b/src/components/Button.jsx @@ -7,6 +7,7 @@ class Button extends React.Component { onClick: PropTypes.func, style: PropTypes.object, className: PropTypes.string, + children: PropTypes.node } render() { diff --git a/src/components/MessagePanel.jsx b/src/components/MessagePanel.jsx index f5e4c81..53c873e 100644 --- a/src/components/MessagePanel.jsx +++ b/src/components/MessagePanel.jsx @@ -9,11 +9,11 @@ class MessagePanel extends React.Component { render() { const errors = this.props.errors.map((m, i) => { - return

{m}

+ return

{m}

}) const infos = this.props.infos.map((m, i) => { - return

{m}

+ return

{m}

}) return
diff --git a/src/components/ScrollContainer.jsx b/src/components/ScrollContainer.jsx index 7425300..cbee91b 100644 --- a/src/components/ScrollContainer.jsx +++ b/src/components/ScrollContainer.jsx @@ -1,9 +1,16 @@ import React from 'react' +import PropTypes from 'prop-types' -const ScrollContainer = (props) => { - return
- {props.children} -
+class ScrollContainer extends React.Component { + static propTypes = { + children: PropTypes.node + } + + render() { + return
+ {this.props.children} +
+ } } export default ScrollContainer diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index 91f5620..383e585 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -25,27 +25,46 @@ import OpenModal from './modals/OpenModal' import style from '../libs/style' -function IconText(props) { - return {props.children} +class IconText extends React.Component { + static propTypes = { + children: PropTypes.node, + } + + render() { + return {this.props.children} + } } -function ToolbarLink(props) { - return - {props.children} - +class ToolbarLink extends React.Component { + static propTypes = { + className: PropTypes.string, + children: PropTypes.node, + } + + render() { + return + {this.props.children} + + } } -function ToolbarAction(props) { - return - {props.children} - +class ToolbarAction extends React.Component { + static propTypes = { + children: PropTypes.node + } + + render() { + return + {this.props.children} + + } } export default class Toolbar extends React.Component { @@ -57,7 +76,8 @@ export default class Toolbar extends React.Component { onStyleOpen: PropTypes.func.isRequired, // A dict of source id's and the available source layers sources: PropTypes.object.isRequired, - onInspectModeToggle: PropTypes.func.isRequired + onInspectModeToggle: PropTypes.func.isRequired, + children: PropTypes.node } constructor(props) { diff --git a/src/components/fields/ColorField.jsx b/src/components/fields/ColorField.jsx index 7599533..1ff229a 100644 --- a/src/components/fields/ColorField.jsx +++ b/src/components/fields/ColorField.jsx @@ -30,7 +30,7 @@ class ColorField extends React.Component { //but I am too stupid to get it to work together with fixed position //and scrollbars so I have to fallback to JavaScript calcPickerOffset() { - const elem = this.refs.colorInput + const elem = this.colorInput if(elem) { const pos = elem.getBoundingClientRect() return { @@ -99,7 +99,7 @@ class ColorField extends React.Component {
this.colorInput = input} onClick={this.togglePicker.bind(this)} style={this.props.style} name={this.props.name} diff --git a/src/components/fields/FunctionSpecField.jsx b/src/components/fields/FunctionSpecField.jsx index 9f5b3f6..b443000 100644 --- a/src/components/fields/FunctionSpecField.jsx +++ b/src/components/fields/FunctionSpecField.jsx @@ -302,49 +302,62 @@ export default class FunctionSpecProperty extends React.Component { } } -function MakeFunctionButtons(props) { - let makeZoomButton, makeDataButton - if (props.fieldSpec['zoom-function']) { - makeZoomButton = +class MakeFunctionButtons extends React.Component { + static propTypes = { + fieldSpec: PropTypes.object, + onZoomClick: PropTypes.func, + } - if (props.fieldSpec['property-function'] && ['piecewise-constant', 'interpolated'].indexOf(props.fieldSpec['function']) !== -1) { - makeDataButton = + + if (this.props.fieldSpec['property-function'] && ['piecewise-constant', 'interpolated'].indexOf(this.props.fieldSpec['function']) !== -1) { + makeDataButton = + } + return
{makeDataButton}{makeZoomButton}
+ } + else { + return null } - return
{makeDataButton}{makeZoomButton}
- } - else { - return null } } -function DeleteStopButton(props) { - return +class DeleteStopButton extends React.Component { + static propTypes = { + onClick: PropTypes.func, + } + + render() { + return + } } function labelFromFieldName(fieldName) { diff --git a/src/components/inputs/AutocompleteInput.jsx b/src/components/inputs/AutocompleteInput.jsx index 2ee4c42..a3611cc 100644 --- a/src/components/inputs/AutocompleteInput.jsx +++ b/src/components/inputs/AutocompleteInput.jsx @@ -17,7 +17,7 @@ class AutocompleteInput extends React.Component { } render() { - const AutocompleteMenu = (items, value, style) =>
+ const AutocompleteMenu = (items, value, style) =>
{items}
return } @@ -95,5 +101,6 @@ function DeleteValueButton(props) { /> } +} export default DynamicArrayInput diff --git a/src/components/inputs/FontInput.jsx b/src/components/inputs/FontInput.jsx index c879cea..8c52083 100644 --- a/src/components/inputs/FontInput.jsx +++ b/src/components/inputs/FontInput.jsx @@ -5,6 +5,7 @@ import AutocompleteInput from './AutocompleteInput' class FontInput extends React.Component { static propTypes = { value: PropTypes.array.isRequired, + default: PropTypes.array, fonts: PropTypes.array, style: PropTypes.object, onChange: PropTypes.func.isRequired, diff --git a/src/components/inputs/InputBlock.jsx b/src/components/inputs/InputBlock.jsx index 0550fbe..37c1d0a 100644 --- a/src/components/inputs/InputBlock.jsx +++ b/src/components/inputs/InputBlock.jsx @@ -14,6 +14,7 @@ class InputBlock extends React.Component { action: PropTypes.element, children: PropTypes.element.isRequired, style: PropTypes.object, + onChange: PropTypes.func, } onChange(e) { diff --git a/src/components/inputs/StringInput.jsx b/src/components/inputs/StringInput.jsx index fe1ec52..314dde8 100644 --- a/src/components/inputs/StringInput.jsx +++ b/src/components/inputs/StringInput.jsx @@ -7,6 +7,7 @@ class StringInput extends React.Component { style: PropTypes.object, default: PropTypes.string, onChange: PropTypes.func, + multi: PropTypes.bool, } constructor(props) { diff --git a/src/components/map/FeatureLayerPopup.jsx b/src/components/map/FeatureLayerPopup.jsx index 26099b3..ca67de5 100644 --- a/src/components/map/FeatureLayerPopup.jsx +++ b/src/components/map/FeatureLayerPopup.jsx @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import InputBlock from '../inputs/InputBlock' import StringInput from '../inputs/StringInput' import LayerIcon from '../icons/LayerIcon' @@ -14,6 +15,10 @@ function groupFeaturesBySourceLayer(features) { } class FeatureLayerPopup extends React.Component { + static propTypes = { + features: PropTypes.array + } + render() { const sources = groupFeaturesBySourceLayer(this.props.features) diff --git a/src/components/map/FeaturePropertyPopup.jsx b/src/components/map/FeaturePropertyPopup.jsx index c83c64d..bf2c505 100644 --- a/src/components/map/FeaturePropertyPopup.jsx +++ b/src/components/map/FeaturePropertyPopup.jsx @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import InputBlock from '../inputs/InputBlock' import StringInput from '../inputs/StringInput' @@ -31,6 +32,9 @@ function renderFeature(feature) { } class FeaturePropertyPopup extends React.Component { + static propTypes = { + features: PropTypes.array + } render() { const features = this.props.features diff --git a/src/components/map/OpenLayers3Map.jsx b/src/components/map/OpenLayers3Map.jsx index 6ca3852..dba57a0 100644 --- a/src/components/map/OpenLayers3Map.jsx +++ b/src/components/map/OpenLayers3Map.jsx @@ -69,6 +69,7 @@ class OpenLayers3Map extends React.Component { onDataChange: PropTypes.func, mapStyle: PropTypes.object.isRequired, accessToken: PropTypes.string, + style: PropTypes.object, } static defaultProps = { diff --git a/src/components/modals/Modal.jsx b/src/components/modals/Modal.jsx index a469940..c980a2e 100644 --- a/src/components/modals/Modal.jsx +++ b/src/components/modals/Modal.jsx @@ -8,6 +8,7 @@ class Modal extends React.Component { isOpen: PropTypes.bool.isRequired, title: PropTypes.string.isRequired, onOpenToggle: PropTypes.func.isRequired, + children: PropTypes.node, } render() { diff --git a/src/components/modals/OpenModal.jsx b/src/components/modals/OpenModal.jsx index df9f565..bcd1ba8 100644 --- a/src/components/modals/OpenModal.jsx +++ b/src/components/modals/OpenModal.jsx @@ -77,7 +77,7 @@ class OpenModal extends React.Component { } onOpenUrl() { - const url = this.refs.styleUrl.value; + const url = this.styleUrlElement.value; this.onStyleSelect(url); } @@ -151,7 +151,7 @@ class OpenModal extends React.Component {

Load from a URL. Note that the URL must have CORS enabled.

- + this.styleUrlElement = input} className="maputnik-input" placeholder="Enter URL..."/>