@@ -13,12 +13,22 @@ Draw pretty git graphs with vanilla JS.
13
13
14
14
## Get started
15
15
16
+ ### Example with ParcelJS
17
+
16
18
> You need to have [ npm] [ get-npm ] installed.
17
19
20
+ Create a new folder for your project and go there: ` mkdir your-project && cd your-project `
21
+
22
+ Initialize your npm project: ` npm init -y `
23
+
18
24
Install the package with npm: ` npm i --save @gitgraph/js `
19
25
26
+ Install Parcel bundler: ` npm i --save-dev parcel-bundler `
27
+
20
28
Now you can use ` createGitgraph ` to render your graph in a DOM element:
21
29
30
+ Create an ` index.html ` file:
31
+
22
32
``` html
23
33
<!DOCTYPE html>
24
34
<html >
@@ -27,13 +37,18 @@ Now you can use `createGitgraph` to render your graph in a DOM element:
27
37
</head >
28
38
<body >
29
39
<!-- DOM element in which we'll mount our graph -->
30
- <div id =" #graph-container" ></div >
40
+ <div id =" graph-container" ></div >
41
+
42
+ <!-- This is for ParcelJS bundler -->
43
+ <script src =" ./index.js" ></script >
31
44
</body >
32
45
</html >
33
46
```
34
47
48
+ Create an ` index.js ` file:
49
+
35
50
``` js
36
- const { createGitgraph } = require ( " @gitgraph/js" ) ;
51
+ import { createGitgraph } from " @gitgraph/js" ;
37
52
38
53
// Get the graph container HTML element.
39
54
const graphContainer = document .getElementById (" graph-container" );
@@ -60,10 +75,25 @@ develop.commit("Prepare v1");
60
75
master .merge (develop).tag (" v1.0.0" );
61
76
```
62
77
63
- This code will render the following graph:
78
+ Add start command in your ` package.json ` :
79
+
80
+ ``` diff
81
+ {
82
+ "name": "your-project",
83
+ "version": "1.0.0",
84
+ "scripts": {
85
+ + "start": "parcel index.html"
86
+ }
87
+ ```
88
+
89
+ Run ` npm start ` . You should see the following graph:
64
90
65
91
![ Example of usage] ( ./assets/example-usage.png )
66
92
93
+ ### Example with browser bundle
94
+
95
+ TODO: fill
96
+
67
97
## More examples
68
98
69
99
[ A bunch of scenarios] [ stories ] has been simulated in our Storybook. You can give them a look 👀
@@ -72,3 +102,7 @@ This code will render the following graph:
72
102
[ gitgraph-repo ] : https://github.com/nicoespeon/gitgraph.js/
73
103
[ stories ] : https://github.com/nicoespeon/gitgraph.js/tree/master/packages/stories/src/gitgraph-js/
74
104
[ migration-guide ] : https://github.com/nicoespeon/gitgraph.js/blob/master/packages/gitgraph-js/MIGRATE_FROM_GITGRAPH.JS.md
105
+
106
+ ```
107
+
108
+ ```
0 commit comments