Files
oslstats/internal/view/playersview/player_page.templ

98 lines
3.2 KiB
Plaintext

package playersview
import "git.haelnorr.com/h/oslstats/internal/db"
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
import "fmt"
templ PlayerLayout(activeSection string, player *db.Player, isOwner bool) {
@baseview.Layout(player.DisplayName() + " - Player Profile") {
<div class="max-w-screen-2xl mx-auto px-4 py-8">
<div class="bg-mantle border border-surface1 rounded-lg overflow-hidden">
<!-- Header -->
<div class="bg-surface0 border-b border-surface1 px-6 py-8">
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center gap-3 mb-2">
<h1 class="text-4xl font-bold text-text">{ player.DisplayName() }</h1>
if isOwner {
<span class="px-2 py-0.5 bg-blue/20 text-blue rounded text-xs font-medium">
Your Profile
</span>
}
</div>
<div class="flex items-center gap-2 flex-wrap">
if player.SlapID != nil {
<span class="px-2 py-1 bg-mantle rounded text-subtext0 font-mono text-sm">
Slapshot ID: { fmt.Sprintf("%d", *player.SlapID) }
</span>
}
</div>
</div>
</div>
</div>
<!-- SlapID Link Prompt (if needed) -->
if player.SlapID == nil && isOwner {
<div class="px-6 pt-6">
@SlapIDSection(player, isOwner)
</div>
}
<!-- Tab Navigation -->
<nav class="bg-surface0 border-b border-surface1" data-tab-nav="player-content">
<ul class="flex flex-wrap">
@playerNavItem("stats", "Stats", activeSection, player)
@playerNavItem("teams", "Teams", activeSection, player)
@playerNavItem("seasons", "Seasons", activeSection, player)
</ul>
</nav>
<!-- Content Area -->
<main class="bg-crust p-6" id="player-content">
{ children... }
</main>
</div>
</div>
<script src="/static/js/tabs.js" defer></script>
}
}
templ playerNavItem(section string, label string, activeSection string, player *db.Player) {
{{
isActive := section == activeSection
baseClasses := "inline-block px-6 py-3 transition-colors cursor-pointer border-b-2"
activeClasses := "border-blue text-blue font-semibold"
inactiveClasses := "border-transparent text-subtext0 hover:text-text hover:border-surface2"
url := fmt.Sprintf("/players/%d/%s", player.ID, section)
}}
<li class="inline-block">
<a
href={ templ.SafeURL(url) }
hx-post={ url }
hx-target="#player-content"
hx-swap="innerHTML"
hx-push-url={ url }
class={ baseClasses, templ.KV(activeClasses, isActive), templ.KV(inactiveClasses, !isActive) }
>
{ label }
</a>
</li>
}
// Full page wrappers (for GET requests / direct navigation)
templ PlayerStatsPage(player *db.Player, isOwner bool, stats *db.PlayerAllTimeStats, seasons []*db.Season, teams []*db.Team) {
@PlayerLayout("stats", player, isOwner) {
@PlayerStatsTab(player, stats, seasons, teams, "", 0)
}
}
templ PlayerTeamsPage(player *db.Player, isOwner bool, teamInfos []*db.PlayerTeamInfo) {
@PlayerLayout("teams", player, isOwner) {
@PlayerTeamsTab(teamInfos)
}
}
templ PlayerSeasonsPage(player *db.Player, isOwner bool, seasonInfos []*db.PlayerSeasonInfo) {
@PlayerLayout("seasons", player, isOwner) {
@PlayerSeasonsTab(seasonInfos)
}
}