Introduce a new `Sidebar` component to encapsulate sidebar logic and rendering. This component utilizes Bubble Tea and Lipgloss for UI elements. The main application now integrates this component for displaying sidebar content.
30 lines
460 B
Go
30 lines
460 B
Go
package components
|
|
|
|
import (
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
type Sidebar struct {
|
|
data string
|
|
}
|
|
|
|
func (s Sidebar) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
switch m := msg.(type) {
|
|
case tea.KeyMsg:
|
|
switch m.String() {
|
|
case "up":
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s Sidebar) View() string {
|
|
sidebar := lipgloss.
|
|
NewStyle().
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
Padding(1, 2).
|
|
Render(s.data)
|
|
return sidebar
|
|
}
|