Documentation
¶
Overview ¶
Package statcard renders a dashboard metric tile: a single bordered card with a small uppercase label, a big bold value, and an optional trend row (glyph + delta + italic sublabel). Compose multiple cards in a horizontal row with lipgloss.JoinHorizontal to open any agent surface — engagements, PRs, revenue, latency.
Stat-cards are stateless from a TUI perspective: every Update is a no-op. The Bubble Tea Init/Update/View shape is still exposed so a parent model can drop a Model into its struct, re-render on every tick, and rebuild cards by chaining the immutable builders.
Index ¶
- type Model
- func (m Model) Height() int
- func (m Model) Init() tea.Cmd
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) Width() int
- func (m Model) WithDelta(s string) Model
- func (m Model) WithEmphasis(on bool) Model
- func (m Model) WithLabel(s string) Model
- func (m Model) WithSublabel(s string) Model
- func (m Model) WithTrend(t Trend) Model
- func (m Model) WithValue(s string) Model
- func (m Model) WithWidth(w int) Model
- type Trend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the immutable stat-card. Each With… builder returns a new Model so callers can compose cards inline in their View().
func New ¶
func New() Model
New constructs a Model bound to theme.Default. Set fields with the chain-builders before calling View().
func NewWithTheme ¶
NewWithTheme is the same as New but lets the parent inject a non-default palette (light theme, alt theme, etc.).
func (Model) Height ¶
Height returns the rendered outer height in cells. 6 for a label+value card, 7 with a delta or sublabel.
func (Model) Init ¶
Init implements tea.Model. Stat-cards do not animate, so no command is issued; this exists so a parent embedding a Model can call Init in its own Init chain without a special case.
func (Model) Update ¶
Update implements tea.Model. Stat-cards do not respond to messages — the parent owns the data and rebuilds the card on every tick. Update returns the receiver unchanged. WindowSizeMsg in particular is a no-op: composing cards into a layout is the parent's responsibility.
func (Model) WithDelta ¶
WithDelta sets the small colored change indicator on line 3, e.g. "+3", "-12%", "0". The trend chooses the color.
func (Model) WithEmphasis ¶
WithEmphasis bumps the card to "primary tile" styling: rounded border over the default normal border, SurfaceStrong over Surface, and a brighter border color. Use sparingly — one or two per row.
func (Model) WithLabel ¶
WithLabel sets the small uppercase label on line 1. Conventionally a noun phrase like "Open issues" or "Revenue".
func (Model) WithSublabel ¶
WithSublabel sets the italic muted line under the value, e.g. "since last week", "across 24 repos".
func (Model) WithTrend ¶
WithTrend chooses the trend glyph and color: up=success, down=error, neutral=muted.
func (Model) WithValue ¶
WithValue sets the big bold value on line 2. Free-form string — "12", "$499/mo", "1.2k", "00:42". No internal formatting; pass the already-formatted display string.
