The ui package contains bubbletea interfaces.
A style.go
file holds lipgloss predefined styles for the package.
All components are instances of a tea.Model
which is composed of models
from the internal
package.
Components can either be single file or independent packages.
Example for status.go
single file component:
package ui
import "github.com/algorandfoundation/algorun-tui/internal"
type StatusViewModel struct {
Data internal.StateModel
IsVisible bool
}
func (m StatusViewModel) Int(){}
//other tea.Model interfaces ...
Once the component is sufficiently complex or needs to be reused, it can be moved to its own package
Example refactor for status.go
to a package:
package status
import "github.com/algorandfoundation/algorun-tui/internal"
type ViewModel struct {
Data internal.StateModel
IsVisible bool
}
package status
// Init Lifecycle
func (m ViewModel) Init(){}
// Update lifecycle
func (m ViewModel) Update(){}
package status
func (m ViewModel) View() string {
return "Amazing View"
}
package status
func EmitSomething(thing internal.Something) tea.Cmd {
return func() tea.Msg {
return thing
}
}
package status
import "github.com/charmbracelet/lipgloss"
var someStyle = lipgloss.NewStyle()