Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: API for user to set value for the NoItems render [List] #410

Open
jaymorelli96 opened this issue Aug 22, 2023 · 0 comments
Open

feat: API for user to set value for the NoItems render [List] #410

jaymorelli96 opened this issue Aug 22, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@jaymorelli96
Copy link

Is your feature request related to a problem? Please describe.
At the moment I couldn't find a way to remove the default "No " + m.itemNamePlural + " found." that is set when there are no visible items in the list.

Describe the solution you'd like
I would like an API in the model that I could do the following:

l := list.New() // New list is created, I am omitting the params for simplicity 
l.SetNoItemsPlaceHolder("Currently this list is empty") // Accepts a string
l.SetNoItemsPlaceHolder() // Possibility to leave blank

Describe alternatives you've considered
I tried something like this, but I couldn't get the title bar to show as well. Also it seems to much of a effort that could be easily done with an API 😄

func (m Model) requestsView() string {
	items := m.requests.VisibleItems()

	if len(items) == 0 {
		noItems := m.requests.Styles.NoItems.Render("Nothing found.")
		return lipgloss.NewStyle().Height(m.height).Render(noItems)
	}

	return m.requests.View()
}

Additional context
This logic is already being done by the func (m Model) populatedView() string in the list.go line 1153. Should be simple to add a new showNoItems bool in the model for at least have the option to omit this

@jaymorelli96 jaymorelli96 added the enhancement New feature or request label Aug 22, 2023
@jaymorelli96 jaymorelli96 changed the title feat: API for user to set value for the NoItems render feat: API for user to set value for the NoItems render [List] Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant