Documentation
¶
Index ¶
- Variables
- func LoadCmd(loader func() ([]*api.Item, error)) tea.Cmd
- func LoadItemCmd(client *api.Client, id int) tea.Cmd
- func LoadUserCmd(client *api.Client, username string) tea.Cmd
- func Run(client *api.Client, title string, loader func() ([]*api.Item, error)) error
- func RunItem(client *api.Client, id int) error
- func RunUser(client *api.Client, username string) error
- func RunWithItems(client *api.Client, title string, items []*api.Item) error
- func RunWithLoader(client *api.Client, title string, loader func() ([]*api.Item, error)) error
- func Sep() string
- type App
- type BackMsg
- type CommentsModel
- type ItemLoaded
- type ListModel
- type OpenItem
- type OpenURL
- type StoriesLoaded
- type UserLoaded
- type UserModel
- type View
Constants ¶
This section is empty.
Variables ¶
var ( // Story list styles. TitleStyle = lipgloss.NewStyle(). Foreground(white). Bold(true) SelectedTitleStyle = lipgloss.NewStyle(). Foreground(orange). Bold(true) MetaStyle = lipgloss.NewStyle(). Foreground(subtleGray) ScoreStyle = lipgloss.NewStyle(). Foreground(orange). Bold(true) IndexStyle = lipgloss.NewStyle(). Foreground(dimGray). Width(4). Align(lipgloss.Right) // Comment styles. CommentAuthorStyle = lipgloss.NewStyle(). Foreground(orange). Bold(true) CommentTimeStyle = lipgloss.NewStyle(). Foreground(subtleGray) CommentTextStyle = lipgloss.NewStyle(). Foreground(white) IndentStyle = lipgloss.NewStyle(). Foreground(dimGray) // Header / title bar. HeaderStyle = lipgloss.NewStyle(). Background(orange). Foreground(lipgloss.Color("#000000")). Bold(true). Padding(0, 1) // Status bar. StatusStyle = lipgloss.NewStyle(). Foreground(subtleGray). Italic(true) // User profile. UserNameStyle = lipgloss.NewStyle(). Foreground(orange). Bold(true). Underline(true) UserKarmaStyle = lipgloss.NewStyle(). Foreground(yellow). Bold(true) // Help bar. HelpStyle = lipgloss.NewStyle(). Foreground(dimGray) // Separator. SepStyle = lipgloss.NewStyle(). Foreground(dimGray). SetString(" · ") // URL. URLStyle = lipgloss.NewStyle(). Foreground(green). Italic(true) )
Functions ¶
func LoadItemCmd ¶
LoadItemCmd fetches a story and its first-level comments in parallel.
func LoadUserCmd ¶
LoadUserCmd fetches a user profile and their recent submissions.
func RunWithItems ¶
RunWithItems starts the TUI with a pre-built item list (e.g. search results).
func RunWithLoader ¶
RunWithLoader starts the TUI loading items async.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the root bubbletea model for the interactive browser.
type CommentsModel ¶
type CommentsModel struct {
// contains filtered or unexported fields
}
CommentsModel is a bubbletea model for a threaded comment view.
func NewCommentsModel ¶
func NewCommentsModel() CommentsModel
NewCommentsModel returns a loading comments model.
func (CommentsModel) Init ¶
func (m CommentsModel) Init() tea.Cmd
func (CommentsModel) Update ¶
func (m CommentsModel) Update(msg tea.Msg) (CommentsModel, tea.Cmd)
func (CommentsModel) View ¶
func (m CommentsModel) View() string
type ItemLoaded ¶
ItemLoaded is sent when a single item (and its comment tree) is ready.
type ListModel ¶
type ListModel struct {
// contains filtered or unexported fields
}
ListModel is a bubbletea model for a scrollable list of stories.
func NewListModel ¶
NewListModel creates a list model with a given title. Items are populated later.
type OpenItem ¶
type OpenItem struct{ ID int }
OpenItem is sent when the user wants to open a story's comments.
type StoriesLoaded ¶
StoriesLoaded is sent when story items have been fetched.
type UserLoaded ¶
UserLoaded is sent when a user profile has been fetched.