Skip to content

Commit

Permalink
Refactor/upgrade add react graph gl (visgl#7)
Browse files Browse the repository at this point in the history
* refactor: upgrade dependencies

* refactor: add react-graph-gl and fix build and lint

* refactor: make react-graph-gl unit tests work

* refactor: organize into graph-gl and react-graph-gl modules

* remove extraneous comment

---------

Co-authored-by: Ed Hager <[email protected]>
  • Loading branch information
dylans and edhager authored Mar 4, 2023
1 parent 753b128 commit d9544cc
Show file tree
Hide file tree
Showing 245 changed files with 15,469 additions and 5,672 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
deprecated/
dist/
node_modules/
dist.*.js
Expand Down
47 changes: 47 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
"plugins": [
"import"
],
"extends": [
"prettier", "plugin:import/errors"
],
"overrides": [
{
"files": [
"*.spec.js", "webpack.config.js"
],
"rules": {
"import/no-extraneous-dependencies": 0
}
}
],
"settings": {},
"rules": {
"guard-for-in": 0,
"no-inline-comments": 0,
"import/no-unresolved": [
"error", {
"ignore": [
"test"
]}],
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": true, "peerDependencies": true}]
},
"env" : {
"browser" : true,
"node" : true,
"es6" : true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022,
"ecmaFeatures": {
"jsx": true
},
babelOptions: {
rootMode: "upward"
},
}
};
22 changes: 0 additions & 22 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
deprecated/
dist/
node_modules/
dist.*.js
Expand Down
21 changes: 21 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
[
'@babel/preset-react',
{
runtime: 'automatic',
loader: {
'.js': 'jsx'
}
}
]
]
};
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

1 change: 1 addition & 0 deletions deprecated/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Included here are imcomplete or old examples.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions examples/.eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions examples/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
rules: {
'import/no-unresolved': 0,
'import/no-extraneous-dependencies': 0
}
};
12 changes: 6 additions & 6 deletions examples/bing-maps/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ loadModule().then(({Map, MapTypeId, Location, DeckOverlay}) => {
filled: true,
pointRadiusMinPixels: 2,
pointRadiusScale: 2000,
getRadius: f => 11 - f.properties.scalerank,
getRadius: (f) => 11 - f.properties.scalerank,
getFillColor: [200, 0, 80, 180],
// Interactive props
pickable: true,
autoHighlight: true,
onClick: info =>
onClick: (info) =>
// eslint-disable-next-line
info.object && alert(`${info.object.properties.name} (${info.object.properties.abbrev})`)
}),
new ArcLayer({
id: 'arcs',
data: AIR_PORTS,
dataTransform: d => d.features.filter(f => f.properties.scalerank < 4),
dataTransform: (d) => d.features.filter((f) => f.properties.scalerank < 4),
// Styles
getSourcePosition: f => [-0.4531566, 51.4709959], // London
getTargetPosition: f => f.geometry.coordinates,
getSourcePosition: (f) => [-0.4531566, 51.4709959], // London
getTargetPosition: (f) => f.geometry.coordinates,
getSourceColor: [0, 128, 200],
getTargetColor: [200, 0, 80],
getWidth: 1
})
],
getTooltip: info => info.object && info.object.properties.name
getTooltip: (info) => info.object && info.object.properties.name
});
map.layers.insert(deckOverlay);
});
6 changes: 3 additions & 3 deletions examples/bing-maps/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<meta charset="UTF-8" />
<title>deck.gl w/ Bing Maps example</title>
<style>
#map {
Expand All @@ -18,6 +18,6 @@
</head>
<body>
<div id="map"></div>
<script src='app.js'></script>
<script src="app.js"></script>
</body>
</html>
9 changes: 5 additions & 4 deletions examples/bing-maps/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"license": "MIT",
"type": "module",
"scripts": {
"start": "webpack-dev-server --progress --hot --open",
"start-local": "webpack-dev-server --env.local --progress --hot --open",
"build": "webpack -p"
},
"dependencies": {
"deck.gl": "^8.4.0"
"deck.gl": "^8.8.26"
},
"devDependencies": {
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.11"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
}
}
2 changes: 1 addition & 1 deletion examples/bing-maps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const config = {
plugins: [new webpack.EnvironmentPlugin(['BingMapsAPIKey'])]
};

module.exports = env => (env && env.local ? require('../webpack.config.local')(config) : config);
module.exports = (env) => (env && env.local ? require('../webpack.config.local')(config) : config);
6 changes: 4 additions & 2 deletions examples/minimal/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import {add} from '@visgl-project-template/submodule';
import {add} from '@deck.gl-community/submodule';

export default function App() {
const a = 1;
const b = 2;
return (
<div>{a} + {b} = {add(a, b)}</div>
<div>
{a} + {b} = {add(a, b)}
</div>
);
}
15 changes: 8 additions & 7 deletions examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
},
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0"
"react-dom": "^16.0.0",
"@deck.gl-community/submodule": "^0.0.1"
},
"devDependencies": {
"@babel/preset-env": "^7.0.0",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.5",
"html-webpack-plugin": "^3.0.7",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.11"
"babel-loader": "^9.1.2",
"html-webpack-plugin": "^5.5.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
}
}
2 changes: 1 addition & 1 deletion examples/minimal/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ const config = {
plugins: [new HtmlWebpackPlugin({title: 'deck.gl example'})]
};

module.exports = env => env && env.local ? require('../webpack.config.local')(config) : config;
module.exports = (env) => (env && env.local ? require('../webpack.config.local')(config) : config);
59 changes: 59 additions & 0 deletions examples/react-graph-gl/simple-graph-viewer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, {Component} from 'react';

import GraphGL, {D3ForceLayout, JSONLoader, NODE_TYPE} from '@deck.gl-community/react-graph-gl';

import SAMPLE_GRAPH_DATASETS from '../../utils/data/sample-datasets';

const DEFAULT_NODE_SIZE = 5;

const DEFAULT_DATASET = 'Random (20, 40)';

class Root extends Component {
state = {
selectedDataset: DEFAULT_DATASET
};

handleChangeGraph = ({target: {value}}) => this.setState({selectedDataset: value});

render() {
const {selectedDataset} = this.state;
const graphData = SAMPLE_GRAPH_DATASETS[selectedDataset]();
const graph = JSONLoader({json: graphData});

return (
<div style={{display: 'flex', flexDirection: 'column', height: '100%'}}>
<div style={{width: '100%', zIndex: 999}}>
<div>
Dataset:
<select value={this.state.selectedDataset} onChange={this.handleChangeGraph}>
{Object.keys(SAMPLE_GRAPH_DATASETS).map((data) => (
<option key={data} value={data}>
{data}
</option>
))}
</select>
</div>
</div>
<div style={{width: '100%', flex: 1}}>
<GraphGL
graph={graph}
layout={new D3ForceLayout()}
nodeStyle={[
{
type: NODE_TYPE.CIRCLE,
radius: DEFAULT_NODE_SIZE,
fill: 'red'
}
]}
edgeStyle={{
stroke: '#000',
strokeWidth: 1
}}
/>
</div>
</div>
);
}
}

export default Root;
7 changes: 7 additions & 0 deletions examples/react-graph-gl/simple-graph-viewer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"license": "MIT",
"type": "module",
"dependencies": {
"deck.gl": "^@deck.gl-community/react-graph-gl"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const LOCAL_DEVELOPMENT_CONFIG = {
}
};

module.exports = config => {
module.exports = (config) => {
config.resolve = config.resolve || {};
config.resolve.alias = Object.assign(
{},
Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"lerna": "2.0.0",
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
11 changes: 5 additions & 6 deletions modules/bing-maps/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "deck.gl-bing-maps",
"name": "@deck.gl-community/bing-maps",
"description": "deck.gl integration with Bing Maps",
"license": "MIT",
"version": "0.1.0-beta.0",
Expand All @@ -15,16 +15,15 @@
"type": "git",
"url": "https://github.com/visgl/deck.gl-community.gl.git"
},
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"main": "dist/index.js",
"module": "dist/index.js",
"files": [
"dist",
"src"
],
"sideEffects": false,
"scripts": {},
"dependencies": {},
"peerDependencies": {
"@deck.gl/core": "^8.0.0"
"dependencies": {
"@deck.gl/core": "^8.8.26"
}
}
Loading

0 comments on commit d9544cc

Please sign in to comment.