refactor: convert function expressions to declarations (#4926)

This commit is contained in:
Vladislav Shkodin
2021-02-08 20:01:21 +02:00
committed by GitHub
parent c0236536dd
commit 141a2eba56
241 changed files with 3444 additions and 2933 deletions

View File

@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import { WidgetPreviewContainer } from 'netlify-cms-ui-default';
const MapPreview = ({ value }) => (
<WidgetPreviewContainer>{value ? value.toString() : null}</WidgetPreviewContainer>
);
function MapPreview({ value }) {
return <WidgetPreviewContainer>{value ? value.toString() : null}</WidgetPreviewContainer>;
}
MapPreview.propTypes = {
value: PropTypes.string,

View File

@ -3,13 +3,16 @@ import previewComponent from './MapPreview';
import schema from './schema';
const controlComponent = withMapControl();
const Widget = (opts = {}) => ({
name: 'map',
controlComponent,
previewComponent,
schema,
...opts,
});
function Widget(opts = {}) {
return {
name: 'map',
controlComponent,
previewComponent,
schema,
...opts,
};
}
export const NetlifyCmsWidgetMap = { Widget, controlComponent, previewComponent };
export default NetlifyCmsWidgetMap;

View File

@ -15,14 +15,18 @@ const formatOptions = {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857',
};
const getDefaultFormat = () => new GeoJSON(formatOptions);
const getDefaultMap = (target, featuresLayer) =>
new Map({
function getDefaultFormat() {
return new GeoJSON(formatOptions);
}
function getDefaultMap(target, featuresLayer) {
return new Map({
target,
layers: [new TileLayer({ source: new OSMSource() }), featuresLayer],
view: new View({ center: [0, 0], zoom: 2 }),
});
}
export default function withMapControl({ getFormat, getMap } = {}) {
return class MapControl extends React.Component {