182 lines
4.2 KiB
Go
182 lines
4.2 KiB
Go
package style
|
||
|
||
import "github.com/charmbracelet/lipgloss"
|
||
|
||
// Palette
|
||
const (
|
||
ColorSky = lipgloss.Color("#00BFFF")
|
||
ColorRunway = lipgloss.Color("#4A4A4A")
|
||
ColorGold = lipgloss.Color("#FFD700")
|
||
ColorGreen = lipgloss.Color("#39D353")
|
||
ColorRed = lipgloss.Color("#FF4444")
|
||
ColorMuted = lipgloss.Color("#626262")
|
||
ColorWhite = lipgloss.Color("#F5F5F5")
|
||
ColorDark = lipgloss.Color("#1A1A2E")
|
||
ColorPanel = lipgloss.Color("#16213E")
|
||
ColorHighlight = lipgloss.Color("#0F3460")
|
||
ColorAccent = lipgloss.Color("#E94560")
|
||
ColorFuel = lipgloss.Color("#FF8C00")
|
||
ColorPassenger = lipgloss.Color("#7EC8E3")
|
||
ColorCash = lipgloss.Color("#FFD700")
|
||
)
|
||
|
||
// Base Styles
|
||
var (
|
||
Bold = lipgloss.NewStyle().Bold(true)
|
||
|
||
Title = lipgloss.NewStyle().
|
||
Bold(true).
|
||
Foreground(ColorSky).
|
||
BorderStyle(lipgloss.DoubleBorder()).
|
||
BorderForeground(ColorSky).
|
||
Padding(0, 2).
|
||
Align(lipgloss.Center)
|
||
|
||
Subtitle = lipgloss.NewStyle().
|
||
Foreground(ColorMuted).
|
||
Italic(true)
|
||
|
||
// Panels
|
||
Panel = lipgloss.NewStyle().
|
||
Border(lipgloss.RoundedBorder()).
|
||
BorderForeground(ColorHighlight).
|
||
Padding(0, 1)
|
||
|
||
PanelFocused = lipgloss.NewStyle().
|
||
Border(lipgloss.RoundedBorder()).
|
||
BorderForeground(ColorSky).
|
||
Padding(0, 1)
|
||
|
||
PanelHeader = lipgloss.NewStyle().
|
||
Bold(true).
|
||
Foreground(ColorSky).
|
||
BorderStyle(lipgloss.NormalBorder()).
|
||
BorderBottom(true).
|
||
BorderForeground(ColorHighlight).
|
||
MarginBottom(1)
|
||
|
||
// Status bar
|
||
StatusBar = lipgloss.NewStyle().
|
||
Background(ColorHighlight).
|
||
Foreground(ColorWhite).
|
||
Padding(0, 1)
|
||
|
||
StatusBarKey = lipgloss.NewStyle().
|
||
Background(ColorAccent).
|
||
Foreground(ColorWhite).
|
||
Padding(0, 1).
|
||
Bold(true)
|
||
|
||
// Resource chips
|
||
FuelChip = lipgloss.NewStyle().
|
||
Foreground(ColorFuel).
|
||
Bold(true)
|
||
|
||
PassengerChip = lipgloss.NewStyle().
|
||
Foreground(ColorPassenger).
|
||
Bold(true)
|
||
|
||
CashChip = lipgloss.NewStyle().
|
||
Foreground(ColorCash).
|
||
Bold(true)
|
||
|
||
// Menu / list items
|
||
MenuItem = lipgloss.NewStyle().
|
||
Foreground(ColorWhite).
|
||
PaddingLeft(2)
|
||
|
||
MenuItemSelected = lipgloss.NewStyle().
|
||
Foreground(ColorSky).
|
||
Bold(true).
|
||
PaddingLeft(1).
|
||
SetString("> ")
|
||
|
||
// Plane status colors
|
||
StatusIdle = lipgloss.NewStyle().Foreground(ColorGreen)
|
||
StatusFly = lipgloss.NewStyle().Foreground(ColorSky)
|
||
StatusMaint = lipgloss.NewStyle().Foreground(ColorGold)
|
||
StatusBoard = lipgloss.NewStyle().Foreground(ColorPassenger)
|
||
StatusTaxi = lipgloss.NewStyle().Foreground(ColorFuel)
|
||
|
||
// Table
|
||
TableHeader = lipgloss.NewStyle().
|
||
Bold(true).
|
||
Foreground(ColorSky).
|
||
BorderStyle(lipgloss.NormalBorder()).
|
||
BorderBottom(true).
|
||
BorderForeground(ColorMuted)
|
||
|
||
TableRow = lipgloss.NewStyle().Foreground(ColorWhite)
|
||
|
||
TableRowAlt = lipgloss.NewStyle().
|
||
Foreground(ColorWhite).
|
||
Background(lipgloss.Color("#0D1B2A"))
|
||
|
||
// Alerts
|
||
Success = lipgloss.NewStyle().
|
||
Foreground(ColorGreen).
|
||
Bold(true).
|
||
SetString("✓ ")
|
||
|
||
Error = lipgloss.NewStyle().
|
||
Foreground(ColorRed).
|
||
Bold(true).
|
||
SetString("✗ ")
|
||
|
||
Warning = lipgloss.NewStyle().
|
||
Foreground(ColorGold).
|
||
Bold(true).
|
||
SetString("⚠ ")
|
||
|
||
Info = lipgloss.NewStyle().
|
||
Foreground(ColorSky).
|
||
Bold(true).
|
||
SetString("ℹ ")
|
||
|
||
// Help text
|
||
HelpKey = lipgloss.NewStyle().Foreground(ColorSky).Bold(true)
|
||
HelpDesc = lipgloss.NewStyle().Foreground(ColorMuted)
|
||
|
||
// Muted / dimmed
|
||
Muted = lipgloss.NewStyle().Foreground(ColorMuted)
|
||
)
|
||
|
||
// Plane status badge
|
||
func PlaneStatusStyle(status string) lipgloss.Style {
|
||
switch status {
|
||
case "idle":
|
||
return StatusIdle
|
||
case "flying":
|
||
return StatusFly
|
||
case "maintenance":
|
||
return StatusMaint
|
||
case "boarding":
|
||
return StatusBoard
|
||
case "taxiing":
|
||
return StatusTaxi
|
||
default:
|
||
return Muted
|
||
}
|
||
}
|
||
|
||
// Resource bar (e.g. fuel/passenger capacity)
|
||
func ResourceBar(current, max int, width int, color lipgloss.Color) string {
|
||
if max == 0 {
|
||
return ""
|
||
}
|
||
filled := (current * width) / max
|
||
if filled > width {
|
||
filled = width
|
||
}
|
||
bar := lipgloss.NewStyle().Foreground(color).Render(repeat("█", filled)) +
|
||
lipgloss.NewStyle().Foreground(ColorMuted).Render(repeat("░", width-filled))
|
||
return bar
|
||
}
|
||
|
||
func repeat(s string, n int) string {
|
||
result := ""
|
||
for i := 0; i < n; i++ {
|
||
result += s
|
||
}
|
||
return result
|
||
}
|