From 7b6e4dfe84c5f29ef29421bac8c461a681005bfa Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 18 May 2022 15:53:45 -0400 Subject: [PATCH] fix: comitter & authored name highlight --- ui/pages/repo/logitem.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/pages/repo/logitem.go b/ui/pages/repo/logitem.go index c6d2bb2c6c81e588452be3b0bff9382490b27f98..33b285e19f2e6b709ee2acffe068b486b7b77232 100644 --- a/ui/pages/repo/logitem.go +++ b/ui/pages/repo/logitem.go @@ -74,6 +74,10 @@ func (d LogItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { return nil } +var ( + highlight = lipgloss.NewStyle().Foreground(lipgloss.Color("#F1F1F1")) +) + // Render renders the item. Implements list.ItemDelegate. func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) { styles := d.common.Styles @@ -99,16 +103,19 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l title := titleStyle.Render( truncateString(i.Title(), m.Width()-style.GetHorizontalFrameSize()-width(hash)-2, "…"), ) - hash = styles.LogItemHash.Copy(). + hashStyle := styles.LogItemHash.Copy(). Align(lipgloss.Right). Width(m.Width() - style.GetHorizontalFrameSize() - width(title) - // FIXME where this "1" is coming from? - 1). - Render(hash) - author := i.Author.Name - commiter := i.Committer.Name + 1) + if index == m.Index() { + hashStyle = hashStyle.Bold(true) + } + hash = hashStyle.Render(hash) + author := highlight.Render(i.Author.Name) + commiter := highlight.Render(i.Committer.Name) who := "" if author != "" && commiter != "" { who = fmt.Sprintf("%s committed", commiter)