-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,219 additions
and
535 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { type MatchParticipant } from "api/_autogen"; | ||
import React from "react"; | ||
import TeamWithRating from "./TeamWithRating"; | ||
|
||
interface RatingDeltaProps { | ||
includeTeamName?: boolean; | ||
participant: MatchParticipant; | ||
ranked: boolean; | ||
} | ||
|
||
const MatchRatingDelta: React.FC<RatingDeltaProps> = ({ | ||
includeTeamName, | ||
participant, | ||
ranked, | ||
}) => { | ||
let newRating = 0; | ||
if (ranked) { | ||
newRating = | ||
participant.rating !== null | ||
? Math.round(participant.rating) | ||
: Math.round(participant.old_rating); | ||
} else { | ||
newRating = Math.round(participant.old_rating); | ||
} | ||
const oldRating = | ||
participant.old_rating !== null ? Math.round(participant.old_rating) : 0; | ||
const ratingDelta = Math.abs(newRating - oldRating); | ||
|
||
const includeName = includeTeamName === undefined || includeTeamName; | ||
return ( | ||
<TeamWithRating | ||
teamName={participant.teamname} | ||
teamId={participant.team} | ||
includeTeamName={includeName} | ||
rating={newRating} | ||
ratingDelta={ratingDelta} | ||
/> | ||
); | ||
}; | ||
|
||
export default MatchRatingDelta; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useMemo } from "react"; | ||
import { useEpisodeId } from "../../contexts/EpisodeContext"; | ||
import { NavLink } from "react-router-dom"; | ||
|
||
interface TeamWithRatingProps { | ||
teamName: string; | ||
teamId: number; | ||
includeTeamName: boolean; | ||
rating: number; | ||
ratingDelta?: number; | ||
} | ||
|
||
const TeamWithRating: React.FC<TeamWithRatingProps> = ({ | ||
teamName, | ||
teamId, | ||
includeTeamName, | ||
rating, | ||
ratingDelta, | ||
}) => { | ||
const { episodeId } = useEpisodeId(); | ||
|
||
const ratingComponent = useMemo(() => { | ||
if (ratingDelta !== undefined) { | ||
const deltaClass = | ||
ratingDelta > 0 | ||
? "text-xs font-semibold slashed-zero text-green-700" | ||
: rating < ratingDelta | ||
? "text-xs font-semibold slashed-zero text-red-700" | ||
: "text-xs font-semibold slashed-zero text-gray-700"; | ||
return ( | ||
<span className={deltaClass}> | ||
{" "} | ||
{includeTeamName && <span>{"("}</span>} | ||
{`${ | ||
ratingDelta > 0 ? " +" : ratingDelta < 0 ? " -" : " ±" | ||
}${ratingDelta.toFixed(0)}`} | ||
{includeTeamName && <span>{")"}</span>} | ||
</span> | ||
); | ||
} else { | ||
return ( | ||
<span> | ||
{" "} | ||
{includeTeamName && <span>{"("}</span>} | ||
{rating.toFixed(0)} | ||
{includeTeamName && <span>{")"}</span>} | ||
</span> | ||
); | ||
} | ||
}, [rating, ratingDelta, includeTeamName]); | ||
|
||
return ( | ||
<> | ||
<NavLink to={`/${episodeId}/team/${teamId}`} className="hover:underline"> | ||
{includeTeamName && <span>{teamName}</span>} | ||
{ratingComponent} | ||
</NavLink> | ||
</> | ||
); | ||
}; | ||
|
||
export default TeamWithRating; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.