static.go

 1package anim
 2
 3import (
 4	"image/color"
 5
 6	tea "github.com/charmbracelet/bubbletea/v2"
 7	"github.com/charmbracelet/lipgloss/v2"
 8)
 9
10type Anim interface {
11	Init() tea.Cmd
12	Update(tea.Msg) (Anim, tea.Cmd)
13	View() string
14	SetLabel(string)
15}
16
17type noAnim struct {
18	Color    color.Color
19	rendered string
20}
21
22func newStatic(label string, foreground color.Color) Anim {
23	a := &noAnim{Color: foreground}
24	a.SetLabel(label)
25	return a
26}
27
28func (s *noAnim) SetLabel(label string) {
29	s.rendered = lipgloss.NewStyle().Foreground(s.Color).Render(label + ellipsisFrames[2])
30}
31
32func (s noAnim) Init() tea.Cmd                   { return nil }
33func (s *noAnim) Update(tea.Msg) (Anim, tea.Cmd) { return s, nil }
34func (s *noAnim) View() string                   { return s.rendered }