### Yarn Start Command Source: https://github.com/mohux/react-brackets/blob/master/README.md This command starts the project's development server using Yarn. It is usually executed after installing dependencies. ```bash yarn start ``` -------------------------------- ### Install react-brackets with npm Source: https://github.com/mohux/react-brackets/blob/master/README.md Installs the react-brackets package using npm. This is the standard way to add the library to your project. ```bash npm install --save react-brackets ``` -------------------------------- ### Yarn Installation Command Source: https://github.com/mohux/react-brackets/blob/master/README.md This command installs the necessary dependencies for the project using Yarn. It is typically run at the root of the project directory. ```bash yarn ``` -------------------------------- ### Install react-brackets with yarn Source: https://github.com/mohux/react-brackets/blob/master/README.md Installs the react-brackets package using yarn. This is an alternative package manager for adding the library to your project. ```bash yarn add --save react-brackets ``` -------------------------------- ### Custom Seed Rendering (Two-Sided) Source: https://github.com/mohux/react-brackets/blob/master/README.md Example of how to implement a custom seed render component for two-sided brackets. ```APIDOC ## Custom Seed Rendering for Two-Sided Brackets ### Description This example demonstrates how to create a custom seed component to render a two-sided single elimination bracket. ### Method Functional Component ### Endpoint N/A (Component-level customization) ### Usage Pass a custom component to the `renderSeedComponent` prop of the `Bracket` component, and set `twoSided` to `true`. ### Request Example (Component Structure) ```jsx import { Bracket, RoundProps, Seed, SeedItem, SeedTeam, RenderSeedProps } from 'react-brackets'; import React from 'react'; const CustomSeed = ({seed, breakpoint, roundIndex, seedIndex, isMiddleOfTwoSided}: RenderSeedProps) => { const Wrapper = isMiddleOfTwoSided ? SingleLineSeed : Seed; return (
{seed.teams[0]?.name || 'NO TEAM '} {seed.teams[1]?.name || 'NO TEAM '}
); }; const Component = () => { // ... rounds definition return ; }; ``` ### Response N/A (Component rendering) ### Response Example N/A (Component rendering) ``` -------------------------------- ### Customizing Bracket Elements with Styled Components in React Source: https://context7.com/mohux/react-brackets/llms.txt This snippet demonstrates how to use styled-components to deeply customize the visual appearance of react-brackets components like SeedItem and SeedTeam. It involves creating styled versions of these components to apply custom CSS, including background gradients, box shadows, hover effects, and typography, allowing for a highly tailored look and feel for tournament brackets. The example requires 'react-brackets' and 'styled-components' libraries. ```jsx import { Bracket, Seed, SeedItem, SeedTeam } from 'react-brackets'; import styled from 'styled-components'; import React from 'react'; const StyledSeedItem = styled(SeedItem)` background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); &:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); transition: all 0.3s ease; } `; const StyledSeedTeam = styled(SeedTeam)` font-family: 'Arial', sans-serif; font-size: 14px; font-weight: 600; padding: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); &:last-child { border-bottom: none; } `; const rounds = [ { title: 'Championship', seeds: [{ id: 1, teams: [{ name: 'Champions' }, { name: 'Runners-up' }] }], }, ]; function StyledBracket() { const StyledSeed = ({ seed, breakpoint }) => { return ( {seed.teams[0]?.name || 'TBD'} {seed.teams[1]?.name || 'TBD'} ); }; return ; } ``` -------------------------------- ### Customizing Seeds for Double Elimination in react-brackets Source: https://github.com/mohux/react-brackets/blob/master/README.md Explains and provides an example for customizing seed rendering specifically for double elimination brackets. It dynamically chooses between `Seed` and `SingleLineSeed` components based on the number of seeds in consecutive rounds, adapting the visual connector lines. ```jsx import { Bracket, RoundProps, Seed, SingleLineSeed, SeedItem, SeedTeam, RenderSeedProps } from 'react-brackets'; import React from 'react'; const CustomSeed = ({seed, breakpoint, roundIndex, seedIndex}: RenderSeedProps) => { // ------ assuming rounds is the losers brackets rounds ------ // losers rounds usually got some identical seeds amount like (2 - 2 - 1 - 1) const isLineConnector = rounds[roundIndex].seeds.length === rounds[roundIndex + 1]?.seeds.length; const Wrapper = isLineConnector ? SingleLineSeed : Seed; // mobileBreakpoint is required to be passed down to a seed return (
{seed.teams[0]?.name || 'NO TEAM '} {seed.teams[1]?.name || 'NO TEAM '}
); }; const Component = () => { //.... return ; }; ``` -------------------------------- ### Render Basic Tournament Bracket with react-brackets Source: https://context7.com/mohux/react-brackets/llms.txt Demonstrates how to use the main Bracket component to render a basic tournament bracket structure. It takes an array of rounds, each containing seeds and teams, and allows configuration of breakpoints and CSS classes for styling. ```jsx import { Bracket } from 'react-brackets'; const rounds = [ { title: 'Round 1', seeds: [ { id: 1, date: new Date().toDateString(), teams: [{ name: 'Team A' }, { name: 'Team B' }], }, { id: 2, date: new Date().toDateString(), teams: [{ name: 'Team C' }, { name: 'Team D' }], }, ], }, { title: 'Finals', seeds: [ { id: 3, date: new Date().toDateString(), teams: [{ name: 'Team A' }, { name: 'Team C' }], }, ], }, ]; function TournamentBracket() { return ( ); } ``` -------------------------------- ### Basic Usage of react-brackets Component Source: https://github.com/mohux/react-brackets/blob/master/README.md Demonstrates the simplest way to use the Bracket component with predefined rounds and seeds. It imports necessary types and defines the structure for tournament rounds. ```jsx import { Bracket, RoundProps } from 'react-brackets'; const rounds: RoundProps[] = [ { title: 'Round one', seeds: [ { id: 1, date: new Date().toDateString(), teams: [{ name: 'Team A' }, { name: 'Team B' }], }, { id: 2, date: new Date().toDateString(), teams: [{ name: 'Team C' }, { name: 'Team D' }], }, ], }, { title: 'Round one', seeds: [ { id: 3, date: new Date().toDateString(), teams: [{ name: 'Team A' }, { name: 'Team C' }], }, ], }, ]; const Component = () => { return ; }; ``` -------------------------------- ### Customizing Seeds in react-brackets Source: https://github.com/mohux/react-brackets/blob/master/README.md Demonstrates how to customize the rendering of individual seeds using the `renderSeedComponent` prop. This allows for complete control over how team information and structure are displayed within a seed, including custom styling and data access. ```jsx import { Bracket, RoundProps, Seed, SeedItem, SeedTeam, RenderSeedProps } from 'react-brackets'; import React from 'react'; const CustomSeed = ({seed, breakpoint, roundIndex, seedIndex}: RenderSeedProps) => { // breakpoint passed to Bracket component // to check if mobile view is triggered or not // mobileBreakpoint is required to be passed down to a seed return (
{seed.teams[0]?.name || 'NO TEAM '} {seed.teams[1]?.name || 'NO TEAM '}
); }; const Component = () => { //.... return ; }; ``` -------------------------------- ### Bracket Component Props Source: https://github.com/mohux/react-brackets/blob/master/README.md Documentation for the props available on the Bracket component. ```APIDOC ## Bracket Component Props ### Description This section details the available props for configuring the Bracket component. ### Parameters #### Props - **rounds** (RoundProps[]) - Required - Array of rounds, each round has {title, array of seeds}. If not using a custom seed render, each seed needs an array of teams, and each team should have a name. - **mobileBreakpoint** (number) - Optional - The window width at which the mobile swipable view is triggered. Pass 0 to disable. Defaults to 992. - **rtl** (boolean) - Optional - Sets the bracket direction to Right-to-Left. Defaults to Left-to-Right. - **twoSided** (boolean) - Optional - If true, renders Single elimination as a two-sided bracket. Defaults to False. - **roundClassName** (string) - Optional - CSS class name for the round wrapper. - **bracketClassName** (string) - Optional - CSS class name for the main bracket container. - **renderSeedComponent** (functional component) - Optional - Custom component for rendering each seed. - **roundTitleComponent** (functional component) - Optional - Custom component for rendering each round title. - **swipeableProps** (SwipeableProps) - Optional - Props for customizing swipeable views. See [React Swipeable Views](https://github.com/oliviertassinari/react-swipeable-views). ``` -------------------------------- ### Configure Mobile Responsive Bracket with Swipeable Views - JSX Source: https://context7.com/mohux/react-brackets/llms.txt Enables mobile responsiveness for the bracket component using swipeable views, allowing users to swipe between rounds on smaller screens. It integrates with the `react-swipeable-views` library by passing `swipeableProps` to the `Bracket` component. Requires 'react-brackets', 'react', and 'react-swipeable-views'. ```jsx import { Bracket } from 'react-brackets'; import React, { useState } from 'react'; const rounds = [ { title: 'Round 1', seeds: [{ id: 1, teams: [{ name: 'A' }, { name: 'B' }] }] }, { title: 'Round 2', seeds: [{ id: 2, teams: [{ name: 'C' }, { name: 'D' }] }] }, { title: 'Round 3', seeds: [{ id: 3, teams: [{ name: 'E' }, { name: 'F' }] }] }, ]; function ResponsiveBracket() { const [currentRound, setCurrentRound] = useState(0); const swipeableProps = { index: currentRound, onChangeIndex: (index) => setCurrentRound(index), enableMouseEvents: true, resistance: true, }; return (
Round {currentRound + 1} of {rounds.length}
); } ``` -------------------------------- ### Customize Seed Rendering in react-brackets Source: https://context7.com/mohux/react-brackets/llms.txt Illustrates how to completely customize the rendering of individual seeds (matches) using the `renderSeedComponent` prop. This advanced customization allows for displaying team scores, logos, dates, and applying conditional styling based on match outcomes. ```jsx import { Bracket, Seed, SeedItem, SeedTeam } from 'react-brackets'; import React from 'react'; const rounds = [ { title: 'Round 1', seeds: [ { id: 1, date: '2025-01-15', teams: [ { name: 'Team Alpha', score: 95, logo: '/alpha.png' }, { name: 'Team Beta', score: 87, logo: '/beta.png' }, ], }, ], }, ]; function CustomSeedBracket() { const CustomSeed = ({ seed, breakpoint, roundIndex, seedIndex }) => { const winner = seed.teams[0]?.score > seed.teams[1]?.score ? 0 : 1; return (
{seed.teams.map((team, idx) => ( {team?.name || 'TBD'} {team?.score || '-'} ))}
{seed.date}
); }; return ; } ``` -------------------------------- ### Implement RTL (Right-to-Left) Bracket Layout - JSX Source: https://context7.com/mohux/react-brackets/llms.txt Configures the bracket component to render in a right-to-left (RTL) layout, suitable for languages like Arabic. This is achieved by passing the `rtl` prop as `true` to the `Bracket` component. Requires 'react-brackets'. ```jsx import { Bracket } from 'react-brackets'; const rounds = [ { title: 'الجولة الأولى', seeds: [ { id: 1, teams: [{ name: 'الفريق أ' }, { name: 'الفريق ب' }] }, { id: 2, teams: [{ name: 'الفريق ج' }, { name: 'الفريق د' }] }, ], }, { title: 'النهائي', seeds: [{ id: 3, teams: [{ name: 'الفريق أ' }, { name: 'الفريق ج' }] }], }, ]; function RTLBracket() { return ( ); } ``` -------------------------------- ### Render Double Elimination Losers Bracket with Connectors - JSX Source: https://context7.com/mohux/react-brackets/llms.txt Renders a double elimination losers bracket using react-brackets. It customizes seed rendering to include line connectors between rounds, especially when consecutive rounds have the same number of seeds. Requires 'react-brackets' and 'react'. ```jsx import { Bracket, Seed, SingleLineSeed, SeedItem, SeedTeam } from 'react-brackets'; import React from 'react'; const losersRounds = [ { title: 'Losers Round 1', seeds: [ { id: 1, teams: [{ name: 'Team A' }, { name: 'Team B' }] }, { id: 2, teams: [{ name: 'Team C' }, { name: 'Team D' }] }, ], }, { title: 'Losers Round 2', seeds: [ { id: 3, teams: [{ name: 'Team E' }, { name: 'Team F' }] }, { id: 4, teams: [{ name: 'Team G' }, { name: 'Team H' }] }, ], }, { title: 'Losers Semifinal', seeds: [{ id: 5, teams: [{ name: 'Team A' }, { name: 'Team E' }] }], }, ]; function LosersBracket() { const CustomLosersSeed = ({ seed, breakpoint, roundIndex, seedIndex, rounds }) => { // Use SingleLineSeed when consecutive rounds have same seed count const isLineConnector = rounds[roundIndex].seeds.length === rounds[roundIndex + 1]?.seeds.length; const Wrapper = isLineConnector ? SingleLineSeed : Seed; return (
{seed.teams[0]?.name || 'TBD'} {seed.teams[1]?.name || 'TBD'}
); }; return ; } ``` -------------------------------- ### Customize Round Title Rendering in react-brackets Source: https://context7.com/mohux/react-brackets/llms.txt Shows how to customize the rendering of round titles using the `roundTitleComponent` prop. This allows for dynamic styling and additional information to be displayed for each round title, such as round numbers. ```jsx import { Bracket } from 'react-brackets'; import React from 'react'; const rounds = [ { title: 'Quarterfinals', seeds: [ { id: 1, teams: [{ name: 'Warriors' }, { name: 'Lakers' }] }, { id: 2, teams: [{ name: 'Celtics' }, { name: 'Heat' }] }, ], }, { title: 'Semifinals', seeds: [{ id: 3, teams: [{ name: 'Warriors' }, { name: 'Celtics' }] }], }, ]; function CustomTitleBracket() { const renderRoundTitle = (title, roundIndex) => { return (
{title} - Round {roundIndex + 1}
); }; return ; } ``` -------------------------------- ### Create Two-Sided Single Elimination Bracket - JSX Source: https://context7.com/mohux/react-brackets/llms.txt Creates a two-sided (mirror-style) single elimination bracket where teams advance from opposite sides towards a central final. It uses a custom seed component to conditionally apply 'SingleLineSeed' for the center final match. Requires 'react-brackets' and 'react'. ```jsx import { Bracket, Seed, SingleLineSeed, SeedItem, SeedTeam } from 'react-brackets'; import React from 'react'; const twoSidedRounds = [ { title: 'Round 1', seeds: [ { id: 1, teams: [{ name: 'Team 1' }, { name: 'Team 2' }] }, { id: 2, teams: [{ name: 'Team 3' }, { name: 'Team 4' }] }, { id: 3, teams: [{ name: 'Team 5' }, { name: 'Team 6' }] }, { id: 4, teams: [{ name: 'Team 7' }, { name: 'Team 8' }] }, ], }, { title: 'Semifinals', seeds: [ { id: 5, teams: [{ name: 'Team 1' }, { name: 'Team 3' }] }, { id: 6, teams: [{ name: 'Team 5' }, { name: 'Team 7' }] }, ], }, { title: 'Finals', seeds: [{ id: 7, teams: [{ name: 'Team 1' }, { name: 'Team 5' }] }], }, ]; function TwoSidedTournament() { const TwoSidedSeed = ({ seed, breakpoint, isMiddleOfTwoSided }) => { // Use SingleLineSeed for center final match const Wrapper = isMiddleOfTwoSided ? SingleLineSeed : Seed; return (
{seed.teams[0]?.name || 'TBD'} {seed.teams[1]?.name || 'TBD'}
); }; return ; } ``` -------------------------------- ### Custom Seed Component for Two-sided Brackets (JSX) Source: https://github.com/mohux/react-brackets/blob/master/README.md This custom seed component is designed for two-sided single elimination brackets. It uses props like 'isMiddleOfTwoSided' to adjust rendering and handles 'no team' placeholders. It requires 'react-brackets' imports. ```jsx import { Bracket, RoundProps, Seed, SeedItem, SeedTeam, RenderSeedProps } from 'react-brackets'; import React from 'react'; const CustomSeed = ({seed, breakpoint, roundIndex, seedIndex, isMiddleOfTwoSided}: RenderSeedProps) => { // breakpoint passed to Bracket component // to check if mobile view is triggered or not // mobileBreakpoint is required to be passed down to a seed const Wrapper = isMiddleOfTwoSided ? SingleLineSeed : Seed return (
{seed.teams[0]?.name || 'NO TEAM '} {seed.teams[1]?.name || 'NO TEAM '}
); }; const Component = () => { //.... return ; }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.