pub struct Figure<'a> {
pub value: &'a str,
pub caption: &'a str,
pub change: Option<&'a str>,
pub tone: Tone,
}Expand description
One figure with a caption: a number and what it counts.
The dashboard shape. A large value over a small caption, several of them in a
strip: a current streak, a completion rate, a total. Added 0.11.0,
93c6a174, after goingson turned out to have five of them across five
screens with five class vocabularies for the one shape — task-overview-stat,
stat-box, month-stat-item, contact-summary-stat, sync-stat. Four put
the value above the caption and one inverts it, which is drift inside the
shape rather than a second shape.
§Why the value is text
“17”, “84%”, “12/30”, “3d”. A figure is whatever the app computed, already
formatted, and the formatting is the app’s because only it knows whether the
number is a percentage, a duration or a ratio. This carries none of the
arithmetic Meter carries, and that is the difference between them: a
meter is a proportion a renderer draws, and a figure is a fact a renderer
sets in type.
§Tone is carried, for Meter’s reason
Three of the five sites tone the figure by their own means — red/blue on
the weekly review, a ${type} class on the monthly one, sync-stat-warn on
sync. So tone is carried at every site that needs it and derived at none, and
no renderer can work out that a streak of zero is worth colouring.
§What is not here
Whether the figure answers a click. One of the five is a control — sync’s “Not Applied: 3” opens the list — and an action is not something this crate can name: nothing here knows what a route is. That belongs beside the figure in whatever layer holds the actions, the same way a row’s activation sits beside its parts rather than inside them.
The arrangement is not here either. Several figures in a strip is a set, and a renderer given them one at a time cannot tell it is looking at one; the layer that holds the tree is where the set gets said.
Fields§
§value: &'a strThe number, formatted the way the app means it to read.
caption: &'a strWhat it counts. The caption under the value.
change: Option<&'a str>How the value has moved, if the app is tracking that.
Added 0.13.0. Text, for value’s reason: only the app
knows whether a move reads as +12.5%, +3 or 2x, and a renderer
handed a number would have to guess.
This is what tone was for and had no consumer of. The MNW
server has four screens whose stat card is a label, a value and a delta,
and the delta is the toned part: the figure itself is an ordinary fact
and it is the movement that reads as good or bad. Without this the delta
has to be folded into the caption, which loses the tone and reads as a
longer caption rather than as a second, smaller line.
tone: ToneWhat the figure means right now. Tone::Neutral is an ordinary fact.
Applies to change where there is one, since that is the
part that carries the judgement, and to the value where there is not.