use ilovetui colors & styles

This commit is contained in:
Hadi
2026-05-26 16:12:10 +02:00
parent 0b395e018a
commit aa458c142f
37 changed files with 295 additions and 686 deletions
+8 -10
View File
@@ -4,7 +4,7 @@ import (
"charm.land/bubbles/v2/list"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/spilltea/internal/style"
ilovetui "github.com/anotherhadi/ilovetui"
)
const (
@@ -48,20 +48,18 @@ type Model struct {
}
func New() Model {
s := style.S
delegate := list.NewDefaultDelegate()
delegate.SetSpacing(0)
delegate.Styles.NormalTitle = lipgloss.NewStyle().Foreground(s.Text).PaddingLeft(2)
delegate.Styles.NormalDesc = lipgloss.NewStyle().Foreground(s.Subtle).PaddingLeft(2)
delegate.Styles.NormalTitle = lipgloss.NewStyle().Foreground(ilovetui.S.Text).PaddingLeft(2)
delegate.Styles.NormalDesc = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle).PaddingLeft(2)
delegate.Styles.SelectedTitle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(s.Primary).
Foreground(s.Primary).Bold(true).PaddingLeft(1)
BorderForeground(ilovetui.S.Primary).
Foreground(ilovetui.S.Primary).Bold(true).PaddingLeft(1)
delegate.Styles.SelectedDesc = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(s.Primary).
Foreground(s.MutedFg).PaddingLeft(1)
BorderForeground(ilovetui.S.Primary).
Foreground(ilovetui.S.Muted).PaddingLeft(1)
l := list.New(allFormats, delegate, popupW, 8)
l.SetShowTitle(false)
@@ -116,5 +114,5 @@ func (m Model) popupHeight() int {
// listHeight = panel content area - hint line (1)
func (m Model) listHeight() int {
return style.PanelContentH(m.popupHeight()) - 1
return ilovetui.ContentHeight(m.popupHeight()) - 1
}
+5 -9
View File
@@ -4,14 +4,12 @@ import (
"strings"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/spilltea/internal/style"
ilovetui "github.com/anotherhadi/ilovetui"
"github.com/charmbracelet/x/ansi"
)
func (m *Model) View(background string) string {
s := style.S
hint := lipgloss.NewStyle().Foreground(s.Subtle).
hint := lipgloss.NewStyle().Foreground(ilovetui.S.Subtle).
Render(" enter: copy • /: filter • esc: cancel")
inner := lipgloss.JoinVertical(lipgloss.Left,
@@ -21,17 +19,15 @@ func (m *Model) View(background string) string {
border := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(s.Primary)
BorderForeground(ilovetui.S.Primary)
popupH := m.popupHeight()
popup := style.RenderWithTitle(border, "Copy as", inner, m.popupInnerWidth()+2, popupH)
popup := ilovetui.RenderWithTitle(border, "Copy as", inner, m.popupInnerWidth()+2, popupH)
return OverlayCenter(background, popup, m.width, m.height)
}
func OverlayCenter(bg, popup string, w, h int) string {
s := style.S
stripped := ansi.Strip(bg)
rawLines := strings.Split(stripped, "\n")
bgRunes := make([][]rune, h)
@@ -67,7 +63,7 @@ func OverlayCenter(bg, popup string, w, h int) string {
startX = 0
}
dim := lipgloss.NewStyle().Foreground(s.Subtle).Faint(true)
dim := lipgloss.NewStyle().Foreground(ilovetui.S.Subtle).Faint(true)
result := make([]string, h)
for y := 0; y < h; y++ {