fix(tui): find dialog bg color

This commit is contained in:
adamdotdevin 2025-07-14 09:09:46 -05:00
parent 8d0350d923
commit 229a280652
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
3 changed files with 31 additions and 9 deletions

View file

@ -54,7 +54,9 @@ func (cg *filesContextGroup) getGitFiles() []dialog.CompletionItemI {
Value: file.Path,
ProviderID: cg.GetId(),
Raw: file,
})
},
dialog.WithBackgroundColor(t.BackgroundPanel()),
)
items = append(items, item)
}
}
@ -100,7 +102,9 @@ func (cg *filesContextGroup) GetChildEntries(
Value: file,
ProviderID: cg.GetId(),
Raw: file,
})
},
dialog.WithBackgroundColor(theme.CurrentTheme().BackgroundPanel()),
)
items = append(items, item)
}
}

View file

@ -9,6 +9,7 @@ import (
"github.com/charmbracelet/bubbles/v2/textarea"
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/lipgloss/v2/compat"
"github.com/lithammer/fuzzysearch/fuzzy"
"github.com/muesli/reflow/truncate"
"github.com/sst/opencode/internal/components/list"
@ -18,10 +19,11 @@ import (
)
type CompletionItem struct {
Title string
Value string
ProviderID string
Raw any
Title string
Value string
ProviderID string
Raw any
backgroundColor *compat.AdaptiveColor
}
type CompletionItemI interface {
@ -38,8 +40,13 @@ func (ci *CompletionItem) Render(selected bool, width int) string {
truncatedStr := truncate.String(string(ci.DisplayValue()), uint(width-4))
backgroundColor := t.BackgroundElement()
if ci.backgroundColor != nil {
backgroundColor = *ci.backgroundColor
}
itemStyle := baseStyle.
Background(t.BackgroundElement()).
Background(backgroundColor).
Padding(0, 1)
if selected {
@ -66,7 +73,18 @@ func (ci *CompletionItem) GetRaw() any {
return ci.Raw
}
func NewCompletionItem(completionItem CompletionItem) CompletionItemI {
type CompletionItemOption func(*CompletionItem)
func WithBackgroundColor(color compat.AdaptiveColor) CompletionItemOption {
return func(ci *CompletionItem) {
ci.backgroundColor = &color
}
}
func NewCompletionItem(completionItem CompletionItem, opts ...CompletionItemOption) CompletionItemI {
for _, opt := range opts {
opt(&completionItem)
}
return &completionItem
}

View file

@ -133,7 +133,7 @@ func (f *findDialogComponent) View() string {
listView := f.list.View()
return styles.NewStyle().
Height(12).
Background(t.BackgroundElement()).
Background(t.BackgroundPanel()).
Width(f.width - 4).
Render(inputView + "\n" + listView)
}