Files
cburn/internal/tui/components/statusbar.go
teernisse 4d46977328 feat: expand component library with bar chart, content cards, and layout helpers
Add BarChart component that renders multi-row Unicode bar charts with
anchored Y-axis labels, automatic tick-step computation, sub-sampling
for narrow terminals, and optional X-axis date labels. The chart
gracefully degrades to a sparkline when width/height is too small.

Add ContentCard, CardRow, and CardInnerWidth utilities for consistent
bordered card layout across all dashboard tabs. ContentCard renders
a lipgloss-bordered card with optional bold title; CardRow joins
pre-rendered cards horizontally; CardInnerWidth computes the usable
text width after accounting for border and padding.

Add LayoutRow helper that distributes a total width into n integer
widths that sum exactly, absorbing the integer-division remainder
into the first items -- eliminates off-by-one pixel drift in multi-
column layouts.

Refactor MetricCard to accept an outerWidth parameter and derive the
content width internally by subtracting border, replacing the old
raw-width parameter that required callers to do the subtraction.
MetricCardRow now uses LayoutRow for exact width distribution.

Refine TabBar to render all tabs on a single row when they fit within
the terminal width, falling back to the two-row layout only when
they overflow.

Simplify StatusBar by removing the unused filterInfo append that was
cluttering the left section.
2026-02-19 15:01:26 -05:00

39 lines
636 B
Go

package components
import (
"fmt"
"cburn/internal/tui/theme"
"github.com/charmbracelet/lipgloss"
)
// RenderStatusBar renders the bottom status bar.
func RenderStatusBar(width int, dataAge string) string {
t := theme.Active
style := lipgloss.NewStyle().
Foreground(t.TextMuted).
Width(width)
left := " [?]help [q]uit"
right := ""
if dataAge != "" {
right = fmt.Sprintf("Data: %s ", dataAge)
}
// Pad middle
padding := width - lipgloss.Width(left) - lipgloss.Width(right)
if padding < 0 {
padding = 0
}
bar := left
for i := 0; i < padding; i++ {
bar += " "
}
bar += right
return style.Render(bar)
}