Almost brackets working

This commit is contained in:
Kristoffer Juelsenn 2022-04-20 10:54:56 +02:00
parent ac71748bb3
commit 7f8ac6d345
3 changed files with 85 additions and 185 deletions

View File

@ -104,8 +104,8 @@ let deleteTournament = tournamentId => event => {
function ManageTournament(props) { function ManageTournament(props) {
const [startTime, setStartTime] = React.useState([new Date(),null]); const [startTime, setStartTime] = React.useState([null,null]);
const [endTime, setEndTime] = React.useState([new Date(),null]); const [endTime, setEndTime] = React.useState([null,null]);
React.useEffect(() => { React.useEffect(() => {
fetch( fetch(
@ -119,8 +119,8 @@ function ManageTournament(props) {
document.getElementById("editName").value = data.data.name; document.getElementById("editName").value = data.data.name;
document.getElementById("editDesc").value = data.data.description; document.getElementById("editDesc").value = data.data.description;
setStartTime(data.data.startTime.slice(0, 16)); // setStartTime(data.data.startTime.slice(0, 16));
setEndTime(data.data.endTime.slice(0, 16)); // setEndTime(data.data.endTime.slice(0, 16));
}) })
.catch((err) => showError(err)); .catch((err) => showError(err));
}, [endTime, props.tournamentId, startTime]); }, [endTime, props.tournamentId, startTime]);

View File

@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
import Appbar from './components/AsuraBar'; import Appbar from './components/AsuraBar';
import TournamentBar from "./components/TournamentBar"; import TournamentBar from "./components/TournamentBar";
import { useParams } from 'react-router-dom' import { useParams } from 'react-router-dom'
import { Button, Paper, Stack, CircularProgress, Box } from "@mui/material"; import { Button, Paper, Stack, CircularProgress, Box, Grid } from "@mui/material";
import "./components/tournamentBracket.css"; import "./components/tournamentBracket.css";
import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; import EmojiEventsIcon from '@mui/icons-material/EmojiEvents';
import DoDisturbIcon from '@mui/icons-material/DoDisturb'; import DoDisturbIcon from '@mui/icons-material/DoDisturb';
@ -12,16 +12,14 @@ function MatchPair(props) {
let match1 = <Match teams={props.teams} match={props.matches[0]} key={0} />; let match1 = <Match teams={props.teams} match={props.matches[0]} key={0} />;
let match2 = <Match teams={props.teams} match={props.matches[1]} key={1} />; let match2 = <Match teams={props.teams} match={props.matches[1]} key={1} />;
return <div className="winners"> return (
<div className="matchups"> <>
{match1} <li className="game game-top">{match1}</li>
{match2} <li className="game game-spacer">&nbsp;</li>
</div> <li className="game game-bottom">{match2}</li>
<div className="connector"> <li class="spacer">&nbsp;</li>
<div className="merger"></div> </>
<div className="line"></div> )
</div>
</div>
} }
function TournamentTier(props) { function TournamentTier(props) {
@ -31,12 +29,10 @@ function TournamentTier(props) {
if (props.tier === 0) { if (props.tier === 0) {
// The final, just a single match without the bracket lines // The final, just a single match without the bracket lines
return ( return (
<div className="round finals"><div className="winners"> <ul className="round finals">
<div className="matchups"> <li class="spacer">&nbsp;</li>
<Match teams={props.teams} match={props.matches[0]} key={0} /> <Match teams={props.teams} match={props.matches[0]} key={0} />
</div> </ul>
</div>
</div>
); );
} else { } else {
// The rest of the rounds/tiers, divide into pairs of two matches // The rest of the rounds/tiers, divide into pairs of two matches
@ -47,9 +43,10 @@ function TournamentTier(props) {
} }
return ( return (
<div className={`round ${roundTypes[props.tier]}`}> <ul className={`round ${roundTypes[props.tier]}`}>
<li class="spacer">&nbsp;</li>
{matchPairs} {matchPairs}
</div> </ul>
); );
} }
} }
@ -91,18 +88,18 @@ function Match(props) {
} }
return ( return (
<div className="matchup"> <>
<div className="participants">
{/* Team 1 (Winner-status?) (Team name) */} {/* Team 1 (Winner-status?) (Team name) */}
<div onClick={setWinner(props.match.team1Id)} className={`participant ${props.match.winnerId && (props.match.team1Id === props.match.winnerId) ? "winner" : ""}`}> <li onClick={setWinner(props.match.team1Id)} className={`game game-top ${props.match.winnerId && (props.match.team1Id === props.match.winnerId) ? "winner" : ""}`}>
<span>{team1Name}</span> {team1Name}
</div> </li>
<li class="game game-spacer">&nbsp;</li>
{/* Team 2 (Winner-status?) (Team name) */} {/* Team 2 (Winner-status?) (Team name) */}
<div onClick={setWinner(props.match.team2Id)} className={`participant ${props.match.winnerId && (props.match.team2Id === props.match.winnerId) ? "winner" : ""}`}> <li onClick={setWinner(props.match.team2Id)} className={`game game-bottom ${props.match.winnerId && (props.match.team2Id === props.match.winnerId) ? "winner" : ""}`}>
<span>{team2Name}</span> {team2Name}
</div> </li>
</div> <li class="spacer">&nbsp;</li>
</div> </>
); );
} }

