updated seasons list
This commit is contained in:
71
internal/view/component/season/status.templ
Normal file
71
internal/view/component/season/status.templ
Normal file
@@ -0,0 +1,71 @@
|
||||
package season
|
||||
|
||||
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>
|
||||
}
|
||||
Reference in New Issue
Block a user