components

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

Index

Constants

View Source
const TrendDays = 90

TrendDays is how far back the trend reads. Ninety rather than the calendar's year: a chart with 364 points on 300 units of width draws under one point per pixel, and "is it getting worse" is a question about the recent past.

Variables

This section is empty.

Functions

func Calendar added in v0.11.2

func Calendar(days []postgres.Day, workflow string, span int) ([]Square, []Month, int, int)

Calendar lays a year of days out as a GitHub-style grid: one column per week, Sunday at the top.

The colour is the day's WORST OUTCOME, not its volume, and that is the whole decision behind this chart. GitHub encodes how much happened, because that is its question. The question here is "when did this pipeline break", and a heatmap where a busy Tuesday and a broken Tuesday are both dark answers neither. Volume is what the bar chart above already draws.

func Card added in v0.7.0

func Card(label string) templ.Component

Card is the base panel: a light surface, a thin border, a warm wide shadow.

func Dot added in v0.7.0

func Dot(status string) templ.Component

Dot is the minimal version, for dense tables where the label is already in the column.

func Duration added in v0.7.0

func Duration(d *time.Duration) string

Duration picks the unit by order of magnitude. "0.4s" says more than "400ms" in a column whose neighbour takes minutes.

func Empty added in v0.7.0

func Empty(msg, hint string) templ.Component

Empty communicates the absence of data without looking like an error. An empty table with no explanation sends the operator looking for a defect where there is none.

func ErrorButton added in v0.7.0

func ErrorButton(runID string) templ.Component

--------------------------------------------------------------------------- Err em dialogo

The error used to occupy a whole row below the run, inside the table. With a real stack trace that pushed the rest of the list off the screen and mixed two things — the list and the detail. Now the row holds a button, and the text lives in a native <dialog>: ESC closes it, the backdrop dims and the focus stays trapped inside it without a line of JavaScript of ours. ---------------------------------------------------------------------------

func ErrorDialog added in v0.7.0

func ErrorDialog(runID, workflow, status, message string) templ.Component

func Heatmap added in v0.11.2

func Heatmap(days []postgres.Day, workflow string) templ.Component

Heatmap draws a year of days, one square each.

Server-rendered SVG like every other chart here: it needs no library, it is in the HTML the first time the page arrives, and it prints. The tooltip is a <title>, which the browser shows on its own -- the same one the bar chart uses.

func LoadTrend added in v0.13.0

func LoadTrend(series []TrendSeries, window string) templ.Component

LoadTrend draws what a workflow's pipelines have been loading.

Four sparklines, server-rendered like the calendar: a chart that needs a runtime is a chart that does not appear on the page somebody opens during an incident.

The panel is DRAWN ONLY when there is history. A workflow whose steps are shell commands has no load to trend, and four empty boxes on its page would be four questions with no answer -- the caller checks, so this never has to render an apology.

func Metric added in v0.7.0

func Metric(label, value, nota string, matiz string) templ.Component

Metric is one of the four numbers at the top of the Overview. The large serif number is what sets the editorial tone — in sans it would become just another dashboard.

func Rosca

Rosca resume a mesma janela em proporcao. O total no centro evita a leitura only relative: 95% of twenty runs is not 95% of two thousand.

func RunsChart added in v0.7.0

func RunsChart(buckets []postgres.Bucket) templ.Component

RunsChart draws one stacked column per hour, with the average-duration line on top — the two readings the Overview screen has to cross: "how many" and "quanto tempo".

func State added in v0.7.0

func State(status string) templ.Component

State desenha o estado de um Run.

The colours are desaturated on purpose: a dashboard's pure green and red fight the parchment and shout louder than the information. The shape carries meaning too — the dot is filled for what has finished and ringed for what is still alive — so it does not depend on colour alone.

func Tag added in v0.7.0

func Tag(text, rota string) templ.Component

Tag is a tag chip. It becomes a link when `rota` exists, to filter.

func Timestamp added in v0.7.0

func Timestamp(t *time.Time) string

Timestamp is the full date, for audit columns, in the timezone of WHOEVER FORMATS -- which is the process's TZ, not the reader's.

