feat: improve modal button highlighting with green background

Replace the reverse video style with a green background and black text for activated buttons. This uses theme.SuccessColor for consistency with the app design and ensures the selected button is clearly visible across different terminal themes with bold text.
This commit is contained in:
Vito Castellano 2025-11-23 01:06:01 +01:00
commit 2873fe61b2
No known key found for this signature in database
GPG key ID: E13085DB38BC5819
3 changed files with 82 additions and 16 deletions

View file

@ -2,6 +2,8 @@ package components
import (
"bbrew/internal/ui/theme"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
@ -11,11 +13,19 @@ type Modal struct {
}
func NewModal(theme *theme.Theme) *Modal {
// Use green background with black text for activated button
// Black text ensures consistent visibility across all terminal themes
activatedStyle := tcell.StyleDefault.
Background(theme.SuccessColor).
Foreground(tcell.ColorBlack).
Bold(true)
modal := tview.NewModal().
SetBackgroundColor(theme.ModalBgColor).
SetTextColor(theme.DefaultTextColor).
SetButtonBackgroundColor(theme.ButtonBgColor).
SetButtonTextColor(theme.ButtonTextColor)
SetButtonTextColor(theme.ButtonTextColor).
SetButtonActivatedStyle(activatedStyle)
return &Modal{
view: modal,
@ -31,7 +41,8 @@ func (m *Modal) Build(text string, confirmFunc func(), cancelFunc func()) *tview
m.view.ClearButtons()
m.view.
SetText(text).
AddButtons([]string{"Confirm", "Cancel"}).
// Add padding to button labels with spaces for better visual appearance
AddButtons([]string{" Confirm ", " Cancel "}).
SetDoneFunc(func(buttonIndex int, _ string) {
switch buttonIndex {
case 0:

View file

@ -2,6 +2,8 @@ package components
import (
"bbrew/internal/ui/theme"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
@ -18,6 +20,10 @@ func NewTable(theme *theme.Theme) *Table {
table.view.SetBorders(false)
table.view.SetSelectable(true, false)
table.view.SetFixed(1, 0)
// Use reverse video for selection to ensure visibility on any terminal theme
table.view.SetSelectedStyle(tcell.StyleDefault.Reverse(true))
return table
}

View file

@ -1,8 +1,12 @@
package theme
import "github.com/gdamore/tcell/v2"
import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
type Theme struct {
// Application-specific colors
DefaultTextColor tcell.Color
DefaultBgColor tcell.Color
WarningColor tcell.Color
@ -18,24 +22,69 @@ type Theme struct {
LegendColor tcell.Color
TableHeaderColor tcell.Color
SearchLabelColor tcell.Color
// tview global styles (mapped to tview.Styles)
PrimitiveBackgroundColor tcell.Color
ContrastBackgroundColor tcell.Color
MoreContrastBackgroundColor tcell.Color
BorderColor tcell.Color
GraphicsColor tcell.Color
PrimaryTextColor tcell.Color
SecondaryTextColor tcell.Color
TertiaryTextColor tcell.Color
InverseTextColor tcell.Color
ContrastSecondaryTextColor tcell.Color
}
func NewTheme() *Theme {
return &Theme{
DefaultTextColor: tcell.ColorWhite,
DefaultBgColor: tcell.ColorBlack,
WarningColor: tcell.ColorYellow,
SuccessColor: tcell.ColorGreen,
ErrorColor: tcell.ColorRed,
theme := &Theme{
// Application-specific colors
DefaultTextColor: tcell.ColorDefault,
DefaultBgColor: tcell.ColorDefault,
TitleColor: tcell.ColorMediumVioletRed,
// Use standard ANSI colors that work well on both light and dark themes
WarningColor: tcell.ColorYellow,
SuccessColor: tcell.ColorGreen,
ErrorColor: tcell.ColorRed,
// Component colors
TitleColor: tcell.ColorPurple,
LabelColor: tcell.ColorYellow,
ButtonBgColor: tcell.ColorGray,
ButtonTextColor: tcell.ColorWhite,
ButtonBgColor: tcell.ColorDefault,
ButtonTextColor: tcell.ColorDefault,
ModalBgColor: tcell.ColorDarkSlateGray,
LegendColor: tcell.ColorWhite,
ModalBgColor: tcell.ColorDefault,
LegendColor: tcell.ColorDefault,
TableHeaderColor: tcell.ColorBlue,
SearchLabelColor: tcell.ColorMediumVioletRed,
SearchLabelColor: tcell.ColorPurple,
// tview global styles - use terminal default colors for better compatibility
// By default, tview uses hardcoded colors (like tcell.ColorBlack) which don't
// adapt to the terminal's theme. We set them all to ColorDefault.
PrimitiveBackgroundColor: tcell.ColorDefault,
ContrastBackgroundColor: tcell.ColorDefault,
MoreContrastBackgroundColor: tcell.ColorDefault,
BorderColor: tcell.ColorDefault,
GraphicsColor: tcell.ColorDefault,
PrimaryTextColor: tcell.ColorDefault,
SecondaryTextColor: tcell.ColorDefault,
TertiaryTextColor: tcell.ColorDefault,
InverseTextColor: tcell.ColorDefault,
ContrastSecondaryTextColor: tcell.ColorDefault,
}
// Apply theme to tview global styles
tview.Styles.PrimitiveBackgroundColor = theme.PrimitiveBackgroundColor
tview.Styles.ContrastBackgroundColor = theme.ContrastBackgroundColor
tview.Styles.MoreContrastBackgroundColor = theme.MoreContrastBackgroundColor
tview.Styles.BorderColor = theme.BorderColor
tview.Styles.TitleColor = theme.TitleColor
tview.Styles.GraphicsColor = theme.GraphicsColor
tview.Styles.PrimaryTextColor = theme.PrimaryTextColor
tview.Styles.SecondaryTextColor = theme.SecondaryTextColor
tview.Styles.TertiaryTextColor = theme.TertiaryTextColor
tview.Styles.InverseTextColor = theme.InverseTextColor
tview.Styles.ContrastSecondaryTextColor = theme.ContrastSecondaryTextColor
return theme
}