Git Product home page Git Product logo

wednesday-world-cup-ui's Introduction

vue-tournament-bracket

Vue component for rendering single elemination tournament brackets.

Based on: https://codepen.io/sdudnyk/pen/bWbqMb.

Rendering is based on flex, see browser support.

Example

Real life example can be found here: panel-rejestracyjny.pl.

Installation and component usage

Install component via:

npm install vue-tournament-bracket

Example:

<template>
    <bracket :rounds="rounds">
        <template slot="player" slot-scope="{{ player }}">
            {{ player.name }}
        </template>
    </bracket>
<template>

<script>
    import Bracket from "vue-tournament-bracket";

    const rounds = [
        //Semi finals
        {
            games: [
                {

                    player1: { id: "1", name: "Competitor 1", winner: false },
                    player2: { id: "4", name: "Competitor 4", winner: true },
                },
                {

                    player1: { id: "5", name: "Competitor 5", winner: false },
                    player2: { id: "8", name: "Competitor 8", winner: true },
                }
            ]
        },
        //Final
        {
            games: [
                {

                    player1: { id: "4", name: "Competitor 4", winner: false },
                    player2: { id: "8", name: "Competitor 8", winner: true },
                }
            ]
        }
    ];

    export default {
        components: {
            Bracket
        },
        data() {
            return {
                rounds: rounds
            }
        }
    }
</script>

Third place play-off

Here is the way to represent third place play-off:

const rounds = [
        //Semi finals
        {
            games: [
                {

                    player1: { id: "1", name: "Competitor 1", winner: false },
                    player2: { id: "4", name: "Competitor 4", winner: true },
                },
                {

                    player1: { id: "5", name: "Competitor 5", winner: false },
                    player2: { id: "8", name: "Competitor 8", winner: true },
                }
            ]
        },
        //Third place play off
        {
            games: [
                {

                    player1: { id: "1", name: "Competitor 1", winner: false },
                    player2: { id: "5", name: "Competitor 5", winner: true },
                }
            ]
        },
        //Final
        {
            games: [
                {

                    player1: { id: "4", name: "Competitor 4", winner: false },
                    player2: { id: "8", name: "Competitor 8", winner: true },
                }
            ]
        }
    ];

Third place play-off

Bottom slot

There is slot with whole match props, use it in following way:

<bracket :rounds="rounds">
    <template #player="{ player }">
        {{ player.name }}
    </template>
    <template #player-extension-bottom="{ match }">
        Extra info: {{ match.title }}
    </template>
</bracket>

May be useful for example for showing tooltips etc.

Bottom slot for match

Game object

Game object requires player1 and player2 objects. You can also add your own and e.g. reuse it in players-extension-bottom slot.

Following properties are forbidden and are going to be replaced with undefined:

  • games
  • hasParent

See matchProperties in GamePlayers for details.

Player object

Player object requires: id property, winner is optional, rest is up to you - rendering is customizable via scoped slot.

  • id is being used for highlighting
  • winner property applies color for player accordingly, can be also null - player's color will be gray

Styling

Apply your custom style by overriding Bracket component CSS. See BracketNode.vue for all styles being used.

Development

Checkout repository and:

npm install
npm run serve

Then open browser and test your changes using App.vue main component for development purposes.

See package.json to discover available commands.

Releasing

npm test
npm run eslint
npm run build
git commit
npm version <version>
git push
npm publish --access=public

License

MIT

wednesday-world-cup-ui's People

Contributors

kamilwylegala avatar jackonelli avatar

Watchers

James Cloos avatar

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.