The marker is not decoration. It used to render "2026-03-10 22:00:00" and stop there, and the same instant reads 22:00 on a machine at UTC-3 and 01:00 in a pod at UTC. Two people comparing one failure at three in the morning disagreed about when it happened, with nothing on the screen to reconcile them. notify/slack.go had already learned this and appends MST for the same reason; the screen had not.

For a value that IS UTC by contract -- a slot, an auto param -- use UTCStamp: local time there would make the screen disagree with the $BREVIS_AUTO_* variable the step actually reads.

func TrendGeometry added in v0.13.0

func TrendGeometry() (int, int)

TrendGeometry hands the template the viewBox it should use.

func TrendWindow added in v0.13.0

func TrendWindow(days []postgres.LoadDay) string

TrendWindow is the span the panel covers, for the caption.

func UTCStamp added in v0.10.1

func UTCStamp(t *time.Time) string

UTCStamp is the full date in UTC, for values that are UTC by contract.

The slot and the auto params are stored, injected and read in UTC -- a step gets `2026-03-11T01:00:00Z` in $BREVIS_AUTO_ADJUSTED_AT. Rendering those in the server's local time made the screen show `2026-03-10 22:00:00` beside a `date` of `2026-03-11`: one day apart, in the same grid, with nothing saying why, and a third answer for anyone who checked the environment.

The screen agreeing with the contract is worth more than the screen agreeing with the clock of whoever ran the deployment.

func When added in v0.7.0

func When(t *time.Time) string

When writes the instant relatively up to a day, and as an absolute date afterwards. "3 min ago" answers the operations question; "Mar 12 04:00" answers the audit one, and the boundary between the two sits around a day.

Types

type Arc added in v0.7.0

type Arc struct {
	Cor     string
	Dash    string
	Offset  int
	Tooltip string
	Link    string
}

type Bar added in v0.7.0

type Bar struct {
	X, Width               int
	BandX, BandWidth       int
	YSucceeded, HSucceeded int
	YFailed, HFailed       int
	YOutros, HOutros       int
	Tooltip                string
	Link                   string
}

type Brand added in v0.7.0

type Brand struct {
	X     int
	Label string
}

type GridLine added in v0.7.0

type GridLine struct {
	Y     int
	Label string
}

type Month added in v0.11.2

type Month struct {
	X     int
	Label string
}

Month is a label above the first column of a month.

type Square added in v0.11.2

type Square struct {
	X, Y    int
	Date    time.Time
	Fill    string
	Tooltip string
	Link    string
	// Empty says nothing ran. It is drawn, and drawn faintly: a missing square
	// would make the grid ragged and a reader would count the gap as a week.
	Empty bool
}

Square is one day of the calendar.

type TrendPoint added in v0.13.0

type TrendPoint struct {
	X, Y    int
	Tooltip string
}

TrendPoint is one day on the line, carrying its own tooltip.

type TrendSeries added in v0.13.0

type TrendSeries struct {
	Label  string
	Latest string // the current value, formatted
	Delta  string // how it moved across the window, e.g. "+38%"
	Hue    string // the CSS class for Delta
	Note   string // what the number means, in words
	Path   string // the polyline's points
	Area   string // the same, closed to the baseline
	Points []TrendPoint
	Empty  bool // no data at all: the panel says so instead of drawing a flat line
	Flat   bool // one day only, so there is no trend yet
}

TrendSeries is one line of the load trend, ready to draw.

Everything the template needs is computed here rather than in the markup: a `.templ` file that does arithmetic is a file where a division by zero becomes a blank page during an incident.

func Trend added in v0.13.0

func Trend(days []postgres.LoadDay) []TrendSeries

Trend turns a workflow's load history into the four series the screen draws.

Four, and these four, because they are the note's own questions: is the dataset growing, is each row getting fatter, is the source getting slower, is the destination getting slower. A fifth would be a number nobody asked for, and this panel has to be readable at a glance during an incident.

type WeekdayLabel added in v0.11.2

type WeekdayLabel struct {
	Y     int
	Label string
}

WeekdayLabel is one of the three labels down the calendar's left edge.

Jump to

Keyboard shortcuts

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