mirror of
https://github.com/Valkyrie00/bold-brew.git
synced 2026-03-14 14:25:53 +01:00
Updates the UI theme system and improves visual consistency and accessibility across different terminal themes. The main changes include refactoring how colors are handled, updating component styles for better visibility, and ensuring that global styles adapt to the user's terminal settings.
90 lines
3 KiB
Go
90 lines
3 KiB
Go
package theme
|
|
|
|
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
|
|
SuccessColor tcell.Color
|
|
ErrorColor tcell.Color
|
|
|
|
TitleColor tcell.Color
|
|
LabelColor tcell.Color
|
|
ButtonBgColor tcell.Color
|
|
ButtonTextColor tcell.Color
|
|
|
|
ModalBgColor tcell.Color
|
|
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 {
|
|
theme := &Theme{
|
|
// Application-specific colors
|
|
DefaultTextColor: tcell.ColorDefault,
|
|
DefaultBgColor: tcell.ColorDefault,
|
|
|
|
// 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.ColorDefault,
|
|
ButtonTextColor: tcell.ColorDefault,
|
|
|
|
ModalBgColor: tcell.ColorDefault,
|
|
LegendColor: tcell.ColorDefault,
|
|
TableHeaderColor: tcell.ColorBlue,
|
|
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
|
|
}
|