@@ -13,12 +13,22 @@ Draw pretty git graphs with vanilla JS.
1313
1414## Get started
1515
16+ ### Example with ParcelJS
17+
1618> You need to have [ npm] [ get-npm ] installed.
1719
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+
1824Install the package with npm: ` npm i --save @gitgraph/js `
1925
26+ Install Parcel bundler: ` npm i --save-dev parcel-bundler `
27+
2028Now you can use ` createGitgraph ` to render your graph in a DOM element:
2129
30+ Create an ` index.html ` file:
31+
2232``` html
2333<!DOCTYPE html>
2434<html >
@@ -27,13 +37,18 @@ Now you can use `createGitgraph` to render your graph in a DOM element:
2737</head >
2838<body >
2939 <!-- 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 >
3144</body >
3245</html >
3346```
3447
48+ Create an ` index.js ` file:
49+
3550``` js
36- const { createGitgraph } = require ( " @gitgraph/js" ) ;
51+ import { createGitgraph } from " @gitgraph/js" ;
3752
3853// Get the graph container HTML element.
3954const graphContainer = document .getElementById (" graph-container" );
@@ -60,10 +75,25 @@ develop.commit("Prepare v1");
6075master .merge (develop).tag (" v1.0.0" );
6176```
6277
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:
6490
6591![ Example of usage] ( ./assets/example-usage.png )
6692
93+ ### Example with browser bundle
94+
95+ TODO: fill
96+
6797## More examples
6898
6999[ 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:
72102[ gitgraph-repo ] : https://github.com/nicoespeon/gitgraph.js/
73103[ stories ] : https://github.com/nicoespeon/gitgraph.js/tree/master/packages/stories/src/gitgraph-js/
74104[ 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