npm install react-tournament-board
or
yarn add react-tournament-board
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"
/>
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;
}
See the open issues for a list of proposed features (and known issues).
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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
© spring-raining - https://github.com/spring-raining - harusamex.com@gmail.com
Project Link: https://github.com/by-kitachan/react-tournament-baord