feat: highlighting Active tasks

This commit is contained in:
Anish Lakhwara 2024-05-04 19:06:55 -07:00
parent 9aeb85a771
commit b7a75c18db
2 changed files with 10 additions and 0 deletions

View file

@ -64,6 +64,9 @@ func CreateTable() table.Model {
Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("57")).
Bold(false)
s.Active = s.Active.
Foreground(lipgloss.Color("0")).
Background(lipgloss.Color("120"))
t.SetStyles(s)
return t
}

View file

@ -112,12 +112,14 @@ type Styles struct {
Header lipgloss.Style
Cell lipgloss.Style
Selected lipgloss.Style
Active lipgloss.Style
}
// DefaultStyles returns a set of default style definitions for this table.
func DefaultStyles() Styles {
return Styles{
Selected: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("212")),
Active: lipgloss.NewStyle().Bold(true).Background(lipgloss.Color("x20")),
Header: lipgloss.NewStyle().Bold(true).Padding(0, 1),
Cell: lipgloss.NewStyle().Padding(0, 1),
}
@ -473,6 +475,8 @@ func (m *Model) renderRow(r int) string {
cellStyle = m.styleFunc(r, i, value)
if r == m.cursor {
cellStyle.Inherit(m.styles.Selected)
} else if r < m.selected {
cellStyle.Inherit(m.styles.Active)
}
} else {
cellStyle = m.styles.Cell
@ -488,6 +492,9 @@ func (m *Model) renderRow(r int) string {
if r == m.cursor {
return m.styles.Selected.Render(row)
}
if r < m.selected {
return m.styles.Active.Render(row)
}
return row
}