Builtin Library
README.md
statusLabel
Numeric label that auto-picks a class by threshold ranges. The caller
passes { good = X, warn = Y } (sorted ascending). Values below good
get the good class; below warn get warn; the rest get bad.
Non-numeric values get the bad class so a missing/erroring data
source is visually loud. Defaults to the engine theme's
debug-timing-good/warn/bad classes shipped in themes/debug.yaml.
Exports
statusLabel(value, thresholds, opts?) -> Node— returns a coloured label widget. Module returns the builder function directly.
Types:
StatusClasses = { good: string, warn: string, bad: string }StatusThresholds = { good: number?, warn: number? }StatusLabelOpts = { id?, classes?, ratioOf?, fmt?, bold?, color?, fontSize? }
Usage
local statusLabel = require("@builtin::modules.zui.widget.statusLabel")
statusLabel(dtMs, { good = 16, warn = 33 })
statusLabel(used, { good = 0.8, warn = 0.95 }, {
ratioOf = max,
fmt = function(v) return string.format("%.1f%%", v * 100) end,
})
Notes
- Pass
ratioOfto comparevalue / ratioOfagainst the thresholds while still feeding the raw value tofmt. Non-positiveratioOfvalues are ignored. - Pass custom
classes = { good, warn, bad }to retarget styling. The default classes live inthemes/debug.yaml. - Non-numeric
valuealways renders in thebadclass so a broken data source is visually loud.