From f54c6d955fbbac3301ccc2a5852bb218cedc0df1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 4 Dec 2024 16:40:31 -0300 Subject: [PATCH 1/3] fix: allow to use empty style properly Signed-off-by: Carlos Alexandro Becker --- list/list.go | 4 ++-- list/style.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/list/list.go b/list/list.go index 6808142b..fd5742af 100644 --- a/list/list.go +++ b/list/list.go @@ -1162,7 +1162,7 @@ func (m Model) statusView() string { } } else if len(m.items) == 0 { // Not filtering: no items. - status = m.Styles.StatusEmpty.Render("No " + m.itemNamePlural) + status = m.Styles.StatusEmpty.Render() } else { // Normal filtered := m.FilterState() == FilterApplied @@ -1217,7 +1217,7 @@ func (m Model) populatedView() string { if m.filterState == Filtering { return "" } - return m.Styles.NoItems.Render("No " + m.itemNamePlural + ".") + return m.Styles.NoItems.Render() } if len(items) > 0 { diff --git a/list/style.go b/list/style.go index e663c07b..1dd466e1 100644 --- a/list/style.go +++ b/list/style.go @@ -67,7 +67,8 @@ func DefaultStyles() (s Styles) { Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}). Padding(0, 0, 1, 2) //nolint:mnd - s.StatusEmpty = lipgloss.NewStyle().Foreground(subduedColor) + s.StatusEmpty = lipgloss.NewStyle().Foreground(subduedColor). + SetString("No items.") s.StatusBarActiveFilter = lipgloss.NewStyle(). Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}) From 6eba26ae28dc409afc077368ba25a519359a526d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 4 Dec 2024 16:47:44 -0300 Subject: [PATCH 2/3] fix: test Signed-off-by: Carlos Alexandro Becker --- list/list_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/list/list_test.go b/list/list_test.go index 2627e5b1..d6b7cb09 100644 --- a/list/list_test.go +++ b/list/list_test.go @@ -55,6 +55,7 @@ func TestStatusBarWithoutItems(t *testing.T) { func TestCustomStatusBarItemName(t *testing.T) { list := New([]Item{item("foo"), item("bar")}, itemDelegate{}, 10, 10) list.SetStatusBarItemName("connection", "connections") + list.Styles.StatusEmpty = list.Styles.StatusEmpty.SetString("No connections.") expected := "2 connections" if !strings.Contains(list.statusView(), expected) { From 84b52a7fd45973d180dbbd0dd914abbe44e11951 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 18 Dec 2024 16:57:11 -0300 Subject: [PATCH 3/3] fix: no items --- list/style.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/list/style.go b/list/style.go index 1dd466e1..290df2d0 100644 --- a/list/style.go +++ b/list/style.go @@ -76,7 +76,8 @@ func DefaultStyles() (s Styles) { s.StatusBarFilterCount = lipgloss.NewStyle().Foreground(verySubduedColor) s.NoItems = lipgloss.NewStyle(). - Foreground(lipgloss.AdaptiveColor{Light: "#909090", Dark: "#626262"}) + Foreground(lipgloss.AdaptiveColor{Light: "#909090", Dark: "#626262"}). + SetString("No items.") s.ArabicPagination = lipgloss.NewStyle().Foreground(subduedColor)