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")). Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("57")). Background(lipgloss.Color("57")).
Bold(false) Bold(false)
s.Active = s.Active.
Foreground(lipgloss.Color("0")).
Background(lipgloss.Color("120"))
t.SetStyles(s) t.SetStyles(s)
return t return t
} }

View file

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