Skip to content

Commit

Permalink
Add demo reel for deeper example
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Miller committed Feb 20, 2024
1 parent f10b31e commit db3c974
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 21 deletions.
8 changes: 4 additions & 4 deletions examples/deeper/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Go Deeper Menu

This example demonstrates using a menu with nested sub views. In this case we will go from Artists to Paintings to Colors.
This example demonstrates using a menu with nested sub views. In this case we will go from Artists to the colors used in their Paintings.

```
Artists -> Paintings -> Colors
Artists -> Colors
```

## Pushing onto the NavStack

The artists component will push paintings onto the Navstack. While Paintings will push Colors onto the Navstack.

## Poping off the NavStack
## Popping off the NavStack

When a color is selected it will be popped off the navstack. But it will also emit a `ColorSelected` message. Which the Paintings component should handle and follow a similar pattern popping off the navstack and then emitting a `Painting Selected` msg. Likewise the Artist component will do the same and the menu will have all it's selections.

<!-- <img src="out.gif" alt="gif"/> -->
<img src="demo.gif" alt="vhs recording of this TUI example"/>



20 changes: 10 additions & 10 deletions examples/deeper/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func GetArtists() []Artist {
Description: "Guernica is a large 1937 oil painting on canvas by Spanish artist Pablo Picasso. One of Picasso's best known works, Guernica is regarded by many art critics as one of the most moving and powerful anti-war paintings in history.",
Colors: []Color{
{
RGB: "black",
RGB: "#000000", //black
Sample: "Black of the bull's eye facing down a matador it does not see.",
},
{
RGB: "white",
RGB: "#FFFFFF", //white
Sample: "White of the background rendered against the sun.",
},
{
RGB: "grey",
RGB: "#808080", //grey
Sample: "So grey the Spanish Civil War returned to present day.",
},
},
Expand All @@ -52,15 +52,15 @@ func GetArtists() []Artist {
Description: "",
Colors: []Color{
{
RGB: "yellow",
RGB: "#ffff00", //yellow
Sample: "The coat and turban have yellow accents with a golden glow.",
},
{
RGB: "blue",
RGB: "#0000ff", //blue
Sample: "Hat's blue and stunning as the model's distain.",
},
{
RGB: "ochre",
RGB: "#cc7722",
Sample: "Skin tones so ochre they burst with sun burn.",
},
},
Expand All @@ -70,11 +70,11 @@ func GetArtists() []Artist {
Description: "This captivating painting depicts a young woman standing by an open window, absorbed in reading a letter.",
Colors: []Color{
{
RGB: "green",
RGB: "#00ff00", //green
Sample: "If only the green curtain could speak.",
},
{
RGB: "red",
RGB: "#ff0000", //red
Sample: "The window drapes are the cheeryest thing in the room.",
},
},
Expand All @@ -84,11 +84,11 @@ func GetArtists() []Artist {
Description: "The scene exudes domestic tranquility and everyday beauty",
Colors: []Color{
{
RGB: "yellow",
RGB: "#ffff00",
Sample: "Yellow was a popular color for the Dutch.",
},
{
RGB: "white",
RGB: "#fdfff5",
Sample: "There is a milk the color of her bonet",
},
},
Expand Down
Binary file added examples/deeper/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions examples/deeper/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Output demo.gif

Require echo

Set Shell "bash"
Set FontSize 32
Set Width 2400
Set Height 1200

Sleep 1.5s
Type "go run ."
Enter
Sleep 2.5s
Down
Sleep 1s
Enter
Sleep 2s
Down 2
Sleep 1s
Down
Sleep 500ms
Down
Sleep 1s
Enter
Sleep 1.5s
Escape
Sleep 1.5s
Down
Enter
Sleep 1.5s
Escape
Up 3
Sleep 1.5s
Enter
Sleep 2s
Enter
Sleep 5s

3 changes: 3 additions & 0 deletions examples/deeper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if msg.String() == "ctrl+c" {
return m, tea.Quit
}
case tea.WindowSizeMsg:
m.menu.SetSize(msg)
return m, nil
}

updatedmenu, cmd := m.menu.Update(msg)
Expand Down
34 changes: 34 additions & 0 deletions examples/deeper/test.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Set Shell zsh
Sleep 1.5s
Type "go run ."
Sleep 500ms
Enter
Sleep 2.5s
Down
Sleep 1s
Enter
Sleep 2s
Down 2
Sleep 1s
Down
Sleep 500ms
Down
Sleep 1s
Enter
Sleep 1.5s
Escape
Sleep 1.5s
Down
Enter
Sleep 1.5s
Escape 2
Type "[A"
Escape
Type "[A"
Escape
Type "[A"
Enter
Sleep 2s
Enter
Sleep 2s

8 changes: 1 addition & 7 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var docStyle = lipgloss.NewStyle()
type model struct {
SelectedColor string
menu menu.Model
window *window.Model
}

func (m model) Init() tea.Cmd {
Expand All @@ -36,10 +35,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit
}
case tea.WindowSizeMsg:
// h, v := docStyle.GetFrameSize()
// m.window.Height = msg.Height
// m.window.Width = msg.Width - h
// m.window.TopOffset = v
m.menu.SetSize(msg)
return m, nil
}
Expand Down Expand Up @@ -79,8 +74,7 @@ func main() {
w := window.New(120, 25, top, side)
ns := navstack.New(&w)
m := model{
menu: menu.New(title, choices, nil),
window: &w,
menu: menu.New(title, choices, nil),
}
ns.Push(navstack.NavigationItem{Model: m, Title: "main menu"})

Expand Down

0 comments on commit db3c974

Please sign in to comment.