summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/layout
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-04-28 08:46:09 -0500
committeradamdottv <[email protected]>2025-04-30 07:46:34 -0500
commit61b605e724eb4cc50ab831534fcdd18e031d68eb (patch)
treeb15b074a8fed1931e179a8d3df08d05b753c7aa3 /internal/tui/layout
parent61d9dc95111d2645a49816f6d9d6cc1014be1a22 (diff)
downloadopencode-61b605e724eb4cc50ab831534fcdd18e031d68eb.tar.gz
opencode-61b605e724eb4cc50ab831534fcdd18e031d68eb.zip
feat: themes
Diffstat (limited to 'internal/tui/layout')
-rw-r--r--internal/tui/layout/container.go37
-rw-r--r--internal/tui/layout/overlay.go10
-rw-r--r--internal/tui/layout/split.go22
3 files changed, 23 insertions, 46 deletions
diff --git a/internal/tui/layout/container.go b/internal/tui/layout/container.go
index b92df5bb8..83aef5879 100644
--- a/internal/tui/layout/container.go
+++ b/internal/tui/layout/container.go
@@ -4,7 +4,7 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
- "github.com/opencode-ai/opencode/internal/tui/styles"
+ "github.com/opencode-ai/opencode/internal/tui/theme"
)
type Container interface {
@@ -29,9 +29,6 @@ type container struct {
borderBottom bool
borderLeft bool
borderStyle lipgloss.Border
- borderColor lipgloss.TerminalColor
-
- backgroundColor lipgloss.TerminalColor
}
func (c *container) Init() tea.Cmd {
@@ -45,13 +42,12 @@ func (c *container) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (c *container) View() string {
+ t := theme.CurrentTheme()
style := lipgloss.NewStyle()
width := c.width
height := c.height
- // Apply background color if specified
- if c.backgroundColor != nil {
- style = style.Background(c.backgroundColor)
- }
+
+ style = style.Background(t.Background())
// Apply border if any side is enabled
if c.borderTop || c.borderRight || c.borderBottom || c.borderLeft {
@@ -69,11 +65,7 @@ func (c *container) View() string {
width--
}
style = style.Border(c.borderStyle, c.borderTop, c.borderRight, c.borderBottom, c.borderLeft)
-
- // Apply border color if specified
- if c.borderColor != nil {
- style = style.BorderBackground(c.backgroundColor).BorderForeground(c.borderColor)
- }
+ style = style.BorderBackground(t.Background()).BorderForeground(t.BorderNormal())
}
style = style.
Width(width).
@@ -132,11 +124,10 @@ func (c *container) BindingKeys() []key.Binding {
type ContainerOption func(*container)
func NewContainer(content tea.Model, options ...ContainerOption) Container {
+
c := &container{
- content: content,
- borderColor: styles.BorderColor,
- borderStyle: lipgloss.NormalBorder(),
- backgroundColor: styles.Background,
+ content: content,
+ borderStyle: lipgloss.NormalBorder(),
}
for _, option := range options {
@@ -201,12 +192,6 @@ func WithBorderStyle(style lipgloss.Border) ContainerOption {
}
}
-func WithBorderColor(color lipgloss.TerminalColor) ContainerOption {
- return func(c *container) {
- c.borderColor = color
- }
-}
-
func WithRoundedBorder() ContainerOption {
return WithBorderStyle(lipgloss.RoundedBorder())
}
@@ -218,9 +203,3 @@ func WithThickBorder() ContainerOption {
func WithDoubleBorder() ContainerOption {
return WithBorderStyle(lipgloss.DoubleBorder())
}
-
-func WithBackgroundColor(color lipgloss.TerminalColor) ContainerOption {
- return func(c *container) {
- c.backgroundColor = color
- }
-}
diff --git a/internal/tui/layout/overlay.go b/internal/tui/layout/overlay.go
index 379747e69..3a14dbc5e 100644
--- a/internal/tui/layout/overlay.go
+++ b/internal/tui/layout/overlay.go
@@ -9,6 +9,7 @@ import (
"github.com/muesli/reflow/truncate"
"github.com/muesli/termenv"
"github.com/opencode-ai/opencode/internal/tui/styles"
+ "github.com/opencode-ai/opencode/internal/tui/theme"
"github.com/opencode-ai/opencode/internal/tui/util"
)
@@ -43,12 +44,15 @@ func PlaceOverlay(
fgHeight := len(fgLines)
if shadow {
+ t := theme.CurrentTheme()
+ baseStyle := styles.BaseStyle()
+
var shadowbg string = ""
shadowchar := lipgloss.NewStyle().
- Background(styles.BackgroundDarker).
- Foreground(styles.Background).
+ Background(t.BackgroundDarker()).
+ Foreground(t.Background()).
Render("░")
- bgchar := styles.BaseStyle.Render(" ")
+ bgchar := baseStyle.Render(" ")
for i := 0; i <= fgHeight; i++ {
if i == 0 {
shadowbg += bgchar + strings.Repeat(bgchar, fgWidth) + "\n"
diff --git a/internal/tui/layout/split.go b/internal/tui/layout/split.go
index 6763e408c..2684a8447 100644
--- a/internal/tui/layout/split.go
+++ b/internal/tui/layout/split.go
@@ -4,7 +4,7 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
- "github.com/opencode-ai/opencode/internal/tui/styles"
+ "github.com/opencode-ai/opencode/internal/tui/theme"
)
type SplitPaneLayout interface {
@@ -29,8 +29,6 @@ type splitPaneLayout struct {
rightPanel Container
leftPanel Container
bottomPanel Container
-
- backgroundColor lipgloss.TerminalColor
}
type SplitPaneOption func(*splitPaneLayout)
@@ -113,11 +111,13 @@ func (s *splitPaneLayout) View() string {
finalView = topSection
}
- if s.backgroundColor != nil && finalView != "" {
+ if finalView != "" {
+ t := theme.CurrentTheme()
+
style := lipgloss.NewStyle().
Width(s.width).
Height(s.height).
- Background(s.backgroundColor)
+ Background(t.Background())
return style.Render(finalView)
}
@@ -241,10 +241,10 @@ func (s *splitPaneLayout) BindingKeys() []key.Binding {
}
func NewSplitPane(options ...SplitPaneOption) SplitPaneLayout {
+
layout := &splitPaneLayout{
- ratio: 0.7,
- verticalRatio: 0.9, // Default 80% for top section, 20% for bottom
- backgroundColor: styles.Background,
+ ratio: 0.7,
+ verticalRatio: 0.9, // Default 90% for top section, 10% for bottom
}
for _, option := range options {
option(layout)
@@ -270,12 +270,6 @@ func WithRatio(ratio float64) SplitPaneOption {
}
}
-func WithSplitBackgroundColor(color lipgloss.TerminalColor) SplitPaneOption {
- return func(s *splitPaneLayout) {
- s.backgroundColor = color
- }
-}
-
func WithBottomPanel(panel Container) SplitPaneOption {
return func(s *splitPaneLayout) {
s.bottomPanel = panel