Soften TUI surfaces, typography and loading indicators

This commit is contained in:
2026-10-09 21:03:39 +01:00
parent dd50344170
commit dc9b7b1c02
16 changed files with 221 additions and 65 deletions
+32 -12
View File
@@ -6,16 +6,36 @@ import (
"github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/lipgloss"
"sort"
"strings"
)
// ANSI colors refer to the terminal's configured palette, not fixed RGB values.
// Unset backgrounds/foregrounds retain terminal defaults for light/dark themes.
// Nested ANSI styles reset their backgrounds when they end. Restore the card's
// base style after those resets, so colored labels don't leave terminal-colored
// holes in an otherwise continuous surface. Plain/no-color output is unchanged.
func surfaceContent(text string, background lipgloss.TerminalColor) string {
paint := lipgloss.NewStyle().Foreground(themeText).Background(background).Render(" ")
open := paint[:strings.IndexByte(paint, ' ')]
if open == "" {
return text
}
for _, reset := range []string{"\x1b[0m", "\x1b[m"} {
text = strings.ReplaceAll(text, reset, reset+open)
}
return text
}
// Semantic accents use the terminal palette. Surfaces adapt to light/dark
// terminals and are automatically reduced on terminals with fewer colors.
var (
themeAccent = lipgloss.Color("6")
themePrimary = lipgloss.Color("4")
themeMuted = lipgloss.Color("8")
themeSuccess = lipgloss.Color("2")
themeError = lipgloss.Color("1")
themeAccent = lipgloss.Color("6")
themePrimary = lipgloss.Color("4")
themeMuted = lipgloss.Color("8")
themeSuccess = lipgloss.Color("2")
themeError = lipgloss.Color("1")
themeSurface = lipgloss.AdaptiveColor{Light: "#F3F4F7", Dark: "#1D2129"}
themeElevated = lipgloss.AdaptiveColor{Light: "#EAEDF3", Dark: "#252B35"}
themeSelection = lipgloss.AdaptiveColor{Light: "#DCE7F5", Dark: "#2B3A4C"}
themeText = lipgloss.AdaptiveColor{Light: "#303744", Dark: "#D9DEE7"}
)
// Names keep their colors when stages are reordered or another version is opened.
@@ -100,7 +120,7 @@ func stageTitle(key, label string, selected bool, graphs ...protocol.Graph) stri
color := stageColor(key, graphs...)
s := lipgloss.NewStyle().Foreground(color).Bold(true)
if selected {
s = s.Foreground(lipgloss.Color("0")).Background(color)
s = s.Background(themeSelection)
}
return s.Render(label)
}
@@ -108,7 +128,7 @@ func stageTitle(key, label string, selected bool, graphs ...protocol.Graph) stri
func stageTab(key, label string, selected bool, graphs ...protocol.Graph) string {
s := lipgloss.NewStyle().Foreground(stageColor(key, graphs...)).Bold(true)
if selected {
s = s.Reverse(true).Underline(true)
s = s.Background(themeSelection).Underline(true)
}
return s.Render(label)
}
@@ -118,9 +138,9 @@ func outcomeLabel(outcome, label string) string {
}
func action(label string, selected bool) string {
s := lipgloss.NewStyle().Foreground(themeAccent).Bold(true)
s := lipgloss.NewStyle().Foreground(themeMuted)
if selected {
s = s.Foreground(themePrimary).Reverse(true)
s = s.Foreground(themeAccent).Background(themeSelection).Bold(true)
}
return s.Render(" " + label + " ")
}
@@ -128,7 +148,7 @@ func action(label string, selected bool) string {
func menuOption(label string, selected bool) string {
s := lipgloss.NewStyle()
if selected {
s = s.Foreground(themePrimary).Bold(true).Reverse(true)
s = s.Foreground(themeAccent).Background(themeSelection).Bold(true)
}
return s.Render(label)
}