1package styles
  2
  3import (
  4	"github.com/charmbracelet/lipgloss"
  5)
  6
  7// XXX: For now, this is in its own package so that it can be shared between
  8// different packages without incurring an illegal import cycle.
  9
 10// Styles defines styles for the UI.
 11type Styles struct {
 12	ActiveBorderColor   lipgloss.Color
 13	InactiveBorderColor lipgloss.Color
 14
 15	App    lipgloss.Style
 16	Header lipgloss.Style
 17
 18	Menu             lipgloss.Style
 19	MenuCursor       lipgloss.Style
 20	MenuItem         lipgloss.Style
 21	MenuLastUpdate   lipgloss.Style
 22	SelectedMenuItem lipgloss.Style
 23
 24	RepoTitleBorder lipgloss.Border
 25	RepoNoteBorder  lipgloss.Border
 26	RepoBodyBorder  lipgloss.Border
 27
 28	RepoTitle    lipgloss.Style
 29	RepoTitleBox lipgloss.Style
 30	RepoNote     lipgloss.Style
 31	RepoNoteBox  lipgloss.Style
 32	RepoBody     lipgloss.Style
 33
 34	Footer      lipgloss.Style
 35	Branch      lipgloss.Style
 36	HelpKey     lipgloss.Style
 37	HelpValue   lipgloss.Style
 38	HelpDivider lipgloss.Style
 39
 40	Error      lipgloss.Style
 41	ErrorTitle lipgloss.Style
 42	ErrorBody  lipgloss.Style
 43
 44	AboutNoReadme lipgloss.Style
 45
 46	LogItemSelector   lipgloss.Style
 47	LogItemActive     lipgloss.Style
 48	LogItemInactive   lipgloss.Style
 49	LogItemHash       lipgloss.Style
 50	LogCommit         lipgloss.Style
 51	LogCommitHash     lipgloss.Style
 52	LogCommitAuthor   lipgloss.Style
 53	LogCommitDate     lipgloss.Style
 54	LogCommitBody     lipgloss.Style
 55	LogCommitStatsAdd lipgloss.Style
 56	LogCommitStatsDel lipgloss.Style
 57	LogPaginator      lipgloss.Style
 58
 59	RefItemSelector lipgloss.Style
 60	RefItemActive   lipgloss.Style
 61	RefItemInactive lipgloss.Style
 62	RefItemBranch   lipgloss.Style
 63	RefItemTag      lipgloss.Style
 64	RefPaginator    lipgloss.Style
 65
 66	TreeItemSelector lipgloss.Style
 67	TreeItemActive   lipgloss.Style
 68	TreeItemInactive lipgloss.Style
 69	TreeFileDir      lipgloss.Style
 70	TreeFileMode     lipgloss.Style
 71	TreeFileSize     lipgloss.Style
 72	TreeFileContent  lipgloss.Style
 73	TreePaginator    lipgloss.Style
 74	TreeNoItems      lipgloss.Style
 75
 76	Spinner lipgloss.Style
 77}
 78
 79// DefaultStyles returns default styles for the UI.
 80func DefaultStyles() *Styles {
 81	s := new(Styles)
 82
 83	s.ActiveBorderColor = lipgloss.Color("62")
 84	s.InactiveBorderColor = lipgloss.Color("236")
 85
 86	s.App = lipgloss.NewStyle().
 87		Margin(1, 2)
 88
 89	s.Header = lipgloss.NewStyle().
 90		Foreground(lipgloss.Color("62")).
 91		Align(lipgloss.Right).
 92		Bold(true)
 93
 94	s.Menu = lipgloss.NewStyle().
 95		BorderStyle(lipgloss.RoundedBorder()).
 96		BorderForeground(s.InactiveBorderColor).
 97		Padding(1, 2).
 98		MarginRight(1).
 99		Width(24)
100
101	s.MenuCursor = lipgloss.NewStyle().
102		Foreground(lipgloss.Color("213")).
103		SetString(">")
104
105	s.MenuItem = lipgloss.NewStyle().
106		Padding(1, 2).
107		Height(4).
108		Border(lipgloss.RoundedBorder()).
109		BorderForeground(lipgloss.Color("241"))
110
111	s.MenuLastUpdate = lipgloss.NewStyle().
112		Foreground(lipgloss.Color("241"))
113
114	s.SelectedMenuItem = s.MenuItem.Copy().
115		BorderForeground(s.ActiveBorderColor)
116
117	s.RepoTitleBorder = lipgloss.Border{
118		Top:         "─",
119		Bottom:      "─",
120		Left:        "│",
121		Right:       "│",
122		TopLeft:     "╭",
123		TopRight:    "┬",
124		BottomLeft:  "├",
125		BottomRight: "┴",
126	}
127
128	s.RepoNoteBorder = lipgloss.Border{
129		Top:         "─",
130		Bottom:      "─",
131		Left:        "│",
132		Right:       "│",
133		TopLeft:     "┬",
134		TopRight:    "╮",
135		BottomLeft:  "┴",
136		BottomRight: "┤",
137	}
138
139	s.RepoBodyBorder = lipgloss.Border{
140		Top:         "",
141		Bottom:      "─",
142		Left:        "│",
143		Right:       "│",
144		TopLeft:     "",
145		TopRight:    "",
146		BottomLeft:  "╰",
147		BottomRight: "╯",
148	}
149
150	s.RepoTitle = lipgloss.NewStyle().
151		Padding(0, 2)
152
153	s.RepoTitleBox = lipgloss.NewStyle().
154		BorderStyle(s.RepoTitleBorder).
155		BorderForeground(s.InactiveBorderColor)
156
157	s.RepoNote = lipgloss.NewStyle().
158		Padding(0, 2).
159		Foreground(lipgloss.Color("168"))
160
161	s.RepoNoteBox = lipgloss.NewStyle().
162		BorderStyle(s.RepoNoteBorder).
163		BorderForeground(s.InactiveBorderColor).
164		BorderTop(true).
165		BorderRight(true).
166		BorderBottom(true).
167		BorderLeft(false)
168
169	s.RepoBody = lipgloss.NewStyle().
170		BorderStyle(s.RepoBodyBorder).
171		BorderForeground(s.InactiveBorderColor).
172		PaddingRight(1)
173
174	s.Footer = lipgloss.NewStyle().
175		MarginTop(1)
176
177	s.Branch = lipgloss.NewStyle().
178		Foreground(lipgloss.Color("203")).
179		Background(lipgloss.Color("236")).
180		Padding(0, 1)
181
182	s.HelpKey = lipgloss.NewStyle().
183		Foreground(lipgloss.Color("241"))
184
185	s.HelpValue = lipgloss.NewStyle().
186		Foreground(lipgloss.Color("239"))
187
188	s.HelpDivider = lipgloss.NewStyle().
189		Foreground(lipgloss.Color("237")).
190		SetString(" • ")
191
192	s.Error = lipgloss.NewStyle().
193		Padding(1)
194
195	s.ErrorTitle = lipgloss.NewStyle().
196		Foreground(lipgloss.Color("230")).
197		Background(lipgloss.Color("204")).
198		Bold(true).
199		Padding(0, 1)
200
201	s.ErrorBody = lipgloss.NewStyle().
202		Foreground(lipgloss.Color("252")).
203		MarginLeft(2).
204		Width(52) // for now
205
206	s.AboutNoReadme = lipgloss.NewStyle().
207		MarginTop(1).
208		MarginLeft(2).
209		Foreground(lipgloss.Color("#626262"))
210
211	s.LogItemInactive = lipgloss.NewStyle().
212		MarginLeft(1)
213
214	s.LogItemSelector = s.LogItemInactive.Copy().
215		Width(1).
216		Foreground(lipgloss.Color("#B083EA"))
217
218	s.LogItemActive = s.LogItemInactive.Copy().
219		Bold(true)
220
221	s.LogItemHash = s.LogItemInactive.Copy().
222		Width(7).
223		Foreground(lipgloss.Color("#A3A322"))
224
225	s.LogCommit = lipgloss.NewStyle().
226		Margin(0, 2)
227
228	s.LogCommitHash = s.LogItemHash.Copy().
229		UnsetMarginLeft().
230		UnsetWidth().
231		Bold(true)
232
233	s.LogCommitBody = lipgloss.NewStyle().
234		MarginTop(1).
235		MarginLeft(2)
236
237	s.LogCommitStatsAdd = lipgloss.NewStyle().
238		Foreground(lipgloss.Color("#00D787")).
239		Bold(true)
240
241	s.LogCommitStatsDel = lipgloss.NewStyle().
242		Foreground(lipgloss.Color("#FD5B5B")).
243		Bold(true)
244
245	s.LogPaginator = lipgloss.NewStyle().
246		Margin(0).
247		Align(lipgloss.Center)
248
249	s.RefItemSelector = s.LogItemSelector.Copy()
250
251	s.RefItemActive = s.LogItemActive.Copy()
252
253	s.RefItemInactive = s.LogItemInactive.Copy()
254
255	s.RefItemBranch = lipgloss.NewStyle()
256
257	s.RefItemTag = lipgloss.NewStyle().
258		Foreground(lipgloss.Color("#A3A322"))
259
260	s.RefPaginator = s.LogPaginator.Copy()
261
262	s.TreeItemSelector = s.LogItemSelector.Copy()
263
264	s.TreeItemActive = s.LogItemActive.Copy()
265
266	s.TreeItemInactive = s.LogItemInactive.Copy()
267
268	s.TreeFileDir = lipgloss.NewStyle().
269		Foreground(lipgloss.Color("#00AAFF"))
270
271	s.TreeFileMode = s.LogItemInactive.Copy().
272		Width(10).
273		Foreground(lipgloss.Color("#777777"))
274
275	s.TreeFileSize = s.LogItemInactive.Copy().
276		Foreground(lipgloss.Color("252"))
277
278	s.TreeFileContent = lipgloss.NewStyle()
279
280	s.TreePaginator = s.LogPaginator.Copy()
281
282	s.TreeNoItems = s.AboutNoReadme.Copy()
283
284	s.Spinner = lipgloss.NewStyle().
285		MarginTop(1).
286		MarginLeft(2).
287		Foreground(lipgloss.Color("205"))
288
289	return s
290}