1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
package common
import (
"image/color"
"charm.land/lipgloss/v2"
)
// Palette defines themed colors shared across the TUI package.
type Palette struct {
Background color.Color
Panel color.Color
Primary color.Color
Accent color.Color
Muted color.Color
Text color.Color
Danger color.Color
}
// NewPalette returns a color palette for dark or light terminal backgrounds.
func NewPalette(isDark bool) Palette {
if isDark {
return Palette{
Background: lipgloss.Color("235"),
Panel: lipgloss.Color("238"),
Primary: lipgloss.Color("75"),
Accent: lipgloss.Color("222"),
Muted: lipgloss.Color("246"),
Text: lipgloss.Color("255"),
Danger: lipgloss.Color("203"),
}
}
return Palette{
Background: lipgloss.Color("255"),
Panel: lipgloss.Color("250"),
Primary: lipgloss.Color("26"),
Accent: lipgloss.Color("88"),
Muted: lipgloss.Color("242"),
Text: lipgloss.Color("235"),
Danger: lipgloss.Color("160"),
}
}
var (
// Palette colors shared across the TUI package.
ColorBackground color.Color
ColorPanel color.Color
ColorPrimary color.Color
ColorAccent color.Color
ColorMuted color.Color
ColorText color.Color
ColorDanger color.Color
)
var (
// ScreenStyle is the base style for full-screen models.
ScreenStyle lipgloss.Style
// HeaderStyle is used by top-level titles and screen headers.
HeaderStyle lipgloss.Style
// TabActiveStyle is applied to the currently-selected tab.
TabActiveStyle lipgloss.Style
// TabInactiveStyle is applied to non-selected tabs.
TabInactiveStyle lipgloss.Style
// PanelStyle is used for boxed sections.
PanelStyle lipgloss.Style
// HelpBarStyle is used for keybinding hints at the bottom.
HelpBarStyle lipgloss.Style
// HighlightStyle emphasizes inline values.
HighlightStyle lipgloss.Style
// ErrorStyle is used for fatal or warning messages.
ErrorStyle lipgloss.Style
)
// ApplyPalette updates shared colors and styles to match the provided theme.
func ApplyPalette(isDark bool) {
palette := NewPalette(isDark)
ColorBackground = palette.Background
ColorPanel = palette.Panel
ColorPrimary = palette.Primary
ColorAccent = palette.Accent
ColorMuted = palette.Muted
ColorText = palette.Text
ColorDanger = palette.Danger
ScreenStyle = lipgloss.NewStyle().Foreground(ColorText)
HeaderStyle = lipgloss.NewStyle().Bold(true).Foreground(ColorPrimary)
TabActiveStyle = lipgloss.NewStyle().
Bold(true).
Foreground(ColorBackground).
Background(ColorPrimary).
Padding(0, 1)
TabInactiveStyle = lipgloss.NewStyle().
Foreground(ColorMuted).
Padding(0, 1)
PanelStyle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder()).
BorderForeground(ColorPanel).
Padding(0, 1)
HelpBarStyle = lipgloss.NewStyle().
Foreground(ColorMuted).
BorderTop(true).
BorderForeground(ColorPanel)
HighlightStyle = lipgloss.NewStyle().Bold(true).Foreground(ColorAccent)
ErrorStyle = lipgloss.NewStyle().Bold(true).Foreground(ColorDanger)
}
func init() {
ApplyPalette(true)
}
|