added league table
This commit is contained in:
@@ -1,15 +1,115 @@
|
||||
package seasonsview
|
||||
|
||||
import "git.haelnorr.com/h/oslstats/internal/db"
|
||||
import "fmt"
|
||||
|
||||
templ SeasonLeagueTablePage(season *db.Season, league *db.League) {
|
||||
templ SeasonLeagueTablePage(season *db.Season, league *db.League, leaderboard []*db.LeaderboardEntry) {
|
||||
@SeasonLeagueLayout("table", season, league) {
|
||||
@SeasonLeagueTable()
|
||||
@SeasonLeagueTable(leaderboard)
|
||||
}
|
||||
}
|
||||
|
||||
templ SeasonLeagueTable() {
|
||||
<div class="bg-surface0 border border-surface1 rounded-lg p-8 text-center">
|
||||
<p class="text-subtext0 text-lg">Coming Soon...</p>
|
||||
</div>
|
||||
templ SeasonLeagueTable(leaderboard []*db.LeaderboardEntry) {
|
||||
if len(leaderboard) == 0 {
|
||||
<div class="bg-surface0 border border-surface1 rounded-lg p-8 text-center">
|
||||
<p class="text-subtext0 text-lg">No teams in this league yet.</p>
|
||||
</div>
|
||||
} else {
|
||||
<div class="bg-surface0 border border-surface1 rounded-lg overflow-hidden">
|
||||
<!-- Scoring key -->
|
||||
<div class="bg-mantle border-b border-surface1 px-4 py-2 flex items-center gap-4 text-xs text-subtext0">
|
||||
<span class="font-semibold text-subtext1">Points:</span>
|
||||
<span>W = { fmt.Sprint(db.PointsWin) }</span>
|
||||
<span>OTW = { fmt.Sprint(db.PointsOvertimeWin) }</span>
|
||||
<span>OTL = { fmt.Sprint(db.PointsOvertimeLoss) }</span>
|
||||
<span>L = { fmt.Sprint(db.PointsLoss) }</span>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full">
|
||||
<thead class="bg-mantle border-b border-surface1">
|
||||
<tr>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-subtext0 w-10">#</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold text-text">Team</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Games Played">GP</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Wins">W</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Overtime Wins">OTW</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Overtime Losses">OTL</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Losses">L</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Goals For">GF</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Goals Against">GA</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-text" title="Goal Differential">GD</th>
|
||||
<th class="px-3 py-3 text-center text-xs font-semibold text-blue" title="Points">PTS</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-surface1">
|
||||
for _, entry := range leaderboard {
|
||||
@leaderboardRow(entry)
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ leaderboardRow(entry *db.LeaderboardEntry) {
|
||||
{{
|
||||
r := entry.Record
|
||||
goalDiff := r.GoalsFor - r.GoalsAgainst
|
||||
var gdStr string
|
||||
if goalDiff > 0 {
|
||||
gdStr = fmt.Sprintf("+%d", goalDiff)
|
||||
} else {
|
||||
gdStr = fmt.Sprint(goalDiff)
|
||||
}
|
||||
}}
|
||||
<tr class="hover:bg-surface1 transition-colors">
|
||||
<td class="px-3 py-3 text-center text-sm font-medium text-subtext0">
|
||||
{ fmt.Sprint(entry.Position) }
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center gap-2">
|
||||
if entry.Team.Color != "" {
|
||||
<span
|
||||
class="w-3 h-3 rounded-full shrink-0"
|
||||
style={ "background-color: " + templ.SafeCSS(entry.Team.Color) }
|
||||
></span>
|
||||
}
|
||||
<span class="text-sm font-medium text-text">{ entry.Team.Name }</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-subtext0">
|
||||
{ fmt.Sprint(r.Played) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-green">
|
||||
{ fmt.Sprint(r.Wins) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-teal">
|
||||
{ fmt.Sprint(r.OvertimeWins) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-peach">
|
||||
{ fmt.Sprint(r.OvertimeLosses) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-red">
|
||||
{ fmt.Sprint(r.Losses) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-text">
|
||||
{ fmt.Sprint(r.GoalsFor) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm text-text">
|
||||
{ fmt.Sprint(r.GoalsAgainst) }
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm">
|
||||
if goalDiff > 0 {
|
||||
<span class="text-green">{ gdStr }</span>
|
||||
} else if goalDiff < 0 {
|
||||
<span class="text-red">{ gdStr }</span>
|
||||
} else {
|
||||
<span class="text-subtext0">{ gdStr }</span>
|
||||
}
|
||||
</td>
|
||||
<td class="px-3 py-3 text-center text-sm font-bold text-blue">
|
||||
{ fmt.Sprint(r.Points) }
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user