react-tournament-board
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-tournament-board

npm MIT License

React tournament board

Installation

npm install react-tournament-board

or

yarn add react-tournament-board

Usage

import { TournamentBoard } from 'react-tournament-board';
import 'react-tournament-board/style.css'; // import styles

<TournamentBoard
  competitor={[
    [
      { id: 'a' },
      [{ id: 'b' }, { id: 'c' }, { id: 'd' }],
      [{ id: 'e' }, { id: 'f' }],
    ],
    [{ id: 'g' }, [{ id: 'h' }, { id: 'i' }]],
  ]}
  matches={[
    {
      result: [{ id: 'b' }, { id: 'c' }, { id: 'd' }],
      winnerId: 'b',
    },
    {
      result: [{ id: 'e' }, { id: 'f' }],
      winnerId: 'f',
    },
    {
      result: [{ id: 'b' }, { id: 'f' }],
      winnerId: 'b',
    },
  ]}
  nodeRenderer={(props) => <div>{props.isLeaf && props.competitor.id}</div>}
  treeLinksLayerProps={{
    stroke: 'silver',
    strokeWidth: 2,
  }}
  winnerLinksLayerProps={{
    stroke: 'magenta',
    strokeWidth: 4,
  }}
  direction="horizontal"
/>

Props of <TournamentBoard />

export interface TournamentBoardProps {
  competitor: MatchingStructure<T>;
  matches?: MatchingResult<U>[];
  nodeRenderer?: (props: NodeRendererProps) => React.ReactNode;
  matchingResultRenderer?: (
    props: MatchingResultRendererProps,
  ) => React.ReactNode;
  treeLinksLayerProps?: React.SVGProps<SVGGElement>;
  winnerLinksLayerProps?: React.SVGProps<SVGGElement>;
  direction?: 'vertical' | 'horizontal';
  boardSize?: number;
  descenderLinkLengthRatio?: number;
  ascenderLinkLengthRatio?: number;
  leafDistance?: number;
  groupDistance?: number;
  leafPadding?: number;
  rootPadding?: number;
  bidirectionalTree?: boolean;
}

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

© spring-raining - https://github.com/spring-raining - harusamex.com@gmail.com

Project Link: https://github.com/spring-raining/react-tournament-baord

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    5
  • 0.1.2
    0
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i react-tournament-board

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

51.9 kB

Total Files

15

Last publish

Collaborators

  • spring-raining