1package styles
2
3import "github.com/charmbracelet/lipgloss"
4
5// Theme contains all composed styles for the Gordon TUI.
6// Styles are organized by component type for easy discovery.
7var Theme = struct {
8 // Text styles
9 Title lipgloss.Style
10 Subtitle lipgloss.Style
11 Heading lipgloss.Style
12 Body lipgloss.Style
13 Muted lipgloss.Style
14 Bold lipgloss.Style
15 Highlight lipgloss.Style
16
17 // Status styles
18 Success lipgloss.Style
19 Error lipgloss.Style
20 Warning lipgloss.Style
21 Info lipgloss.Style
22
23 // Badge styles (compact status indicators)
24 BadgeSuccess lipgloss.Style
25 BadgeError lipgloss.Style
26 BadgeWarning lipgloss.Style
27 BadgeInfo lipgloss.Style
28 BadgePending lipgloss.Style
29
30 // Table styles
31 TableHeader lipgloss.Style
32 TableRow lipgloss.Style
33 TableRowSelected lipgloss.Style
34 TableRowAlt lipgloss.Style
35 TableCell lipgloss.Style
36 TableBorder lipgloss.Style
37
38 // Form styles
39 FormLabel lipgloss.Style
40 FormInput lipgloss.Style
41 FormPlaceholder lipgloss.Style
42 FormFocused lipgloss.Style
43 FormError lipgloss.Style
44
45 // List styles
46 ListItem lipgloss.Style
47 ListItemSelected lipgloss.Style
48 ListBullet lipgloss.Style
49
50 // Box/Container styles
51 Box lipgloss.Style
52 BoxHighlight lipgloss.Style
53 BoxError lipgloss.Style
54
55 // Banner/Header styles
56 Banner lipgloss.Style
57 BannerTitle lipgloss.Style
58
59 // Help styles
60 HelpKey lipgloss.Style
61 HelpDesc lipgloss.Style
62}{
63 // Text styles
64 Title: lipgloss.NewStyle().
65 Bold(true).
66 Foreground(ColorPrimary),
67
68 Subtitle: lipgloss.NewStyle().
69 Foreground(ColorTextMuted),
70
71 Heading: lipgloss.NewStyle().
72 Bold(true).
73 Foreground(ColorText),
74
75 Body: lipgloss.NewStyle().
76 Foreground(ColorText),
77
78 Muted: lipgloss.NewStyle().
79 Foreground(ColorTextMuted),
80
81 Bold: lipgloss.NewStyle().
82 Bold(true).
83 Foreground(ColorText),
84
85 Highlight: lipgloss.NewStyle().
86 Foreground(ColorPrimary),
87
88 // Status styles
89 Success: lipgloss.NewStyle().
90 Foreground(ColorSuccess),
91
92 Error: lipgloss.NewStyle().
93 Foreground(ColorError),
94
95 Warning: lipgloss.NewStyle().
96 Foreground(ColorWarning),
97
98 Info: lipgloss.NewStyle().
99 Foreground(ColorInfo),
100
101 // Badge styles
102 BadgeSuccess: lipgloss.NewStyle().
103 Foreground(ColorBg).
104 Background(ColorSuccess).
105 Padding(0, 1),
106
107 BadgeError: lipgloss.NewStyle().
108 Foreground(ColorBg).
109 Background(ColorError).
110 Padding(0, 1),
111
112 BadgeWarning: lipgloss.NewStyle().
113 Foreground(ColorBg).
114 Background(ColorWarning).
115 Padding(0, 1),
116
117 BadgeInfo: lipgloss.NewStyle().
118 Foreground(ColorBg).
119 Background(ColorInfo).
120 Padding(0, 1),
121
122 BadgePending: lipgloss.NewStyle().
123 Foreground(ColorBg).
124 Background(ColorTextMuted).
125 Padding(0, 1),
126
127 // Table styles
128 TableHeader: lipgloss.NewStyle().
129 Bold(true).
130 Foreground(ColorPrimary).
131 BorderBottom(true).
132 BorderStyle(lipgloss.NormalBorder()).
133 BorderForeground(ColorBorder),
134
135 TableRow: lipgloss.NewStyle().
136 Foreground(ColorText),
137
138 TableRowSelected: lipgloss.NewStyle().
139 Foreground(ColorPrimary).
140 Background(ColorBgMuted),
141
142 TableRowAlt: lipgloss.NewStyle().
143 Foreground(ColorTextMuted),
144
145 TableCell: lipgloss.NewStyle().
146 Padding(0, 1),
147
148 TableBorder: lipgloss.NewStyle().
149 Foreground(ColorBorder),
150
151 // Form styles
152 FormLabel: lipgloss.NewStyle().
153 Foreground(ColorText).
154 Bold(true),
155
156 FormInput: lipgloss.NewStyle().
157 Foreground(ColorText).
158 Background(ColorBgMuted).
159 Padding(0, 1),
160
161 FormPlaceholder: lipgloss.NewStyle().
162 Foreground(ColorTextMuted),
163
164 FormFocused: lipgloss.NewStyle().
165 Foreground(ColorPrimary).
166 Background(ColorBgMuted).
167 BorderLeft(true).
168 BorderStyle(lipgloss.NormalBorder()).
169 BorderForeground(ColorPrimary).
170 Padding(0, 1),
171
172 FormError: lipgloss.NewStyle().
173 Foreground(ColorError),
174
175 // List styles
176 ListItem: lipgloss.NewStyle().
177 Foreground(ColorText).
178 PaddingLeft(2),
179
180 ListItemSelected: lipgloss.NewStyle().
181 Foreground(ColorPrimary).
182 PaddingLeft(2),
183
184 ListBullet: lipgloss.NewStyle().
185 Foreground(ColorPrimary),
186
187 // Box/Container styles
188 Box: lipgloss.NewStyle().
189 Border(lipgloss.RoundedBorder()).
190 BorderForeground(ColorBorder).
191 Padding(1, 2),
192
193 BoxHighlight: lipgloss.NewStyle().
194 Border(lipgloss.RoundedBorder()).
195 BorderForeground(ColorPrimary).
196 Padding(1, 2),
197
198 BoxError: lipgloss.NewStyle().
199 Border(lipgloss.RoundedBorder()).
200 BorderForeground(ColorError).
201 Padding(1, 2),
202
203 // Banner/Header styles
204 Banner: lipgloss.NewStyle().
205 Border(lipgloss.RoundedBorder()).
206 BorderForeground(ColorPrimary).
207 Padding(0, 2),
208
209 BannerTitle: lipgloss.NewStyle().
210 Bold(true).
211 Foreground(ColorPrimary),
212
213 // Help styles
214 HelpKey: lipgloss.NewStyle().
215 Foreground(ColorPrimary),
216
217 HelpDesc: lipgloss.NewStyle().
218 Foreground(ColorTextMuted),
219}
220
221// Render helpers for common patterns.
222
223// RenderStatus returns a styled status indicator with icon.
224func RenderStatus(status string, running bool) string {
225 if running {
226 return Theme.Success.Render(IconSuccess + " " + status)
227 }
228 return Theme.Error.Render(IconError + " " + status)
229}
230
231// RenderBadge returns a styled badge for the given status.
232func RenderBadge(status string) string {
233 switch status {
234 case "running", "success", "ok", "active":
235 return Theme.BadgeSuccess.Render(status)
236 case "error", "failed", "stopped":
237 return Theme.BadgeError.Render(status)
238 case "warning", "degraded":
239 return Theme.BadgeWarning.Render(status)
240 case "pending", "starting":
241 return Theme.BadgePending.Render(status)
242 default:
243 return Theme.BadgeInfo.Render(status)
244 }
245}
246
247// RenderKeyHelp returns formatted key binding help text.
248func RenderKeyHelp(key, desc string) string {
249 return Theme.HelpKey.Render(key) + " " + Theme.HelpDesc.Render(desc)
250}
251
252// RenderListItem returns a formatted list item with bullet.
253func RenderListItem(item string, selected bool) string {
254 bullet := Theme.ListBullet.Render(IconBullet)
255 if selected {
256 return bullet + " " + Theme.ListItemSelected.Render(item)
257 }
258 return bullet + " " + Theme.ListItem.Render(item)
259}
260
261// RenderError returns a styled error message.
262func RenderError(msg string) string {
263 return Theme.Error.Render(IconError + " " + msg)
264}
265
266// RenderSuccess returns a styled success message.
267func RenderSuccess(msg string) string {
268 return Theme.Success.Render(IconSuccess + " " + msg)
269}
270
271// RenderWarning returns a styled warning message.
272func RenderWarning(msg string) string {
273 return Theme.Warning.Render(IconWarning + " " + msg)
274}
275
276// RenderInfo returns a styled info message.
277func RenderInfo(msg string) string {
278 return Theme.Info.Render(IconInfo + " " + msg)
279}