1package footer
2
3import (
4 "github.com/charmbracelet/bubbles/help"
5 tea "github.com/charmbracelet/bubbletea"
6 "github.com/charmbracelet/soft-serve/ui/common"
7)
8
9// Footer is a Bubble Tea model that displays help and other info.
10type Footer struct {
11 common common.Common
12 help help.Model
13 keymap help.KeyMap
14}
15
16// New creates a new Footer.
17func New(c common.Common, keymap help.KeyMap) *Footer {
18 h := help.New()
19 h.Styles.ShortKey = c.Styles.HelpKey
20 h.Styles.ShortDesc = c.Styles.HelpValue
21 h.Styles.FullKey = c.Styles.HelpKey
22 h.Styles.FullDesc = c.Styles.HelpValue
23 f := &Footer{
24 common: c,
25 help: h,
26 keymap: keymap,
27 }
28 return f
29}
30
31// SetSize implements common.Component.
32func (f *Footer) SetSize(width, height int) {
33 f.common.Width = width
34 f.common.Height = height
35}
36
37// Init implements tea.Model.
38func (f *Footer) Init() tea.Cmd {
39 return nil
40}
41
42// Update implements tea.Model.
43func (f *Footer) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
44 return f, nil
45}
46
47// View implements tea.Model.
48func (f *Footer) View() string {
49 if f.keymap == nil {
50 return ""
51 }
52 s := f.common.Styles.Footer.Copy().Width(f.common.Width)
53 return s.Render(f.help.View(f.keymap))
54}