Documentation
¶
Overview ¶
Package chrome provides the structural primitives that wrap every console pane: a fixed Page layout (header + body + footer), a Theme that centralizes colors / paddings / separators, a Header that draws the tab bar plus status pill, and a Footer that auto-renders keybinding hints from the active pane's help.KeyMap.
The package owns the visual chrome only. Pane content is provided by each pane's own model.View call, sized to fit Page.BodyArea.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
func Render(in HeaderInput) string
Render returns a 2-row block: the tab/status line plus a thin horizontal rule beneath it. The rule is the only structural element — no colored background, no hard border — so the header reads as a "zone" without dominating the screen visually.
Layout:
[1] Monitor [2] New Item [3] Connection connected • pro • 7 streams • … ──────────────────────────────────────────────────────────────────────────────────────────────
Types ¶
type EmptyKeyMap ¶
type EmptyKeyMap struct{}
EmptyKeyMap is a no-op help.KeyMap that returns no bindings. Useful as a placeholder before the first pane has loaded.
func (EmptyKeyMap) FullHelp ¶
func (EmptyKeyMap) FullHelp() [][]key.Binding
FullHelp implements help.KeyMap.
func (EmptyKeyMap) ShortHelp ¶
func (EmptyKeyMap) ShortHelp() []key.Binding
ShortHelp implements help.KeyMap.
type Footer ¶
type Footer struct {
// contains filtered or unexported fields
}
Footer wraps `bubbles/v2/help.Model` so each pane can hand it a help.KeyMap and get a consistent footer-height keybinding hint row for free. Toggle ShowAll to expand to the full multi-row layout.
func NewFooter ¶
NewFooter constructs a Footer with theme-derived help styles. Width is set per-render via Render(width, keymap).
func (*Footer) Render ¶
Render produces the footer string, padded to width. Hits the help.Model with the active pane's keymap so the displayed hints always reflect what the user can actually do right now.
func (*Footer) SetShowAll ¶
SetShowAll toggles between the short single-line help and the full expanded help. The TUI's `?` binding flips this.
type HeaderInput ¶
type HeaderInput struct {
Width int
Tabs []TabItem
Team string // optional active team label, rendered to the left of the status pill so the user can see scope on every pane
Status string // primary status text (e.g. "connected • pro • 7 streams")
StatusKind StatusKind // colors the status pill
Clock string // optional trailing server-time, faint-styled
Theme *Theme
}
HeaderInput bundles everything the renderer needs. Built fresh on each render call so the Header itself stays stateless — easier to reason about, easier to test.
type Page ¶
Page is a value type carrying the terminal dimensions and a Theme reference. Constructed fresh on every render with the latest size.
Page itself owns no state — it's a thin renderer that knows how the header / body / footer compose. Centralizing this composition keeps every pane a single Render(width, height) -> string call away from the rest of the layout, with no per-pane chrome reimplementation.
func (Page) BodyArea ¶
BodyArea returns the inner-content rectangle for a given header and footer. Caller passes the already-rendered chrome strings; BodyArea measures their actual height (which can vary — the footer's bubbles/help expands when ShowAll toggles on) and subtracts. Clamped to a 1x1 minimum so a tiny terminal still produces something renderable rather than panicking on negative dimensions.
The Theme.HeaderHeight / Theme.FooterHeight constants are kept as defaults for tests and for callers that don't want to render chrome up-front, but the runtime View path uses this dynamic measurement so the help-toggle can grow the footer without truncating the body.
func (Page) Render ¶
Render assembles the three chrome sections into a single string the program can hand to tea.NewView. Header and footer are expected to have already been width-padded to p.Width by the caller. The body is height-clamped here so a pane that under-renders doesn't push the footer up the screen, and an over-rendering pane gets its trailing rows truncated rather than pushing the footer offscreen.
type StatusKind ¶
type StatusKind int
StatusKind classifies the right-side status pill so the renderer can pick the matching color (green for connected, yellow for connecting, red for disconnected/error states).
const ( StatusKindNeutral StatusKind = iota StatusKindOK StatusKindWarn StatusKindErr )
type TabItem ¶
TabItem is a single entry in the header's tab bar. Number is the 1-indexed quick-jump key surfaced as `[N]`; Title is the human label.
type Theme ¶
type Theme struct {
// Reserved row counts for the page chrome. Fixed so panes can
// compute their body height without measuring rendered output.
HeaderHeight int
// Foreground colors — re-exported from ui.* for ergonomic access
// inside this package and in the chrome consumers.
AccentFg color.Color // active tab text, focused pane title
OkFg color.Color // connected status, "live" indicator
WarnFg color.Color // reconnecting status, partial-state warnings
ErrFg color.Color // disconnected, error states, outage markers
MutedFg color.Color // inactive tabs, faint footer hints, separator
// Composed styles. Built once and shared so we don't re-allocate
// a lipgloss.Style on every render call.
HeaderBar lipgloss.Style // base style for the whole header row
TabActive lipgloss.Style // active tab pill
TabInactive lipgloss.Style // inactive tab pill
StatusPill lipgloss.Style // base for the right-side status
StatusOK lipgloss.Style // green-fg variant
StatusWarn lipgloss.Style // yellow-fg variant
StatusErr lipgloss.Style // red-fg variant
HeaderUnderln lipgloss.Style // separator row beneath the header
BodyPadding lipgloss.Style // applied to pane content
}
Theme is the single source of truth for the TUI's visual styling. Built once at startup from the shared `ui` palette so the console matches the rest of the CLI's output.
Every style constant lives here; panes pull what they need rather than re-deriving from raw colors. Rationale: changing a color (e.g. switching from Catppuccin Mauve to Lavender) becomes a single-line edit instead of a project-wide grep.