a05f2d38dd7a468f00be87fc1863e90052ae3eb7
- 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/logitem.go b/ui/pages/repo/logitem.go
2index 73d46ad2101b43484de97e5aabe9794d3d24d88f..856b200db7c08a65c27bc4ee3d1b4ab52d42f755 100644
3--- a/ui/pages/repo/logitem.go
4+++ b/ui/pages/repo/logitem.go
5@@ -76,7 +76,6 @@ func (d LogItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
6
7 // Render renders the item. Implements list.ItemDelegate.
8 func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
9- styles := d.common.Styles.Log
10 i, ok := listItem.(LogItem)
11 if !ok {
12 return
13@@ -85,58 +84,49 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
14 return
15 }
16
17- var titleStyler,
18- descStyler,
19- keywordStyler func(string) string
20- style := styles.ItemInactive
21-
22+ styles := d.common.Styles.LogItem.Normal
23 if index == m.Index() {
24- titleStyler = styles.ItemTitleActive.Render
25- descStyler = styles.ItemDescActive.Render
26- keywordStyler = styles.ItemKeywordActive.Render
27- style = styles.ItemActive
28- } else {
29- titleStyler = styles.ItemTitleInactive.Render
30- descStyler = styles.ItemDescInactive.Render
31- keywordStyler = styles.ItemKeywordInactive.Render
32+ styles = d.common.Styles.LogItem.Active
33 }
34
35+ horizontalFrameSize := styles.Base.GetHorizontalFrameSize()
36+
37 hash := i.Commit.ID.String()[:7]
38 if !i.copied.IsZero() && i.copied.Add(time.Second).After(time.Now()) {
39 hash = "copied"
40 }
41- title := titleStyler(
42+ title := styles.Title.Render(
43 common.TruncateString(i.Title(),
44 m.Width()-
45- style.GetHorizontalFrameSize()-
46+ horizontalFrameSize-
47 // 9 is the length of the hash (7) + the left padding (1) + the
48 // title truncation symbol (1)
49 9),
50 )
51- hashStyle := styles.ItemHash.Copy().
52+ hashStyle := styles.Hash.Copy().
53 Align(lipgloss.Right).
54 PaddingLeft(1).
55 Width(m.Width() -
56- style.GetHorizontalFrameSize() -
57+ horizontalFrameSize -
58 lipgloss.Width(title) - 1) // 1 is for the left padding
59 if index == m.Index() {
60 hashStyle = hashStyle.Bold(true)
61 }
62 hash = hashStyle.Render(hash)
63- if m.Width()-style.GetHorizontalFrameSize()-hashStyle.GetHorizontalFrameSize()-hashStyle.GetWidth() <= 0 {
64+ if m.Width()-horizontalFrameSize-hashStyle.GetHorizontalFrameSize()-hashStyle.GetWidth() <= 0 {
65 hash = ""
66- title = titleStyler(
67+ title = styles.Title.Render(
68 common.TruncateString(i.Title(),
69- m.Width()-style.GetHorizontalFrameSize()),
70+ m.Width()-horizontalFrameSize),
71 )
72 }
73 author := i.Author.Name
74 committer := i.Committer.Name
75 who := ""
76 if author != "" && committer != "" {
77- who = keywordStyler(committer) + descStyler(" committed")
78+ who = styles.Keyword.Render(committer) + styles.Desc.Render(" committed")
79 if author != committer {
80- who = keywordStyler(author) + descStyler(" authored and ") + who
81+ who = styles.Keyword.Render(author) + styles.Desc.Render(" authored and ") + who
82 }
83 who += " "
84 }
85@@ -144,15 +134,15 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
86 if i.Committer.When.Year() != time.Now().Year() {
87 date += fmt.Sprintf(" %d", i.Committer.When.Year())
88 }
89- who += descStyler("on ") + keywordStyler(date)
90- who = common.TruncateString(who, m.Width()-style.GetHorizontalFrameSize())
91+ who += styles.Desc.Render("on ") + styles.Keyword.Render(date)
92+ who = common.TruncateString(who, m.Width()-horizontalFrameSize)
93 fmt.Fprint(w,
94- style.Render(
95+ styles.Base.Render(
96 lipgloss.JoinVertical(lipgloss.Top,
97 truncate.String(fmt.Sprintf("%s%s",
98 title,
99 hash,
100- ), uint(m.Width()-style.GetHorizontalFrameSize())),
101+ ), uint(m.Width()-horizontalFrameSize)),
102 who,
103 ),
104 ),
105diff --git a/ui/styles/styles.go b/ui/styles/styles.go
106index 6f092bd3e005a96a44cf4ef760c5cbdef571842f..2243a13e83188a03317e700f7c6a875f3613e349 100644
107--- a/ui/styles/styles.go
108+++ b/ui/styles/styles.go
109@@ -46,26 +46,32 @@ type Styles struct {
110
111 AboutNoReadme lipgloss.Style
112
113+ LogItem struct {
114+ Normal struct {
115+ Base lipgloss.Style
116+ Hash lipgloss.Style
117+ Title lipgloss.Style
118+ Desc lipgloss.Style
119+ Keyword lipgloss.Style
120+ }
121+ Active struct {
122+ Base lipgloss.Style
123+ Hash lipgloss.Style
124+ Title lipgloss.Style
125+ Desc lipgloss.Style
126+ Keyword lipgloss.Style
127+ }
128+ }
129+
130 Log struct {
131- Item lipgloss.Style
132- ItemSelector lipgloss.Style
133- ItemActive lipgloss.Style
134- ItemInactive lipgloss.Style
135- ItemHash lipgloss.Style
136- ItemTitleInactive lipgloss.Style
137- ItemTitleActive lipgloss.Style
138- ItemDescInactive lipgloss.Style
139- ItemDescActive lipgloss.Style
140- ItemKeywordActive lipgloss.Style
141- ItemKeywordInactive lipgloss.Style
142- Commit lipgloss.Style
143- CommitHash lipgloss.Style
144- CommitAuthor lipgloss.Style
145- CommitDate lipgloss.Style
146- CommitBody lipgloss.Style
147- CommitStatsAdd lipgloss.Style
148- CommitStatsDel lipgloss.Style
149- Paginator lipgloss.Style
150+ Commit lipgloss.Style
151+ CommitHash lipgloss.Style
152+ CommitAuthor lipgloss.Style
153+ CommitDate lipgloss.Style
154+ CommitBody lipgloss.Style
155+ CommitStatsAdd lipgloss.Style
156+ CommitStatsDel lipgloss.Style
157+ Paginator lipgloss.Style
158 }
159
160 Ref struct {
161@@ -115,6 +121,7 @@ func DefaultStyles() *Styles {
162 highlightColor := lipgloss.Color("210")
163 highlightColorDim := lipgloss.Color("174")
164 selectorColor := lipgloss.Color("167")
165+ hashColor := lipgloss.Color("184")
166
167 s := new(Styles)
168
169@@ -217,46 +224,52 @@ func DefaultStyles() *Styles {
170 MarginLeft(2).
171 Foreground(lipgloss.Color("242"))
172
173- s.Log.ItemInactive = lipgloss.NewStyle().
174+ s.LogItem.Normal.Base = lipgloss.NewStyle().
175 Border(lipgloss.Border{
176 Left: " ",
177 }, false, false, false, true).
178 PaddingLeft(1)
179
180- s.Log.ItemActive = s.Log.ItemInactive.Copy().
181+ s.LogItem.Active.Base = s.LogItem.Normal.Base.Copy().
182 Border(lipgloss.Border{
183 Left: "┃",
184 }, false, false, false, true).
185 BorderForeground(selectorColor)
186
187- s.Log.ItemSelector = s.Log.ItemInactive.Copy().
188- Width(1).
189- Foreground(lipgloss.Color("62"))
190+ s.LogItem.Active.Hash = s.LogItem.Normal.Hash.Copy().
191+ Foreground(hashColor)
192
193- s.Log.ItemHash = s.Log.ItemInactive.Copy().
194- Foreground(lipgloss.Color("184"))
195+ s.LogItem.Active.Hash = lipgloss.NewStyle().
196+ Bold(true).
197+ Foreground(highlightColor)
198
199- s.Log.ItemTitleInactive = lipgloss.NewStyle().
200+ s.LogItem.Normal.Title = lipgloss.NewStyle().
201 Foreground(lipgloss.Color("105"))
202
203- s.Log.ItemTitleActive = lipgloss.NewStyle().
204+ s.LogItem.Active.Title = lipgloss.NewStyle().
205 Foreground(highlightColor).
206 Bold(true)
207
208- s.Log.ItemDescInactive = lipgloss.NewStyle().