View File

@ -1,153 +1,56 @@
html,body{ /*
height:100%; * Flex Layout Specifics
} */
.bracket{ .bracket{
display: flex; display:flex;
position: relative; flex-direction:row;
flex-direction: row; }
justify-content: center; .round{
align-items: center; display:flex;
width: 90vw; flex-direction:column;
height: 100%; justify-content:center;
padding:2%; width:200px;
} list-style:none;
padding:0;
}
.round .spacer{ flex-grow:1; }
.round .spacer:first-child,
.round .spacer:last-child{ flex-grow:.5; }
.winners{ .round .game-spacer{
margin: 2vw; flex-grow:1;
} }
.participants{ /*
border-radius: 0.25vw; * General Styles
overflow: hidden; */
border: 1px solid gray; body{
} font-family:sans-serif;
.participants .participant { font-size:small;
box-sizing: border-box; padding:10px;
color: #404040; line-height:1.4em;
background: white; }
width: 10vw;
height: 3vw;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.12);
}
.participants .participant span {
margin: 0 1.25vw;
line-height: 3;
font-size: 1rem;
font-family: "Roboto Slab";
overflow: ellipsis;
}
.participants .participant:not(:last-child) {
border-bottom: thin solid #dcdddd;
}
.participants .participant.loser {
color: #dc563f;
border-color: #dc563f;
}
.participants .participant.winner {
color: white;
background-color: #1ab35a;
}
.participants .participant:hover{ li.game{
cursor: pointer; padding-left:20px;
background-color: #1ab35a; }
}
.matchups{ li.game.winner{
display: flex; font-weight:bold;
flex-direction: column; }
justify-content: center; li.game span{
align-items: center; float:right;
width: 100%; margin-right:5px;
height: 100%; }
}
.matchup{ li.game-top{ border-bottom:1px solid #aaa; }
margin: 1vw 0;
}
.winners{ li.game-spacer{
display: flex; border-right:1px solid #aaa;
justify-content: center; min-height:40px;
flex-direction: row; }
margin: 2vh 0;
}
.round{ li.game-bottom{
height: 100%; border-top:1px solid #aaa;
} }
.round.thirtysecondfinals{
margin: 0vh 2vw;
height: 100%;
}
.round.sixteenthfinals{
margin: 0vh 2vw;
height: 100%;
}
.round.eighthfinals{
margin: 0vh 2vw;
height: 100%;
}
.round.quarterfinals{
margin: 0vh 2vw;
height: 100%;
}
.round.semifinals{
margin: 0vh 2vw;
height: 100%;
}
.round.finals{
margin: 0vh 2vw;
}
.connector{
display:none;
height: 100%;
}
/* .bracket .round .winners>div.connector.filled .line,
.bracket .round .winners>div.connector.filled.bottom .merger:after,
.bracket .round .winners>div.connector.filled.top .merger:before {
border-color: #60c645;
}
.bracket .round .winners>div.connector .line,
.bracket .round .winners>div.connector .merger {
box-sizing: border-box;
width: 2rem;
display: inline-block;
vertical-align: top;
}
.bracket .round .winners>div.connector .line {
border-bottom: thin solid #c0c0c8;
height: 25%;
}
.bracket .round .winners>div.connector .merger {
position: relative;
height: 50%;
}
.bracket .round .winners>div.connector .merger:before,
.bracket .round .winners>div.connector .merger:after {
content: "";
display: block;
box-sizing: border-box;
width: 100%;
height: 50%;
border: 0 solid;
border-color: #c0c0c8;
}
.bracket .round .winners>div.connector .merger:before {
border-right-width: thin;
border-top-width: thin;
}
.bracket .round .winners>div.connector .merger:after {
border-right-width: thin;
border-bottom-width: thin;
} */