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(tree): support width and indenter styling #446

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dlvhdr
Copy link

@dlvhdr dlvhdr commented Nov 23, 2024

Some of the stuff I've been implementing on charmbracelet/bubbles#639 should go into lipgloss. This would help simplify the bubble code and is better for separating the rendering logic into lipgloss itself.

This PR adds two things:

  1. The ability to style the indenter with both a static style and a function style
  2. The ability to specify the tree's width, which allows tree nodes to stretch to fill it.

I've also wrote a new example to show what this enables.

TODO: check this against my tree bubble

Warning

This does introduce a "breaking change", not in the API but:
Trees that have subtrees with their own renderers, meaning they set a custom item/enumerator style, will need to now also set an indenter style, if they want to keep a consistent indentation styling.
If they don't set one the default empty style is used and it can look weird to suddenly have 2 kinds of indentation stylings.
Previously this was solved by using the enumerator style.

image image

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks awesome!

i have only a couple of style remarks, but this looks great to me!

tree/renderer.go Outdated Show resolved Hide resolved
tree/renderer.go Outdated Show resolved Hide resolved
tree/tree.go Show resolved Hide resolved
@caarlos0
Copy link
Member

caarlos0 commented Dec 3, 2024

about the breaking change, I think its a fair one. We are soon to release v2, so maybe we could pack it there, as it is already a breaking change release.

@dlvhdr dlvhdr marked this pull request as ready for review December 5, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants