motd-assist/internal/ui/styles.go
Tronax d56659e21a
feat: add motd-assist TUI for managing dynamic MOTDs
Initial Go project built with Bubble Tea and Lip Gloss:
- Live preview and management of /etc/update-motd.d scripts
- Embedded presets (ubuntu-default, minimal, server-dashboard)
- Bundled POSIX sh style scripts (brand header, sysinfo panel, footer)
- Snapshot/restore safety around applying changes
- CLI subcommands preview, apply, restore, list-presets
- Unit tests for detect, sanitize, and apply logic
2026-08-24 14:19:28 +02:00

56 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ui
import "github.com/charmbracelet/lipgloss"
var (
colorAccent = lipgloss.Color("75")
colorBright = lipgloss.Color("81")
colorGood = lipgloss.Color("114")
colorWarn = lipgloss.Color("214")
colorBad = lipgloss.Color("203")
colorDim = lipgloss.Color("244")
colorBorder = lipgloss.Color("240")
focusedTitle = lipgloss.NewStyle().Bold(true).Foreground(colorBright)
dimStyle = lipgloss.NewStyle().Foreground(colorDim)
goodStyle = lipgloss.NewStyle().Foreground(colorGood)
badStyle = lipgloss.NewStyle().Foreground(colorBad)
warnStyle = lipgloss.NewStyle().Foreground(colorWarn)
cursorStyle = lipgloss.NewStyle().Bold(true).Foreground(colorBright)
helpStyle = lipgloss.NewStyle().Foreground(colorDim)
)
// paneBox baut den Rahmen-Stil für ein Pane mit gegebener Außenbreite/-höhe.
// lipgloss zählt Padding zur Breite, den Rahmen nicht daher w-2/h-2.
func paneBox(focused bool, w, h int) lipgloss.Style {
s := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(colorBorder).
PaddingLeft(1).
PaddingRight(1)
if focused {
s = s.BorderForeground(colorAccent)
}
if w > 0 {
s = s.Width(w - 2)
}
if h > 0 {
s = s.Height(h - 2)
}
return s
}
// truncate schneidet s Anzeigebreite auf w und hängt … an.
func truncate(s string, w int) string {
if w <= 0 {
return ""
}
r := []rune(s)
if len(r) <= w {
return s
}
if w == 1 {
return "…"
}
return string(r[:w-1]) + "…"
}