Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] Change BottomWidget to pure functional component (#249)

Oskarf93629c4bdfc
diff --git a/src/components/bottom-widget.js b/src/components/bottom-widget.js
index 7cffc8b8f..efad05699 100644
--- a/src/components/bottom-widget.js
+++ b/src/components/bottom-widget.js
@@ -18,11 +18,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import React, {Component} from 'react';
+import React from 'react';
import PropTypes from 'prop-types';
import TimeWidgetFactory from './filters/time-widget';
-const propsTypes = {
+const propTypes = {
filters: PropTypes.array,
datasets: PropTypes.object,
uiState: PropTypes.object,
@@ -31,51 +31,49 @@ const propsTypes = {
containerW: PropTypes.number
};
-const MaxWidth = 1080;
+const maxWidth = 1080;
BottomWidgetFactory.deps = [TimeWidgetFactory];
export default function BottomWidgetFactory(TimeWidget) {
- class BottomWidget extends Component {
- render() {
- const {
- datasets,
- filters,
- visStateActions,
- containerW,
- uiState,
- sidePanelWidth
- } = this.props;
- const {activeSidePanel} = uiState;
- const isOpen = Boolean(activeSidePanel);
+ const BottomWidget = (props) => {
+ const {
+ datasets,
+ filters,
+ visStateActions,
+ containerW,
+ uiState,
+ sidePanelWidth
+ } = props;
+ const {activeSidePanel} = uiState;
+ const isOpen = Boolean(activeSidePanel);
- const enlargedFilterIdx = filters.findIndex(f => f.enlarged);
- const isAnyFilterAnimating = filters.some(f => f.isAnimating);
- const enlargedFilterWidth = isOpen ? containerW - sidePanelWidth : containerW;
+ const enlargedFilterIdx = filters.findIndex(f => f.enlarged);
+ const isAnyFilterAnimating = filters.some(f => f.isAnimating);
+ const enlargedFilterWidth = isOpen ? containerW - sidePanelWidth : containerW;
- if (enlargedFilterIdx < 0) {
- return null;
- }
-
- return (
- <TimeWidget
- fields={datasets[filters[enlargedFilterIdx].dataId].fields}
- setFilterPlot={visStateActions.setFilterPlot}
- setFilter={visStateActions.setFilter}
- toggleAnimation={visStateActions.toggleAnimation}
- updateAnimationSpeed={visStateActions.updateAnimationSpeed}
- enlargeFilter={visStateActions.enlargeFilter}
- width={Math.min(MaxWidth, enlargedFilterWidth)}
- isAnyFilterAnimating={isAnyFilterAnimating}
- enlargedIdx={enlargedFilterIdx}
- filter={filters[enlargedFilterIdx]}
- />
- );
+ if (enlargedFilterIdx < 0) {
+ return null;
}
+
+ return (
+ <TimeWidget
+ fields={datasets[filters[enlargedFilterIdx].dataId].fields}
+ setFilterPlot={visStateActions.setFilterPlot}
+ setFilter={visStateActions.setFilter}
+ toggleAnimation={visStateActions.toggleAnimation}
+ updateAnimationSpeed={visStateActions.updateAnimationSpeed}
+ enlargeFilter={visStateActions.enlargeFilter}
+ width={Math.min(maxWidth, enlargedFilterWidth)}
+ isAnyFilterAnimating={isAnyFilterAnimating}
+ enlargedIdx={enlargedFilterIdx}
+ filter={filters[enlargedFilterIdx]}
+ />
+ );
}
- BottomWidget.propsTypes = propsTypes;
+ BottomWidget.propTypes = propTypes;
return BottomWidget;
}