diff --git a/src/client/src/TournamentOverview.js b/src/client/src/TournamentOverview.js index ea162b4..59bec17 100644 --- a/src/client/src/TournamentOverview.js +++ b/src/client/src/TournamentOverview.js @@ -3,72 +3,53 @@ import { Link } from "react-router-dom"; import Appbar from './components/AsuraBar'; import TournamentBar from "./components/TournamentBar"; import { useParams } from 'react-router-dom' -import { Button, Paper, Stack, CircularProgress, Box } from "@mui/material"; +import { Button, IconButton, Paper, Stack, CircularProgress, Box, Grid, Typography, Container } from "@mui/material"; import "./components/tournamentBracket.css"; +import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; +import DoDisturbIcon from '@mui/icons-material/DoDisturb'; +import BackspaceIcon from '@mui/icons-material/Backspace'; +import AddCircleIcon from '@mui/icons-material/AddCircle'; -function MatchPair(props) { - let match1 = ; - let match2 = ; - - return
-
- {match1} - {match2} -
-
-
-
-
-
+function showError(error) { + alert("Something went wrong. \n" + error); + console.error(error); } -function TournamentTier(props) { - // One round/tier of the tournament, as used by BracketViewer +function TournamentTier(props){ let roundTypes = ["finals", "semifinals", "quarterfinals", "eighthfinals", "sixteenthfinals", "thirtysecondfinals"]; - - if (props.tier === 0) { - // The final, just a single match without the bracket lines - return ( -
-
- -
-
-
- ); - } else { - // The rest of the rounds/tiers, divide into pairs of two matches - let matchPairCount = props.matches.length / 2; - let matchPairs = []; - for (let i = 0; i < matchPairCount; i++) { - matchPairs.push(); + let matches = []; + for (let i = 0; i < props.matches.length; i++) { + matches.push(); } - - return ( -
- {matchPairs} -
- ); - } + return( +
    +
  •  
  • + {matches} +
+ ) } -function Match(props) { - // A single match object, as used by MatchPair and TournamentTier +function Match(props){ let team1Name = "TBA"; let team2Name = "TBA"; - if (props.match.team1Id !== null) { + if(props.match.team1Id !== null) { team1Name = props.teams.find(team => team.id === props.match.team1Id).name; } - if (props.match.team2Id !== null) { + if(props.match.team2Id !== null) { team2Name = props.teams.find(team => team.id === props.match.team2Id).name; } let setWinner = curryTeamId => event => { let teamId = curryTeamId; + console.log(teamId) if (!teamId || teamId == null) { showError("No team selected"); return; } + // if(props.match.winnerId === teamId){ + // showError("Team already won"); + // return; + // } let formData = new FormData(); formData.append("winnerId",teamId); let body = new URLSearchParams(formData); @@ -89,27 +70,52 @@ function Match(props) { } return ( -
-
+ <> {/* Team 1 (Winner-status?) (Team name) */} -
- {team1Name} -
+
  • + + + {team1Name} + + { props.match.winnerId && (props.match.team1Id === props.match.winnerId) && + + } + { props.match.team1Id !== null && + + } + {/* { props.match.winnerId && (props.match.team1Id === props.match.winnerId) && + + } */} + +
  • +
  •  
  • {/* Team 2 (Winner-status?) (Team name) */} -
    - {team2Name} -
    -
    -
    +
  • + + + {team2Name} + + { props.match.winnerId && (props.match.team2Id === props.match.winnerId) && + + } + { props.match.team2Id !== null && + + } + {/* { props.match.winnerId && (props.match.team2Id === props.match.winnerId) && + + } */} + +
  • +
  •  
  • + ); } -function BracketViewer(props) { +function BracketViewer(props){ const [tournament, setTournament] = React.useState(null); const [matches, setMatches] = React.useState(null); const [teams, setTeams] = React.useState(null); - // One fetch statement for each of the three state variables React.useEffect(() => { fetch(process.env.REACT_APP_API_URL + `/tournament/${props.tournamentId}`) .then(res => res.json()) @@ -162,7 +168,6 @@ function BracketViewer(props) { }) .catch(err => showError(err)); }, []); - return ( (matches && teams) ? //
    diff --git a/src/client/src/components/tournamentBracket.css b/src/client/src/components/tournamentBracket.css index 1bc3144..844f186 100644 --- a/src/client/src/components/tournamentBracket.css +++ b/src/client/src/components/tournamentBracket.css @@ -1,142 +1,69 @@ -/* https://codepen.io/semibran/pen/VjmPJd */ -html { - font-size: 1rem; -} +/* + * Flex Layout Specifics +*/ +.bracket{ + display:flex; + flex-direction:row; + justify-content: center; + } + .round{ + display:flex; + flex-direction:column; + justify-content:center; + width:200px; + list-style:none; + padding:0; + font-size: 2rem; + } + .round .spacer{ flex-grow:1;} + .round .spacer:first-child, + .round .spacer:last-child{ flex-grow:.5; } + .round .game-spacer{ + flex-grow:1; + } + + /* + * General Styles + */ +/* body{ + font-family:sans-serif; + font-size:medium; + padding:10px; + line-height:1.4em; + } */ -.bracket { - display: inline-block; - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - white-space: nowrap; -} - -.bracket .round { - display: inline-block; - vertical-align: middle; -} - -.bracket .round .winners>div { - display: inline-block; - vertical-align: middle; -} - -.bracket .round .winners>div.matchups .matchup:last-child { - margin-bottom: 0 !important; -} - -.bracket .round .winners>div.matchups .matchup .participants { - border-radius: 0.25rem; - overflow: hidden; - border: 1px solid gray; -} - -.bracket .round .winners>div.matchups .matchup .participants .participant { - box-sizing: border-box; - color: #404040; - border-left: 0.25rem solid #858585; - background: white; - width: 14rem; - height: 3rem; - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.12); -} - -.bracket .round .winners>div.matchups .matchup .participants .participant.winner { - color: green; - border-color: #60c645; -} - -.bracket .round .winners>div.matchups .matchup .participants .participant.loser { - color: #dc563f; - border-color: #dc563f; -} - -.bracket .round .winners>div.matchups .matchup .participants .participant:not(:last-child) { - border-bottom: thin solid #f0f2f2; -} - -.bracket .round .winners>div.matchups .matchup .participants .participant span { - margin: 0 1.25rem; - line-height: 3; - font-size: 1rem; - font-family: "Roboto Slab"; - overflow: ellipsis; -} - -.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: 4rem; -} - -.bracket .round .winners>div.connector .merger { - position: relative; - height: 8rem; -} - -.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; -} - -.bracket .round.quarterfinals .winners:not(:last-child) { - margin-bottom: 2rem; -} - -.bracket .round.quarterfinals .winners .matchups .matchup:not(:last-child) { - margin-bottom: 2rem; -} - -.bracket .round.semifinals .winners .matchups .matchup:not(:last-child) { - margin-bottom: 10rem; -} - -.bracket .round.semifinals .winners .connector .merger { - height: 16rem; -} - -.bracket .round.semifinals .winners .connector .line { - height: 8rem; -} - -.bracket .round.finals .winners .connector .merger { - height: 3rem; -} - -.bracket .round.finals .winners .connector .line { - height: 1.5rem; -} - -.participant:hover { - background: lightgreen!important; -} \ No newline at end of file + .teamName{ + max-width: 7.5vw; + overflow: hidden; + word-wrap: none; + } + + li.game{ + padding-left:20px; + } + .winnerTrophy{ + visibility: hidden; + } + + .teamName.winner{ + font-weight:bold; + } + li.game.winner > div.winnerTrophy{ + visibility: visible; + } + /* li.game .winnerTrophy{ + float:right; + margin-right:5px; + } */ + + li.game-top{ border-bottom:1px solid #aaa; } + + li.game-spacer{ + border-right:1px solid #aaa; + min-height:10vh; + } + + li.game-bottom{ + border-top:1px solid #aaa; + } + \ No newline at end of file