react-tournament-board
v1.0.0
Published
[![npm][version-shield]][version-url] [![MIT License][license-shield]][license-url]
Downloads
5
Maintainers
Readme
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.
- 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
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
© spring-raining - https://github.com/spring-raining - [email protected]
Project Link: https://github.com/spring-raining/react-tournament-baord