Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to deck 8.9, kepler v3.1, react-map-gl 7, and react 18 #286

Merged
merged 15 commits into from
Jan 31, 2025
6 changes: 3 additions & 3 deletions examples/kepler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<body>
<div id="app"></div>
</body>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript">
Root.renderToDOM(document.getElementById('app'));
<script type="module">
import {renderToDOM} from './src/main.jsx';
renderToDOM(document.getElementById('app'));
</script>
</html>
53 changes: 24 additions & 29 deletions examples/kepler/package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
{
"scripts": {
"start": "webpack-dev-server --progress --hot --open",
"start-local": "webpack-dev-server --env.local --progress --hot --open",
"start-local-luma": "webpack-dev-server --env.local --env.local-luma --progress --hot --open",
"clean": "rm -rf yarn.lock ./node_modules",
"bootstrap": "yarn clean && yarn",
"build": "rm -rf dist && mkdir dist && cp index.html dist/ && webpack --env.production=true"
"start": "vite --open",
"start-local": "vite --config ../vite.config.local.mjs",
"build": "vite build"
},
"dependencies": {
"deck.gl": "8.2.0",
"deck.gl": "8.9.27",
"d3-request": "^1.0.6",
"global": "^4.3.0",
"hubble.gl": "^1.3.0",
"kepler.gl": "^2.5.5",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react-map-gl": "^5.2.10",
"react-markdown": "^4.2.2",
"hubble.gl": "^1.4.0-alpha.0",
"kepler.gl": "3.1.0-alpha.5",
"mapbox-gl": "1.13.1",
"maplibre-gl": "^3.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^7.1.6",
"react-markdown": "^6.0.3",
"react-palm": "^3.3.6",
"redux-actions": "^2.2.1",
"redux-thunk": "^1.0.0",
"react-intl": "^3.12.0"
"redux-logger": "^3.0.6",
"react-router": "3.2.5",
"react-router-redux": "^4.0.8",
"react-intl": "^3.12.0",
"styled-components": "6.1.8"
},
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"babel-loader": "^8.0.0",
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1",
"webpack-dev-middleware": "^3.5.1",
"webpack-dev-server": "^3.1.14",
"webpack-hot-middleware": "^2.24.3"
"vite": "^4.0.0"
},
"resolutions_comments": [
"deck.gl: pinned to 8.2.0 for compatibility with kepler.gl"
"deck.gl: pinned to 8.9.27 for compatibility with kepler.gl"
],
"resolutions": {
"deck.gl": "8.2.0",
"@luma.gl/constants": "8.2.0",
"@luma.gl/core": "8.2.0",
"@luma.gl/shadertools": "8.2.0",
"@luma.gl/experimental": "8.2.0"
"deck.gl": "8.9.27",
"@luma.gl/constants": "8.5.21",
"@luma.gl/core": "8.5.21",
"@luma.gl/shadertools": "8.5.21",
"@luma.gl/experimental": "8.5.21"
}
}
2 changes: 1 addition & 1 deletion examples/kepler/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

import {text as requestText, json as requestJson} from 'd3-request';
import {toggleModal} from 'kepler.gl/actions';
import {toggleModal} from '@kepler.gl/actions';

