diff --git a/cmd/tables/tableUtil.go b/cmd/tables/tableUtil.go index 0f4f06b..5411876 100644 --- a/cmd/tables/tableUtil.go +++ b/cmd/tables/tableUtil.go @@ -2,6 +2,7 @@ package table import ( "fmt" + "github.com/charmbracelet/lipgloss" "time" ) @@ -12,6 +13,26 @@ const ( tableHeight = 10 ) +var ( + lowOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("2")) // green + mediumOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("214")) // orange + highOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("9")) // red + unknownOccupancyStyle = lipgloss.NewStyle().Italic(true).Faint(true).Italic(true) +) + +func styleOccupancy(s string) string { + switch s { + case "low": + return lowOccupancyStyle.Render(s) + case "medium": + return mediumOccupancyStyle.Render(s) + case "high": + return highOccupancyStyle.Render(s) + default: + return unknownOccupancyStyle.Render(s) + } +} + // CalculateHumanRelativeTime used for calucating human-readable "from now" time. E.g 'in 20 minutes' func CalculateHumanRelativeTime(departureTime string) string { now := time.Now() diff --git a/cmd/tables/timetableTable.go b/cmd/tables/timetableTable.go index ee1b96a..ba822b9 100644 --- a/cmd/tables/timetableTable.go +++ b/cmd/tables/timetableTable.go @@ -11,26 +11,6 @@ import ( "github.com/charmbracelet/lipgloss" ) -var ( - lowOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("2")) // green - mediumOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("214")) // orange - highOccupancyStyle = lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("9")) // red - unknownOccupancyStyle = lipgloss.NewStyle().Italic(true).Faint(true).Italic(true) -) - -func styleOccupancy(s string) string { - switch s { - case "low": - return lowOccupancyStyle.Render(s) - case "medium": - return mediumOccupancyStyle.Render(s) - case "high": - return highOccupancyStyle.Render(s) - default: - return unknownOccupancyStyle.Render(s) - } -} - type timetableTableModel struct { table table.Model selectedDetails string