Przeglądaj źródła

fix(tui): find dialog bg color

adamdotdevin 7 miesięcy temu
rodzic
commit
229a280652

+ 6 - 2
packages/tui/internal/completions/files.go

@@ -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)
 		}
 	}

+ 24 - 6
packages/tui/internal/components/dialog/complete.go

@@ -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
 }
 

+ 1 - 1
packages/tui/internal/components/dialog/find.go

@@ -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)
 }