Skip to content

Commit

Permalink
docs: add toggled list example
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed May 31, 2024
1 parent c440039 commit 4aa863b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/list/toggled/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"

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

type dir string
type file string

func (d dir) String() string {
return lipgloss.NewStyle().Foreground(lipgloss.Color("99")).Height(2).Render(string(d) + "/")
}

func (f file) String() string {
return lipgloss.NewStyle().Faint(true).Height(2).Render(string(f))
}

func main() {
l := tree(
dir("home"),
tree(
file("README.md"),
file("Groceries"),
dir("Emotes"),
tree(
file("KEK.png"),
file("LUL.png"),
file("OmegaLUL.png"),
file("Poggers.png"),
),
),
)
fmt.Println(l)
}

func tree(items ...any) *list.List {
return list.New(items...).Enumerator(list.Tree).Indenter(list.TreeIndent)
}

0 comments on commit 4aa863b

Please sign in to comment.