Skip to content

Commit 3d08b01

Browse files
author
danielcaldas
committed
- Create lib dir with transpiled code
- Add entry main to package.json - Fix id prop in Graph - Bump to 0.0.2 - Update docs
1 parent 60ebc33 commit 3d08b01

File tree

9 files changed

+79
-15
lines changed

9 files changed

+79
-15
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ typings/
6464
# End of https://www.gitignore.io/api/node
6565

6666
# PROJECT configurations
67-
dist/
67+
dist
68+
lib
6869
coverage
6970
sandbox/rd3g.sandbox.bundle.js.map
7071
gen-docs

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.babelrc
2+
.DS_Store
23
.eslintrc.js
34
.git
45
.gitignore
@@ -8,6 +9,7 @@ docs
89
gen-docs
910
package.json
1011
sandbox
12+
src
1113
test
1214
webpack.config.dist.js
1315
webpack.config.js

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The code for the live example (<https://danielcaldas.github.io/react-d3-graph/sa
2222
can be consulted here <https://github.com/danielcaldas/react-d3-graph/blob/master/sandbox/Sandbox.js>
2323

2424
```javascript
25+
import { Graph } from 'react-d3-graph';
26+
2527
// Graph payload (with minimalist structure)
2628
const data = {
2729
nodes: [

docs/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<meta charset='utf-8' />
5-
<title>react-d3-graph | Documentation</title>
6-
<meta name='viewport' content='width=device-width,initial-scale=1'>
5+
<title>react-d3-graph | Documentation</title>
6+
<meta name='viewport' content='wiodth=device-width,initial-scale=1'>
77
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
88
<link href='assets/style.css' type='text/css' rel='stylesheet' />
99
<link href='assets/github.css' type='text/css' rel='stylesheet' />
@@ -14,7 +14,7 @@
1414
<div class='fixed xs-hide fix-3 overflow-auto max-height-100'>
1515
<div class='py1 px2'>
1616
<h2>react-d3-graph</h2>
17-
<h3 class='mb0 no-anchor'>v0.0.1</h3>
17+
<h3 class='mb0 no-anchor'>v0.0.2</h3>
1818
<div class='mb1'><code></code></div>
1919
<input
2020
placeholder='Filter'
@@ -1608,7 +1608,9 @@ <h3 class='fl m0' id='graph'>
16081608
<div class='py1 quiet mt1 prose-big'>Example</div>
16091609

16101610

1611-
<pre class='p1 overflow-auto round fill-light'><span class="hljs-comment">// Graph payload (with minimalist structure)</span>
1611+
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">import</span> { Graph } <span class="hljs-keyword">from</span> <span class="hljs-string">'react-d3-graph'</span>;
1612+
1613+
<span class="hljs-comment">// Graph payload (with minimalist structure)</span>
16121614
<span class="hljs-keyword">const</span> data = {
16131615
<span class="hljs-attr">nodes</span>: [
16141616
{<span class="hljs-attr">id</span>: <span class="hljs-string">'Harry'</span>},

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-d3-graph",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "React component to build interactive and configurable graphs with d3 effortlessly",
55
"author": "Daniel Caldas",
66
"license": "MIT",
@@ -9,6 +9,7 @@
99
"dist": "node_modules/.bin/npm-run-all --parallel dist:*",
1010
"dist:rd3g": "rm -rf dist/ && webpack --config webpack.config.dist.js -p --display-modules",
1111
"dist:sandbox": "webpack --config webpack.config.js -p",
12+
"dist:transpile": "./node_modules/babel-cli/bin/babel.js -d lib src",
1213
"docs": "node_modules/documentation/bin/documentation.js build src/**/*.js -f html -o gen-docs && node_modules/documentation/bin/documentation.js build src/**/*.js -f md > gen-docs/DOCUMENTATION.md",
1314
"docs:lint": "node_modules/documentation/bin/documentation.js lint src/**/*.js",
1415
"docs:watch": "node_modules/documentation/bin/documentation.js build src/**/*.js -f html -o gen-docs --watch",
@@ -22,6 +23,7 @@
2223
"react": "^15.5.0"
2324
},
2425
"devDependencies": {
26+
"babel-cli": "^6.24.1",
2527
"babel-core": "6.24.0",
2628
"babel-jest": "19.0.0",
2729
"babel-loader": "6.4.1",
@@ -53,6 +55,7 @@
5355
"engines": {
5456
"node": ">=6.9.5"
5557
},
58+
"main": "lib/index.js",
5659
"repository": {
5760
"type": "git",
5861
"url": "git+https://github.com/danielcaldas/react-d3-graph.git"

sandbox/rd3g.sandbox.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Graph/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import Utils from '../../utils';
1515
* The code for the live example (https://danielcaldas.github.io/react-d3-graph/sandbox/index.html)
1616
* can be consulted here https://github.com/danielcaldas/react-d3-graph/blob/master/sandbox/Sandbox.js
1717
* @example
18+
* import { Graph } from 'react-d3-graph';
19+
*
1820
* // Graph payload (with minimalist structure)
1921
* const data = {
2022
* nodes: [
@@ -132,15 +134,15 @@ export default class Graph extends React.Component {
132134
* {@link https://github.com/d3/d3-zoom#zoom}
133135
* @return {undefined}
134136
*/
135-
_zoomConfig = () => d3.select(`#${this.props.id}-${CONST.GRAPH_WRAPPER_ID}`)
137+
_zoomConfig = () => d3.select(`#${this.id}-${CONST.GRAPH_WRAPPER_ID}`)
136138
.call(d3.zoom().scaleExtent([this.state.config.minZoom, this.state.config.maxZoom])
137139
.on('zoom', this._zoomed));
138140

139141
/**
140142
* Handler for 'zoom' event within zoom config.
141143
* @return {Object} returns the transformed elements within the svg graph area.
142144
*/
143-
_zoomed = () => d3.selectAll(`#${this.props.id}-${CONST.GRAPH_CONTAINER_ID}`).attr('transform', d3.event.transform);
145+
_zoomed = () => d3.selectAll(`#${this.id}-${CONST.GRAPH_CONTAINER_ID}`).attr('transform', d3.event.transform);
144146

145147
/**
146148
* Handles mouse out node event.
@@ -212,6 +214,7 @@ export default class Graph extends React.Component {
212214
let {nodes, indexMapping} = GraphHelper.initializeNodes(graph.nodes);
213215
let links = GraphHelper.initializeLinks(graph.links); // Matrix of graph connections
214216

217+
this.id = this.props.id.replace(/ /g, '_');
215218
this.indexMapping = indexMapping;
216219
this.simulation = GraphHelper.createForceSimulation(config.width, config.height);
217220

@@ -253,7 +256,7 @@ export default class Graph extends React.Component {
253256
.on('drag', this._onDragMove)
254257
.on('end', this._onDragEnd);
255258

256-
d3.select(`#${this.props.id}-${CONST.GRAPH_WRAPPER_ID}`).selectAll('.node').call(customNodeDrag);
259+
d3.select(`#${this.id}-${CONST.GRAPH_WRAPPER_ID}`).selectAll('.node').call(customNodeDrag);
257260
}
258261

259262
// Graph zoom and drag&drop all network
@@ -291,9 +294,9 @@ export default class Graph extends React.Component {
291294
};
292295

293296
return (
294-
<div id={`${this.props.id}-${CONST.GRAPH_WRAPPER_ID}`}>
297+
<div id={`${this.id}-${CONST.GRAPH_WRAPPER_ID}`}>
295298
<svg style={svgStyle}>
296-
<g id={`${this.props.id}-${CONST.GRAPH_CONTAINER_ID}`}>
299+
<g id={`${this.id}-${CONST.GRAPH_CONTAINER_ID}`}>
297300
{links}
298301
{nodes}
299302
</g>

yarn.lock

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,27 @@ aws4@^1.2.1:
258258
version "1.6.0"
259259
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"
260260

261+
babel-cli@^6.24.1:
262+
version "6.24.1"
263+
resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283"
264+
dependencies:
265+
babel-core "^6.24.1"
266+
babel-polyfill "^6.23.0"
267+
babel-register "^6.24.1"
268+
babel-runtime "^6.22.0"
269+
commander "^2.8.1"
270+
convert-source-map "^1.1.0"
271+
fs-readdir-recursive "^1.0.0"
272+
glob "^7.0.0"
273+
lodash "^4.2.0"
274+
output-file-sync "^1.1.0"
275+
path-is-absolute "^1.0.0"
276+
slash "^1.0.0"
277+
source-map "^0.5.0"
278+
v8flags "^2.0.10"
279+
optionalDependencies:
280+
chokidar "^1.6.1"
281+
261282
babel-code-frame@^6.11.0, babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
262283
version "6.22.0"
263284
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
@@ -896,6 +917,14 @@ babel-plugin-transform-strict-mode@^6.24.1:
896917
babel-runtime "^6.22.0"
897918
babel-types "^6.24.1"
898919

920+
babel-polyfill@^6.23.0:
921+
version "6.23.0"
922+
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d"
923+
dependencies:
924+
babel-runtime "^6.22.0"
925+
core-js "^2.4.0"
926+
regenerator-runtime "^0.10.0"
927+
899928
[email protected], babel-preset-es2015@^6.16.0:
900929
version "6.24.1"
901930
resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939"
@@ -1319,7 +1348,7 @@ character-reference-invalid@^1.0.0:
13191348
version "1.1.0"
13201349
resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.0.tgz#dec9ad1dfb9f8d06b4fcdaa2adc3c4fd97af1e68"
13211350

1322-
chokidar@^1.2.0, chokidar@^1.4.3, chokidar@^1.6.0:
1351+
chokidar@^1.2.0, chokidar@^1.4.3, chokidar@^1.6.0, chokidar@^1.6.1:
13231352
version "1.6.1"
13241353
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2"
13251354
dependencies:
@@ -1476,7 +1505,7 @@ comma-separated-tokens@^1.0.1:
14761505
dependencies:
14771506
trim "0.0.1"
14781507

1479-
commander@2, [email protected]:
1508+
commander@2, [email protected], commander@^2.8.1:
14801509
version "2.9.0"
14811510
resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
14821511
dependencies:
@@ -2957,6 +2986,10 @@ from@~0:
29572986
version "0.1.7"
29582987
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
29592988

2989+
fs-readdir-recursive@^1.0.0:
2990+
version "1.0.0"
2991+
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560"
2992+
29602993
fs.realpath@^1.0.0:
29612994
version "1.0.0"
29622995
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -3118,7 +3151,7 @@ globby@^5.0.0:
31183151
pify "^2.0.0"
31193152
pinkie-promise "^2.0.0"
31203153

3121-
graceful-fs@^4.0.0, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
3154+
graceful-fs@^4.0.0, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6:
31223155
version "4.1.11"
31233156
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
31243157

@@ -4786,6 +4819,14 @@ osenv@^0.1.4:
47864819
os-homedir "^1.0.0"
47874820
os-tmpdir "^1.0.0"
47884821

4822+
output-file-sync@^1.1.0:
4823+
version "1.1.2"
4824+
resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76"
4825+
dependencies:
4826+
graceful-fs "^4.1.4"
4827+
mkdirp "^0.5.1"
4828+
object-assign "^4.1.0"
4829+
47894830
p-limit@^1.1.0:
47904831
version "1.1.0"
47914832
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc"
@@ -6604,6 +6645,10 @@ url@^0.11.0:
66046645
punycode "1.3.2"
66056646
querystring "0.2.0"
66066647

6648+
user-home@^1.1.1:
6649+
version "1.1.1"
6650+
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"
6651+
66076652
user-home@^2.0.0:
66086653
version "2.0.0"
66096654
resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f"
@@ -6640,6 +6685,12 @@ uuid@^3.0.0:
66406685
version "3.0.1"
66416686
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
66426687

6688+
v8flags@^2.0.10:
6689+
version "2.1.1"
6690+
resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4"
6691+
dependencies:
6692+
user-home "^1.1.1"
6693+
66436694
vali-date@^1.0.0:
66446695
version "1.0.0"
66456696
resolved "https://registry.yarnpkg.com/vali-date/-/vali-date-1.0.0.tgz#1b904a59609fb328ef078138420934f6b86709a6"

0 commit comments

Comments
 (0)