[go: up one dir, main page]

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: trees and lists #264

Merged
merged 97 commits into from
May 24, 2024
Merged

feat: trees and lists #264

merged 97 commits into from
May 24, 2024

Conversation

caarlos0
Copy link
Member
@caarlos0 caarlos0 commented Feb 16, 2024

Worked on top of @maaslalani trees and lists implementations, fixed some bugs, refactor some stuff, added a couple of possibilities (namely, sublists (as trees)), etc.

Its a big PR, but it if it makes it better, it closes this 4 other PRs:

closes #242
closes #240
closes #243
closes #263

Some examples:

CleanShot 2024-02-16 at 10 30 22@2x
CleanShot 2024-02-16 at 10 31 00@2x
CleanShot 2024-02-16 at 10 31 25@2x
CleanShot 2024-02-16 at 10 32 43@2x
CleanShot 2024-02-16 at 11 08 51@2x

maaslalani and others added 28 commits November 30, 2023 10:50
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 added the enhancement New feature or request label Feb 16, 2024
meowgorithm and others added 2 commits April 18, 2024 11:15
* chore(examples): go mod tidy

* feat(tree): add rounded corner enumerator
@bashbunni
Copy link
Member

Hey @testinfected we're still doing some usability tests on the API to decide if the developer experience is where we want it to be before release. No ETA yet, but the functionality is there, just want to make sure it's easy to use before publishing. We don't want to have to break the API in the future, so now's the time to get it all sorted :)

@nervo
Copy link
Contributor
nervo commented May 13, 2024

@bashbunni i just wonder something 🤔

There are today two ways to use a list as a user input in the charmbracelet ecosystem:

Do you plan something on this subject ? It could be amazing to use the same list either in a user input or output way ❤️

@caarlos0
Copy link
Member Author

hey @nervo !

Ideally, we'll use this new component on both of these once this is merged :)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@bashbunni
Copy link
Member
bashbunni commented May 15, 2024

Docs:

  • We should probably populate the "Overview" section of the Godoc with a basic example
  • It's still unclear to me when to use a tree vs a list - maybe something we can include in the godoc?

Unexpected Behaviour:

  • If I add sublists in Items instead of as an Item, I get multiple bullet points.
    double-bullets

Styling Qs:

  • how do I style a Root elem? Can I style by depth?
  • how do I create a sublist with titles/categories?
    • Use a tree with Root
  • when do I use stylefunc vs style?

@bashbunni bashbunni added the proposal Introduce new API change label May 15, 2024
@bashbunni
Copy link
Member

We should also improve godoc on StyleFunc usage for lists/trees. I'm searching examples to figure out how to use it

@caarlos0
Copy link
Member Author

If I add sublists in Items instead of as an Item, I get multiple bullet points.

can you share an example?

@bashbunni
Copy link
Member
bashbunni commented May 15, 2024

@caarlos0 🤦‍♀️ totally didn't include the code to repro did I? LOL

The broken one (using Items to set list elements):

	l := list.New().Items(
		"S",
		list.New().Items([]string{"vim", "doom emacs"}),
		list.New().Item("I like fuzzy socks"),
	)

	fmt.Println(l)

gives me
image

The one used in examples:

	l2 := list.New().
		Item("S").
		Item(list.New().Items([]string{"vim", "doom emacs"})).
		Item(list.New().Item("I like fuzzy socks"))
	fmt.Println(l2)

which doesn't include the extra bullets, even though technically these two solutions should have the same output
image

@caarlos0
Copy link
Member Author

fixed @bashbunni

caarlos0 and others added 10 commits May 15, 2024 17:38
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
* docs(godoc): add overview

* docs(godoc): include examples in godoc

* docs(godoc): fix roman numerals example

* docs(godoc): fix tree examples

* docs(godoc): attempt to fix list Enumerator examples
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 merged commit d21c576 into master May 24, 2024
20 checks passed
@meowgorithm meowgorithm deleted the tree-final branch May 31, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request proposal Introduce new API change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants