Skip to content

Commit

Permalink
test(tree): add ExampleSetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Jan 10, 2025
1 parent 1c1eb7a commit 0cdf875
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tree/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tree_test
import (
"fmt"

"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/tree"
)

Expand Down Expand Up @@ -66,6 +67,35 @@ func ExampleNewLeaf() {
//
}

func ExampleSetValue() {
enumeratorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("63")).MarginRight(1)
rootStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("35"))
itemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("212"))

t := tree.
Root("⁜ Makeup").
Child(
"Glossier",
"Fenty Beauty",
tree.New().Child(
"Gloss Bomb Universal Lip Luminizer",
"Hot Cheeks Velour Blushlighter",
),
"Nyx",
"Mac",
"Milk",
).
Enumerator(tree.RoundedEnumerator).
EnumeratorStyle(enumeratorStyle).
RootStyle(rootStyle).
ItemStyle(itemStyle)
glossier := t.Children().At(0)
glossier.SetValue(tree.Root(glossier.Value()).Child(tree.Root("Apparel").Child("Pink Hoodie", "Baseball Cap")))
fmt.Println(t.String())
// Output:
// hello
}

// Tree Examples

func ExampleTree_Hide() {
Expand Down

0 comments on commit 0cdf875

Please sign in to comment.