Git Product home page Git Product logo

react-tournament-bracket's Introduction

npm Build Status react-tournament-bracket

image

React components for rendering a tournament bracket

Demo

Go here

Install

npm i react-tournament-bracket 

Usage

These bracket components rely on a cyclical graph data structure.
Thus, to render a bracket, you pass in only the final game. If you have a set of games matching the model, you can pass them all in to render all the brackets. The Bracket Generator will discover which games are considered 'finals' and order the rendered brackets by the height of the winning path.

import { Bracket } from 'react-tournament-bracket';
import { render } from 'react-dom';

render(<Bracket game={game}/>, document.getElementById('app'));

Development

TODO

  • Component documentation
  • Better handling of mouse team highlighting (currently, when moving between teams in a particular game, the mouse events fire in inconsistent order and can result in the wrong team left highlighted)
  • Consider simplifying the game model passed to this component
  • Add tests

react-tournament-bracket's People

Contributors

lowewenzel avatar moodysalem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-tournament-bracket's Issues

DATA BASIC

Hello sir!
Do you have data basic to run this tournament bracket. My BE returns for me a data json. But i don't know where to start with your tournament bracket
Thank you.

BracketGenerator more than 3 rounds

hello, want to ask. Does this components can make more than 3 rounds? i am trying to add to 4 but things starting to break.

Screenshot_10

this is my JSOG data

[{
    "@id": "15",
    "scheduled": 1592127724000,
    "name": "Cup",
    "sides": {
        "home": {
            "team": null,
            "score": null,
            "seed": {
                "sourceGame": {
                    "@id": "20",
                    "id": "b6e869cc-e6ad-4151-9186-5df828b45802",
                    "scheduled": 1592127724000,
                    "name": "C1",
                    "gameGroup": null,
                    "sides": {
                        "home": {
                            "team": null,
                            "score": null,
                            "seed": {
                                "sourceGame": {
                                    "@id": "1",
                                    "scheduled": 1592127724000,
                                    "name": "B1",
                                    "sides": {
                                        "home": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "sourceGame": {
                                                    "@id": "1",
                                                    "scheduled": 1592127724000,
                                                    "name": "b3",
                                                    "sides": {
                                                        "home": {
                                                            "team": {
                                                                "@id": "11",
                                                                "name": "West Salem Panthers"
                                                            },
                                                            "score": null,
                                                        },
                                                        "visitor": {
                                                            "team": null,
                                                            "score": null,
                                                        }
                                                    }
                                                },
                                                "sourcePool": null,
                                                "rank": 2,
                                                "displayName": "Winner of A1"
                                            }
                                        },
                                        "visitor": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "sourceGame": null,
                                                "sourcePool": null,
                                                "rank": 3,
                                                "displayName": "Winner of A2"
                                            }
                                        }
                                    }
                                },
                                "sourcePool": null,
                                "rank": 1,
                                "displayName": "Winner of B1"
                            }
                        },
                        "visitor": {
                            "team": null,
                            "score": null,
                            "seed": {
                                "sourceGame": {
                                    "@id": "1",
                                    "scheduled": 1592127724000,
                                    "name": "B2",
                                    "sides": {
                                        "home": {
                                            "team": {
                                                "@ref": "13"
                                            },
                                            "score": null,
                                            "seed": {
                                                "sourceGame": null,
                                                "sourcePool": {
                                                    "@ref": "14"
                                                },
                                                "rank": 2,
                                                "displayName": "Winner of A3"
                                            }
                                        },
                                        "visitor": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "sourceGame": null,
                                                "sourcePool": {
                                                    "@ref": "12"
                                                },
                                                "rank": 3,
                                                "displayName": "Winner of A4"
                                            }
                                        }
                                    }
                                },
                                "sourcePool": null,
                                "rank": 1,
                                "displayName": "Winner of B2"
                            }
                        }
                    },
                },
                "sourcePool": null,
                "rank": 1,
                "displayName": "Winner of C1"
            }
        },
        "visitor": {
            "team": null,
            "score": null,
            "seed": {
                "sourceGame": {
                    "@id": "17",
                    "id": "5dd25794-429b-4a1b-9926-bca93438a799",
                    "scheduled": 1592127724000,
                    "name": "C2",
                    "sides": {
                        "home": {
                            "team": null,
                            "score": null,
                            "seed": {
                                "sourceGame": {
                                    "@id": "18",
                                    "id": "b43e7160-9a6a-4fef-8d6a-1dfb73473653",
                                    "scheduled": 1592127724000,
                                    "name": "B3",
                                    "sides": {
                                        "home": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "displayName": "Winner of A5"
                                            }
                                        },
                                        "visitor": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "displayName": "Winner of A6"
                                            }
                                        }
                                    },
                                },
                                "sourcePool": null,
                                "rank": 1,
                                "displayName": "Winner of B3"
                            }
                        },
                        "visitor": {
                            "team": null,
                            "score": null,
                            "seed": {
                                "sourceGame": {
                                    "@id": "18",
                                    "id": "b43e7160-9a6a-4fef-8d6a-1dfb73473653",
                                    "scheduled": 1592127724000,
                                    "name": "B4",
                                    "sides": {
                                        "home": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "sourceGame": {
                                                    "@id": "18",
                                                    "id": "b43e7160-9a6a-4fef-8d6a-1dfb73473653",
                                                    "scheduled": 1592127724000,
                                                    "name": "B4",
                                                    "sides": {
                                                        "home": {
                                                            "team": null,
                                                            "score": null,
                                                            "seed": {
                                                                "displayName": "Winner of A7"
                                                            }
                                                        },
                                                        "visitor": {
                                                            "team": null,
                                                            "score": null,
                                                            "seed": {
                                                                "displayName": "Winner of A8"
                                                            }
                                                        }
                                                    },
                                                },
                                                "sourcePool": null,
                                                "rank": 1,
                                                "displayName": "Winner of B4"
                                            }
                                        },
                                        "visitor": {
                                            "team": null,
                                            "score": null,
                                            "seed": {
                                                "sourceGame": {
                                                    "@id": "18",
                                                    "id": "b43e7160-9a6a-4fef-8d6a-1dfb73473653",
                                                    "scheduled": 1592127724000,
                                                    "name": "B4",
                                                    "sides": {
                                                        "home": {
                                                            "team": null,
                                                            "score": null,
                                                            "seed": {
                                                                "displayName": "Winner of A7"
                                                            }
                                                        },
                                                        "visitor": {
                                                            "team": null,
                                                            "score": null,
                                                            "seed": {
                                                                "displayName": "Winner of A8"
                                                            }
                                                        }
                                                    },
                                                },
                                                "sourcePool": null,
                                                "rank": 1,
                                                "displayName": "Winner of B4"
                                            }
                                        }
                                    },
                                },
                                "sourcePool": null,
                                "rank": 1,
                                "displayName": "Winner of B4"
                            }
                        }
                    }
                },
                "sourcePool": null,
                "rank": 1,
                "displayName": "Winner of C2"
            }
        }
    }
}]

Add documentation to readme

I'm interested in using this repo as the foundation for a project, but I'm having trouble understanding exactly what the data structure and props of a game is supposed to look like.

@moodysalem if you can quickly explain to me how it works, or even point to the source code used in the demo, I can submit a PR to update the docs in the readme.

How to adjust bracket styles?

I see the style props are:

styles?: {
    backgroundColor: string;
    hoverBackgroundColor: string;
    scoreBackground: string;
    winningScoreBackground: string;
    teamNameStyle: React.CSSProperties;
    teamScoreStyle: React.CSSProperties;
    gameNameStyle: React.CSSProperties;
    gameTimeStyle: React.CSSProperties;
    teamSeparatorStyle: React.CSSProperties;
  };

How, when rendering the component, can you adjust or override these? (Making the lines white instead of black, or the bracket sizes a bit bigger for example)

Provide @types/react-tournament-bracket

Please provide a @types/react-tournament-bracket module so we can do the following:

npm i @types/react-tournament-bracket

or

yarn add @types/react-tournament-bracket

That way we can apply your module to TypeScript based React-TSX files.

Very complex data

Data required may be a very deep object, flat schema would be so much less pain!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.