import {
LOADING_SAMPLE_ERROR_MESSAGE,
Expand Down
74 changes: 43 additions & 31 deletions examples/kepler/src/app.js → examples/kepler/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,40 @@

import React, {Component} from 'react';
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import styled, {createGlobalStyle, ThemeProvider} from 'styled-components';
import styled, {createGlobalStyle, ThemeProvider, StyleSheetManager} from 'styled-components';
import window from 'global/window';
import {connect} from 'react-redux';
import {IntlProvider} from 'react-intl';
import {messages} from 'kepler.gl/localization';
import {theme} from 'kepler.gl/styles';
import {messages} from '@kepler.gl/localization';
import {theme} from '@kepler.gl/styles';
import {replaceLoadDataModal} from './factories/load-data-modal';
import {replaceMapControl} from './factories/map-control';
import {replacePanelHeader} from './factories/panel-header';
import {replaceSaveExportDropdown} from './factories/export-modal';
import {AUTH_TOKENS} from './constants/default-settings';
import {loadSampleConfigurations} from './actions';

import isPropValid from '@emotion/is-prop-valid';
import ExportVideo from './components/export-video';

// Sample data
/* eslint-disable no-unused-vars */
import sampleTripData, {testCsvData, sampleTripDataConfig} from './data/sample-trip-data';
import sampleAnimateTrip from './data/sample-animate-trip-data';
import {addDataToMap} from 'kepler.gl/actions';
import {processCsvData, processGeojson} from 'kepler.gl/processors';
import {addDataToMap} from '@kepler.gl/actions';
import {processCsvData, processGeojson} from '@kepler.gl/processors';
/* eslint-enable no-unused-vars */

const KeplerGl = require('kepler.gl/components').injectComponents([
// This implements the default behavior from styled-components v5
function shouldForwardProp(propName, target) {
if (typeof target === 'string') {
// For HTML elements, forward the prop if it is a valid HTML attribute
return isPropValid(propName);
}
// For other elements, forward all props
return true;
}

const KeplerGl = (await import('@kepler.gl/components')).injectComponents([
replaceLoadDataModal(),
replaceMapControl(),
replacePanelHeader(),
Expand Down Expand Up @@ -185,30 +195,32 @@ class App extends Component {

render() {
return (
<IntlProvider locale="en" messages={messages.en}>
<ThemeProvider theme={theme}>
<GlobalStyle />
<WindowSize>
<ExportVideo />
<div style={{transition: 'margin 1s, height 1s', flex: 1}}>
<AutoSizer>
{({height, width}) => (
<KeplerGl
mapboxApiAccessToken={AUTH_TOKENS.MAPBOX_TOKEN}
id="map"
/*
* Specify path to keplerGl state, because it is not mount at the root
*/
getState={keplerGlGetState}
width={width}
height={height}
/>
)}
</AutoSizer>
</div>
</WindowSize>
</ThemeProvider>
</IntlProvider>
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
{/* <IntlProvider locale="en" messages={messages.en}> */}
<ThemeProvider theme={theme}>
<GlobalStyle />
<WindowSize>
<ExportVideo />
<div style={{transition: 'margin 1s, height 1s', flex: 1}}>
<AutoSizer>
{({height, width}) => (
<KeplerGl
mapboxApiAccessToken={AUTH_TOKENS.MAPBOX_TOKEN}
id="map"
/*
* Specify path to keplerGl state, because it is not mount at the root
*/
getState={keplerGlGetState}
width={width}
height={height}
/>
)}
</AutoSizer>
</div>
</WindowSize>
</ThemeProvider>
{/* </IntlProvider> */}
</StyleSheetManager>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import styled, {withTheme} from 'styled-components';
import {InjectKeplerUI, ExportVideoModal, ExportVideoPanelContainer} from '@hubble.gl/react';
// Redux stores/actions
import {toggleHubbleExportModal} from '../actions';
import {setFilter, setLayerAnimationTime} from 'kepler.gl/actions';
import {setFilter, setLayerAnimationTime} from '@kepler.gl/actions';
import mapboxgl from 'mapbox-gl';
import {messages} from '../constants/localization';
import {IntlProvider} from 'react-intl';

// Hook up mutual kepler imports
import {
Expand All @@ -37,7 +40,7 @@ import {
LoadingSpinner,
ModalTabsFactory,
Play
} from 'kepler.gl/components';
} from '@kepler.gl/components';

const IconButton = styled(Button)`
padding: 0;
Expand All @@ -55,7 +58,10 @@ const KEPLER_UI = {
Slider,
LoadingSpinner,
ModalTabsFactory,
Play
Play,
messages,
locale: 'en',
IntlProvider
};

const mapStateToProps = state => {
Expand Down Expand Up @@ -95,6 +101,9 @@ class ExportVideo extends Component {
onTripFrameUpdate={onTripFrameUpdate}
exportVideoWidth={720}
defaultFileName={'hubble.gl'}
mapProps={{
mapLib: mapboxgl
}}
/>
</ExportVideoModal>
</div>
Expand Down
154 changes: 0 additions & 154 deletions examples/kepler/src/components/load-data-modal/sample-data-viewer.js

This file was deleted.

Loading
Loading