sbachinin / bracketry

Visualize bracket of a knockout tournament in the browser
https://bracketry.app/
MIT License
10 stars 0 forks source link

Extra data? #6

Closed peterlondon1 closed 1 month ago

peterlondon1 commented 2 months ago

If I wanted to add extra information about each Match, say match date, time and court, is there any hook to connect such data?

I know I can use getMatchTopHTML() to inject extra information, the issue is how to organise this extra information and bring it to the HTML page. It would be great if there was a part of the standard Bracketry Data structure that could be extended for such use.

Thanks.

sbachinin commented 2 months ago

I think time and court you can provide as matchStatus in your data. (It can be any HTML string, styled as you like). There are no other built-in slots for such info except matchStatus and matchTop. If more customization is needed, currently the only way is to use getMatchElement where you construct everything yourself.

In theory I can add more slots but only if it's something conventional and widely used in other bracket solutions. But currently I have no such ideas.

peterlondon1 commented 2 months ago

If you use matchStatus that gets displayed in a set position (the "RETIRED" slot) to the right of the player names.

sbachinin commented 2 months ago

I assume that time & similar data is often displayed in this position

peterlondon1 commented 2 months ago

If one used matchStatus it would expand the size of the draw a lot horizontally. I wanted to use getMatchTopHTML() to place court info above the player names without increasing the horizontal size of each "match".

I will be able to create some mechanism to get the data in, but if your Data structure could accommodate extra custom data for each match that would make it much simpler.

But I understand you are probably busy with a lot of other things, and I'm very grateful regardless for your great library!

sbachinin commented 2 months ago

I'm not sure I understand your idea about extra data. You can add any arbitrary data to Data object, and I can add some new "official" fields, but the question is, where to display this data. Currently you have the means to display anything at top, right and bottom (I forgot about getMatchBottomHTML). I think it must be enough to tell everything about the match

If matchStatus makes your matches too wide, then provide an html string where everything is made narrower using css (something like <div style="max-width: 150px">time</div>)

peterlondon1 commented 2 months ago

Apologies! I read your comment above the description of Data "The only possible shape of data (one which can be passed to createBracket) is described in this d.ts file". I took this to mean I couldn't change it at all.

But, as you say, I can! And now I'm sorted, thanks. (Perhaps you could add to your description of Data something like "Extra custom fields can be added to supply extra information about elements within this structure"?)

Thanks again for your help!

sbachinin commented 2 months ago

Thanks, I’ll try to rephrase this statement

peterlondon1 commented 2 months ago

Have noticed your added text! Cheers.