//! The renderer-agnostic half of the make-family design system. //! //! //! //! `makeover` answers *what colour*, and varies by theme. `makeover-geometry` //! answers *how much space*, and varies by density and surface. This crate //! answers *what the thing is*, and varies by nothing. //! //! # The deferral rule //! //! A description names intents and relationships, never values. Say //! [`Fill::Raised`], never `#D9DDF4`. Say `Gap::Peer`, never `6px`. What is //! left once colour and spacing are deferred is **composition**: which edges //! are lit, what inverts on press, what nests in what. //! //! The constraint that shapes all of it: a renderer that can only paint //! rectangles has to be able to express the result. egui has no //! `box-shadow: inset` and one stroke per widget with no per-side control; a //! terminal has box-drawing characters and one cell of resolution, and cannot //! draw a two-tone lit edge at all. A description that assumes per-side edges //! is a CSS description wearing a neutral name. So this crate names the //! *intent* — this region is a well — and each renderer chooses an expression //! it can actually produce, including dropping half of one. //! //! # Scope //! //! Depth came first: the bevel and the surfaces it shapes. That much was //! settled the hard way — the vocabulary here was read off audiofiles' //! `ui::theme` and `ui::widgets`, which are the only implementation written //! by a consumer with no CSS, then checked against both webview apps. All //! three agreed once Balanced Breakfast's fills were corrected. //! //! 0.2.0 adds the rest of the description, each member drawn the same way, //! from what the three apps already hand-write rather than from a taxonomy: //! //! - Components. [`Token`] (badge against chip), [`Notice`] (toast against //! banner), [`RowPart`], [`Heading`], [`Selector`], [`Readiness`], and //! [`Tone`], which is the one intent family they share. //! - Schemas. [`Field`] for forms and [`Column`] for lists and tables. //! - Structure. [`Region`] for the parts of a screen, [`Arrangement`] for how //! a screen is put together. //! //! **Validation** was absent on purpose here, on the grounds that neither app //! had a shared story. That reasoning is retired — see 0.11.0 below, which is //! where the constraints arrived and why the argument did not survive contact //! with what the apps were measured to do. //! //! 0.3.0 closes a gap the first real adoption found, which is what adopting //! against goingson first was for. [`Selector`] described only the *chosen* //! option, so an unchosen one fell through to [`Depth::Flat`] and no renderer //! drew it; goingson's tab strip recesses its unchosen tabs by hand and could //! not delete the line, because being recessed is *why* the chosen tab reads as //! coming forward. So [`Selector::unchosen`] joins `chosen`, and saying it //! needed [`Fill::Sunken`] and [`Depth::Sunken`]: a surface set back by colour //! with no edge, which is neither a well nor level-with. //! //! 0.7.0 adds [`State`], the interaction axis, closing the gap that adopting //! against three apps rather than one made visible. The description named //! rest and, through [`Depth::pressed`], pressed. It named neither focus nor //! disabled, so `makeover-webview` emitted a hover rule and stopped, and each //! consumer completed the primitive from outside by out-specifying a rule it //! did not own: 19 such rules in goingson, 21 in the MNW server, a further set //! in Balanced Breakfast, and three focus rings that do not match. The axis is //! deliberately two members wide, because hover and pressed belong where they //! already are. [`State`]'s own docs carry that argument. //! //! 0.8.0 finishes [`Field`], which described a field well enough to label it and //! not well enough to draw it. Writing `makeover-webview`'s form emitter found //! three things missing and the renderer supplied all three from outside: the //! current value, a select's options, and the placeholder. Two of those move //! here and one does not. //! //! - [`Field::placeholder`] is user-facing text sitting beside `label` and //! `hint`. There was never a reading on which it was renderer state; it was //! outside only because adding a field to a published struct is breaking. //! - [`Field::options`] moves because every renderer needs them and each was //! going to invent its own shape. [`Choice`] is the shape `makeover-webview` //! already arrived at, taken as-is rather than redesigned. //! - The current value stays renderer-side and is not coming here. It is the //! one of the three that is genuinely state: a webview reads it out of the //! DOM, an immediate-mode renderer holds a `&mut` to the app's own field, and //! a description that carried it would be a form model. //! //! 0.9.0 opens [`RowPart`], which was the last closed enum in the vocabulary, //! and adds [`RowPart::Tokens`]. Both halves come from the same finding, made //! by the first two real screens described through the router rather than by //! reading a stylesheet. //! //! A goingson project card carries two trailing badges, a type and a toned //! status; a contact card carries a primary email *and* a strip of tags. `Meta` //! is one slot and one string, so both ports joined their facts with a //! separator and lost what the second one was: a status reads as text where it //! used to read as colour. [`Token`] already says exactly the right thing — a //! small labelled thing with a kind, a tone and an optional action — and could //! only ever be a node in its own right, never inside a row. //! //! So the missing thing was permission rather than a concept. `Tokens` is that //! permission, and `#[non_exhaustive]` arrives with it so the next member is not //! a lockstep event across three renderers. The pairing is the point: this //! enum's own consumer in `makeover-webview` carried a comment predicting it //! would stop compiling one day, which is a lockstep break written down and //! waited for rather than prevented. //! //! Balanced Breakfast was checked before the member was added, because one //! consumer wanting something is not evidence. It packs a count and two icon //! buttons into the same single `Meta` slot while leaving `Actions` empty, so //! the slot was already straining under a second consumer for a different //! reason. //! //! 0.10.0 adds [`Meter`], a proportion carried as a pair rather than as a //! percentage. Its own docs carry the argument; the short form is that the //! percentage shape had already been tried in goingson and had already needed a //! companion flag to recover what rounding and clamping threw away. //! //! 0.11.0 is four members from the quasi proving ground, batched into one //! release because pre-1.0 a minor is breaking and a cascade is nine repos. //! Three findings that arrived with them turned out not to belong here at all: //! this crate has no notion of an action, a route or a destination, so anything //! asking what a control *calls* was never the vocabulary's to say. //! //! - [`Figure`], a value with a caption. goingson had five of them across five //! screens with five class vocabularies for the one shape, which is the //! divergence this crate exists to end, sitting in plain sight and counted for //! the first time. //! - [`RowPart::Proportion`], so a [`Meter`] can sit in a row. `Meter` reached //! two of its seven sites at 0.10.0 and the other five are row-shaped. Exactly //! [`RowPart::Tokens`]'s problem with a different payload, and it takes //! `Tokens`' answer: the part carries the description of a bar, not a node. //! - [`Field::max_length`], [`Field::min`] and [`Field::max`], joining //! [`Field::required`], which had been sitting here as the sole constraint //! while the header above claimed there were none. The set stops before //! `pattern`, which fails the renderer test and is one site in one app. //! - [`FieldKind::File`]. Every host has an honest answer — a native picker, an //! ``, a path prompt, an argument — and it carries no //! accepted-types list because `accept` appears at zero sites in either app. //! //! The evidence rule changed under these, and it is worth recording because four //! earlier decisions were made under the old one. The two-app test said a shape //! earns a word once a second app wants it. It is backwards: a rule that //! withholds a word until a second app has duplicated the code guarantees the //! duplication, and app three writes it a third time. The bar is now generic //! against bespoke — is this furniture any app would have, or is it this app's //! own? Bespoke keeps [`Region::Bespoke`], which already carries a completion //! heatmap and is the right answer for a calendar nobody will build twice. //! //! 0.12.0 is two more from the same proving ground, and the same sorting //! happened first: six findings came out of a measurement of goingson's whole //! frontend, and four of them turned out to be asking what a control *calls*, //! which this crate cannot say. The two that were really here: //! //! - [`Readiness`] grows from two states to four. It named `Ready` and //! `Pending` and stopped, so a screen whose list came back empty had nothing //! to say about it; goingson draws an empty state at 27 sites and Balanced //! Breakfast at 9. `Empty` and `Failed` are the same axis rather than a new //! member beside it, because a region shows one of the four and never two. //! `#[non_exhaustive]` arrives with them, the pairing [`RowPart`] made at //! 0.9.0 and for the same reason. //! - [`Column::sortable`], [`Column::sorted`] and [`Sort`]. The one finding in //! the set that completes a member rather than adding one: `Column` shipped //! with a width and a priority and could not say that a table is ordered by a //! column, so a described table could draw no caret and offer no reordering. //! //! 0.14.0 is two additive members on two `#[non_exhaustive]` enums, released //! together because publishing twice for that is waste and the cascade below //! this crate is nine repos. //! //! - [`Depth::Overlay`]. The enum could say raised, well, sunken and flat, and //! could not say that a surface sits *over* the page. Every renderer already //! had the surface — `makeover-tui`'s `Palette::overlay`, //! `makeover-immediate`'s `Palette::elevation`, `makeover-webview`'s //! `--elevation-overlay` — and none of them could be reached from a //! description. buckets_of_money has 16 modals waiting on it. //! - [`CellPart`], which is [`RowPart`] for tables. A row's parts have carried //! their own content intent since 0.2.0, so `.row-actions` inherits rather //! than taking a text colour; a table cell had no such vocabulary and //! `makeover-webview` emitted one undifferentiated `.cell`, so a button in a //! cell was painted as text. The four members are the four things quasi's //! `Cell` was measured to hold, and the count is in that crate's history //! rather than assumed here. //! //! 0.15.0 adds [`FieldKind::Date`] and [`FieldKind::DateTime`], on the argument //! [`FieldKind::Email`] was admitted on: a webview emits a different `type=`, //! which is a native picker, the platform's validation and a different keyboard //! on a touch device. Described as text with a "YYYY-MM-DD" hint, all three are //! lost. //! //! Two members and not one or five, from a count rather than from symmetry: 13 //! sites of `date` and 13 of `datetime-local` across the MNW server and //! goingson, and zero of `time`, `month` or `week`. The wire format each takes //! is named here as [`DATE_FORMAT`] and [`DATETIME_FORMAT`], because a host //! left to pick its own would disagree with a server silently, and //! [`FieldKind::temporal`] is the pair asked about once rather than at each //! renderer. `FieldKind`'s own comment claiming `radio` was the last HTML input //! type missing was already false when 0.8.1 wrote it; these are what it was //! missing. //! //! What each of the 0.12.0 findings deliberately leaves out is the address — what pressing a //! header calls, and where an empty state's "Add your first project" button //! goes. That is the boundary this crate is defined by, and four findings moved //! across it rather than being answered here. //! //! 0.19.0 narrows [`State`] to [`State::Disabled`] alone. `State::Focus` is //! gone: a description never states what has focus, because what focus *is* //! differs per host and every renderer had already decided for itself — the //! webview draws it from `:focus-visible`, egui refused the variant outright, //! and quasi-tui honoured it once at startup and overrode it thereafter. //! //! 0.20.0 adds [`Region::Widget`], the third tier, and `#[non_exhaustive]` to //! [`Region`] with it. Every vocabulary finding until now had two answers //! available — grow the primitive set, or [`Region::Bespoke`] — and a whole //! class of thing is wrong for both. A carousel is not a primitive, because a //! terminal has none and that is the test `Node::Html` failed. It is not //! bespoke either, because bespoke is what one app owns and every part of a //! carousel is furniture plus members this crate already has. //! //! The cost of the binary was that refusing a primitive was expensive: the app //! hand-rolls the thing forever, so the pressure always ran toward growing the //! primitive set with one host's idioms. A named assembly changes what "no" //! costs without changing what the vocabulary can say. //! //! MNW's carousel is the first consumer and was the finding that started it: one //! partial, three pages, an ordered set of frames with a position, prev/next and //! a dot strip, all of it sayable already and none of it nameable. See wiki //! `widget-tier` for the ownership model, which is why this member carries a //! name a renderer may decline to know. //! //! 0.21.0 adds [`Image`] and [`Fit`], found by trying to describe MNW's //! carousel under 0.20.0's widget tier and getting one step in. Nothing named a //! picture. The vocabulary could say a number with a caption, a badge, a meter //! and a table, and could not say the thing three of MNW's public pages are //! mostly made of. //! //! It reads as an oversight and is a measurement: 24 `` sites across 22 //! MNW templates, against one in goingson and none in Balanced Breakfast or //! audiofiles. A picture is furniture a *content platform* has, and MNW is the //! only one in the tree, so the evidence never arrived from the two-app //! direction the earlier rule looked in. Under the generic-against-bespoke bar //! it is not close: a picture is not one app's own. //! //! A primitive rather than a widget, which is worth stating now that the tier //! makes it a real question. A widget is an assembly of things already sayable //! and a picture is a leaf, assembled from nothing. It also passes the test //! `Node::Html` failed — every host has an honest answer, including a terminal, //! which has a graphics protocol or has [`Image::alt`]. //! //! [`Image`] carries no source, the split [`Act`] already makes: an address is //! not this crate's to hold. See its own docs, which is where the argument is. //! //! 0.22.0 finishes [`Image`], which 0.21.0 shipped unable to say how much room //! a picture needs. Without that a renderer cannot reserve space, so a picture //! occupies nothing until its bytes arrive and then takes its full height at //! once. Measured on MNW's landing page: a 478px jump per frame and a //! cumulative layout shift of 0.087 for the page. //! //! - [`Image::intrinsic`], the picture's own dimensions, carried as [`Extent`]. //! A fact about the asset rather than a display size, which is what keeps it //! on this side of the deferral rule: 5120x3412 is what the file *is*, and no //! renderer can learn it without fetching the bytes. //! - [`Loading`], and the default flips to [`Loading::Eager`]. 0.21.0 emitted //! the webview's `loading="lazy"` for every picture, which read one //! consumer's habit as a rule. Deferring a picture that is on screen at first //! paint saves nothing and makes its shift land later. The carousel is the //! case that proves this cannot be one renderer-wide setting: its first frame //! is on screen and its others are not, in one widget, at one moment. //! //! 0.23.0 adds [`Showing`], which is three open findings collapsing into one //! member. A tab group could not say which tab was open, a carousel could not //! say which frame was up, and a disclosure could not say whether its child was //! showing. All three are the same missing sentence, and while it was missing a //! renderer had two moves: match on a widget name, or draw every child. //! //! So the widget tier was taking the blame for a gap one level below it. With //! this a renderer derives its chrome from the description — labels get a strip, //! no labels get previous/position/next — once, for every widget there will ever //! be, and [`Region::Widget`]'s name goes back to being app vocabulary a //! renderer may decline to know. //! //! Only the kind lives here. Which child is up, and what each child is called, //! sit with whatever holds the regions, the same split [`Selector`] already made //! against `Node::Select`. //! //! 0.27.0 adds [`Region::Group`], which closes a gap this crate had carried //! since 0.2.0 without noticing: [`Heading::Section`] is documented as naming a //! block within the screen, and there was no block. A section heading is a leaf //! beside the things it names, so the description could say a section had //! *started* and never that one had ended. //! //! Found by asking how a screen distinguishes groups of settings by colour, and //! the answer turned out to be two findings rather than one. This is the first //! and it is the precondition: there is nothing to tint until there is a //! container. The second — every renderer already resolves `category.one` //! through `category.six` and no description can reach any of them — is filed //! and not shipped here. //! //! What the colour question settled anyway, because it shapes this member: the //! group carries no colour and no ordinal. A renderer distinguishing sibling //! groups derives the assignment from their order, which is //! [`Region::Columns`]' reasoning about counts applied to colour — the children //! say, and a value here would be a second source for something the description //! already states by containing them. //! //! # Reach, focus and the focus ring //! //! Three terms, and no others, for what 0.19.0 moved out of the description. //! **Reach** is which things can take focus and in what order; a browser reads //! it off the document, a TUI derives it from draw order, egui from its own id //! stack. **Focus** is which reached thing has the keyboard right now: the //! renderer's, live, never described and never round-tripped through a //! description. The **focus ring** is the visible cue; the token (`focus-ring`, //! derived by `makeover` from the action colour) is the one shared artifact and //! the drawing is the renderer's. Retired as names for any of this: "focus //! stroke", "focus cue", "wants focus". "Caret" is a different thing — the text //! cursor inside a field — and keeps its name. //! //! # The three tones, and what a colour claims //! //! One rule, settled 2026-08-16, for how colour says whether a thing can be //! used. Every renderer answers to it, and it is stated here because the //! description is what names the intents. //! //! | the thing | intent | //! |-----------|--------| //! | active, emphasised, the thing itself | `content` | //! | inactive but usable: it still answers a press | `content-secondary` | //! | inert: disabled, or not a control at all | `content-muted` | //! //! `content-muted` is the one with a claim in it. [`State::Disabled`] resolves //! to it, so a live control wearing it is telling the user it will not answer — //! and being wrong about that is worse than being quiet, because the user's //! response is to stop trying. A sortable column heading that was never sorted, //! and every unchosen option in a radio group, both read as dead lists that way; //! those are the two this rule was written out of. What is legitimately muted is //! a caption, a hint, a placeholder, a meter's reading, an axis label: text that //! was never going to answer anything. //! //! The three are one ramp and not three colours. `makeover`'s `Emphasis` derives //! the quieter two from the ink, so "one step back" means the same distance in //! every theme and a renderer cannot land between them by picking its own. //! //! # First paint is final paint //! //! One rule, settled 2026-08-16. Nothing may change size or position after it is //! first drawn, and nothing may stand in for content that has not arrived yet. //! Both halves are absolute. //! //! It is stated here, rather than left to each renderer, because a renderer can //! only reserve space the description gave it enough to size. A member whose //! size depends on its content therefore owes whatever makes it sizeable while //! the content is still absent, and that is the second admission test for a new //! member: not only does it compose something this crate already names, it can //! be laid out before it is filled. //! //! The mechanism is a reservation, and [`Sort`]'s caret is the worked example. //! The caret is drawn into a box its own width whether or not the column is //! sorted, so pressing a heading cannot reflow the row it sits in. The box names //! no magnitude, which is what keeps it out of `makeover-geometry`'s territory. //! Reserve from what is known; never discover geometry from what has not //! arrived. //! //! The trap is an `Option` that means "not yet". [`Readiness::Pending`] is the //! honest way to say a region is still waiting. An optional *measurement* is //! not: a count that shows up later widens the text that prints it and moves //! everything beside it, which is the reflow this rule exists to forbid. So an //! `Option` on a measurement means the host will never know it — a property of //! the query, fixed for the life of the screen — and a renderer sizes for the //! answer it was handed rather than for the one it hopes is coming. //! //! # Any width, one answer //! //! The sibling of the rule above, and settled the same day. That one is //! independence from *when*; this one is independence from *how you got here*. //! //! A rendering is a pure function of the description and the viewport. The same //! description at the same width is the same output, whatever widths came //! before it. No renderer may carry geometry across frames, and none may narrow //! by counting. //! //! The failure this forbids is ordinary enough to be the default everywhere //! else: a page that hides its sidebar below some width, remembers that it hid //! it, and does not bring it back the same way. Layout there is a function of //! `(width, history)`, so dragging a window to 900 wide is a different screen //! depending on whether you came from 1400 or from 600. Nobody chose that; it //! is what measuring and remembering produce. //! //! The mechanism is [`Width`] for what grows and [`Priority`] for what drops. //! Both are declared, both are read off the description, and neither needs a //! measurement. A renderer narrows by raising a cutoff over a total order, //! never by counting what fits and stopping — `makeover-tui`'s table states //! that as its own rule and tests it, and `makeover-webview` reaches the same //! place with `@media` and `display: none`, which is path-independent by //! construction because CSS has nowhere to keep the previous width. //! //! Two things follow for anything new. A member that would need last frame's //! size to lay out this frame is refused, the same way a member that cannot be //! sized before it is filled is refused. And a fact about what disappears //! belongs in the description, because a host that has to infer it can only //! infer it from a measurement. //! //! # Where the description stops //! //! The rule is that a member is added when an app needs a fact the vocabulary //! cannot state, and refused when what it wants is presentation it should be //! asking a renderer for. That is the whole test. It is not a quota, and the //! goal is every screen described. //! //! ## What the timeline refusal got wrong, 2026-08-15 //! //! This section used to read "a day-plan timeline, a kanban board and a //! calendar are not describable here and will not become describable", and it //! propagated: 12 files across three apps, three libraries and the design wiki //! cited it, including audiofiles and the MNW server, neither of which has a //! timeline. It is withdrawn, and [`Track`] is the member it was refusing. //! //! The error was pricing. The argument assumed a timeline needs a component //! library's worth of vocabulary, and nobody measured it. Held against //! goingson's `day-planning-render.js`, the members it actually needed and //! could not get were two integers: where a thing starts, and how long it //! lasts. Labels, gridlines, item bodies and tones were all furniture this //! crate already named. A refusal that expensive should have carried a //! measurement, and did not. //! //! The reasoning underneath it survives and is still the test: slot heights, //! gridline colour, how overlapping things stack, which hour scrolls into view. //! Those are presentation, they stay the renderer's, and [`Track`] carries none //! of them. What changed is the conclusion, not the principle. //! //! ## The other two, measured 2026-08-15 //! //! The same sentence refused a kanban board and a calendar. Both were counted //! the way the timeline should have been, and neither came out where the //! refusal put it. //! //! **Kanban: one member, and it is [`Region::Columns`].** Held against //! goingson's `tasks-kanban.js`, every card fact was already sayable — title, //! project, due date, the blocked and unblocks badges, subtask progress, the //! open action and the context menu are `Row`'s existing parts. A column is a //! heading, a count and a list. What nothing could say was that the columns are //! *peers*: [`Arrangement`] offers list-detail and sidebar-content, and a board //! described as either is a lie about the screen. Dragging a card between //! columns never entered into it — a drop's effect is "set status", a discrete //! action `Row`'s menu already carries, and the drag itself is affordance. //! //! **Calendar: no members, no consumer, and a sharper reason (Max, //! 2026-08-15).** The month grid's primacy in calendar apps is an artifact of //! paper: paper cannot be queried, so it has to show every day at once as a //! fallback index. Routes, search and ranking do that job better, which is the //! argument `events-calendar.js` already lost to a segmented list on //! 2026-08-11. //! //! Three jobs survive that reasoning, and only one of them needs a grid: //! //! 1. **Spans across days** — a stretch of leave, a trip, a sprint. You cannot //! see "away the 3rd to the 17th" in a list without diffing dates. This is //! [`Track`] with [`Unit::Days`], not a calendar, and //! [`Track::days`] is it. //! 2. **Density at a glance** — which weeks were heavy. That is a heatmap, and //! goingson describes both of its heatmaps as lists already. //! 3. **Weekday periodicity** — "every other Tuesday", "the 15th is a //! Saturday". This is the only job that needs the seven-column wrap, because //! alignment is the whole of what makes it visible. //! //! So the open question is not "is a calendar describable" but "is job 3 worth //! a member", and nothing in the tree asks for job 3 yet. GoingsOn //! quasicoherent `4a1237b6`. //! //! A month grid renders today as a //! [`Table`](crate::Column): seven weekday columns, weeks as rows, blanks for //! the offset. goingson's monthly review reached this conclusion before this //! note did and describes its month as a list of days that had something on //! them, marking today with an ordinary badge. What the tree actually contains //! is two completion heatmaps — one scalar per day — and no calendar at all: //! `events-calendar.js` was deleted 2026-08-11 in favour of a segmented list, //! and no MNW template mentions one. So the refusal was defending a screen //! nobody has. If one is built, measure again; the facts already fit and only //! the grid's shape would be in question. //! //! The pattern worth keeping from all three: one sentence refused three things //! for one reason, and the reason was wrong three different ways. Count the //! members. //! //! [`Region::Bespoke`] remains for the genuinely app-owned, and its //! justification does not depend on the withdrawn claim. The //! description names the *place* and the app owns the contents, so a screen //! containing a timeline is still a whole screen and still routable. Without //! it, the four goingson screens that make the app worth using would need a //! second, undescribed path beside the router, and two paths is how a //! vocabulary starts drifting from its app again. //! //! [`Region::Widget`] sits between that limit and the primitives, and it does //! not move the limit. A widget is an assembly of members this crate *already* //! has, under a name a renderer may or may not recognise. Anything that needs a //! member the vocabulary does not have is still a finding about the vocabulary //! or still bespoke; naming an assembly buys no new expressive power, which is //! exactly why it is safe to let the set grow outside this crate. #![forbid(unsafe_code)] /// A colour intent this crate refers to but never resolves. /// /// The string is the token name `makeover` publishes, so a renderer can look /// it up without this crate knowing what colour came back. pub trait Intent { /// The `makeover` intent token this resolves against. fn token(self) -> &'static str; } /// Which way the light falls across a two-tone edge. /// /// The whole content of a bevel, once colour and thickness are deferred. The /// light is always assumed to come from the top left: every consumer measured /// agreed on that and none of them ever varied it, so it is an invariant here /// rather than a parameter. /// /// # The two corners that belong to both edges /// /// Top-right and bottom-left are where the lit run meets the shaded one, and /// the description's claim is that they belong to *both*. How a renderer says /// that is its own business, because the answer is bounded by resolution and /// not by taste: /// /// - A terminal cell is roughly 8x17 device pixels, so giving the whole corner /// to one tone thickens that edge by a cell and reads as one run overrunning /// the other. A half-cell glyph divides the cell already, so `makeover-tui` /// splits it and recovers real information. Its box-drawing fallback cannot: /// a single stroke has no half to give, so there both corners go to dark. /// - A pixel bevel is a one-point stroke by default, which makes the corner a /// one-point square. There is nothing to divide — a diagonal seam across one /// point is sub-pixel, and antialiasing renders it as the blend a mitred join /// already produces. So `makeover-immediate` mitres and is *not* diverging; /// it is the same rule at a resolution where the split degenerates. /// /// Stated here so the difference reads as a decision rather than as drift. A /// renderer with room to divide the corner should; one without should mitre or /// pick the shaded tone, and neither is a bug. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Bevel { /// Lit from the top left: light on top and left, dark on bottom and right. Raised, /// The same edge inverted, which is also the pressed state of anything /// that draws itself [`Bevel::Raised`]. Inset, } impl Bevel { /// The edge intents, as `(top_left, bottom_right)`. /// /// Split out from any painting because the inversion *is* the idea, and /// it is the one part every renderer implements identically. #[must_use] pub const fn edges(self) -> (Edge, Edge) { match self { Self::Raised => (Edge::Light, Edge::Dark), Self::Inset => (Edge::Dark, Edge::Light), } } /// Pressing inverts. A raised control reads as inset while held. /// /// Stated here rather than left to each consumer because a cascade can /// carry a pressed state and an immediate-mode renderer cannot: audiofiles /// resolves this per call site, eighteen times. #[must_use] pub const fn pressed(self) -> Self { match self { Self::Raised => Self::Inset, Self::Inset => Self::Raised, } } } /// One side of a bevel, named by the intent it takes. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Edge { /// The lit side. Light, /// The shadowed side. Dark, } impl Intent for Edge { fn token(self) -> &'static str { match self { Self::Light => "bevel-light", Self::Dark => "bevel-dark", } } } /// A surface intent a region is filled with. /// /// `#[non_exhaustive]`, so a renderer must carry a wildcard arm and a new /// member is additive rather than breaking. Added 0.4.0, after [`Sunken`] /// (an additive member, 0.3.0) hard-broke `makeover-tui` and /// `makeover-immediate` at compile time and left neither able to move until /// both published. The vocabulary exists to grow and the renderers exist to /// disagree about how much of it they answer, so growth must not be a /// lockstep event. The renderer's wildcard is not a hole: [`Fill`] is /// resolved through a fallible lookup, and a missing intent is answered with /// structure rather than with a substituted colour. /// /// [`Sunken`]: Fill::Sunken #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Fill { /// The page behind everything. Page, /// A surface lifted off the page: cards, controls, menus, toasts. Raised, /// A surface floating above the page rather than resting on it. Overlay, /// The inside of a well. Well, /// A surface set back from the one it sits on, by colour and nothing else. /// /// Not a well. A well is a hole with an edge, and the two are authored in /// opposite directions: `makeover` derives `surface-well` by inverting /// against the theme's own content colour, while `surface-sunken` is /// authored and free to sit darker than raised (goingson's does). Naming /// only the well left the recessed-with-no-edge surface unsayable, which is /// what an unchosen tab is: it recedes so the chosen one can come forward, /// and it carries no bevel of its own. /// /// Added 0.3.0, from goingson's tab strip, which hand-writes exactly this /// and could not delete the line because no member described it. Sunken, } // No `fallback` here, deliberately. An earlier cut had `Fill::Well` fall back // to `Fill::Page` so a consumer on makeover 2.2.0, which has no `surface-well`, // had something to paint. makeover-tui found that wrong within a day: page is // the surface a well is usually cut into, so on a terminal that substitution // produces exactly the invisibility it was meant to prevent, and the right // answer there is a drawn edge rather than a different colour. // // Substituting one intent for another is renderer policy. The description says // what the region is and stops. impl Intent for Fill { fn token(self) -> &'static str { match self { Self::Page => "surface-page", Self::Raised => "surface-raised", Self::Overlay => "surface-overlay", Self::Well => "surface-well", Self::Sunken => "surface-sunken", } } } /// How a region sits relative to the surface behind it. /// /// Fill and bevel are named together because naming them apart is what let /// them disagree. Every consumer measured had at least one region carrying a /// raised bevel over a recessed fill: audiofiles fixed it in `raised_frame` /// and recorded the bug in its doc comment, and Balanced Breakfast still had /// twelve of them a year later. A single name for the pair makes that /// unrepresentable. /// `#[non_exhaustive]` for the same reason as [`Fill`], and in the same /// release: a depth this renderer has no drawing for should cost it a /// wildcard arm, not a compile error and a wait on someone else's publish. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Depth { /// Level with its surroundings. No edge. Flat, /// A card laid on the panel it sits in. Raised, /// A hole in the panel, with content down inside it. For anything the /// user looks *into*: a table body, a tag tree, a text field. Well, /// Set back from what it sits on, by colour alone. No edge. /// /// The one member carrying a fill without a bevel, so a renderer cannot /// assume the two arrive together. That is deliberate and it is still the /// pairing rule: both halves come off the same `Depth`, so they cannot /// disagree, and here one half is legitimately absent. /// /// Distinct from [`Depth::Flat`], which has no fill either and inherits. /// Recessed and level-with are different claims, and only one of them /// needs a colour. Sunken, /// A surface sitting *over* the page rather than in it. A modal, a popover, /// a menu. /// /// Takes elevation and no bevel: a surface overlaying the page is lifted /// off it, and a surface in the page is cut into it. That is the same /// pairing rule the rest of the enum holds, applied to the one case where /// the separation is not an edge at all — the lift and the scrim behind it /// are already saying where the surface is. /// /// Every renderer had the surface before it had this variant. /// `makeover-tui` carries `Palette::overlay`, `makeover-immediate` gained /// `Palette::elevation` at 0.10.0, and `makeover-webview` emits /// `--elevation-overlay`. What was missing was the route from a description /// to any of them, which is why this is one variant rather than a feature. Overlay, } impl Depth { /// The edge this depth is drawn with, if it has one. #[must_use] pub const fn bevel(self) -> Option { match self { // Sunken joins Flat here, for the opposite reason: Flat has no edge // because nothing separates it from its surroundings, and Sunken has // none because its colour is already doing the separating. Self::Flat | Self::Sunken => None, // A third reason to have no edge, which is why it gets its own arm // rather than joining the two above: an overlay is separated by the // lift and by the scrim behind it, so an edge would be a second // answer to a question already answered. Self::Overlay => None, Self::Raised => Some(Bevel::Raised), Self::Well => Some(Bevel::Inset), } } /// The surface this depth is filled with. /// /// [`Depth::Flat`] has no fill of its own: it inherits whatever it sits on, /// which is the difference between level-with and painted-the-same-colour. #[must_use] pub const fn fill(self) -> Option { match self { Self::Flat => None, Self::Raised => Some(Fill::Raised), Self::Well => Some(Fill::Well), Self::Sunken => Some(Fill::Sunken), Self::Overlay => Some(Fill::Overlay), } } /// Pressing a raised region reads as a well, and nothing else moves. /// /// [`Depth::Overlay`] is untouched along with the rest: an overlay is a /// surface, not a control, so there is nothing there to press. #[must_use] pub const fn pressed(self) -> Self { match self { Self::Raised => Self::Well, other => other, } } } /// An interaction state a region can be in, beside whatever [`Depth`] it is. /// /// Orthogonal to depth on purpose. A disabled button is still [`Depth::Raised`] /// and a disabled field is still a [`Depth::Well`], so folding either member /// into `Depth` would make [`Depth::bevel`] and [`Depth::fill`] answer for /// something that is not a depth, and would leave disabled-button and /// disabled-field sharing one variant that cannot tell them apart. /// /// # Why hover and pressed are not members /// /// The line is whether every renderer has the state to express, not whether CSS /// does. Hover is renderer policy and `makeover-webview` says so in its own /// header: a terminal and an immediate-mode painter have no pointer hovering /// over anything, and pressed already arrives through [`Bevel::pressed`] and /// [`Depth::pressed`], where it belongs, because pressing is a depth inversion /// rather than a separate condition. /// /// Focus and disabled are different in kind. A TUI has a focused widget and a /// greyed-out one; so does egui. Both were unsayable here, so all three webview /// consumers supplied them from outside the primitive by out-specifying rules /// they did not own: goingson alone carries 19 of them, and the MNW server /// another 21. That is the divergence this crate exists to end, arriving one /// layer down. /// /// # The principle this encodes /// /// A primitive owns every state it implies. A renderer that emits a hover rule /// for a thing owes disabled and the capability answer for that same thing, /// because anything less exports the completion work to N consumers who will /// each do it differently. /// /// Focus is not on that list and was removed from this axis in 0.19.0. It is /// the renderer's, decided after the description; see the crate header, "Reach, /// focus and the focus ring", for the three terms and who owns each. /// /// `#[non_exhaustive]` for the reason [`Fill`] and [`Depth`] carry it: growth /// must not be a lockstep event across the three renderers. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum State { /// Present, visible, and not answering. /// /// Not the same as absent, and deliberately not a [`Fill`]: a disabled /// control keeps the surface it always had and stops responding, so what /// changes is its content and its interactivity rather than what it is. Disabled, } impl State { /// Whether a region in this state stops answering the pointer. /// /// Stated in the description rather than left to each renderer, on the same /// reasoning as [`Bevel::pressed`]: a cascade carries it for free and an /// immediate-mode renderer resolves it per call site, so leaving it unsaid /// means resolving it once per consumer and disagreeing. #[must_use] pub const fn suppresses_interaction(self) -> bool { // A match rather than a bare `true`, so a member added to this // `#[non_exhaustive]` axis has to answer the question rather than // inheriting an answer. match self { Self::Disabled => true, } } } impl Intent for State { fn token(self) -> &'static str { match self { // Reusing the muted content intent rather than minting a // `disabled` colour. Disabled is a reduction and not a status, and // `makeover-webview`'s progress rules already record the reading // that `content-muted` is what disabled looks like. Self::Disabled => "content-muted", } } } /// What a region is saying, when it is saying something. /// /// The one intent family shared by badges, notices and nothing else. Kept /// separate from [`Fill`] because a surface is where a thing sits and a tone is /// what it means, and the three apps agree on the four statuses: /// `info_banner` / `warning_banner` in audiofiles, `.toast-info` / /// `.toast-success` / `.toast-error` in goingson, `.toast.success` / /// `.toast.error` in Balanced Breakfast. /// /// The per-tag palette (`category-one` through `category-six`) is deliberately /// not here. Which colour a *particular* tag takes is app domain, and both /// webview apps already carry it as a `data-color` attribute. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Tone { /// No status. Reads as ordinary de-emphasised content. Neutral, /// Something worth knowing and nothing to do about it. Info, /// Something finished and it worked. Success, /// Something the user should look at before continuing. Warning, /// Something broken, or something about to be destroyed. Danger, } impl Intent for Tone { fn token(self) -> &'static str { match self { // Neutral has no status token of its own. It takes the muted // content intent, which is what both webview apps already spell as // `data-color="muted"`. Self::Neutral => "content-muted", Self::Info => "info", Self::Success => "success", Self::Warning => "warning", Self::Danger => "danger", } } } /// A small labelled thing that sits inside something else. /// /// Two members, because the three apps drew three taxonomies and only one line /// runs through all of them: does it answer a click. audiofiles has /// `classification_badge` (a label) against `tag_chip`, `tag_chip_removable` /// and `selectable_tag` (all of which do). Balanced Breakfast has `.tag` and /// `.badge` against `.tag-chip`. goingson is the one that has to move: its /// `.tag` and `.badge` are a single CSS rule, so every call site has to be read /// to decide which of the two it always was. /// /// The evidence that a chip is a real concept rather than a badge with a /// cursor: audiofiles inverts its bevel on press and Balanced Breakfast latches /// `.tag-chip.active` with the inset bevel. Two independent arrivals at "a chip /// holds itself down", which is exactly what [`Depth::pressed`] already says. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Token { /// Non-interactive status or count. Answers no click. Badge, /// An interactive or removable token. Answers a click, and latches if it /// stands for a filter that is either on or off. Chip { /// Whether it carries its own remove affordance. removable: bool, }, } impl Token { /// Whether this answers a click. /// /// The whole difference between the two members, and the reason a renderer /// with no hover (a touch surface, a terminal) can still tell them apart. #[must_use] pub const fn interactive(self) -> bool { matches!(self, Self::Chip { .. }) } /// How it sits, given whether it is currently latched down. /// /// A badge is flat: it is a label, and giving it an edge would say it can /// be pressed. A chip is raised, and inset while latched. #[must_use] pub const fn depth(self, latched: bool) -> Depth { match self { Self::Badge => Depth::Flat, Self::Chip { .. } if latched => Depth::Well, Self::Chip { .. } => Depth::Raised, } } } /// Something the app is telling the user, unprompted. /// /// Two concepts, not one with a placement. They differ in more than where they /// sit: a toast is transient, stacked and self-dismissing, and a banner is /// persistent, in flow, one per region, and dismissed by fixing the condition /// it reports. Folding them into one member with a placement parameter would /// make lifetime, stacking and dismissal all placement-dependent, which is the /// description leaking renderer policy. /// /// All three apps have banners: `info_banner` and `warning_banner` in /// audiofiles, five of them in goingson (sync, sync-result, vacation-day, /// timer-active, past-review), `.update-banner` in Balanced Breakfast. The two /// webview apps also have toasts. So neither member is speculative, and no app /// gains a concept it lacks except audiofiles, whose renderer may legitimately /// decline to draw a toast at all. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Notice { /// Transient, stacked, dismisses itself. Toast, /// Persistent, in flow, one per region, dismissed by fixing the cause. Banner, } impl Notice { /// Whether it goes away on its own. #[must_use] pub const fn transient(self) -> bool { matches!(self, Self::Toast) } /// How it sits. /// /// A toast floats above the page rather than resting on it, which is /// [`Fill::Overlay`]'s whole reason to exist. A banner is a card in the /// flow. Both are raised, and they are raised off different things. #[must_use] pub const fn fill(self) -> Fill { match self { Self::Toast => Fill::Overlay, Self::Banner => Fill::Raised, } } } /// The parts of a list row. /// /// Four to begin with, taken from Balanced Breakfast, which was the only /// consumer that had all of them (`row-primary`, `row-secondary`, `row-meta`, /// `row-actions`). audiofiles has two and no slot structure at all, so it gains /// meta and actions as real work rather than a rename; goingson moves off /// `task-row` / `task-cell`. /// /// [`Tokens`](Self::Tokens) joined at 0.9.0, and `#[non_exhaustive]` with it. /// See the crate header for why the two arrived together. /// /// # Meta against Tokens /// /// The line is whether the thing has its own standing. `Meta` is one short /// trailing fact about the row, written as text: a count, a size, a date. /// `Tokens` is a set of small labelled things, each of which can be toned and /// can answer a click. "3 files" is meta. A status badge that is amber, and a /// tag you can click to filter by, are tokens. /// /// Keeping them apart is what a single widened slot would have foreclosed. A /// renderer can right-align one string and cannot usefully do the same to a /// strip of chips, and a fact that is not clickable should not be drawn as /// though it were. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RowPart { /// The thing itself. What the row is called. Primary, /// Supporting text under the primary. Secondary, /// A short trailing fact: a count, a size, a date. Meta, /// Controls that act on this row. Actions, /// Small labelled things belonging to the row: badges, chips, tags. /// /// Each carries its own [`Token`] kind and [`Tone`], so a renderer with no /// colour still has the kind to work with, and one with no chips still has /// the label. That is the constrained-consumer test this vocabulary exists /// to pass, and it is why the tone lives on the token rather than on the /// part. Tokens, /// How much of a set the row's thing has done: a [`Meter`] in the row. /// /// Added 0.11.0, `da5666ae`, and it is [`Tokens`](Self::Tokens)'s problem /// again with a different payload. [`Meter`] arrived at 0.10.0 and closed /// two of the seven sites that asked for it; the other five sit in rows, and /// a row holds no nodes by the ruling that a row part may not carry an /// arbitrary node — the door through which a description becomes a /// templating language. So the part carries the *description of a bar* /// rather than a node, exactly as `Tokens` carries tags rather than nodes. /// /// Without it a row flattens the proportion into [`Meta`](Self::Meta) as /// "3/7 subtasks", which keeps both numbers and loses the reading, the same /// way a toned status badge read as prose before `Tokens`. Proportion, } impl RowPart { /// The content intent the part takes. #[must_use] pub const fn intent(self) -> &'static str { match self { Self::Primary => "content", Self::Secondary => "content-secondary", Self::Meta => "content-muted", // Actions carry controls rather than text, so they inherit. Self::Actions => "content", // So do tokens: each one carries its own tone, and a part-level // intent underneath it would fight the token that sits on it. Self::Tokens => "content", // And so does a proportion, for the same reason: the meter carries // the tone, and it is about the ratio rather than about the row. Self::Proportion => "content", } } } /// How far down the heading tree a title sits. /// /// Three, and only the three that are actually headings. The bands those used /// to be filed with (goingson's `.page-header`, Balanced Breakfast's `.header` /// and `.detail-header`) are arrangement, not type, and live at /// [`Region::Band`]. One of them contains no text at all. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Heading { /// Names the whole screen. One per screen. Page, /// Names a block within the screen. Section, /// Names a sub-block inside an already-named section. Subsection, } impl Heading { /// Whether a rule follows the heading. /// /// audiofiles' `section_header` draws a separator and its /// `subsection_label` deliberately does not, which is the only thing /// distinguishing the two once weight and colour are deferred. #[must_use] pub const fn separated(self) -> bool { matches!(self, Self::Section) } } /// A control that picks between things. /// /// Three, because three distinct behaviours are in play and collapsing any two /// loses something. A segmented control picks a value; a tab picks a pane; a /// toggle picks nothing and simply holds itself on or off. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Selector { /// Exactly one of N, and the options abut. Segmented, /// Independent on or off, on its own. Toggle, /// Navigation between panes. The folder semantic. Tabs, } impl Selector { /// How the chosen option sits. /// /// Held in for a segmented control and a toggle, which is the same shape /// pressing produces and the whole economy of the idiom: one appearance, /// two reasons to wear it. A tab is the exception, because the selected /// folder tab comes *forward* to join the pane it opens. #[must_use] pub const fn chosen(self) -> Depth { match self { Self::Segmented | Self::Toggle => Depth::Well, Self::Tabs => Depth::Raised, } } /// How the options that were *not* picked sit. /// /// Added 0.3.0. Describing only [`Selector::chosen`] left the unchosen /// option falling through to [`Depth::Flat`], which says it is level with /// the strip it sits in, and no renderer emitted anything for it. That is /// wrong in both directions and goingson proved it: its unchosen tabs are /// recessed by hand, and being recessed is *why* the chosen one reads as /// coming forward. Against a flat strip, a raised chosen tab is a bevel /// drawn on the strip's own colour, which is a much weaker folder effect /// than the contrast the idiom is named after. /// /// Each member is the inverse of its chosen state, which is the whole /// content of "picked" once colour is deferred: /// /// - Tabs recede, so the chosen one comes forward. /// - A segment and a toggle stand up, so the chosen one is held in. #[must_use] pub const fn unchosen(self) -> Depth { match self { Self::Tabs => Depth::Sunken, Self::Segmented | Self::Toggle => Depth::Raised, } } /// Whether the options touch. /// /// The gap is the entire difference between a segmented control and a row /// of buttons that happen to sit near each other, which is what audiofiles' /// `segmented_control` says in its own comment and why it zeroes the /// spacing by hand. #[must_use] pub const fn abutting(self) -> bool { matches!(self, Self::Segmented | Self::Tabs) } } /// What is in a region right now. /// /// The state, not the shimmer. Whether pending paints a skeleton, a spinner or /// nothing at all is renderer policy, the same class of decision that got /// `Fill::fallback` deleted from this crate. goingson and Balanced Breakfast /// each grew a skeleton with differently-named parts; both keep them, as the /// webview renderer's expression of [`Readiness::Pending`]. audiofiles has none /// and needs none, because an immediate-mode renderer simply repaints. /// /// # Four states and not two, as of 0.12.0 /// /// `703f4cd2`. It named `Ready` and `Pending` and stopped, so a described screen /// whose list came back empty had to render an empty region or invent its own /// placeholder text, and neither says what it is. goingson draws one at 27 sites /// across 12 files and Balanced Breakfast at 9, with a class family that had /// already drifted into `empty-state`, `empty-state--error`, `error-state` and /// six more. /// /// The four are one axis because they are mutually exclusive: a region shows its /// content, or a sign that it is coming, or a sign that there is none, or a sign /// that it broke. Never two. That is the test for one enum against several /// fields, and it is why this grew rather than a new member arriving beside it. /// /// # What is not here /// /// **The message.** "No projects yet" is content, and this names a state. It /// lives with whatever holds the region — in quasi's case a `Slot` — alongside /// the action that leads out of the emptiness, since an address is the one thing /// this crate never names. /// /// **How much room it gets.** goingson's `--compact`, `--dashboard` and /// `--padded` are the same state at three sizes, and a size is /// `makeover-geometry`'s question. Naming them here would be this crate stating /// values again. /// /// **The icon.** Presentation, and each host has its own answer or none. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Readiness { /// The content is here. Ready, /// The content is on its way. /// /// For a region that changes *after* the first paint, and never for the /// first paint itself: see "First paint is final paint" in the crate header. /// A host that renders once, with its data already in hand, has nothing to /// say this about, and a screen arriving in this state is describing a /// moment its host should not have been in. /// /// What stands in occupies the geometry the content will occupy. A stand-in /// sized to itself rather than to what replaces it is the reflow the rule /// forbids, arriving one repaint later. Pending, /// The content arrived and there is none of it. /// /// Not a failure. An empty list is the normal state of a new install, and a /// renderer that drew it in a danger tone would be reporting a fault where /// there is none. Empty, /// The content did not arrive. Failed, } impl Readiness { /// Whether the region draws its own content, or something standing in for /// it. /// /// The question every renderer asks first, so it is answered once here /// rather than by a `matches!` in each. A state added later is a stand-in /// until proven otherwise: falling back to drawing content that may not be /// there is the worse of the two mistakes. #[must_use] pub const fn shows_content(self) -> bool { matches!(self, Self::Ready) } /// What the state means, for a renderer choosing a colour. /// /// Derived rather than carried, which is the opposite of [`Meter`] and /// [`Figure`], and the difference is worth stating: a proportion's meaning /// depends on what is being counted and only the app knows it, while /// "nothing here yet" and "this broke" mean the same thing in every app that /// will ever have them. #[must_use] pub const fn tone(self) -> Tone { match self { Self::Failed => Tone::Danger, _ => Tone::Neutral, } } } /// How much of a set is done. /// /// Added 0.10.0. Nine sites across the two webview apps drew a bar and nothing /// here named one, so every described screen concatenated the two numbers into /// its heading text instead: "Subtasks 3/7", "Time Tracking 45m tracked / 30m /// est, over". Every fact survives that and the reading does not, which is the /// same loss `RowPart::Tokens` closed when a toned status badge became prose. /// /// # Why a pair and not a percentage /// /// Both numbers, not the percentage the apps compute from them. The percentage /// was the obvious shape and it had already been tried: goingson's /// `Task::time_progress` divides, rounds, and then clamps to 100, which throws /// away the one case the bar exists to show — 45 minutes tracked against a /// 30-minute estimate. It carries a separate `is_over_estimate` boolean beside /// it to recover the fact the clamp dropped. A pair keeps the over-run without a /// companion flag, and [`percent`](Meter::percent) is still one call away for a /// renderer that wants it. /// /// The pair is also what the apps already have at every site. All seven /// determinate bars write the ratio into the accessible layer and never the /// percentage: `title="3/7 subtasks"`, `aria-label="3 of 7 subtasks completed"`, /// a milestone's own `3/7` span. Given 43 nothing can recover "3 of 7", so a /// percentage member would have made [`label`](Meter::label) mandatory at every /// call site, which is the concatenated text this member removes, moved one /// layer down. /// /// # What this is not /// /// The progress of an *operation*. Two of the nine sites are that — goingson's /// focus timer, Balanced Breakfast's feed fetch — and they get nothing here, on /// purpose. Both are imperative controllers over a live handle, driven by a tick /// or an event stream, and a description is built once and dropped. Holding one /// would mean growing a way to update a description between renders, which is a /// different feature. [`Readiness::Pending`] and a [`Notice::Toast`] carry the /// honest part. /// /// The two cases are distinguishable in the markup rather than by taste: every /// determinate bar in both apps carries a tone, and neither operation bar /// carries one. Two codebases drew that line the same way without coordinating. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Meter<'a> { /// How much is done. May exceed [`total`](Self::total), and that is the /// case worth drawing. pub done: u32, /// How much there is to do. Zero means there is no set, not that the set is /// complete. pub total: u32, /// What the proportion means right now. /// /// Carried rather than derived, because no renderer can work it out. The /// same 90% is [`Tone::Success`] on a subtask rollup and [`Tone::Danger`] on /// a time estimate, and goingson picks between them from `is_over_estimate`, /// a fact about the data and not about the number. pub tone: Tone, /// What is being counted, if the bar says so: "subtasks", "tasks". /// /// The noun, not the ratio. A renderer builds "3 of 7 subtasks" from this /// and the two numbers; handing it the assembled string would put the /// sentence order in the description, where a terminal at one line and a /// tooltip want different ones. pub label: Option<&'a str>, } impl<'a> Meter<'a> { /// A proportion with no tone and no label. #[must_use] pub const fn new(done: u32, total: u32) -> Self { Self { done, total, tone: Tone::Neutral, label: None, } } /// What the proportion means. #[must_use] pub const fn tone(mut self, tone: Tone) -> Self { self.tone = tone; self } /// What is being counted. #[must_use] pub const fn label(mut self, label: &'a str) -> Self { self.label = Some(label); self } /// How full the bar is, 0 to 100, clamped. /// /// For drawing, which is the only thing a clamped number is good for. Ask /// [`overflowing`](Self::overflowing) before reporting it as a fact, or this /// is `time_progress`'s bug again with the clamp moved. /// /// An empty set reads as 0. Nothing is done, because there is nothing to do /// and no bar to fill; the apps guard on the count before drawing at all. #[must_use] pub const fn percent(&self) -> u8 { if self.total == 0 { return 0; } let scaled = (self.done as u64 * 100) / self.total as u64; if scaled > 100 { 100 } else { scaled as u8 } } /// Whether more is done than there was to do. /// /// The fact [`percent`](Self::percent) destroys, kept reachable so a /// renderer can mark the over-run rather than drawing a full bar and /// implying it landed exactly. #[must_use] pub const fn overflowing(&self) -> bool { self.done > self.total } /// Whether there is a set at all. /// /// A meter over nothing is sayable on purpose, for the same reason a field /// with no options is: it is what an app with an unloaded count actually /// has, and a renderer that shows an empty bar says so on screen rather than /// dividing by zero. #[must_use] pub const fn is_empty(&self) -> bool { self.total == 0 } } /// 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. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Figure<'a> { /// The number, formatted the way the app means it to read. pub value: &'a str, /// What it counts. The caption under the value. pub caption: &'a str, /// How the value has moved, if the app is tracking that. /// /// Added 0.13.0. Text, for [`value`](Self::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`](Self::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. pub change: Option<&'a str>, /// What the figure means right now. [`Tone::Neutral`] is an ordinary fact. /// /// Applies to [`change`](Self::change) where there is one, since that is the /// part that carries the judgement, and to the value where there is not. pub tone: Tone, } impl<'a> Figure<'a> { /// A figure that is an ordinary fact. #[must_use] pub const fn new(value: &'a str, caption: &'a str) -> Self { Self { value, caption, change: None, tone: Tone::Neutral, } } /// How the value has moved. #[must_use] pub const fn change(mut self, change: &'a str) -> Self { self.change = Some(change); self } /// What the figure means. #[must_use] pub const fn tone(mut self, tone: Tone) -> Self { self.tone = tone; self } } /// Something the user can do, and what it costs to say so. /// /// Added 0.17.0, out of `quasi-tui`: the terminal renderer had drawn one of /// these for months and every other consumer that wanted a button had written /// its own, because this layer named [`RowPart::Actions`] as a *slot* and never /// named the thing that goes in it. Beside [`Meter`] and [`Figure`] for the /// reason those are here: a renderer that is handed the parts has to decide how /// to say them, and a renderer that is handed a finished string has already had /// the decision made for it. /// /// No address. Where a control goes is the app's business and every host /// follows it differently — an `hx-get`, a protocol URL, a function call — so /// the description says what the control *is* and the caller keeps what it /// does. That is the same split [`Choice`] makes. /// /// No confirmation flag either, and that one is a finding rather than an /// omission: a question asked *after* a control is pressed belongs to whatever /// is holding the interaction, and a renderer that drew it would be asking /// before there was anything to answer. /// How a picture sits in the box it is given. /// /// An intent rather than a value, so a renderer picks the expression it has: /// `object-fit` in a webview, a texture's UV rect in egui, and in a terminal a /// choice about how many cells the blit gets. Named because MNW already makes /// the distinction deliberately at 17 sites and makes it three different ways, /// which is a policy the app decided rather than one a shared crate would be /// picking by accident. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[non_exhaustive] pub enum Fit { /// The picture's own proportions, and the box takes the height they imply. /// /// The default because it is the only one that shows the whole picture at /// its own shape, so a renderer that ignores this enum entirely is still /// right about the common case. A screenshot wants this; the shipped MNW /// carousel sets no `object-fit` at all, which is this. #[default] Natural, /// Fill the box and crop whatever does not fit. /// /// For a picture in a slot whose shape the layout fixed: a thumbnail, an /// avatar, cover art. 15 of MNW's 17 sites. Cover, /// Fit inside the box whole, leaving space on two sides. /// /// The letterbox. For when the whole picture matters more than filling the /// space, and the space is not the picture's shape. Contain, } /// A picture, and what it says to someone who is not looking at it. /// /// # No source /// /// [`Act`]'s split, for [`Act`]'s reason. A source is an address, and this /// crate has no notion of an address: it says what a thing *is* and the caller /// keeps what it points at. The three findings dropped from 0.11.0 were all /// this same shape. /// /// It matters more here than it does for a control, because a picture is the /// one member where the address is most of what a webview needs and *none* of /// what the description knows. `quasi_router::Node::Image` carries the URL, the /// way it carries an `Action` for a control. /// /// # Why [`alt`](Self::alt) is not optional /// /// Every other host has to draw something, and for two of the three the alt /// text is not a fallback but the whole rendering: a terminal without a /// graphics protocol has the words and nothing else. Making it optional would /// make "this picture is invisible on a terminal" the default, and the /// description would be carrying a webview assumption in its shape. /// /// An image that genuinely says nothing — a rule, a spacer, a decoration /// repeating what the text beside it already said — is an empty `alt`, which is /// the same thing HTML means by it and is a claim rather than an oversight. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Image<'a> { /// What the picture says, for anything not showing it. /// /// Empty means the picture is decorative and adds nothing to the text /// around it. See the type's own docs on why this is not an `Option`. pub alt: &'a str, /// A visible line under the picture, where the app wants one. /// /// Distinct from [`alt`](Self::alt) and the difference is who it is for: a /// caption is content everybody reads, alt text is what stands in for the /// picture. A screenshot captioned "The library view" still needs alt text /// describing what is in the shot. pub caption: Option<&'a str>, /// How it sits in the box it is given. pub fit: Fit, /// The picture's own dimensions, where the app knows them. /// /// **Not a display size**, and that distinction is what makes this belong /// here rather than fall foul of the deferral rule. Saying a picture should /// be 320 points wide is a layout value and is not the description's to /// give. Saying the file is 5120x3412 is a fact *about the picture*, the /// same kind of fact [`alt`](Self::alt) is, and no renderer can find it out /// without fetching the bytes. /// /// # What it is for, and it is not decoration /// /// Without it a renderer cannot reserve room, so the picture occupies /// nothing until it arrives and then takes its full height at once, /// shoving everything below it down the screen. Measured on MNW's landing /// page 2026-08-14: a 478px jump per frame, and a cumulative layout shift /// of 0.087 for the page, which is most of the way to the 0.1 that counts /// as bad. /// /// Every host wants it and none can derive it. A webview writes `width` and /// `height` so the browser holds the space; egui sizes a texture; a /// terminal with a graphics protocol scales a blit into cells. This was /// missing from 0.21.0, which is the release that added [`Image`], and its /// absence is the defect rather than an omission. /// /// `None` is honest and common: a creator-uploaded image whose dimensions /// the app never recorded genuinely does not know. It means the renderer /// cannot reserve, not that the picture has no size. pub intrinsic: Option, /// Whether the picture is needed with the screen, or can arrive later. pub loading: Loading, } /// A picture's own pixel dimensions. /// /// Deliberately not [`makeover_geometry`]'s business. Geometry answers *how /// much space a thing should get*, which is a scale question with the same /// answer on every screen. This is the intrinsic size of one asset, which is a /// fact about that asset and varies per picture. /// /// [`makeover_geometry`]: https://docs.rs/makeover-geometry #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Extent { /// Width in the picture's own pixels. pub width: u32, /// Height in the picture's own pixels. pub height: u32, } impl Extent { /// A picture's dimensions. #[must_use] pub const fn new(width: u32, height: u32) -> Self { Self { width, height } } /// Width over height, or `None` if either side is zero. /// /// The form a renderer actually reserves space with: a box that knows its /// proportion holds the right height at any width, which is what a /// responsive picture needs and what a fixed pixel height cannot give. #[must_use] pub fn ratio(self) -> Option { (self.width > 0 && self.height > 0).then(|| self.width as f32 / self.height as f32) } } /// When a picture is needed. /// /// A claim about *importance and position* rather than a fetch mechanism, which /// is why it is the description's to make: only the app knows whether a picture /// is the first thing on the screen or the fortieth thing down a list. /// /// # Eager is the default, and that is a correctness choice /// /// 0.21.0 emitted the webview's `loading="lazy"` for every picture, on the /// evidence that the one consumer measured wrote it. That was reading a habit /// as a rule. Deferring a picture that is on screen at first paint does not /// save anything -- it is needed immediately either way -- and it delays the /// arrival, so the space it eventually takes is claimed later and the shift is /// more visible, not less. /// /// So the safe answer is the default and the optimisation is opted into. A /// carousel is the case that proves the two cannot be one setting for the /// renderer to choose: its first frame is on screen and its other frames are /// not, in the same widget, at the same moment. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[non_exhaustive] pub enum Loading { /// Needed with the screen. Fetch it now. #[default] Eager, /// Not on screen yet. It can wait until it is near. Lazy, } impl<'a> Image<'a> { /// A picture that carries its own proportions. #[must_use] pub const fn new(alt: &'a str) -> Self { Self { alt, caption: None, fit: Fit::Natural, intrinsic: None, loading: Loading::Eager, } } /// The picture's own dimensions, so a renderer can hold its place. #[must_use] pub const fn intrinsic(mut self, width: u32, height: u32) -> Self { self.intrinsic = Some(Extent::new(width, height)); self } /// This picture is not on screen yet; it can arrive when it is near. #[must_use] pub const fn lazy(mut self) -> Self { self.loading = Loading::Lazy; self } /// A visible line under it. #[must_use] pub const fn caption(mut self, caption: &'a str) -> Self { self.caption = Some(caption); self } /// How it sits in its box. #[must_use] pub const fn fit(mut self, fit: Fit) -> Self { self.fit = fit; self } /// Whether the picture adds anything for someone not looking at it. /// /// A renderer with no way to show a picture uses this to decide between /// drawing the alt text and drawing nothing at all. Both are correct and /// the difference is this flag: standing in for a decorative rule with the /// word "decoration" is worse than leaving the space empty. #[must_use] pub const fn speaks(self) -> bool { !self.alt.is_empty() } } /// What a [`Track`]'s integers count. /// /// `Track::fraction` never needed this -- the arithmetic is the same whatever /// the numbers mean -- which is exactly how the ruler came to assume minutes /// and print `00:00` over a month. A renderer drawing an axis has to write a /// label, and it cannot derive the unit from the numbers. /// /// Added 2026-08-15, after a probe put a fifteen-day span on a /// thirty-one-slot track and got correct geometry under a wall clock. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[non_exhaustive] pub enum Unit { /// Minutes from the start of a day. A day view. #[default] Minutes, /// Whole days. A month strip, a sprint, a stretch of leave. /// /// A day-granularity axis is a *strip*, not a calendar: one line with /// spans laid along it. What it deliberately does not do is wrap into /// weeks, which is the shape that makes weekday periodicity visible and /// the one job of a month grid that a strip cannot take over. See the /// crate header. Days, } /// A window on an axis, in whatever [`Unit`] its [`Track`] counts. /// /// The axis a [`Track`] draws. Offsets rather than instants, because a /// description carrying a `DateTime` would carry a timezone with it and the /// vocabulary has no business holding one. The app knows which day or month /// this is; the description says how far along it a thing sits. /// /// `to` is exclusive and may exceed the natural period, which is how a span /// running past the end is said without a second date: under /// [`Unit::Minutes`], `Span::new(1320, 1560)` is 22:00 to 02:00. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Span { from: u16, to: u16, } impl Span { /// Midnight to midnight, the ordinary day. pub const DAY: Self = Self { from: 0, to: 1440 }; /// A span, clamped to a sane one. /// /// An empty or backwards span is a caller bug that should not cost a /// renderer a division by zero, so `to` is forced at least one minute past /// `from` rather than returning an error nobody can act on. Same reasoning /// as [`Share::percent`], which clamps rather than refuses. #[must_use] pub const fn new(from: u16, to: u16) -> Self { Self { from, to: if to > from { to } else { from + 1 }, } } /// The first minute on the axis. #[must_use] pub const fn from(self) -> u16 { self.from } /// One past the last minute on the axis. #[must_use] pub const fn to(self) -> u16 { self.to } /// How much the axis covers, in its track's unit. Never zero. #[must_use] pub const fn length(self) -> u16 { self.to - self.from } /// Whether an offset falls on this axis. #[must_use] pub const fn holds(self, minute: u16) -> bool { minute >= self.from && minute < self.to } } impl Default for Span { fn default() -> Self { Self::DAY } } /// Where a thing sits on a [`Track`], and for how long. /// /// The one fact a list cannot carry and the whole reason this primitive exists. /// A list says what order things come in; a track says a thing starts 135 /// minutes along and lasts 45, which is a different claim and not derivable /// from the first. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Placement { at: u16, length: u16, } impl Placement { /// A placement, clamped to a drawable one. /// /// Zero length becomes one for the same reason [`Span::new`] clamps: a /// zero-height thing is invisible rather than expressive, and every /// renderer would need its own guard. #[must_use] pub const fn new(at: u16, length: u16) -> Self { Self { at, length: if length == 0 { 1 } else { length }, } } /// Offset from the axis origin, matching [`Span`]'s. #[must_use] pub const fn at(self) -> u16 { self.at } /// How long it lasts, in its track's unit. Never zero. #[must_use] pub const fn length(self) -> u16 { self.length } /// One past its last minute. #[must_use] pub const fn end(self) -> u16 { self.at + self.length } /// Whether two placements cover any of the same time. /// /// Geometry, and deliberately not a described field. Whether an overlap is /// a *conflict* is the app's judgment -- a meeting inside a block of free /// time overlaps and is fine -- and that judgment travels the way every /// other judgment does, as a [`Tone`] on the thing itself. What a renderer /// needs in order to lay two things side by side instead of on top of each /// other is this, and it can compute it. /// /// The alternative was a `conflicts: bool` on each entry, which is state /// that can disagree with the times beside it. Two sources for one fact is /// how a screen starts rendering a conflict badge on a thing that no longer /// conflicts. #[must_use] pub const fn overlaps(self, other: Self) -> bool { self.at < other.end() && other.at < self.end() } } /// A time axis: things placed by when they happen, rather than flowed. /// /// # Why this is a primitive /// /// This crate refused to name it until 2026-08-15, on the argument that a /// description expressive enough to draw a timeline is a component library /// wearing a description's name. The refusal is withdrawn, and it is worth /// being precise about what was wrong with it, because the reasoning it used /// applies to real cases and should not be discarded with it. /// /// What a timeline needs that a [`List`](Region::Pane) does not is **one** /// thing: placement. Where a thing sits is a fact about the thing, the way a /// row's primary text is, and it is not derivable from order. Everything else a /// day view draws -- the labels, the gridlines, the item bodies, the tones -- /// is furniture this vocabulary already names. Measured against goingson's /// `day-planning-render.js`, the only members it needed and could not get were /// `at` and `minutes`. /// /// So the timeline was never a component library's worth of vocabulary. It was /// two integers, and the refusal was priced as though it were the whole widget. /// The test that matters is not "does this shape look complicated" but "how /// many members does it actually add, and are they facts or presentation". /// Slot heights, gridline colour, how overlaps stack and which hour scrolls /// into view on open are all presentation and all stay the renderer's, which is /// why they are absent here. /// /// # What it does not carry /// /// No pixel measure, no scroll offset, no drag affordance. A renderer draws the /// span at whatever density its host uses; `makeover-geometry` owns that the /// way it owns everything else measured in pixels. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Track { /// The window the axis covers. pub span: Span, /// The granularity a thing can be placed on, in minutes. /// /// goingson's day view is 15, giving 96 slots across a day. A renderer uses /// it to decide where gridlines fall and what a drop lands on; it does not /// constrain [`Placement`], because data arriving from a calendar does not /// respect anyone's grid. pub slot: u16, /// How often the axis labels itself, in its own unit. /// /// 60 gives an hourly ruler over a 15-minute grid, which is the common /// shape and the reason this is separate from `slot`. Zero means an /// unlabelled axis. pub tick: u16, /// What `span`, `slot`, `tick` and every [`Placement`] on it count. /// /// The one field here a renderer cannot derive, and the reason it exists: /// [`fraction`](Self::fraction) is unit-agnostic, so a day-granularity /// track produced correct geometry under an hours-and-minutes ruler until /// this was added. Geometry never needed it; a label always did. pub unit: Unit, } impl Track { /// An ordinary day: midnight to midnight, quarter-hour slots, hourly ticks. pub const DAY: Self = Self { span: Span::DAY, slot: 15, tick: 60, unit: Unit::Minutes, }; /// A track over `span`, with the day's usual granularity. #[must_use] pub const fn over(span: Span) -> Self { Self { span, slot: 15, tick: 60, unit: Unit::Minutes, } } /// A strip of whole days: one slot a day, a label a week. /// /// The shape a stretch of leave or a sprint is drawn on. Not a calendar -- /// it does not wrap into weeks, and the crate header says why that /// distinction is the whole of what a month grid still has over this. #[must_use] pub const fn days(span: Span) -> Self { Self { span, slot: 1, tick: 7, unit: Unit::Days, } } /// How many slots the axis holds. /// /// Rounded up, so a span that does not divide evenly by `slot` still has a /// slot covering its tail rather than dropping it. Never zero: `slot` of 0 /// reads as one slot spanning the whole axis rather than a division by /// zero, since a renderer asking this question has already committed to /// drawing something. #[must_use] pub const fn slots(self) -> u16 { if self.slot == 0 { 1 } else { self.span.length().div_ceil(self.slot) } } /// Where a placement sits on the axis, as a fraction from 0.0 to 1.0. /// /// The one calculation every renderer would otherwise write itself, and the /// place the three would drift apart. Clamped, so a placement outside the /// span draws at the edge rather than off it -- an event running past /// midnight is a real thing and truncating it is better than either /// panicking or drawing it somewhere impossible. #[must_use] pub fn fraction(self, minute: u16) -> f32 { let span = f32::from(self.span.length()); let offset = f32::from(minute.saturating_sub(self.span.from())); (offset / span).clamp(0.0, 1.0) } } impl Default for Track { fn default() -> Self { Self::DAY } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Act<'a> { /// What the control says. pub label: &'a str, /// The key that reaches it where a host has keys. /// /// The one member written for a terminal before there was one. A webview /// hangs it off `accesskey` or ignores it; a terminal has nothing else to /// offer, so this is the whole of how a control is reached there. pub key: Option<&'a str>, /// What pressing it means. [`Tone::Danger`] is the destructive one. pub tone: Tone, /// Disabled, or nothing said. /// /// [`State::Disabled`] is what changes what a renderer may do: see /// [`State::suppresses_interaction`], which is what says a disabled control /// is drawn and not reachable. It has been the only member since 0.19.0, /// and a control's focus is not sayable here at all — see the crate header, /// "Reach, focus and the focus ring". pub state: Option, } impl<'a> Act<'a> { /// An ordinary control, reachable, with no key. #[must_use] pub const fn new(label: &'a str) -> Self { Self { label, key: None, tone: Tone::Neutral, state: None, } } /// The key that reaches it. #[must_use] pub const fn key(mut self, key: &'a str) -> Self { self.key = Some(key); self } /// What pressing it means. #[must_use] pub const fn tone(mut self, tone: Tone) -> Self { self.tone = tone; self } /// Focus, or disabled. #[must_use] pub const fn state(mut self, state: State) -> Self { self.state = Some(state); self } /// Whether the control is drawn and does not answer. #[must_use] pub fn disabled(&self) -> bool { self.state.is_some_and(State::suppresses_interaction) } } /// A named part of a screen. /// /// The thing `makeover-geometry` deliberately does not name: it names the space /// *between* things by relationship, and nothing named the things. Six named /// members, taken from what the two webview apps actually use, plus /// [`Region::Bespoke`] for the parts no description should reach. Both apps' /// `layout.css` currently names exactly two things, `.raised` and `.well`, so /// this layer is absent rather than divergent, which makes it the cheapest of /// the schemas to add and the easiest to over-build. /// /// `#[non_exhaustive]` arrives with [`Region::Widget`], the pairing [`RowPart`] /// made at 0.9.0 and [`Readiness`] at 0.12.0, and for the same reason: the /// member after this one should not be a lockstep event across three renderers. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Region<'a> { /// A full-width strip with a title slot and an actions cluster, either of /// which may be empty. goingson's `.page-header`, Balanced Breakfast's /// `.header` and `.detail-header` are all this, differing only in which /// slots they fill. Band, /// A persistent column beside the content, holding navigation. Sidebar, /// A region of content with its own scroll. Pane, /// Things that belong together, and nothing else. /// /// The block [`Heading::Section`] has been naming since 0.2.0 without the /// vocabulary being able to contain it. A section heading is a leaf sitting /// *beside* the things it names, so nothing said where a section started or /// ended and a renderer learned one had ended only because the next heading /// arrived. /// /// # The measurement /// /// 41 [`Heading::Section`] sites across the ten screens described through /// the router, not one of them contained. audiofiles' settings screen is the /// clearest: one pane holding a heading, a field, a heading, two toggles, a /// heading, a toggle and a heading, which is four sections and no /// containers. Under the hand-written CSS the ports are replacing the same /// block is spelled `.settings-section` in goingson, `.form-section` and /// `.content-section` in the MNW server, `.help-section` in Balanced /// Breakfast: three apps, four names, one shape. /// /// # Why the existing members were the wrong answer /// /// [`Pane`](Self::Pane) is what apps reached for, and it is 28 of the 45 /// regions in the described screens. It claims a scroll of its own and /// [`Depth::Well`], so four settings groups inside a pane are four wells /// inside a well and four scroll contexts. Neither claim is true of a group. /// /// [`Widget`](Self::Widget) is wrong from the other side. Its own docs say a /// widget is never how a primitive gets added by the back door, and a run of /// related controls under a heading is furniture any app would have, which /// is the generic-against-bespoke bar a primitive has to clear. /// /// # What it does not carry /// /// **A heading.** A group usually has one and it is an ordinary node in the /// body, the way it already was. A group of related toggles with no heading /// is a real thing and a mandatory slot would forbid it. /// /// **A depth.** [`Depth::Flat`], on [`Bespoke`](Self::Bespoke)'s reasoning: /// it inherits, and an app that wants its group in a well puts it in a /// [`Pane`](Self::Pane), which composes rather than adding a knob here. /// /// **A colour.** Distinguishing sibling groups by colour is the thing this /// member was asked for and it is deliberately not stated here. The /// description says these things belong together; which of the theme's /// categorical colours a renderer reaches for, and whether it reaches for /// one at all, is derived from sibling order at the renderer. A terminal /// that tints nothing and separates with a rule is honouring this. Group, /// Two panes side by side, where the left chooses what the right shows. Split, /// Peer regions across, all of them equals. /// /// A kanban board's columns, and the shape [`Split`](Self::Split) is not: /// a split's two panes stand in a master-detail relationship, where the /// left chooses what the right shows. These choose nothing about each /// other. Each is a whole region and the set is the arrangement. /// /// # What it does not carry /// /// **How many.** The children say, and a count here would be a second /// source for something the description already states by containing them. /// /// **How wide.** Peers are equal by definition, so there is no [`Share`] to /// state. A board whose columns wanted different widths would be a /// different member, and no app has one. /// /// **What happens when there is no room.** Scroll across, wrap, or collapse /// to one column at a time: all three are right on some host, none is /// derivable from the description, and every one of them is presentation. /// A terminal that stacks them vertically is honouring this, not degrading /// it. /// /// # Why it is not an `Arrangement` /// /// [`Arrangement`] is the page's shape, and a board is usually a region /// *inside* a page that also has a band over it. Naming it here composes; /// naming it there would make a screen either a board or a list-detail and /// never a band above a board. It also keeps [`Arrangement::share`] /// meaningful, which a peer arrangement has no answer for. Columns, /// A set of panes, one visible at a time, with a [`Selector::Tabs`] above. TabGroup, /// Content over a scrim, taking input until dismissed. Modal, /// A region this crate names the *place* of and nothing else. The app owns /// what goes in it. /// /// The escape hatch, and the thing that keeps the description honest about /// its own limits. A day-plan timeline, a kanban board, a calendar and the /// paint interaction over the timeline are not describable here and are not /// going to become describable: a description expressive enough to produce /// a timeline is a widget library wearing a description's name. /// /// But a screen containing one still has to be a screen. Without this /// member the description covers only the boring screens, and the four that /// make goingson worth using would need a second, undescribed path beside /// the router. Two paths is how the vocabulary starts drifting from the app /// again, which is the exact failure this crate exists to end. /// /// So the description says "a thing called `day-plan` goes here" and stops. /// The name is opaque: this crate never interprets it, and no renderer is /// expected to know what it means beyond handing the space over. Bespoke { /// What the app calls it. Never interpreted here. name: &'a str, }, /// A named assembly of things the vocabulary already says. /// /// The third tier, between a primitive and [`Bespoke`](Self::Bespoke). /// Stated by Max 2026-08-12 answering the carousel: "something in between a /// primitive and a bespoke interface, like a widget, which is just an /// assembly of primitives." Full note: wiki `widget-tier`. /// /// # What separates it from the two members either side /// /// A primitive is a thing every renderer draws from scratch, and the test /// it has to pass is that every host has an honest answer. A carousel fails /// that test — a terminal has no carousel — which is the same refusal /// `Node::Html` got and is why the carousel sat unsayable for months. /// /// [`Bespoke`](Self::Bespoke) fails it from the other side. Bespoke is for /// what one app owns and nobody will build twice, and it carries *no* /// contents: the description names the place and stops. A carousel is /// furniture any app would have, and every part of it — an ordered set of /// frames, a position, prev and next, a strip of position indicators — is /// already sayable. Only the assembly had no name. /// /// So this member is the pair the other two are not: a name **and** /// contents. The contents are the assembly, in the region's own body, said /// in members that already exist. /// /// # Why the name does not have to be understood /// /// A renderer that recognises the name draws it the way its host does it: a /// carousel in a webview, a pager with a count in a terminal, a selector in /// egui. A renderer that does not recognise it walks the body, which is /// primitives all the way down and which it can already draw. /// /// That is what lets the widget set be **open** without every renderer /// knowing every widget. An unrecognised widget degrades to its assembly /// instead of failing, so a second or third party can name one without /// three renderers releasing in lockstep to accept it. Contrast /// [`Bespoke`](Self::Bespoke), which no renderer can degrade: there is /// nothing under it to fall back to. /// /// # What it does not do /// /// A widget is an assembly of things the vocabulary *already* says, so it /// buys no expressive power. Anything needing a member the vocabulary does /// not have is a finding about the vocabulary, and the answer to a finding /// is to add the member. A widget is never the way a primitive gets added /// by the back door. /// /// This used to say "it does not make a timeline describable, and the /// refusal in the crate header stands unchanged". The timeline is /// describable as of 2026-08-15 -- see [`Track`] -- and it got there the /// way the paragraph above says it should have: by adding the two members /// that were missing, not by dressing the screen up as an assembly. Widget { /// What the assembly is called. This crate never interprets it, and a /// renderer is free not to know it. name: &'a str, }, } impl<'a> Region<'a> { /// How the region sits on what is behind it. #[must_use] pub const fn depth(self) -> Depth { match self { Self::Band | Self::Sidebar | Self::Split | Self::TabGroup => Depth::Flat, // Flat, and it inherits. A group says its contents belong together // and says nothing about the surface they sit on, so a group in a // pane is in a well and a group on the page is on the page. An app // wanting one lifted puts it in a `Pane`. Self::Group => Depth::Flat, // Flat, and it is the container rather than the columns. Each // column is its own region and brings its own depth; a well here // would put a second edge around a row of wells. Self::Columns => Depth::Flat, // A pane is looked into, the same as a table body or a tag tree. Self::Pane => Depth::Well, Self::Modal => Depth::Raised, // Flat because it inherits: a bespoke region takes the depth of // whatever frames it. An app that wants its timeline in a well puts // it in a `Pane`, which composes rather than adding a knob here. // // A widget inherits for the same reason and it matters more here, // because a widget is drawn by whichever renderer recognises it. A // depth set here would be this crate deciding that a carousel is // raised on every host, which is the kind of value the deferral // rule exists to refuse. Self::Bespoke { .. } | Self::Widget { .. } => Depth::Flat, } } /// Whether this crate can say anything about the region's contents. /// /// A renderer walks the description and hands every region it understands /// to the right drawing code. This is how it tells the two apart, and the /// reason it is a method rather than a `matches!` at each renderer: there /// is exactly one opaque member and there should stay exactly one. /// /// [`Widget`](Self::Widget) is described, and that is the whole of what /// separates it from [`Bespoke`](Self::Bespoke) here. Both carry a name /// this crate never interprets; only one of them carries contents under it. /// A renderer that does not recognise a widget's name still walks its body, /// so there is nothing for it to hand over and nothing it cannot draw. #[must_use] pub const fn described(self) -> bool { !matches!(self, Self::Bespoke { .. }) } /// The name an app gave this region, if it gave one. /// /// [`Bespoke`](Self::Bespoke) and [`Widget`](Self::Widget) are the two /// members that carry a name, for two different purposes: one says what the /// app will fill the space with, the other says what the assembly under it /// is called. A renderer dispatching on either wants the string without /// caring which member it came from, and writing that `matches!` at each /// renderer is how the two drift apart. #[must_use] pub const fn name(self) -> Option<&'a str> { match self { Self::Bespoke { name } | Self::Widget { name } => Some(name), // Spelled out rather than a wildcard, so a member added later has // to answer whether it carries a name instead of inheriting `None` // by sitting under a `_`. Self::Band | Self::Sidebar | Self::Pane | Self::Group | Self::Split | Self::Columns | Self::TabGroup | Self::Modal => None, } } } /// How many of a region's children are visible at once. /// /// `4dcd241b`. Three findings turned out to be one sentence the vocabulary /// could not say: *this region holds several children and shows some of them, /// and the reader can change which.* [`Region::TabGroup`] existed with nothing /// saying which tab was open, a carousel had nothing saying which frame was up, /// and a disclosure had nothing saying whether its one child was showing at all. /// /// Because the fact lived nowhere, a renderer had two moves: hardcode a widget /// name, or draw every child. That is what put per-widget code in renderers, and /// it was the missing member rather than the widget tier that put it there. /// /// # What is here and what is not /// /// The *kind*, and only the kind. Which child is currently up is the current /// answer, and a layer that defers every address does not hold the current /// answer either — the split [`Selector`] already makes, where this crate says /// what kind of chooser a thing is and the router says which option is picked. /// So a holder of regions carries the index and the per-child label beside this. /// /// # What a renderer does with it /// /// Derives its chrome, once, for every widget rather than per name: /// /// - Children carrying labels get a strip of the labels, the current one marked. /// - Children carrying none get previous, position, next. /// - [`AtMostOne`](Self::AtMostOne) over one child gets a summary line that /// opens. /// /// The name on [`Region::Widget`] survives as app vocabulary, for a renderer /// that wants to do something *special* with one, which is what it should have /// been from the start. /// /// Degradation runs the way it already did: a renderer ignoring this draws every /// child, which is more content rather than less. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[non_exhaustive] pub enum Showing { /// Every child, in order. What every region did before this existed. #[default] All, /// Exactly one. A carousel, a tab group. One, /// One, or none. A disclosure, which is closed until it is opened. AtMostOne, } impl Showing { /// Whether the reader can change which child is up. /// /// The question every renderer's region arm asks before deriving any /// chrome, and a method rather than a `matches!` at each renderer for /// [`Region::name`]'s reason: three renderers writing the same comparison is /// how they come to disagree about a member added later. #[must_use] pub const fn selective(self) -> bool { !matches!(self, Self::All) } /// Whether showing nothing is a legal state. /// /// True only for [`AtMostOne`](Self::AtMostOne). A renderer needs this to /// know whether its control closes as well as moves: a carousel's row moves /// between frames and never reaches empty, and a disclosure's summary line /// is the same control wearing its closed state. #[must_use] pub const fn dismissible(self) -> bool { matches!(self, Self::AtMostOne) } } /// A window onto a sequence: where it starts, how much it covers, and how long /// the sequence is when that is known. /// /// The mechanism under two things the vocabulary deliberately keeps apart. A /// carousel is a window of one frame over children that are all present; a /// paged list is a window of a page over rows most of which were never fetched. /// Those are different facts and they stay different types — [`Showing`] says /// which child is up, [`Paging`] says where a reader is in a query — but the /// arithmetic underneath is one piece of code, so a terminal and a browser /// cannot come to disagree about which frame is last. /// /// # Why `of` is optional and `count` is not /// /// `count` is what is on screen and is therefore always known. `of` is the /// length of the thing being windowed, and a host that cannot count says so by /// leaving it empty **for the life of the screen**. It is never "not counted /// yet": see "First paint is final paint" in the crate header. A total that /// turns up on a later pass widens the text that prints it. /// /// # Clamping /// /// Every derivation clamps rather than refusing, and a zero `count` answers /// `None` rather than dividing. A window past the end is a bug in the host, and /// a renderer that answered it by drawing nothing would report a region that /// vanished, which is the hardest kind of bug to find from what is on screen. /// [`Share::percent`] clamps for the same reason. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub struct Window { /// The index into the sequence where the window starts. pub from: usize, /// How many the window covers. One, for a carousel. pub count: usize, /// How long the sequence is, when the host can say. pub of: Option, } impl Window { /// A window of `count`, starting at `from`, over a sequence of unknown /// length. #[must_use] pub const fn new(from: usize, count: usize) -> Self { Self { from, count, of: None, } } /// How long the sequence is. #[must_use] pub const fn of(mut self, of: usize) -> Self { self.of = Some(of); self } /// One item of a sequence whose length is known. A carousel frame. #[must_use] pub const fn frame(at: usize, of: usize) -> Self { Self { from: at, count: 1, of: Some(of), } } /// Which window this is, counting from zero. /// /// `None` when `count` is zero, which is the only input with no answer /// rather than a clamped one. #[must_use] pub const fn index(self) -> Option { if self.count == 0 { return None; } Some(self.from / self.count) } /// How many windows the sequence holds. /// /// `None` unless both the length and a non-zero `count` are known. A /// partial answer here would be a renderer drawing "of 0". #[must_use] pub const fn windows(self) -> Option { match self.of { Some(of) if self.count > 0 => Some(of.div_ceil(self.count)), _ => None, } } /// Whether anything sits before this window. #[must_use] pub const fn has_before(self) -> bool { self.from > 0 } /// How many sit after this window, when the length is known. /// /// Here rather than in each renderer for [`Showing::selective`]'s reason: /// three of them writing the same subtraction is how they come to disagree, /// and this one has an underflow in it for whoever writes it fourth. #[must_use] pub const fn after(self) -> Option { match self.of { Some(of) => Some(of.saturating_sub(self.from.saturating_add(self.count))), None => None, } } /// Whether anything sits after it. /// /// `true` when the length is unknown: a host that cannot count cannot rule /// out more, and offering a way forward that turns out to be empty is the /// cheaper of the two mistakes. #[must_use] pub const fn has_after(self) -> bool { match self.of { Some(of) => self.from.saturating_add(self.count) < of, None => true, } } /// The window with `from` brought inside the sequence. /// /// A no-op when the length is unknown, since there is nothing to clamp /// against. #[must_use] pub const fn clamped(mut self) -> Self { if let Some(of) = self.of && self.from >= of { // `max(1)` by hand: `Ord::max` is not const yet, and a zero-count // window would otherwise clamp onto the end rather than inside it. let step = if self.count == 0 { 1 } else { self.count }; self.from = of.saturating_sub(step); } self } } /// Where a reader is in a set that arrived in parts. /// /// A [`Window`] wearing the paged reading of itself. Distinct from a carousel's /// window at the top level on purpose, because the intent differs and a call /// site should say which one it means, while the arithmetic below is shared so /// the two cannot drift apart. /// /// # The two idioms, and which one a renderer may draw /// /// Load-more and numbered pages are both this type. Which is honest is /// [`paged`](Self::paged): a set whose page size is known can be drawn as /// "Page 3 of 8", and one without can only be drawn as "150 of 400" and a way /// forward. Saying it here rather than letting each renderer guess is the point /// — three renderers inferring it from the numbers is how they come to disagree. /// /// # What it does not carry /// /// No addresses. `makeover-layout` cannot name an action, and the way to ask for /// the next part is the host's: `quasi_router` pairs this with the addresses the /// same way `Row` pairs its parts with `Row::activate`. That split is the reason /// this type is reusable by a carousel, which has nothing to ask. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub struct Paging { /// The window onto the set. pub window: Window, /// Whether the parts are a fixed size, and so whether pages are countable. /// /// `false` for load-more, where the window simply grew and "page 2" would /// name nothing. pub paged: bool, } impl Paging { /// A page of `per`, starting at `from`. #[must_use] pub const fn pages(from: usize, per: usize) -> Self { Self { window: Window::new(from, per), paged: true, } } /// The first `shown`, with more behind them. /// /// The load-more shape: the window starts at the beginning and grows, so /// there is no page to number. #[must_use] pub const fn more(shown: usize) -> Self { Self { window: Window::new(0, shown), paged: false, } } /// How many there are altogether. /// /// Left unsaid by a host that cannot count, and left unsaid **for good**: /// a total arriving later widens whatever prints it. See "First paint is /// final paint" in the crate header. #[must_use] pub const fn of(mut self, of: usize) -> Self { self.window = self.window.of(of); self } /// Which page this is, counting from one, when pages are countable. /// /// One-based because it is read aloud. [`Window::index`] is the zero-based /// form for anyone indexing with it. #[must_use] pub const fn page(self) -> Option { if !self.paged { return None; } match self.window.index() { Some(index) => Some(index + 1), None => None, } } /// How many pages there are, when that is countable. #[must_use] pub const fn pages_total(self) -> Option { if !self.paged { return None; } self.window.windows() } /// How many are on screen. #[must_use] pub const fn shown(self) -> usize { self.window.count } /// How many there are, when the host counted. #[must_use] pub const fn total(self) -> Option { self.window.of } /// How many are not shown yet, when the host counted. /// /// The figure a load-more control puts in its label. `None` is the honest /// and common case: a set that cannot say how many more there are still has /// a way to ask for them. #[must_use] pub const fn remaining(self) -> Option { self.window.after() } /// Whether there is anything further on. #[must_use] pub const fn has_more(self) -> bool { self.window.has_after() } /// Whether there is anything back the other way. #[must_use] pub const fn has_previous(self) -> bool { self.window.has_before() } } /// How much of the width an arrangement's first region takes. /// /// `e0fd485e`. Nothing said how much room a region got, so every renderer /// invented its own number and two hosts showing one screen disagreed about /// its proportions. A webview never noticed, because the stylesheet answered /// once for every consumer; a terminal has no stylesheet to inherit from, so /// `quasi-tui` picked 24 columns for a sidebar and 40% for a list pane and /// neither had anything behind it. /// /// # A proportion, never a unit /// /// Held as a percentage, and that is the only form it comes in. A description /// carrying columns would be describing a terminal and one carrying pixels a /// webview, and the whole point is that both honour the same fact: a terminal /// resolves it against a column count, a webview writes it into a grid, and /// neither has to know what the other did. /// /// It is not [`makeover_geometry::Ratio`]'s job either, which was the first /// guess. Geometry is scales that answer the same for every screen and takes /// no input that would let a sidebar screen differ from a list-detail one. /// /// [`makeover_geometry::Ratio`]: https://docs.rs/makeover-geometry #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Share(u8); impl Share { /// What a sidebar takes, when nobody says otherwise. /// /// A quarter. `quasi-tui` drew 24 columns, which is a quarter of a /// 96-column terminal and about a fifth of a wide one; a quarter is that /// number said in the form a webview can honour too. pub const SIDEBAR: Self = Self(25); /// What the list side of a list-detail takes, when nobody says otherwise. /// /// `quasi-tui`'s 40%, which was already a proportion and is the one number /// this member did not have to invent. pub const LIST: Self = Self(40); /// A share of the width, as a percentage. /// /// Clamped to 5..=95 rather than refused. A description that asked for a /// region of nothing is a bug in the app, and a renderer drawing a region /// zero cells wide reports it as a region that vanished, which is the /// hardest kind of bug to find from what is on the screen. #[must_use] pub const fn percent(percent: u8) -> Self { Self(if percent < 5 { 5 } else if percent > 95 { 95 } else { percent }) } /// The share as a percentage. #[must_use] pub const fn as_percent(self) -> u8 { self.0 } /// This share of a width, rounded to the nearest whole unit. /// /// What a terminal calls to turn the proportion into columns. At least one, /// because a region the description named should be visible: a screen /// 3 columns wide is unusable either way, and a sidebar that is there is a /// truer picture of the description than a sidebar that is not. #[must_use] pub const fn of(self, whole: u16) -> u16 { let taken = (whole as u32 * self.0 as u32).div_ceil(100); if taken == 0 { 1 } else { taken as u16 } } } /// How a screen is laid out. /// /// Two, and the second is not a variant of the first. goingson is list-detail, /// Balanced Breakfast is sidebar plus content, and neither app has a third. /// The tab group is a modifier rather than a member, because goingson uses it /// *inside* the same content region rather than instead of one. /// /// This exists at all because the router has to be able to express a screen /// rather than only a control. Discovering the arrangement layer missing after /// the renderers exist is a redesign; naming two now is a morning. /// /// # Why the share rides here /// /// `e0fd485e`. A share is per-arrangement: how much a sidebar takes and how /// much a list side takes are different questions, and this enum is the only /// thing that knows which one is being asked. Geometry would have had to invent /// a channel to be told. /// /// [`list_detail`](Self::list_detail) and /// [`sidebar_content`](Self::sidebar_content) build these with the default /// shares, so a screen that has no opinion does not have to have one. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Arrangement { /// A list that chooses what the detail beside it shows. ListDetail { /// Whether the detail side is a [`Region::TabGroup`]. tabbed: bool, /// How much of the width the list side takes. share: Share, }, /// Navigation down the side, content filling the rest. SidebarContent { /// How much of the width the sidebar takes. share: Share, }, } impl Arrangement { /// A list and a detail beside it, at the default share. #[must_use] pub const fn list_detail(tabbed: bool) -> Self { Self::ListDetail { tabbed, share: Share::LIST, } } /// A sidebar and content beside it, at the default share. #[must_use] pub const fn sidebar_content() -> Self { Self::SidebarContent { share: Share::SIDEBAR, } } /// How much of the width the first region takes. #[must_use] pub const fn share(self) -> Share { match self { Self::ListDetail { share, .. } | Self::SidebarContent { share } => share, } } /// The same arrangement, at this share. #[must_use] pub const fn with_share(self, share: Share) -> Self { match self { Self::ListDetail { tabbed, .. } => Self::ListDetail { tabbed, share }, Self::SidebarContent { .. } => Self::SidebarContent { share }, } } } /// How wide the content of a whole screen runs. /// /// `0eccff0d`, and [`Share`]'s sibling one level up: that one says how a /// screen's width is divided between regions, this says how much of the window /// the screen uses in the first place. Both are the description's, which is /// what answering the two together settled. /// /// Measured in the MNW server, where 69 of 72 templates carry exactly one of /// three mutually exclusive classes and the choice is per screen. GoingsOn /// reaches for `max-width` 56 times and Balanced Breakfast 12, neither with a /// token for it, so three apps were solving one thing by hand. /// /// # Named for the measure, not for MNW's classes /// /// A renderer that is not a browser has to answer this too, and `padded-page` /// tells a terminal nothing. The three say how wide the text runs, which is a /// question every renderer can answer: a webview with a `max-width`, a terminal /// with gutters, an immediate-mode frame with its own width. /// /// `#[non_exhaustive]` for [`Fill`]'s reason. The set is closed today because /// the measurement found three, and a fourth arriving should not be a lockstep /// release across nine repos. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[non_exhaustive] pub enum Measure { /// The whole width, with gutters. The default, and 53 of the 69. /// /// What a dashboard, a table and a settings screen want: the content is /// wide because the content *is* wide, and constraining it would waste the /// window. #[default] Wide, /// Capped at a comfortable page width, centred. 13 of the 69. /// /// A form, a sign-in, a purchase. Content that does not get better by /// getting wider, but is not prose either. Contained, /// Capped at a line length that reads well. 3 of the 69. /// /// Prose. The narrowest of the three, and the one with a reason outside /// taste: a line of text past roughly 75 characters costs the reader the /// return sweep. Reading, } impl Measure { /// A stable name, for a renderer that needs to spell it. /// /// Here rather than in each renderer for [`Sort::as_str`]'s reason: three /// renderers spelling one enum is three chances to spell it differently. #[must_use] pub const fn as_str(self) -> &'static str { match self { Self::Wide => "wide", Self::Contained => "contained", Self::Reading => "reading", } } } /// What kind of value a form field takes. /// /// The union of the two vocabularies that diverged, which is what triggered /// this crate. They have since converged on their own: both apps now have a /// `renderFormField` emitting the same anatomy, and what is left differing is /// the kind set, the error shape, and whether the return is a string or a node. /// /// Validation is deliberately absent. Neither app has a shared story (goingson /// validates after collecting the form data, with per-field transform hooks; /// Balanced Breakfast has `required` and nothing else), and a schema that /// describes fields but not constraints acquires a constraint layer per app, /// which is exactly how the current divergence started. Naming it absent is a /// decision; leaving it unmentioned would not be. /// `#[non_exhaustive]` for the reason [`Fill`] is: renderers match on this and /// the set keeps growing, so growth must not be a lockstep event. Email, Url /// and Tel arriving in 0.5.0 is the second growth in two releases. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum FieldKind { /// A single line of text. Text, /// A single line of text that must never be echoed, logged or round-tripped /// through anything that might persist it. Secret, /// A number. Number, /// An email address. /// /// Distinct from [`Text`](Self::Text) because the distinction is not /// decoration: a webview renderer emits `type="email"`, which on a touch /// device changes the keyboard that appears and turns on the platform's own /// validation. goingson ships to iOS, so collapsing this into text costs a /// keyboard with no `@` on it. /// /// Added 0.5.0, from goingson's contact form. Email, /// A URL. Same reasoning as [`Email`](Self::Email). /// /// Added 0.5.0, from goingson's contact-social and contact-feed forms. Url, /// A telephone number. Same reasoning as [`Email`](Self::Email), and the /// clearest case of it: the keyboard is a numeric pad rather than letters. /// /// Added 0.5.0, from goingson's contact-phone form. Tel, /// A calendar day, with no time of day in it. /// /// [`Email`](Self::Email)'s argument, and it carries further: a webview /// emits `type="date"`, which is a native picker, the platform's own /// validation, and on a touch device the date keyboard. Described as /// [`Text`](Self::Text) with a hint reading "YYYY-MM-DD", all three are /// lost and the hint is doing the platform's job in prose. /// /// The membership test passes on every host without stretching: a webview /// and a Tauri app emit the input, egui has a date picker, a terminal /// prompts for a day and can validate it, a CLI takes an argument. /// /// # The value is ISO 8601, `YYYY-MM-DD` /// /// Named here rather than left to each host, because a host that picks /// differently sends a server something it parses differently, and the /// failure is silent and per-host. It is ``'s own wire /// format, so the webview renderer owes nothing to honour it and the other /// hosts have one spelling to meet. [`DATE_FORMAT`] is the constant, and a /// test asserts this doc and that constant agree. /// /// Added 0.15.0, from the MNW server's git access-token expiry /// (`user_ssh_keys_tab.html`) and six further sites across the server and /// goingson. Date, /// A calendar day and a time of day together. /// /// Apart from [`Date`](Self::Date) because the question is different rather /// than more precise: "which day does this expire" and "at what moment does /// this publish" are asked by different screens and answered by different /// controls. A webview emits `type="datetime-local"` for one and /// `type="date"` for the other, and a host that collapsed them would ask /// half the tree for a precision it does not want. /// /// Both arrived together on measurement rather than on symmetry: 13 sites /// of each across the MNW server and goingson, and **zero** of `time`, /// `month` or `week`, which is why those are not here. A member added for a /// case nobody has is a member designed against nothing, which is /// [`File`](Self::File)'s reasoning about `accept` applied to a whole /// member. /// /// # The value is `YYYY-MM-DDTHH:MM`, local, with no zone /// /// ``'s own format, and the "local" is the /// load-bearing half: the value carries no offset and no `Z`, so the moment /// it names is only fixed once something supplies a zone. That is the app's /// business and not the description's. Seconds are absent, which is the /// browser's own default and is left as the rule rather than restated as a /// constraint. [`DATETIME_FORMAT`] is the constant. /// /// [`Field::min`] and [`Field::max`] already take "the host's own spelling /// of a bound", so a floor of *not in the past* needs nothing new here: it /// is a string in this same format. /// /// Added 0.15.0, from goingson's snooze picker and day planner and the MNW /// server's publish-at fields. DateTime, /// Several lines of text. Textarea, /// One of a fixed set, offered behind a control that shows one at a time. Select, /// One of a fixed set, with every option on screen at once. /// /// Not a presentation of [`Select`](Self::Select), which is the reading to /// resist: what differs is a property of the *question*. A choice that is /// consequential or irreversible has to be readable without opening /// anything, because a closed control shows one option and hides the rest, /// and the one it shows is whichever was current before the user had read /// the alternatives. audiofiles asks whether a library copies samples into /// its store or references them where they lie — which cannot be changed /// afterwards — and had already promoted that out of a checkbox by hand, /// with a comment giving this reason, before the description could say it. /// /// It was described here at 0.8.1 as "the one HTML input type this enum was /// missing", which was not true then and is not true now: `file` arrived at /// 0.11.0 and `date` and `datetime-local` at 0.15.0. Everything here is /// still an ``, a `