diff options
| author | adamdottv <[email protected]> | 2025-04-28 08:46:09 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-04-30 07:46:34 -0500 |
| commit | 61b605e724eb4cc50ab831534fcdd18e031d68eb (patch) | |
| tree | b15b074a8fed1931e179a8d3df08d05b753c7aa3 /internal/tui/components/logs | |
| parent | 61d9dc95111d2645a49816f6d9d6cc1014be1a22 (diff) | |
| download | opencode-61b605e724eb4cc50ab831534fcdd18e031d68eb.tar.gz opencode-61b605e724eb4cc50ab831534fcdd18e031d68eb.zip | |
feat: themes
Diffstat (limited to 'internal/tui/components/logs')
| -rw-r--r-- | internal/tui/components/logs/details.go | 28 | ||||
| -rw-r--r-- | internal/tui/components/logs/table.go | 7 |
2 files changed, 21 insertions, 14 deletions
diff --git a/internal/tui/components/logs/details.go b/internal/tui/components/logs/details.go index 8aaa7a41c..9d7713bbf 100644 --- a/internal/tui/components/logs/details.go +++ b/internal/tui/components/logs/details.go @@ -12,6 +12,7 @@ import ( "github.com/opencode-ai/opencode/internal/logging" "github.com/opencode-ai/opencode/internal/tui/layout" "github.com/opencode-ai/opencode/internal/tui/styles" + "github.com/opencode-ai/opencode/internal/tui/theme" ) type DetailComponent interface { @@ -49,9 +50,10 @@ func (i *detailCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (i *detailCmp) updateContent() { var content strings.Builder + t := theme.CurrentTheme() // Format the header with timestamp and level - timeStyle := lipgloss.NewStyle().Foreground(styles.SubText0) + timeStyle := lipgloss.NewStyle().Foreground(t.TextMuted()) levelStyle := getLevelStyle(i.currentLog.Level) header := lipgloss.JoinHorizontal( @@ -65,7 +67,7 @@ func (i *detailCmp) updateContent() { content.WriteString("\n\n") // Message with styling - messageStyle := lipgloss.NewStyle().Bold(true).Foreground(styles.Text) + messageStyle := lipgloss.NewStyle().Bold(true).Foreground(t.Text()) content.WriteString(messageStyle.Render("Message:")) content.WriteString("\n") content.WriteString(lipgloss.NewStyle().Padding(0, 2).Render(i.currentLog.Message)) @@ -73,13 +75,13 @@ func (i *detailCmp) updateContent() { // Attributes section if len(i.currentLog.Attributes) > 0 { - attrHeaderStyle := lipgloss.NewStyle().Bold(true).Foreground(styles.Text) + attrHeaderStyle := lipgloss.NewStyle().Bold(true).Foreground(t.Text()) content.WriteString(attrHeaderStyle.Render("Attributes:")) content.WriteString("\n") // Create a table-like display for attributes - keyStyle := lipgloss.NewStyle().Foreground(styles.Primary).Bold(true) - valueStyle := lipgloss.NewStyle().Foreground(styles.Text) + keyStyle := lipgloss.NewStyle().Foreground(t.Primary()).Bold(true) + valueStyle := lipgloss.NewStyle().Foreground(t.Text()) for _, attr := range i.currentLog.Attributes { attrLine := fmt.Sprintf("%s: %s", @@ -96,23 +98,25 @@ func (i *detailCmp) updateContent() { func getLevelStyle(level string) lipgloss.Style { style := lipgloss.NewStyle().Bold(true) - + t := theme.CurrentTheme() + switch strings.ToLower(level) { case "info": - return style.Foreground(styles.Blue) + return style.Foreground(t.Info()) case "warn", "warning": - return style.Foreground(styles.Warning) + return style.Foreground(t.Warning()) case "error", "err": - return style.Foreground(styles.Error) + return style.Foreground(t.Error()) case "debug": - return style.Foreground(styles.Green) + return style.Foreground(t.Success()) default: - return style.Foreground(styles.Text) + return style.Foreground(t.Text()) } } func (i *detailCmp) View() string { - return styles.ForceReplaceBackgroundWithLipgloss(i.viewport.View(), styles.Background) + t := theme.CurrentTheme() + return styles.ForceReplaceBackgroundWithLipgloss(i.viewport.View(), t.Background()) } func (i *detailCmp) GetSize() (int, int) { diff --git a/internal/tui/components/logs/table.go b/internal/tui/components/logs/table.go index bffa7b1ad..b9386cb73 100644 --- a/internal/tui/components/logs/table.go +++ b/internal/tui/components/logs/table.go @@ -11,6 +11,7 @@ import ( "github.com/opencode-ai/opencode/internal/pubsub" "github.com/opencode-ai/opencode/internal/tui/layout" "github.com/opencode-ai/opencode/internal/tui/styles" + "github.com/opencode-ai/opencode/internal/tui/theme" "github.com/opencode-ai/opencode/internal/tui/util" ) @@ -61,7 +62,8 @@ func (i *tableCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (i *tableCmp) View() string { - return styles.ForceReplaceBackgroundWithLipgloss(i.table.View(), styles.Background) + t := theme.CurrentTheme() + return styles.ForceReplaceBackgroundWithLipgloss(i.table.View(), t.Background()) } func (i *tableCmp) GetSize() (int, int) { @@ -114,6 +116,7 @@ func (i *tableCmp) setRows() { } func NewLogsTable() TableComponent { + t := theme.CurrentTheme() columns := []table.Column{ {Title: "ID", Width: 4}, {Title: "Time", Width: 4}, @@ -122,7 +125,7 @@ func NewLogsTable() TableComponent { {Title: "Attributes", Width: 10}, } defaultStyles := table.DefaultStyles() - defaultStyles.Selected = defaultStyles.Selected.Foreground(styles.Primary) + defaultStyles.Selected = defaultStyles.Selected.Foreground(t.Primary()) tableModel := table.New( table.WithColumns(columns), table.WithStyles(defaultStyles), |
