Diff
1diff --git a/tui/bubble.go b/tui/bubble.go
2index 87df275f3cf175f71a0436d49b84964a01f8b5cf..375828f37da0a12b3c46432e404d024bf51c9657 100644
3--- a/tui/bubble.go
4+++ b/tui/bubble.go
5@@ -2,10 +2,12 @@ package tui
6
7 import (
8 "fmt"
9+ "io"
10 "smoothie/git"
11 "smoothie/tui/bubbles/commits"
12 "smoothie/tui/bubbles/repo"
13 "smoothie/tui/bubbles/selection"
14+ "strings"
15
16 tea "github.com/charmbracelet/bubbletea"
17 "github.com/charmbracelet/lipgloss"
18@@ -142,26 +144,34 @@ func (b *Bubble) viewForBox(i int, width int, height int) string {
19 return ls.Render(b.boxes[i].View())
20 }
21
22+func (b Bubble) footerView(w io.Writer) {
23+ h := []helpEntry{
24+ {"tab", "section"},
25+ {"↑/↓", "navigate"},
26+ {"q", "quit"},
27+ }
28+ for i, v := range h {
29+ fmt.Fprint(w, v)
30+ if i != len(h)-1 {
31+ fmt.Fprint(w, helpDivider)
32+ }
33+ }
34+}
35+
36 func (b *Bubble) View() string {
37+ s := strings.Builder{}
38 w := b.width - 3
39- f := ""
40- s := ""
41- content := ""
42- h := headerStyle.Width(w - 2).Render(b.config.Name)
43- f += footerHighlightStyle.Bold(true).Render("tab ")
44- f += footerStyle.Render("section • ")
45- f += footerHighlightStyle.Bold(true).Render("j/k ")
46- f += footerStyle.Render("down/up • ")
47- f += footerHighlightStyle.Bold(true).Render("q ")
48- f += footerStyle.Render("quit")
49+ s.WriteString(headerStyle.Width(w - 2).Render(b.config.Name))
50+ s.WriteRune('\n')
51 switch b.state {
52 case loadedState:
53 lb := b.viewForBox(0, boxLeftWidth, 0)
54 rb := b.viewForBox(1, b.width-boxLeftWidth-10, b.height-8)
55- s += lipgloss.JoinHorizontal(lipgloss.Top, lb, rb)
56+ s.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, lb, rb))
57 case errorState:
58- s += errorStyle.Render(fmt.Sprintf("Bummer: %s", b.error))
59+ s.WriteString(errorStyle.Render(fmt.Sprintf("Bummer: %s", b.error)))
60 }
61- content = h + "\n" + s + "\n" + f
62- return appBoxStyle.Width(w).Height(b.height).Render(content)
63+ s.WriteRune('\n')
64+ b.footerView(&s)
65+ return appBoxStyle.Width(w).Height(b.height).Render(s.String())
66 }
67diff --git a/tui/help.go b/tui/help.go
68new file mode 100644
69index 0000000000000000000000000000000000000000..19b290aff51536cefc194b6eac3ef9b525824121
70--- /dev/null
71+++ b/tui/help.go
72@@ -0,0 +1,12 @@
73+package tui
74+
75+import "fmt"
76+
77+type helpEntry struct {
78+ key string
79+ val string
80+}
81+
82+func (h helpEntry) String() string {
83+ return fmt.Sprintf("%s %s", helpKeyStyle.Render(h.key), helpValueStyle.Render(h.val))
84+}
85diff --git a/tui/style.go b/tui/style.go
86index 1a45f6c4c55cd84194312ac59f50c164ca00cb41..d4ff52ae7cf06964c9dac96991f87fad27f4968f 100644
87--- a/tui/style.go
88+++ b/tui/style.go
89@@ -38,11 +38,15 @@ var headerStyle = lipgloss.NewStyle().
90 var normalStyle = lipgloss.NewStyle().
91 Foreground(lipgloss.Color("#FFFFFF"))
92
93-var footerStyle = lipgloss.NewStyle().
94- Foreground(lipgloss.Color("#373737"))
95-
96-var footerHighlightStyle = lipgloss.NewStyle().
97- Foreground(lipgloss.Color("#DCDCDC"))
98-
99 var errorStyle = lipgloss.NewStyle().
100 Foreground(lipgloss.Color("#FF00000"))
101+
102+var helpKeyStyle = lipgloss.NewStyle().
103+ Foreground(lipgloss.Color("241"))
104+
105+var helpValueStyle = lipgloss.NewStyle().
106+ Foreground(lipgloss.Color("239"))
107+
108+var helpDivider = lipgloss.NewStyle().
109+ Foreground(lipgloss.Color("237")).
110+ SetString(" • ")