components

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package components provides reusable TUI building blocks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	// contains filtered or unexported fields
}

Header renders the top bar: greeting, role, cycle, breadcrumb.

func NewHeader

func NewHeader(userName, role, cycle string, styles HeaderStyles) Header

NewHeader creates a new header component.

func (Header) Height

func (h Header) Height() int

Height returns how many lines the header occupies at the current width. It must stay in lockstep with View(): the app reserves exactly this many rows for the header, so any divergence overflows the terminal and corrupts the layout.

func (*Header) SetWidth

func (h *Header) SetWidth(w int)

SetWidth updates the header width.

func (Header) View

func (h Header) View() string

View renders the header.

type HeaderStyles

type HeaderStyles struct {
	Bar        lipgloss.Style
	Greeting   lipgloss.Style
	Meta       lipgloss.Style
	Breadcrumb lipgloss.Style
}

HeaderStyles holds the styles for the header component.

type Modal struct {
	Title   string
	Message string
	Kind    ModalKind
	Input   string
	Visible bool
	// contains filtered or unexported fields
}

Modal renders a centered overlay dialog for confirmations or short text input.

func NewModal

func NewModal(styles ModalStyles) Modal

NewModal creates a new modal.

func (*Modal) AppendInput

func (m *Modal) AppendInput(s string)

AppendInput adds a character to the input.

func (*Modal) BackspaceInput

func (m *Modal) BackspaceInput()

BackspaceInput removes the last rune from the input. It deletes a whole UTF-8 rune (not a single byte) so backspacing over a multi-byte character never leaves invalid UTF-8 in the captured value.

func (*Modal) Hide

func (m *Modal) Hide()

Hide closes the modal.

func (*Modal) SetSize

func (m *Modal) SetSize(w, h int)

SetSize updates modal dimensions.

func (*Modal) ShowConfirm

func (m *Modal) ShowConfirm(title, message string)

ShowConfirm opens a confirmation modal.

func (*Modal) ShowInput

func (m *Modal) ShowInput(title, message string)

ShowInput opens a text input modal.

func (Modal) View

func (m Modal) View() string

View renders the modal overlay.

type ModalKind

type ModalKind int

ModalKind distinguishes between confirmation and text input modals.

const (
	ModalConfirm ModalKind = iota
	ModalInput
)

type ModalStyles

type ModalStyles struct {
	Border  lipgloss.Style
	Title   lipgloss.Style
	Message lipgloss.Style
	Input   lipgloss.Style
	Hint    lipgloss.Style
}

ModalStyles holds the styles for the modal component.

type StatusBar

type StatusBar struct {
	// contains filtered or unexported fields
}

StatusBar renders the bottom bar: view name, pending count, help hint, time.

func NewStatusBar

func NewStatusBar(styles StatusBarStyles) StatusBar

NewStatusBar creates a new status bar.

func (*StatusBar) NextSpinner

func (s *StatusBar) NextSpinner()

NextSpinner advances the spinner animation frame.

func (*StatusBar) SetBusy

func (s *StatusBar) SetBusy(active bool, label string)

SetBusy updates whether the status bar should show an inline busy indicator.

func (*StatusBar) SetExitArmed added in v0.9.0

func (s *StatusBar) SetExitArmed(armed bool)

SetExitArmed sets whether the status bar should show the double-esc-to-quit hint.

func (*StatusBar) SetPending

func (s *StatusBar) SetPending(count int)

SetPending updates the pending count.

func (*StatusBar) SetRefresh

func (s *StatusBar) SetRefresh(t time.Time)

SetRefresh updates the last refresh time.

func (*StatusBar) SetScroll

func (s *StatusBar) SetScroll(pos string)

SetScroll updates the scroll position indicator (e.g. "3/12").

func (*StatusBar) SetView

func (s *StatusBar) SetView(label string)

SetView updates the displayed view label.

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(w int)

SetWidth updates the status bar width.

func (StatusBar) View

func (s StatusBar) View() string

View renders the status bar.

type StatusBarStyles

type StatusBarStyles struct {
	Bar     lipgloss.Style
	Label   lipgloss.Style
	Pending lipgloss.Style
	Hint    lipgloss.Style
	Clock   lipgloss.Style
	Stale   lipgloss.Style
}

StatusBarStyles holds the styles for the status bar.

type Tab

type Tab struct {
	Label    string
	Shortcut string
}

Tab represents a single tab in the tab strip.

type TabStrip

type TabStrip struct {
	// contains filtered or unexported fields
}

TabStrip renders a horizontal tab bar.

func NewTabStrip

func NewTabStrip(tabs []Tab, styles TabStripStyles) TabStrip

NewTabStrip creates a new tab strip.

func (*TabStrip) SetActive

func (t *TabStrip) SetActive(idx int)

SetActive updates the active tab index.

func (*TabStrip) SetWidth

func (t *TabStrip) SetWidth(w int)

SetWidth updates the tab strip width.

func (TabStrip) View

func (t TabStrip) View() string

View renders the tab strip.

type TabStripStyles

type TabStripStyles struct {
	Active    lipgloss.Style
	Inactive  lipgloss.Style
	Bar       lipgloss.Style
	Separator lipgloss.Style
}

TabStripStyles holds the styles for the tab strip.

type Toast

type Toast struct {
	Message   string
	Kind      ToastKind
	ExpiresAt time.Time
	// contains filtered or unexported fields
}

Toast renders an ephemeral notification.

func NewToast

func NewToast(styles ToastStyles) Toast

NewToast creates a new toast component.

func (*Toast) Show

func (t *Toast) Show(msg string, kind ToastKind, duration time.Duration)

Show displays a toast for the given duration.

func (Toast) View

func (t Toast) View() string

View renders the toast. Returns empty string if not visible.

func (Toast) Visible

func (t Toast) Visible() bool

Visible returns true if the toast has not expired.

type ToastKind

type ToastKind int

ToastKind distinguishes toast types.

const (
	ToastSuccess ToastKind = iota
	ToastError
	ToastInfo
)

type ToastStyles

type ToastStyles struct {
	Success lipgloss.Style
	Error   lipgloss.Style
	Info    lipgloss.Style
}

ToastStyles holds the styles for toast notifications.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL