package components import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) type Sidebar struct { Data []string Sindex int } func (s Sidebar) Init() tea.Cmd { return nil } func (s *Sidebar) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch m := msg.(type) { case tea.KeyMsg: switch m.String() { case "up": if s.Sindex > 0 { s.Sindex-- } case "down": if s.Sindex < len(s.Data)-1 { s.Sindex++ } } } return s, nil } func (s Sidebar) View() string { var items []string for i, item := range s.Data { if i == s.Sindex { items = append(items, lipgloss. NewStyle(). Foreground(lipgloss.Color("#FFFFFF")). Background(lipgloss.Color("#93BD57")). Render(item)) } else { items = append(items, item) } } return lipgloss. NewStyle(). BorderStyle(lipgloss.NormalBorder()). Padding(1, 2). Render(lipgloss.JoinVertical(lipgloss.Left, items...)) }