Drarig29 / brackets-viewer.js

A simple library to display tournament brackets (round-robin, single elimination, double elimination).
https://drarig29.github.io/brackets-docs
MIT License
177 stars 45 forks source link

Add feature #64

Closed Emmanuel97423 closed 3 years ago

Emmanuel97423 commented 3 years ago

Hi @Drarig29 . I want to add a link to match page for each seed. I check the bracket-viewer.js but i be carefull . You are a best practise for that ? Best Regard,

Drarig29 commented 3 years ago

Do your changes as you would do generally. Please try to keep DOM related logic in the dom.ts file. So that the main.ts stays not cluttered.

When you are done with your changes, just run the linter with npm run lint.

When there are no warnings you can make a pull request and I will review it 😉

Emmanuel97423 commented 3 years ago

Do your changes as you would do generally. Please try to keep DOM related logic in the dom.ts file. So that the main.ts stays not cluttered.

When you are done with your changes, just run the linter with npm run lint.

When there are no warnings you can make a pull request and I will review it 😉

I've not /src files in my Nuxt project. I've just bracket-viewer. js and bracket-viewer.css. No dom.ts or main.ts . What i do bad ?

Drarig29 commented 3 years ago

Oh okay I thought you wanted to make the changes on the library.

Well this feature does not exist yet. I speak about it in #38

I can add it for you.

When you say "I want to add a link to match page for each seed", what do you mean by "seed"?

Do you mean each node of the tree? (each match?)

Emmanuel97423 commented 3 years ago

I want say link for each match (participant1 vs participant2)...

Drarig29 commented 3 years ago

Okay, let me do this.

Drarig29 commented 3 years ago

I will add the possibility to set a onMatchClicked callback but the viewer does not come with anything to render a single match. You will have to design such a page manually.

I mean something like this page: https://www.toornament.com/en_US/tournaments/4153340356159348736/matches/4158520239729696775/

Drarig29 commented 3 years ago

Okay, with commit https://github.com/Drarig29/brackets-viewer.js/commit/ae66b72b505cc273e78ca3d089d03f75c027f48b you can now do this:

bracketsViewer.onMatchClicked = match => console.log(match)

I think you'll have enough information with only match.

To test this, change your CDN url to point to the commit:

- src: "https://cdn.jsdelivr.net/npm/brackets-viewer/dist/brackets-viewer.min.js"
+ src: "https://cdn.jsdelivr.net/gh/Drarig29/brackets-viewer.js@ae66b72b505cc273e78ca3d089d03f75c027f48b/dist/brackets-viewer.min.js"

If this change suits you, it will be added in the next release of the library :wink: