Documentation
¶
Overview ¶
Package layout provides frame-based structural layout primitives for terminal UIs built with viewkit.
Index ¶
- Constants
- Variables
- func BodyBudget(height int) int
- func ContentRows(height int) int
- func CountLines(s string) int
- func DialogWidth(screenWidth int) int
- func FillHeight(body string, height int) string
- func FirstLine(s string) string
- func Fit(s string, width int) string
- func FitBlock(block string, w, h int) string
- func FitCols(cols, width int) int
- func FitsScreenWidth(screenWidth int) bool
- func FlexColCount(width, minWidth, maxCols int) int
- func IndentLines(s string, n int) string
- func Lines(s string) []string
- func Overlay(bg, fg string, pos ...OverlayPos) string
- func PadLines(body string, rows int) string
- func ScrollPanel(title string, lines []string, rows, offset int) string
- func ScrollableBody(body string, rows int) string
- func ScrollableRows(body string, rows int) int
- func SplitStickyFooter(body string) (content, footer string)
- func Spread(left, right string, width int) string
- func SpreadBGIn(th theme.Theme, bg lipgloss.TerminalColor, left, right string, width int) string
- func Stack(sections ...string) string
- func StackFit(tier Tier, sections ...Section) string
- func StackTight(sections ...string) string
- func StackTightFit(tier Tier, sections ...Section) string
- func TooNarrowIn(t theme.Theme, screenWidth int) string
- func ViewportContentRows(rows int) int
- func ViewportLayout(body string, rows, offset int) string
- type Arranger
- type FlexBounds
- type FlexColumns
- type FlexRows
- type FlexSections
- type Focusable
- type Frame
- func (f Frame) BodyWidth() int
- func (f Frame) Box(lines ...string) string
- func (f Frame) CellBox(title string, lines ...string) string
- func (f Frame) CellPanel(title string, lines []string, offset int) string
- func (f Frame) CellTitledBox(title string, lines ...string) string
- func (f Frame) CellTitledBoxIcon(icon, title string, lines ...string) string
- func (f Frame) Cursor(selected bool) string
- func (f Frame) Fit(s string) string
- func (f Frame) Focus() Frame
- func (f Frame) Glyphs() glyph.Set
- func (f Frame) Header(title string, detail ...string) string
- func (f Frame) HintLine(pairs ...keys.Hint) string
- func (f Frame) Panel(title string, lines ...string) string
- func (f Frame) Row(label, value string) string
- func (f Frame) Rule() string
- func (f Frame) Scheme() keys.Scheme
- func (f Frame) Screen() Frame
- func (f Frame) ScrollPanel(title string, lines []string, rows, offset int) string
- func (f Frame) ScrollPanelWithPrefix(title string, prefix, lines []string, rows, offset int) string
- func (f Frame) Selectable(label string, selected bool) string
- func (f Frame) Spread(left, right string) string
- func (f Frame) Theme() theme.Theme
- func (f Frame) TitledBox(title string, lines ...string) string
- func (f Frame) TitledBoxIcon(icon, title string, lines ...string) string
- func (f Frame) Viewport(body string, rows, offset int) string
- func (f Frame) WithHeight(h int) Frame
- func (f Frame) WithUI(scope *ui.Scope) Frame
- func (f Frame) WithWidth(width int) Frame
- type Grid
- type GridPos
- type LayoutFactory
- type OverlayPos
- type Pane
- type PaneFactory
- type PaneInfo
- type PaneRef
- type Params
- type Registry
- type Ring
- type Screen
- type ScreenSpec
- type ScrollState
- type Section
- type SingleColumn
- type Surface
- type Tier
- type TierRows
Examples ¶
Constants ¶
const ( DefaultFlexMinWidth = 40 DefaultFlexMaxCols = 4 )
Defaults for FlexColumns/FlexRows/FlexSections when MinWidth or MaxCols is unset (< 1): tracks at least 40 cells wide, at most 4 of them.
const DialogMaxWidth = 56
DialogMaxWidth caps how wide DialogWidth will grow on a wide screen.
const MinTrackWidth = SlimMinWidth
MinTrackWidth is the narrowest column a tiling layout will create. It is the same floor Slim panes use, and it is what Frame.CellBox needs to stay inside the rect its layout hands it. It is not enough for Frame.TitledBox, which clamps its body up to theme.MinBodyWidth and therefore needs theme.MinBodyWidth+4 columns; panes that tile into narrow tracks want Frame.CellTitledBox, which clamps down instead.
const SlimMinWidth = 20
SlimMinWidth is the narrowest a Slim pane will be squeezed to (in cells) before it stops shrinking.
Variables ¶
var ( ErrUnknownLayout = errors.New("layout: unknown layout") ErrUnknownPane = errors.New("layout: unknown pane") )
ErrUnknownLayout and ErrUnknownPane report spec keys missing from the registry; match with errors.Is.
var Center = OverlayPos{XFrac: 0.5, YFrac: 0.5}
Center anchors an overlay in the middle of the background.
var StrictScope bool
StrictScope is a test hook — when true, Frame accessors panic on nil UI so fallback leaks surface.
Functions ¶
func BodyBudget ¶
BodyBudget converts a terminal height into the rows available to the body after the vertical app margins, floored at 1. A non-positive height (size unknown) assumes the minimum body height rather than returning 0.
func ContentRows ¶
ContentRows is BodyBudget for callers that would rather render nothing than guess: a non-positive height returns 0 instead of the minimum-height fallback.
func CountLines ¶
CountLines reports how many display lines s occupies. Unlike strings.Count+1 conventions elsewhere, an empty string still counts as one line, and a trailing newline adds a final (empty) line.
func DialogWidth ¶ added in v0.1.6
DialogWidth returns the width for a modal drawn over a screen of the given width: inset from both edges, but never wider than DialogMaxWidth.
func FillHeight ¶ added in v0.0.4
FillHeight pads body with trailing newlines until it spans height rows. A body already at or over the height is returned unchanged — nothing is trimmed.
func FirstLine ¶ added in v0.1.6
FirstLine returns the first non-empty line of s with surrounding whitespace trimmed, or "" when s holds no text. It measures nothing — pair it with Fit when the result also needs to respect a width budget.
func Fit ¶
Fit truncates a single line to width cells, ANSI-aware, appending an ellipsis when it cuts. Unlike Spread it only ever shortens one string; widths below 1 return "".
func FitBlock ¶
FitBlock forces block to exactly w x h cells: each line is ANSI-aware truncated or space-padded to w, and rows are dropped or blank-padded to h.
func FitCols ¶ added in v0.1.13
FitCols reduces a requested column count until every column is at least MinTrackWidth wide, never dropping below a single column. A width below one cannot hold even a single track, so it also yields a single column.
func FitsScreenWidth ¶
FitsScreenWidth reports whether a terminal of this width can host the UI. Unknown widths (<= 0) are assumed to fit; below theme.MinScreenWidth render TooNarrow instead.
func FlexColCount ¶
FlexColCount returns how many equal-width tracks fit in width, given a minimum track width and a hard cap, clamped to [1, maxCols]. The requested minimum is itself floored at MinTrackWidth: a track narrower than that cannot hold a box, so asking for one yields fewer, wider columns instead.
func IndentLines ¶ added in v0.0.4
IndentLines prefixes every line of s (including blank ones) with n spaces.
func Lines ¶ added in v0.1.6
Lines splits s into display lines. Every trailing newline is dropped, so a block ending in "\n" yields no spurious empty last line; interior blank lines are preserved. Input is assumed to use "\n" endings, not CRLF.
func Overlay ¶
func Overlay(bg, fg string, pos ...OverlayPos) string
Overlay draws fg on top of bg at the given anchor (Center when omitted). The covered strip of each background line is replaced — ANSI-aware, with the foreground padded to its block width so background text cannot bleed through. A foreground taller than the background extends the result downward rather than being clipped.
func PadLines ¶
PadLines pads body with trailing newlines until it spans rows display lines. It never trims: a body already at or over the budget is returned unchanged. rows <= 0 returns "".
func ScrollPanel ¶
ScrollPanel is Frame.ScrollPanel on the default-width frame.
func ScrollableBody ¶
ScrollableBody returns the part of body that ViewportLayout would scroll: the content above the sticky footer. A body with no footer scrolls whole and is returned as is; if the footer leaves no room to scroll it returns "".
func ScrollableRows ¶
ScrollableRows returns how many of the given rows ViewportLayout would give the scrolling content once the sticky footer (and the separator line before it) is paid for. Callers use it to clamp scroll offsets.
func SplitStickyFooter ¶
SplitStickyFooter splits body at its *last* blank line: everything after it is the sticky footer, everything before it the scrollable content. A body with no blank line has no footer.
func Spread ¶
Spread lays left and right on one line with the gap between them padded so the line is exactly width cells (theme.BodyWidth when width <= 0). When both sides cannot fit, the right side wins: left is truncated with an ellipsis first, and dropped entirely before right is ever shortened.
func SpreadBGIn ¶ added in v0.2.2
SpreadBGIn is Spread with the gap painted in the given background color, for lines that sit on a filled strip (status bars, headers). The truncation ellipsis is styled to match the strip, dimmed with th.
func Stack ¶
Stack joins non-empty sections with a blank line between them; empty sections vanish rather than leaving double gaps.
func StackFit ¶
StackFit stacks the sections visible at the given tier (tier >= MinTier) with blank lines between them, like Stack.
func StackTight ¶
StackTight joins non-empty sections with single newlines (no blank line between them).
func StackTightFit ¶
StackTightFit is StackFit joined with single newlines instead of blank lines.
func TooNarrowIn ¶ added in v0.2.2
TooNarrowIn renders th's "terminal too narrow" notice, sized to the given width (or the minimum layout width when the width is unknown), showing the current and required column counts.
func ViewportContentRows ¶
ViewportContentRows reports how many content rows Viewport shows for a given budget once the hint line and optional margin row are paid for — use it to clamp offsets consistently with Viewport's own windowing.
func ViewportLayout ¶
ViewportLayout scrolls body inside rows of height while keeping a sticky footer pinned to the bottom, hint lines styled with the built-in default theme. The footer is whatever follows the last blank line (see SplitStickyFooter); only the content above it scrolls with offset. If the footer alone fills the budget the content is dropped entirely, and rows <= 0 returns the body unscrolled.
Types ¶
type Arranger ¶ added in v0.2.0
Arranger positions and renders a set of panes into a single block. f is the full area available, tier filters panes by MinTier, and focusedName marks which interactive pane renders with a focused Frame. Implementations include SingleColumn, Grid, FlexColumns, FlexRows, and FlexSections.
type FlexBounds ¶ added in v0.2.1
FlexBounds is the shared track sizing for flex layouts: minimum track width and maximum column count. Zero values fall back to the Default* constants.
func (FlexBounds) Columns ¶ added in v0.2.1
func (b FlexBounds) Columns(width int) int
Columns reports how many tracks fit at the given width.
type FlexColumns ¶
type FlexColumns struct {
FlexBounds
}
FlexColumns is a responsive column-masonry layout: panes are distributed round-robin into N equal-width vertical stacks, where N grows with width. Columns keep a fixed width, so a pane never expands into an empty neighbour.
type FlexRows ¶
type FlexRows struct {
FlexBounds
}
FlexRows is a responsive row-major layout: panes fill left-to-right into rows of up to N tracks (N grows with width). A row with fewer panes than N — most often the ragged final row — divides the full width among only the panes present, so a pane with no neighbour expands to fill the row. Each row is as tall as its tallest pane; shorter panes are padded to match.
type FlexSections ¶
type FlexSections struct {
FlexBounds
}
FlexSections is FlexColumns applied per pane Group: panes sharing a Group value are flowed together under a titled section header (a rule line labeled with the group name), sections stacked in first-appearance order. Panes with an empty Group render without a header.
type Focusable ¶
Focusable names a candidate for the focus ring; only entries with Interactive set actually join it.
type Frame ¶
type Frame struct {
Width int
Height int
Focused bool
// UI is the rendering scope (theme, keys, glyphs). Nil falls back to the
// built-in defaults; derive new frames with WithWidth/Screen/WithUI so the
// scope is never dropped.
UI *ui.Scope
}
Frame is the rendering context handed to every layout helper: the width and height (in terminal cells) a block may occupy, and whether the block owns focus. A zero Height means "unconstrained"; helpers that need a height fall back to natural content height. Frame is a value type — Focus and WithHeight return modified copies.
Example ¶
package main
import (
"github.com/codyconfer/viewkit/layout"
)
func main() {
f := layout.NewFrame(60)
body := layout.Stack(
f.Header("STATUS", "local"),
f.Panel(
"TOKENS",
f.Row("balance", "12"),
f.Row("rate", "0.8/s"),
),
)
_ = layout.ViewportLayout(body, 12, 0)
}
Output:
func DefaultFrame ¶
func DefaultFrame() Frame
DefaultFrame returns a Frame at the standard body width (theme.BodyWidth).
func DocumentFrame ¶ added in v0.2.0
func DocumentFrame() Frame
DocumentFrame returns a Frame at the standard document width (theme.BodyWidth) — the frame for scrollback/document output that is not sized to a live terminal.
func FrameFor ¶ added in v0.0.4
FrameFor sizes a Frame to the terminal behind w when w is a *os.File on a tty; anything else (pipes, buffers, size errors) gets DefaultFrame.
func NewFrame ¶
NewFrame returns a Frame for the given body width. Non-positive widths fall back to theme.BodyWidth, and any width below theme.MinBodyWidth is clamped *up* to it — so boxes built on NewFrame widths can exceed the space a tiling layout allotted; see Frame.CellBox for the clamp-down alternative.
func ScreenFrame ¶
ScreenFrame converts a full terminal width into a body Frame by subtracting theme.ScreenPaddingWidth; unknown widths get DefaultFrame. NewFrame's minimum-width clamp still applies.
func (Frame) BodyWidth ¶
BodyWidth is the frame's width after NewFrame's clamping: non-positive widths become theme.BodyWidth and narrow ones are raised to theme.MinBodyWidth. Box, Panel, and TitledBox all size their bodies from it.
func (Frame) Box ¶
Box renders lines inside the theme panel border at the frame's BodyWidth. Because BodyWidth clamps narrow frames *up* to theme.MinBodyWidth, a Box can be wider than f.Width; inside a tiling layout use Frame.CellBox instead, which clamps down to fit the cell. A focused frame uses the focus border style.
func (Frame) CellBox ¶
CellBox renders a bordered box that fills exactly f.Width columns: the border and padding cost 4 columns, so the body is f.Width-4. Unlike NewFrame, a cell narrower than theme.MinBodyWidth+4 clamps the body *down* rather than up, so the box never spills past the rect its layout gave it and never loses its right border to the compositor.
func (Frame) CellTitledBox ¶ added in v0.1.14
CellTitledBox is TitledBox sized to fit inside f.Width rather than around it. TitledBox routes through Frame.BodyWidth, which clamps a narrow body *up* to theme.MinBodyWidth, so a titled pane needs theme.MinBodyWidth+4 columns before it stops spilling past the rect its layout gave it — MinTrackWidth alone is not enough. CellTitledBox clamps the body down instead, exactly as CellBox does, and so keeps its right border in any track.
func (Frame) CellTitledBoxIcon ¶ added in v0.1.14
CellTitledBoxIcon is CellTitledBox with an icon before the title, clamped down to f.Width like the rest of the Cell* family.
func (Frame) Cursor ¶ added in v0.2.2
Cursor returns the two-cell selection marker: "▸ " when selected, otherwise two spaces so unselected rows keep the same indent.
func (Frame) Glyphs ¶ added in v0.2.2
Glyphs returns the scoped glyph set, or the default-mode set when unscoped.
func (Frame) Header ¶
Header renders a title line followed by a Rule. Detail parts are appended dim after a "·" separator; blank parts are skipped, and the whole line is truncated with an ellipsis at the rule's width.
func (Frame) HintLine ¶
HintLine renders key hints as "key label" pairs separated by dim dots, wrapping onto additional lines whenever the next pair would push past the body width.
func (Frame) Panel ¶
Panel is Box with a styled title as its first line (truncated to the body width). It shares Box's clamp-up behavior on narrow frames; the tiling-safe variant is Frame.CellBox / Frame.CellPanel.
func (Frame) Row ¶
Row renders a dim label on the left and value on the right, spread across the body width.
func (Frame) Rule ¶
Rule renders a dim horizontal rule spanning the body width plus the 4 columns of box border/padding, so it lines up with Box and Panel edges.
func (Frame) Scheme ¶ added in v0.2.2
Scheme returns the scoped key scheme, or the built-in default when unscoped.
func (Frame) Screen ¶ added in v0.2.2
Screen returns a copy sized as a body frame for a full terminal of the frame's width (ScreenFrame rules), preserving the scope.
func (Frame) ScrollPanel ¶
ScrollPanel renders a Panel showing a rows-high window of lines starting at offset. When lines overflow the window a dim "↕ a–b of n" footer line is appended inside the panel; offsets are clamped, never wrapped.
func (Frame) ScrollPanelWithPrefix ¶
ScrollPanelWithPrefix is ScrollPanel with fixed prefix lines pinned above the scrolling window (they do not scroll and do not count against rows). With no lines at all, the panel shows just the prefix.
func (Frame) Selectable ¶
Selectable renders a list row: Cursor marker plus the label, accent-styled when selected and truncated to leave room for the marker.
func (Frame) Theme ¶ added in v0.2.2
Theme returns the scoped theme, or the built-in default when unscoped.
func (Frame) TitledBox ¶ added in v0.0.4
TitledBox renders a rounded box with the title embedded in the top border. The body is f.BodyWidth() wide, so like Box it clamps narrow frames *up* to theme.MinBodyWidth and can overflow a tiling layout's rect — use Frame.CellTitledBox inside grids.
func (Frame) TitledBoxIcon ¶ added in v0.0.4
TitledBoxIcon is TitledBox with an icon rendered before the title in the top border. It shares TitledBox's clamp-up behavior.
func (Frame) Viewport ¶ added in v0.2.2
Viewport shows a scrolled window of body within a rows budget. A body that fits is returned whole; otherwise the last row (plus, at rows >= 3, a blank margin row) is spent on a "▲▼ pgup/pgdn · a–b of n" hint, so the content window is ViewportContentRows(rows) tall. Offsets are clamped; rows < 1 returns "".
func (Frame) WithHeight ¶
WithHeight returns a copy of the frame constrained to h rows.
type Grid ¶
Grid is a tiling Arranger: the frame is divided into Cols equal-width column tracks and panes are placed by GridPos (or auto-flowed), then composited to fill the frame exactly. Rows is a minimum row count; the grid grows past it as panes need. Panes tiled into grid tracks should render with the CellBox / CellTitledBox family, which stay inside their rect — see MinTrackWidth.
func (Grid) Arrange ¶
Arrange implements Arranger. Column count is reduced with FitCols so no track drops below MinTrackWidth (pinned panes then reflow via auto-flow); Slim panes give up width to their row-mates; and the result is composited to exactly f.Width x f.Height, truncating pane output that overruns its rect. A frame without a height (f.Height < 1) falls back to SingleColumn.
type GridPos ¶
GridPos pins a pane to grid coordinates. Col/Row are zero-based; spans below 1 count as 1, and out-of-range values are clamped into the grid. Panes without a Pos cascade into the next free block instead.
type LayoutFactory ¶
type LayoutFactory func(params Params) (Arranger, error) //nolint:revive // name predates the lint rule; renaming would break callers
LayoutFactory builds an Arranger from spec parameters.
type OverlayPos ¶
OverlayPos anchors an overlay as fractions of the free space between the foreground and background blocks: 0 is the left/top edge, 1 the right/bottom, 0.5 centered.
type Pane ¶
type Pane struct {
Name string
Title string
Group string
Interactive bool
MinTier Tier
Pos *GridPos
Slim bool
Render func(Frame) string
}
Pane is one composable region of a Screen. Render is called with the Frame (width/height/focus) the Arranger allotted; MinTier hides the pane on screens shorter than its tier; Pos pins it to grid coordinates; Slim lets row-mates take width it does not need; Interactive panes with a Name join the focus Ring.
type PaneFactory ¶
PaneFactory builds a Pane from the caller's context. Returning ok=false omits the pane from the screen (BuildScreen skips it silently).
type PaneInfo ¶
PaneInfo is a registered pane's key and human-readable title, as returned by Registry.PaneKeys.
type PaneRef ¶
type PaneRef struct {
Key string `json:"key"`
Pos *GridPos `json:"pos,omitempty"`
MinTier *Tier `json:"minTier,omitempty"`
Slim bool `json:"slim,omitempty"`
}
PaneRef names a registered pane in a ScreenSpec and optionally overrides the placement fields (Pos, MinTier, Slim) of the Pane its factory builds. Slim only sets the flag — a spec cannot clear a factory's Slim.
type Params ¶
Params carries layout options from a ScreenSpec (typically decoded JSON or YAML) into a LayoutFactory.
type Registry ¶
type Registry[Ctx any] struct { // contains filtered or unexported fields }
Registry maps spec keys to pane and layout factories for BuildScreen. Ctx is whatever state pane factories need at build time. Use NewRegistry — it pre-registers the built-in layouts.
func NewRegistry ¶
NewRegistry returns a Registry with the built-in layouts pre-registered: "single" (SingleColumn), "flex-columns", "flex-rows", "sections" (all honoring minWidth/maxCols params), and "grid" (cols/rows params).
func (*Registry[Ctx]) LayoutFn ¶
func (r *Registry[Ctx]) LayoutFn(key string, f LayoutFactory) *Registry[Ctx]
LayoutFn registers a layout factory under key and returns the registry for chaining. Registering an existing key — including a built-in like "grid" — replaces it.
func (*Registry[Ctx]) LayoutKeys ¶
LayoutKeys lists registered layout keys, sorted alphabetically.
func (*Registry[Ctx]) Pane ¶
func (r *Registry[Ctx]) Pane(key, title string, f PaneFactory[Ctx]) *Registry[Ctx]
Pane registers a pane factory under key and returns the registry for chaining. Registering an existing key overwrites the previous factory and title in place; the key keeps its original position in PaneKeys order.
type Ring ¶
type Ring []string
Ring is the ordered list of interactive pane names focus cycles through. Callers keep an integer index and use At/Step; both tolerate out-of-range indexes by clamping.
func NewRing ¶
NewRing builds a Ring from the interactive entries, preserving order and skipping non-interactive ones.
func PaneRing ¶
PaneRing builds the focus Ring for a pane set: only interactive panes are included, in declaration order.
type Screen ¶
Screen pairs a pane set with the Arranger that lays it out. A nil Layout falls back to SingleColumn.
func BuildScreen ¶
func BuildScreen[Ctx any](s ScreenSpec, ctx Ctx, r *Registry[Ctx]) (Screen, error)
BuildScreen resolves a ScreenSpec against the registry. Unknown layout or pane keys (and a nil registry) are errors, but a pane factory returning ok=false just omits that pane. Spec-level Pos/MinTier/Slim overrides are applied to each built pane.
type ScreenSpec ¶
type ScreenSpec struct {
Layout string `json:"layout"`
LayoutParams Params `json:"layoutParams,omitempty"`
Panes []PaneRef `json:"panes"`
}
ScreenSpec is the declarative, serializable description of a Screen: a layout key with its params plus the panes to place. BuildScreen resolves it against a Registry.
type ScrollState ¶
type ScrollState struct {
Offset int
}
ScrollState is a scroll offset (in lines) with clamped mutation helpers. Embed or hold it by value in a view and pass the current totals into Scroll and Reveal; the state itself does not know the content size.
func (*ScrollState) Reveal ¶
func (s *ScrollState) Reveal(index, total, rows int)
Reveal adjusts the offset just enough to bring line index into the visible window, then clamps like Scroll. Lines already visible leave the offset untouched.
func (*ScrollState) Scroll ¶
func (s *ScrollState) Scroll(delta, total, rows int)
Scroll moves the offset by delta lines and clamps it to [0, total-rows], where total is the line count and rows the visible window height.
type Section ¶
Section is a block of rendered content plus the minimum Tier at which it should appear; StackFit and StackTightFit drop sections below the tier.
type SingleColumn ¶
type SingleColumn struct{}
SingleColumn is the simplest Arranger: every visible pane renders at the full frame width and the results are stacked vertically with blank lines between them. It ignores Frame.Height, Pos, and Slim.
type Surface ¶ added in v0.5.1
Surface is a solid-background rendering context for inline panel content.
func NewSurface ¶ added in v0.5.1
func NewSurface(width int, background lipgloss.TerminalColor) Surface
NewSurface creates a background-filled surface at width terminal cells.
type Tier ¶
type Tier int
Tier buckets terminal height into three coarse size classes so views can drop optional content on short screens instead of measuring exact rows. Higher tiers include everything lower ones show.
The three height tiers, from most to least constrained. TierForHeight maps a raw terminal height onto one of these.
func TierForHeight ¶
TierForHeight maps a terminal height to its Tier using the theme's body height thresholds. Unknown (non-positive) heights land on TierMedium via BodyBudget's minimum-height fallback.