Skip to content

Commit d93b18a

Browse files
committed
Update before publishing
1 parent 45faaa7 commit d93b18a

File tree

5 files changed

+22
-44
lines changed

5 files changed

+22
-44
lines changed

README.md

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,25 @@ Import the library using [jsDelivr](https://www.jsdelivr.com/):
1010
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/Drarig29/brackets-viewer.js/dist/brackets-viewer.min.js"></script>
1111
```
1212

13-
It'll also be available on npm later.
13+
Or using [npm](https://www.npmjs.com/package/brackets-viewer):
1414

15-
The render will happen in any DOM element with class `.tournament`. Therefore, **it must exist**.
16-
17-
Now, you can use it like this:
15+
```html
16+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/brackets-viewer/dist/brackets-viewer.min.css" />
17+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brackets-viewer/dist/brackets-viewer.min.js"></script>
18+
```
1819

19-
```js
20-
bracketsViewer.render({
21-
name: "Example",
22-
type: "double_elimination",
23-
minorOrdering: ['reverse', 'pair_flip', 'reverse', 'natural'],
24-
teams: [
25-
"Team 1", "Team 2",
26-
"Team 3", "Team 4",
27-
"Team 5", "Team 6",
28-
"Team 7", "Team 8",
29-
"Team 9", "Team 10",
30-
"Team 11", "Team 12",
31-
"Team 13", "Team 14",
32-
"Team 15", "Team 16",
33-
],
34-
results: [[ /* Winner Bracket */
35-
[[1, 5], [2, 4], [6, 3], [2, 3], [1, 5], [5, 3], [7, 2], [1, 2]],
36-
[[1, 2], [3, 4], [5, 6], [7, 8]],
37-
[[9, 1], [8, 2]],
38-
[[1, 3]],
39-
], [ /* Loser Bracket */
40-
[[5, 1], [1, 2], [3, 2], [6, 9]],
41-
[[8, 2], [1, 2], [6, 2], [1, 3]],
42-
[[1, 2], [3, 1]],
43-
[[3, 0], [1, 9]],
44-
[[3, 2]],
45-
[[4, 2]],
46-
], [ /* Grand Final */
47-
[[2, 1]],
48-
]],
49-
})
20+
Now, you can use it with data generated using [brackets-manager](https://www.npmjs.com/package/brackets-manager) just like in the `/demo` folder.
5021

51-
```
22+
To quickly test, you can use `json-server`:
23+
- Run the npm script named `db` to serve the static database file `/demo/db.json`
24+
```bash
25+
npm run db
26+
```
5227

53-
See `index.html` in the demo folder for examples.
28+
- Use directly the `db.json` file generated by unit tests in the `brackets-manager` project
29+
```bash
30+
npx json-server --watch path/to/brackets-manager/db.json
31+
```
5432

5533
## How to build?
5634

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const stage = (await fetch('http://localhost:3000/stage?number=1').then(res => res.json()))[0];
1313
const data = await fetch('http://localhost:3000/db').then(res => res.json());
1414

15-
bracketsViewer.render({
15+
bracketsViewer.render('#root', {
1616
stage,
1717
groups: data.group,
1818
rounds: data.round,

dist/brackets-viewer.min.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.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "brackets-viewer.js",
2+
"name": "brackets-viewer",
33
"version": "1.0.0",
4-
"description": "A simple library to display tournament brackets (pools, single elimination, double elimination)",
4+
"description": "A simple library to display tournament brackets (round-robin, single elimination, double elimination)",
55
"files": [
66
"dist/"
77
],
@@ -45,4 +45,4 @@
4545
"dependencies": {
4646
"brackets-model": "^0.2.10"
4747
}
48-
}
48+
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class BracketsViewer {
1414
readonly teamRefsDOM: { [key: number]: HTMLElement[] } = {};
1515
private participants!: Participant[];
1616

17-
public render(data: ViewerData) {
18-
const root = $('#root');
17+
public render(rootSelector: string, data: ViewerData) {
18+
const root = $(rootSelector);
1919

2020
if (root.length === 0) {
2121
throw Error('Root not found. You must have a root element with id "root"')

0 commit comments

Comments
 (0)