@@ -74,10 +74,6 @@ func (d LogItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
return nil
}
-var (
- faint = func(s string) string { return lipgloss.NewStyle().Faint(true).Render(s) }
-)
-
// 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
@@ -89,17 +85,27 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
return
}
- titleStyle := styles.LogItemTitle.Copy()
+ var titleStyler,
+ descStyler,
+ keywordStyler func(string) string
style := styles.LogItemInactive
+
if index == m.Index() {
- titleStyle.Bold(true)
+ titleStyler = styles.LogItemTitleActive.Render
+ descStyler = styles.LogItemDescActive.Render
+ keywordStyler = styles.LogItemKeywordActive.Render
style = styles.LogItemActive
+ } else {
+ titleStyler = styles.LogItemTitleInactive.Render
+ descStyler = styles.LogItemDescInactive.Render
+ keywordStyler = styles.LogItemKeywordInactive.Render
}
+
hash := i.Commit.ID.String()[:7]
if !i.copied.IsZero() && i.copied.Add(time.Second).After(time.Now()) {
hash = "copied"
}
- title := titleStyle.Render(
+ title := titleStyler(
common.TruncateString(i.Title(),
m.Width()-
style.GetHorizontalFrameSize()-
@@ -119,27 +125,26 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
hash = hashStyle.Render(hash)
if m.Width()-style.GetHorizontalFrameSize()-hashStyle.GetHorizontalFrameSize()-hashStyle.GetWidth() <= 0 {
hash = ""
- title = titleStyle.Render(
+ title = titleStyler(
common.TruncateString(i.Title(),
m.Width()-style.GetHorizontalFrameSize()),
)
}
author := i.Author.Name
- commiter := i.Committer.Name
+ committer := i.Committer.Name
who := ""
- if author != "" && commiter != "" {
- who = commiter + faint(" committed")
- if author != commiter {
- who = author + faint(" authored and ") + who
+ if author != "" && committer != "" {
+ who = keywordStyler(committer) + descStyler(" committed")
+ if author != committer {
+ who = keywordStyler(author) + descStyler(" authored and ") + who
}
who += " "
}
- date := fmt.Sprintf("on %s", i.Committer.When.Format("Feb 02"))
- date = faint(date)
+ date := i.Committer.When.Format("Feb 02")
if i.Committer.When.Year() != time.Now().Year() {
date += fmt.Sprintf(" %d", i.Committer.When.Year())
}
- who += date
+ who += descStyler("on ") + keywordStyler(date)
who = common.TruncateString(who, m.Width()-style.GetHorizontalFrameSize())
fmt.Fprint(w,
style.Render(
@@ -44,20 +44,25 @@ type Styles struct {
AboutNoReadme lipgloss.Style
- LogItem lipgloss.Style
- LogItemSelector lipgloss.Style
- LogItemActive lipgloss.Style
- LogItemInactive lipgloss.Style
- LogItemHash lipgloss.Style
- LogItemTitle lipgloss.Style
- LogCommit lipgloss.Style
- LogCommitHash lipgloss.Style
- LogCommitAuthor lipgloss.Style
- LogCommitDate lipgloss.Style
- LogCommitBody lipgloss.Style
- LogCommitStatsAdd lipgloss.Style
- LogCommitStatsDel lipgloss.Style
- LogPaginator lipgloss.Style
+ LogItem lipgloss.Style
+ LogItemSelector lipgloss.Style
+ LogItemActive lipgloss.Style
+ LogItemInactive lipgloss.Style
+ LogItemHash lipgloss.Style
+ LogItemTitleInactive lipgloss.Style
+ LogItemTitleActive lipgloss.Style
+ LogItemDescInactive lipgloss.Style
+ LogItemDescActive lipgloss.Style
+ LogItemKeywordActive lipgloss.Style
+ LogItemKeywordInactive lipgloss.Style
+ LogCommit lipgloss.Style
+ LogCommitHash lipgloss.Style
+ LogCommitAuthor lipgloss.Style
+ LogCommitDate lipgloss.Style
+ LogCommitBody lipgloss.Style
+ LogCommitStatsAdd lipgloss.Style
+ LogCommitStatsDel lipgloss.Style
+ LogPaginator lipgloss.Style
RefItemSelector lipgloss.Style
RefItemActive lipgloss.Style
@@ -101,7 +106,7 @@ type Styles struct {
func DefaultStyles() *Styles {
highlightColor := lipgloss.Color("210")
highlightColorDim := lipgloss.Color("174")
- selectorColor := lipgloss.Color("204")
+ selectorColor := lipgloss.Color("167")
s := new(Styles)
@@ -214,7 +219,7 @@ func DefaultStyles() *Styles {
Border(lipgloss.Border{
Left: "┃",
}, false, false, false, true).
- BorderForeground(lipgloss.Color("#B083EA"))
+ BorderForeground(selectorColor)
s.LogItemSelector = s.LogItemInactive.Copy().
Width(1).
@@ -223,9 +228,21 @@ func DefaultStyles() *Styles {
s.LogItemHash = s.LogItemInactive.Copy().
Foreground(lipgloss.Color("#A3A322"))
- s.LogItemTitle = lipgloss.NewStyle().
+ s.LogItemTitleInactive = lipgloss.NewStyle().
Foreground(lipgloss.Color("#B083EA"))
+ s.LogItemTitleActive = lipgloss.NewStyle().
+ Foreground(highlightColor).
+ Bold(true)
+
+ s.LogItemDescInactive = lipgloss.NewStyle()
+
+ s.LogItemDescActive = lipgloss.NewStyle().
+ Foreground(lipgloss.Color("95"))
+
+ s.LogItemKeywordActive = s.LogItemDescActive.Copy().
+ Foreground(highlightColorDim)
+
s.LogCommit = lipgloss.NewStyle().
Margin(0, 2)