72 lines
2.0 KiB
Plaintext
72 lines
2.0 KiB
Plaintext
package seasonsview
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/db"
|
|
import "time"
|
|
|
|
// StatusBadge renders a season status badge
|
|
// Parameters:
|
|
// - season: pointer to db.Season
|
|
// - compact: bool - true for list view (text only, small), false for detail view (icon + text, large)
|
|
// - useShortLabels: bool - true for "Active/Finals", false for "In Progress/Finals in Progress"
|
|
templ StatusBadge(season *db.Season, compact bool, useShortLabels bool) {
|
|
{{
|
|
now := time.Now()
|
|
status := ""
|
|
statusColor := ""
|
|
statusBg := ""
|
|
|
|
// Determine status based on dates
|
|
if now.Before(season.StartDate) {
|
|
status = "Upcoming"
|
|
statusColor = "text-blue"
|
|
statusBg = "bg-blue/10 border-blue"
|
|
} else if !season.EndDate.IsZero() && now.After(season.EndDate.Time) {
|
|
status = "Completed"
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
} else if !season.FinalsStartDate.IsZero() && now.After(season.FinalsStartDate.Time) {
|
|
if !season.FinalsEndDate.IsZero() && now.After(season.FinalsEndDate.Time) {
|
|
status = "Completed"
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
} else {
|
|
if useShortLabels {
|
|
status = "Finals"
|
|
} else {
|
|
status = "Finals in Progress"
|
|
}
|
|
statusColor = "text-yellow"
|
|
statusBg = "bg-yellow/10 border-yellow"
|
|
}
|
|
} else {
|
|
if useShortLabels {
|
|
status = "Active"
|
|
} else {
|
|
status = "In Progress"
|
|
}
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
}
|
|
|
|
// Determine size classes
|
|
var sizeClasses string
|
|
var textSize string
|
|
var iconSize string
|
|
if compact {
|
|
sizeClasses = "px-2 py-1"
|
|
textSize = "text-xs"
|
|
iconSize = "text-sm"
|
|
} else {
|
|
sizeClasses = "px-4 py-2"
|
|
textSize = "text-lg"
|
|
iconSize = "text-2xl"
|
|
}
|
|
}}
|
|
<div class={ "rounded-lg border-2 inline-flex items-center gap-2 " + sizeClasses + " " + statusBg }>
|
|
if !compact {
|
|
<span class={ iconSize + " " + statusColor }>●</span>
|
|
}
|
|
<span class={ textSize + " font-semibold " + statusColor }>{ status }</span>
|
|
</div>
|
|
}
|