components

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ButtonAccent = ButtonPrimary

ButtonAccent is ButtonPrimary by its older name: it was the workbench's Run, which is that screen's primary action, and the two are one kind now.

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 LogoTitle

func LogoTitle(key string) string

LogoTitle is the name a key's brand is read by: a brand is its own name in every language. The two keys that are words ("file", "gateway") are sentences the app says (logo.file, logo.gateway), never this.

func TrendWindow

func TrendWindow(days []postgres.LoadDay) (from, to string)

TrendWindow is the span the panel covers, for the caption: the first and the last day.

Types

type BarSegment

type BarSegment struct {
	Share float64
	Class string
}

BarSegment is one part of a Stat's bar: its share of the whole (0..1) and its color class.

type ButtonKind

type ButtonKind int

ButtonKind is what a button is for, and therefore how loud it is.

const (
	// ButtonSecondary is the default: bordered, quiet, most buttons.
	ButtonSecondary ButtonKind = iota
	// ButtonPrimary is the one thing a screen most wants done, in the accent:
	// the lime is spent here, on the open section and on the focus ring, and
	// nowhere else, so it always points at the next click. One per screen.
	ButtonPrimary
	// ButtonDanger is a verb that loses something.
	ButtonDanger
)

type ButtonSize

type ButtonSize int

ButtonSize is a button's height.

const (
	SizeRegular ButtonSize = iota // 32px
	SizeSmall                     // 26px, in a table row or a dense toolbar
)

type CalendarSummary

type CalendarSummary struct {
	RanDays, FailedDays, Streak int
	LastFailure, Since          *time.Time
}

CalendarSummary is what the calendar says before its grid: how many days it ran, how many failed, how many days since the last failure -- or since it began, if it never failed -- when that was, and since when it runs.

func SummarizeCalendar added in v0.43.0

func SummarizeCalendar(days []postgres.Day, now time.Time) CalendarSummary

SummarizeCalendar counts the days that ran and failed, and how long since the last failure -- or since the first run, when there was none. The squares, months and weekday names are the app's: it draws the calendar and says its words.

type Def

type Def struct {
	Term, Value string
	// Mono draws the value in the machine's face: a URI, a cron, a key.
	Mono bool
}

Def is one row of a DefinitionList.

type KVItem

type KVItem struct {
	Key, Value, Note string
}

KVItem is one cell of a key-value grid: a machine's key, its value, and a note on what it means.

type LoadBar

type LoadBar struct {
	Href  string
	Rows  *int64
	Title string
}

LoadBar is one load on a destination's page.

type SegOption

type SegOption struct {
	Label, Href string
	// Count is printed beside the label when set: how many rows the choice
	// would show. A string so the caller decides "3" or "3+".
	Count   string
	Current bool
}

SegOption is one choice in a segmented filter: a link, so the filter is a URL and works with no script.

type Stat

type Stat struct {
	Label, Value string
	// Unit is printed small beside the number ("s", "GB"); Note faint, on
	// the value's line (density-base DB4).
	Unit, Note string
	// Icon is a glyph name for the label; empty draws none.
	Icon string
	// Dot is a state's color (a `bg-state-*` class) for a dot before the
	// label; empty draws none.
	Dot string
	// Bar is an optional thin bar under the value, in segments.
	Bar []BarSegment
	// Sub is faint text beside the label ("· 3 loads").
	Sub string
	// Tone is a text color class for the value, for a number that needs a
	// look (`text-state-failed`); empty is the ink.
	Tone string
	// Title is the cell's tooltip: how to read what it shows.
	Title string
}

Stat is one number in a Stats strip.

type Tab

type Tab struct {
	Key, Label string
	// Count is drawn quieter beside the label ("Logs 17"); empty draws none.
	Count    string
	Selected bool
}

Tab is one tab in a tablist.

type TrendPoint

type TrendPoint struct {
	X, Y  int
	Date  string // YYYY-MM-DD
	Value float64
}

TrendPoint is one day on the line: where it is drawn, and what it was.

type TrendSeries

type TrendSeries struct {
	// Key is "rows", "bytes", "extract" or "load"; Unit is "count", "size" (bytes) or "seconds".
	Key, Unit string
	Latest    float64 // the current value
	// Delta is how it moved across the window: "" (nothing to say), "new" (from nothing to something),
	// "steady" or "pct", with Pct the percentage, rounded.
	Delta  string
	Pct    int
	Hue    string // the CSS class for Delta
	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. It holds numbers and codes, never words: the app names the series (Key), writes the numbers in the unit the series is measured in (Unit) and says what the delta means.

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

func Trend

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.

Jump to

Keyboard shortcuts

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