7b49657cc82a55fc04174ce4460f519b4996f800
- Author
- Christian Rocha <christian@rocha.is>
- Committer
- Ayman Bagabas <ayman.bagabas@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/ui/pages/repo/filesitem.go b/ui/pages/repo/filesitem.go
2index 9be5f4a76b0aa7f0044d0e08f83de22172048396..95f9d5a565b182d20e67e7d24e848654d5c0ebca 100644
3--- a/ui/pages/repo/filesitem.go
4+++ b/ui/pages/repo/filesitem.go
5@@ -96,7 +96,7 @@ func (d FileItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
6
7 // Render implements list.ItemDelegate.
8 func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
9- s := d.common.Styles
10+ s := d.common.Styles.Tree
11 i, ok := listItem.(FileItem)
12 if !ok {
13 return
14@@ -109,32 +109,32 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
15 if i.entry.IsTree() {
16 size = strings.Repeat(" ", sizeLen)
17 if index == m.Index() {
18- name = s.TreeFileDirActive.Render(name)
19+ name = s.FileDirActive.Render(name)
20 } else {
21- name = s.TreeFileDirInactive.Render(name)
22+ name = s.FileDirInactive.Render(name)
23 }
24 }
25 var nameStyle, sizeStyle, modeStyle lipgloss.Style
26 mode := i.Mode()
27 if index == m.Index() {
28- nameStyle = s.TreeItemActive
29- sizeStyle = s.TreeFileSizeActive
30- modeStyle = s.TreeFileModeActive
31- fmt.Fprint(w, s.TreeItemSelector.Render(">"))
32+ nameStyle = s.ItemActive
33+ sizeStyle = s.FileSizeActive
34+ modeStyle = s.FileModeActive
35+ fmt.Fprint(w, s.ItemSelector.Render(">"))
36 } else {
37- nameStyle = s.TreeItemInactive
38- sizeStyle = s.TreeFileSizeInactive
39- modeStyle = s.TreeFileModeInactive
40- fmt.Fprint(w, s.TreeItemSelector.Render(" "))
41+ nameStyle = s.ItemInactive
42+ sizeStyle = s.FileSizeInactive
43+ modeStyle = s.FileModeInactive
44+ fmt.Fprint(w, s.ItemSelector.Render(" "))
45 }
46 sizeStyle = sizeStyle.Copy().
47 Width(8).
48 Align(lipgloss.Right).
49 MarginLeft(1)
50- leftMargin := s.TreeItemSelector.GetMarginLeft() +
51- s.TreeItemSelector.GetWidth() +
52- s.TreeFileModeInactive.GetMarginLeft() +
53- s.TreeFileModeInactive.GetWidth() +
54+ leftMargin := s.ItemSelector.GetMarginLeft() +
55+ s.ItemSelector.GetWidth() +
56+ s.FileModeInactive.GetMarginLeft() +
57+ s.FileModeInactive.GetWidth() +
58 nameStyle.GetMarginLeft() +
59 sizeStyle.GetHorizontalFrameSize()
60 name = common.TruncateString(name, m.Width()-leftMargin)
61@@ -142,8 +142,8 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
62 size = sizeStyle.Render(size)
63 modeStr := modeStyle.Render(mode.String())
64 truncate := lipgloss.NewStyle().MaxWidth(m.Width() -
65- s.TreeItemSelector.GetHorizontalFrameSize() -
66- s.TreeItemSelector.GetWidth())
67+ s.ItemSelector.GetHorizontalFrameSize() -
68+ s.ItemSelector.GetWidth())
69 fmt.Fprint(w,
70 truncate.Render(fmt.Sprintf("%s%s%s",
71 modeStr,
72diff --git a/ui/pages/repo/refsitem.go b/ui/pages/repo/refsitem.go
73index 32010664baaa6548ebd3bd2b65ac61f0eaa9c486..eb07f7044293e045ade31f822be75f7d7c28db54 100644
74--- a/ui/pages/repo/refsitem.go
75+++ b/ui/pages/repo/refsitem.go
76@@ -85,7 +85,7 @@ func (d RefItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
77
78 // Render implements list.ItemDelegate.
79 func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
80- s := d.common.Styles
81+ s := d.common.Styles.Ref
82 i, ok := listItem.(RefItem)
83 if !ok {
84 return
85@@ -98,27 +98,27 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
86 isActive := index == m.Index()
87
88 if isTag && isActive {
89- st = s.RefItemTagActive
90+ st = s.ItemTagActive
91 } else if isTag {
92- st = s.RefItemTagInactive
93+ st = s.ItemTagInactive
94 } else if isActive {
95- st = s.RefItemActive
96+ st = s.ItemActive
97 } else {
98- st = s.RefItemInactive
99+ st = s.ItemInactive
100 }
101
102 if isActive {
103- selector = s.RefItemSelector.String()
104+ selector = s.ItemSelector.String()
105 } else {
106 selector = " "
107 }
108
109 ref := i.Short()
110- ref = s.RefItemBranch.Render(ref)
111+ ref = s.ItemBranch.Render(ref)
112 refMaxWidth := m.Width() -
113- s.RefItemSelector.GetMarginLeft() -
114- s.RefItemSelector.GetWidth() -
115- s.RefItemInactive.GetMarginLeft()
116+ s.ItemSelector.GetMarginLeft() -
117+ s.ItemSelector.GetWidth() -
118+ s.ItemInactive.GetMarginLeft()
119 ref = common.TruncateString(ref, refMaxWidth)
120 ref = st.Render(ref)
121 fmt.Fprint(w, selector, ref)
122diff --git a/ui/pages/repo/repo.go b/ui/pages/repo/repo.go
123index f448ab697f5e7c81a13d465f7b204e0b60fac6f4..b87fc0e0b8758636cc0e2b54dbb7917ad6238890 100644
124--- a/ui/pages/repo/repo.go
125+++ b/ui/pages/repo/repo.go
126@@ -100,9 +100,9 @@ func New(cfg *config.Config, c common.Common) *Repo {
127 // SetSize implements common.Component.
128 func (r *Repo) SetSize(width, height int) {
129 r.common.SetSize(width, height)
130- hm := r.common.Styles.RepoBody.GetVerticalFrameSize() +
131- r.common.Styles.RepoHeader.GetHeight() +
132- r.common.Styles.RepoHeader.GetVerticalFrameSize() +
133+ hm := r.common.Styles.Repo.Body.GetVerticalFrameSize() +
134+ r.common.Styles.Repo.Header.GetHeight() +
135+ r.common.Styles.Repo.Header.GetVerticalFrameSize() +
136 r.common.Styles.StatusBar.GetHeight() +
137 r.common.Styles.Tabs.GetHeight() +
138 r.common.Styles.Tabs.GetVerticalFrameSize()
139@@ -242,13 +242,13 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
140
141 // View implements tea.Model.
142 func (r *Repo) View() string {
143- s := r.common.Styles.Repo.Copy().
144+ s := r.common.Styles.Repo.Base.Copy().
145 Width(r.common.Width).
146 Height(r.common.Height)
147- repoBodyStyle := r.common.Styles.RepoBody.Copy()
148+ repoBodyStyle := r.common.Styles.Repo.Body.Copy()
149 hm := repoBodyStyle.GetVerticalFrameSize() +
150- r.common.Styles.RepoHeader.GetHeight() +
151- r.common.Styles.RepoHeader.GetVerticalFrameSize() +
152+ r.common.Styles.Repo.Header.GetHeight() +
153+ r.common.Styles.Repo.Header.GetVerticalFrameSize() +
154 r.common.Styles.StatusBar.GetHeight() +
155 r.common.Styles.Tabs.GetHeight() +
156 r.common.Styles.Tabs.GetVerticalFrameSize()
157@@ -270,13 +270,13 @@ func (r *Repo) headerView() string {
158 }
159 cfg := r.cfg
160 truncate := lipgloss.NewStyle().MaxWidth(r.common.Width)
161- name := r.common.Styles.RepoHeaderName.Render(r.selectedRepo.Name())
162+ name := r.common.Styles.Repo.HeaderName.Render(r.selectedRepo.Name())
163 desc := r.selectedRepo.Description()
164 if desc == "" {
165 desc = name
166 name = ""
167 } else {
168- desc = r.common.Styles.RepoHeaderDesc.Render(desc)
169+ desc = r.common.Styles.Repo.HeaderDesc.Render(desc)
170 }
171 // TODO move this into a style.
172 urlStyle := lipgloss.NewStyle().
173@@ -287,7 +287,7 @@ func (r *Repo) headerView() string {
174 url := git.RepoURL(cfg.Host, cfg.Port, r.selectedRepo.Repo())
175 url = common.TruncateString(url, r.common.Width-lipgloss.Width(desc)-1)
176 url = urlStyle.Render(url)
177- style := r.common.Styles.RepoHeader.Copy().Width(r.common.Width)
178+ style := r.common.Styles.Repo.Header.Copy().Width(r.common.Width)
179 return style.Render(
180 lipgloss.JoinVertical(lipgloss.Top,
181 truncate.Render(name),
182diff --git a/ui/pages/selection/item.go b/ui/pages/selection/item.go
183index 6e0c7efc8d33bfa52f07dd00feec66824ef9328a..93deced2fba20720237704d8712e6a0802d26a76 100644
184--- a/ui/pages/selection/item.go
185+++ b/ui/pages/selection/item.go
186@@ -159,7 +159,7 @@ func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
187 s.WriteString("\n")
188 s.WriteString(desc)
189 s.WriteString("\n")
190- cmdStyle := styles.RepoCommand.Copy()
191+ cmdStyle := styles.Repo.Command.Copy()
192 cmd := common.TruncateString(i.Command(), m.Width()-itemStyle.GetHorizontalFrameSize())
193 cmd = cmdStyle.Render(cmd)
194 if !i.copied.IsZero() && i.copied.Add(time.Second).After(time.Now()) {
195diff --git a/ui/styles/styles.go b/ui/styles/styles.go
196index a8e8f6686de83b5e82017347f0a6ad5c8be97e61..1ff6ef1686a07e338037fe0b9be03143adc60752 100644
197--- a/ui/styles/styles.go
198+++ b/ui/styles/styles.go
199@@ -24,13 +24,15 @@ type Styles struct {
200 SelectorBox lipgloss.Style
201 ReadmeBox lipgloss.Style
202
203- Repo lipgloss.Style
204- RepoTitle lipgloss.Style
205- RepoCommand lipgloss.Style
206- RepoBody lipgloss.Style
207- RepoHeader lipgloss.Style
208- RepoHeaderName lipgloss.Style
209- RepoHeaderDesc lipgloss.Style
210+ Repo struct {
211+ Base lipgloss.Style
212+ Title lipgloss.Style
213+ Command lipgloss.Style
214+ Body lipgloss.Style
215+ Header lipgloss.Style
216+ HeaderName lipgloss.Style
217+ HeaderDesc lipgloss.Style
218+ }
219
220 Footer lipgloss.Style
221 Branch lipgloss.Style
222@@ -66,26 +68,30 @@ type Styles struct {
223 Paginator lipgloss.Style
224 }
225
226- RefItemSelector lipgloss.Style
227- RefItemActive lipgloss.Style
228- RefItemInactive lipgloss.Style
229- RefItemBranch lipgloss.Style
230- RefItemTagInactive lipgloss.Style
231- RefItemTagActive lipgloss.Style
232- RefPaginator lipgloss.Style
233-
234- TreeItemSelector lipgloss.Style
235- TreeItemActive lipgloss.Style
236- TreeItemInactive lipgloss.Style
237- TreeFileDirInactive lipgloss.Style
238- TreeFileDirActive lipgloss.Style
239- TreeFileModeInactive lipgloss.Style
240- TreeFileModeActive lipgloss.Style
241- TreeFileSizeInactive lipgloss.Style
242- TreeFileSizeActive lipgloss.Style
243- TreeFileContent lipgloss.Style
244- TreePaginator lipgloss.Style
245- TreeNoItems lipgloss.Style
246+ Ref struct {
247+ ItemSelector lipgloss.Style
248+ ItemActive lipgloss.Style
249+ ItemInactive lipgloss.Style
250+ ItemBranch lipgloss.Style
251+ ItemTagInactive lipgloss.Style
252+ ItemTagActive lipgloss.Style
253+ Paginator lipgloss.Style
254+ }
255+
256+ Tree struct {
257+ ItemSelector lipgloss.Style
258+ ItemActive lipgloss.Style
259+ ItemInactive lipgloss.Style
260+ FileDirInactive lipgloss.Style
261+ FileDirActive lipgloss.Style
262+ FileModeInactive lipgloss.Style
263+ FileModeActive lipgloss.Style
264+ FileSizeInactive lipgloss.Style
265+ FileSizeActive lipgloss.Style
266+ FileContent lipgloss.Style
267+ Paginator lipgloss.Style
268+ NoItems lipgloss.Style
269+ }
270
271 Spinner lipgloss.Style
272
273@@ -151,26 +157,26 @@ func DefaultStyles() *Styles {
274
275 s.ReadmeBox = lipgloss.NewStyle()
276
277- s.Repo = lipgloss.NewStyle()
278+ s.Repo.Base = lipgloss.NewStyle()
279
280- s.RepoTitle = lipgloss.NewStyle().
281+ s.Repo.Title = lipgloss.NewStyle().
282 Padding(0, 2)
283
284- s.RepoCommand = lipgloss.NewStyle().
285+ s.Repo.Command = lipgloss.NewStyle().
286 Foreground(lipgloss.Color("168"))
287
288- s.RepoBody = lipgloss.NewStyle().
289+ s.Repo.Body = lipgloss.NewStyle().
290 Margin(1, 0)
291
292- s.RepoHeader = lipgloss.NewStyle().
293+ s.Repo.Header = lipgloss.NewStyle().
294 Height(2).
295 Border(lipgloss.NormalBorder(), false, false, true, false).
296 BorderForeground(lipgloss.Color("238"))
297
298- s.RepoHeaderName = lipgloss.NewStyle().