max / makeover-layout
| 1 | //! The renderer-agnostic half of the make-family design system. |
| 2 | //! |
| 3 | //! <!-- wiki: makeover-layout --> |
| 4 | //! |
| 5 | //! `makeover` answers *what colour*, and varies by theme. `makeover-geometry` |
| 6 | //! answers *how much space*, and varies by density and surface. This crate |
| 7 | //! answers *what the thing is*, and varies by nothing. |
| 8 | //! |
| 9 | //! # The deferral rule |
| 10 | //! |
| 11 | //! A description names intents and relationships, never values. Say |
| 12 | //! [`Fill::Raised`], never `#D9DDF4`. Say `Gap::Peer`, never `6px`. What is |
| 13 | //! left once colour and spacing are deferred is **composition**: which edges |
| 14 | //! are lit, what inverts on press, what nests in what. |
| 15 | //! |
| 16 | //! The constraint that shapes all of it: a renderer that can only paint |
| 17 | //! rectangles has to be able to express the result. egui has no |
| 18 | //! `box-shadow: inset` and one stroke per widget with no per-side control; a |
| 19 | //! terminal has box-drawing characters and one cell of resolution, and cannot |
| 20 | //! draw a two-tone lit edge at all. A description that assumes per-side edges |
| 21 | //! is a CSS description wearing a neutral name. So this crate names the |
| 22 | //! *intent* — this region is a well — and each renderer chooses an expression |
| 23 | //! it can actually produce, including dropping half of one. |
| 24 | //! |
| 25 | //! # Scope |
| 26 | //! |
| 27 | //! Depth came first: the bevel and the surfaces it shapes. That much was |
| 28 | //! settled the hard way — the vocabulary here was read off audiofiles' |
| 29 | //! `ui::theme` and `ui::widgets`, which are the only implementation written |
| 30 | //! by a consumer with no CSS, then checked against both webview apps. All |
| 31 | //! three agreed once Balanced Breakfast's fills were corrected. |
| 32 | //! |
| 33 | //! 0.2.0 adds the rest of the description, each member drawn the same way, |
| 34 | //! from what the three apps already hand-write rather than from a taxonomy: |
| 35 | //! |
| 36 | //! - Components. [`Token`] (badge against chip), [`Notice`] (toast against |
| 37 | //! banner), [`RowPart`], [`Heading`], [`Selector`], [`Readiness`], and |
| 38 | //! [`Tone`], which is the one intent family they share. |
| 39 | //! - Schemas. [`Field`] for forms and [`Column`] for lists and tables. |
| 40 | //! - Structure. [`Region`] for the parts of a screen, [`Arrangement`] for how |
| 41 | //! a screen is put together. |
| 42 | //! |
| 43 | //! **Validation** was absent on purpose here, on the grounds that neither app |
| 44 | //! had a shared story. That reasoning is retired — see 0.11.0 below, which is |
| 45 | //! where the constraints arrived and why the argument did not survive contact |
| 46 | //! with what the apps were measured to do. |
| 47 | //! |
| 48 | //! 0.3.0 closes a gap the first real adoption found, which is what adopting |
| 49 | //! against goingson first was for. [`Selector`] described only the *chosen* |
| 50 | //! option, so an unchosen one fell through to [`Depth::Flat`] and no renderer |
| 51 | //! drew it; goingson's tab strip recesses its unchosen tabs by hand and could |
| 52 | //! not delete the line, because being recessed is *why* the chosen tab reads as |
| 53 | //! coming forward. So [`Selector::unchosen`] joins `chosen`, and saying it |
| 54 | //! needed [`Fill::Sunken`] and [`Depth::Sunken`]: a surface set back by colour |
| 55 | //! with no edge, which is neither a well nor level-with. |
| 56 | //! |
| 57 | //! 0.7.0 adds [`State`], the interaction axis, closing the gap that adopting |
| 58 | //! against three apps rather than one made visible. The description named |
| 59 | //! rest and, through [`Depth::pressed`], pressed. It named neither focus nor |
| 60 | //! disabled, so `makeover-webview` emitted a hover rule and stopped, and each |
| 61 | //! consumer completed the primitive from outside by out-specifying a rule it |
| 62 | //! did not own: 19 such rules in goingson, 21 in the MNW server, a further set |
| 63 | //! in Balanced Breakfast, and three focus rings that do not match. The axis is |
| 64 | //! deliberately two members wide, because hover and pressed belong where they |
| 65 | //! already are. [`State`]'s own docs carry that argument. |
| 66 | //! |
| 67 | //! 0.8.0 finishes [`Field`], which described a field well enough to label it and |
| 68 | //! not well enough to draw it. Writing `makeover-webview`'s form emitter found |
| 69 | //! three things missing and the renderer supplied all three from outside: the |
| 70 | //! current value, a select's options, and the placeholder. Two of those move |
| 71 | //! here and one does not. |
| 72 | //! |
| 73 | //! - [`Field::placeholder`] is user-facing text sitting beside `label` and |
| 74 | //! `hint`. There was never a reading on which it was renderer state; it was |
| 75 | //! outside only because adding a field to a published struct is breaking. |
| 76 | //! - [`Field::options`] moves because every renderer needs them and each was |
| 77 | //! going to invent its own shape. [`Choice`] is the shape `makeover-webview` |
| 78 | //! already arrived at, taken as-is rather than redesigned. |
| 79 | //! - The current value stays renderer-side and is not coming here. It is the |
| 80 | //! one of the three that is genuinely state: a webview reads it out of the |
| 81 | //! DOM, an immediate-mode renderer holds a `&mut` to the app's own field, and |
| 82 | //! a description that carried it would be a form model. |
| 83 | //! |
| 84 | //! 0.9.0 opens [`RowPart`], which was the last closed enum in the vocabulary, |
| 85 | //! and adds [`RowPart::Tokens`]. Both halves come from the same finding, made |
| 86 | //! by the first two real screens described through the router rather than by |
| 87 | //! reading a stylesheet. |
| 88 | //! |
| 89 | //! A goingson project card carries two trailing badges, a type and a toned |
| 90 | //! status; a contact card carries a primary email *and* a strip of tags. `Meta` |
| 91 | //! is one slot and one string, so both ports joined their facts with a |
| 92 | //! separator and lost what the second one was: a status reads as text where it |
| 93 | //! used to read as colour. [`Token`] already says exactly the right thing — a |
| 94 | //! small labelled thing with a kind, a tone and an optional action — and could |
| 95 | //! only ever be a node in its own right, never inside a row. |
| 96 | //! |
| 97 | //! So the missing thing was permission rather than a concept. `Tokens` is that |
| 98 | //! permission, and `#[non_exhaustive]` arrives with it so the next member is not |
| 99 | //! a lockstep event across three renderers. The pairing is the point: this |
| 100 | //! enum's own consumer in `makeover-webview` carried a comment predicting it |
| 101 | //! would stop compiling one day, which is a lockstep break written down and |
| 102 | //! waited for rather than prevented. |
| 103 | //! |
| 104 | //! Balanced Breakfast was checked before the member was added, because one |
| 105 | //! consumer wanting something is not evidence. It packs a count and two icon |
| 106 | //! buttons into the same single `Meta` slot while leaving `Actions` empty, so |
| 107 | //! the slot was already straining under a second consumer for a different |
| 108 | //! reason. |
| 109 | //! |
| 110 | //! 0.10.0 adds [`Meter`], a proportion carried as a pair rather than as a |
| 111 | //! percentage. Its own docs carry the argument; the short form is that the |
| 112 | //! percentage shape had already been tried in goingson and had already needed a |
| 113 | //! companion flag to recover what rounding and clamping threw away. |
| 114 | //! |
| 115 | //! 0.11.0 is four members from the quasi proving ground, batched into one |
| 116 | //! release because pre-1.0 a minor is breaking and a cascade is nine repos. |
| 117 | //! Three findings that arrived with them turned out not to belong here at all: |
| 118 | //! this crate has no notion of an action, a route or a destination, so anything |
| 119 | //! asking what a control *calls* was never the vocabulary's to say. |
| 120 | //! |
| 121 | //! - [`Figure`], a value with a caption. goingson had five of them across five |
| 122 | //! screens with five class vocabularies for the one shape, which is the |
| 123 | //! divergence this crate exists to end, sitting in plain sight and counted for |
| 124 | //! the first time. |
| 125 | //! - [`RowPart::Proportion`], so a [`Meter`] can sit in a row. `Meter` reached |
| 126 | //! two of its seven sites at 0.10.0 and the other five are row-shaped. Exactly |
| 127 | //! [`RowPart::Tokens`]'s problem with a different payload, and it takes |
| 128 | //! `Tokens`' answer: the part carries the description of a bar, not a node. |
| 129 | //! - [`Field::max_length`], [`Field::min`] and [`Field::max`], joining |
| 130 | //! [`Field::required`], which had been sitting here as the sole constraint |
| 131 | //! while the header above claimed there were none. The set stops before |
| 132 | //! `pattern`, which fails the renderer test and is one site in one app. |
| 133 | //! - [`FieldKind::File`]. Every host has an honest answer — a native picker, an |
| 134 | //! `<input type="file">`, a path prompt, an argument — and it carries no |
| 135 | //! accepted-types list because `accept` appears at zero sites in either app. |
| 136 | //! |
| 137 | //! The evidence rule changed under these, and it is worth recording because four |
| 138 | //! earlier decisions were made under the old one. The two-app test said a shape |
| 139 | //! earns a word once a second app wants it. It is backwards: a rule that |
| 140 | //! withholds a word until a second app has duplicated the code guarantees the |
| 141 | //! duplication, and app three writes it a third time. The bar is now generic |
| 142 | //! against bespoke — is this furniture any app would have, or is it this app's |
| 143 | //! own? Bespoke keeps [`Region::Bespoke`], which already carries a completion |
| 144 | //! heatmap and is the right answer for a calendar nobody will build twice. |
| 145 | //! |
| 146 | //! 0.12.0 is two more from the same proving ground, and the same sorting |
| 147 | //! happened first: six findings came out of a measurement of goingson's whole |
| 148 | //! frontend, and four of them turned out to be asking what a control *calls*, |
| 149 | //! which this crate cannot say. The two that were really here: |
| 150 | //! |
| 151 | //! - [`Readiness`] grows from two states to four. It named `Ready` and |
| 152 | //! `Pending` and stopped, so a screen whose list came back empty had nothing |
| 153 | //! to say about it; goingson draws an empty state at 27 sites and Balanced |
| 154 | //! Breakfast at 9. `Empty` and `Failed` are the same axis rather than a new |
| 155 | //! member beside it, because a region shows one of the four and never two. |
| 156 | //! `#[non_exhaustive]` arrives with them, the pairing [`RowPart`] made at |
| 157 | //! 0.9.0 and for the same reason. |
| 158 | //! - [`Column::sortable`], [`Column::sorted`] and [`Sort`]. The one finding in |
| 159 | //! the set that completes a member rather than adding one: `Column` shipped |
| 160 | //! with a width and a priority and could not say that a table is ordered by a |
| 161 | //! column, so a described table could draw no caret and offer no reordering. |
| 162 | //! |
| 163 | //! 0.14.0 is two additive members on two `#[non_exhaustive]` enums, released |
| 164 | //! together because publishing twice for that is waste and the cascade below |
| 165 | //! this crate is nine repos. |
| 166 | //! |
| 167 | //! - [`Depth::Overlay`]. The enum could say raised, well, sunken and flat, and |
| 168 | //! could not say that a surface sits *over* the page. Every renderer already |
| 169 | //! had the surface — `makeover-tui`'s `Palette::overlay`, |
| 170 | //! `makeover-immediate`'s `Palette::elevation`, `makeover-webview`'s |
| 171 | //! `--elevation-overlay` — and none of them could be reached from a |
| 172 | //! description. buckets_of_money has 16 modals waiting on it. |
| 173 | //! - [`CellPart`], which is [`RowPart`] for tables. A row's parts have carried |
| 174 | //! their own content intent since 0.2.0, so `.row-actions` inherits rather |
| 175 | //! than taking a text colour; a table cell had no such vocabulary and |
| 176 | //! `makeover-webview` emitted one undifferentiated `.cell`, so a button in a |
| 177 | //! cell was painted as text. The four members are the four things quasi's |
| 178 | //! `Cell` was measured to hold, and the count is in that crate's history |
| 179 | //! rather than assumed here. |
| 180 | //! |
| 181 | //! 0.15.0 adds [`FieldKind::Date`] and [`FieldKind::DateTime`], on the argument |
| 182 | //! [`FieldKind::Email`] was admitted on: a webview emits a different `type=`, |
| 183 | //! which is a native picker, the platform's validation and a different keyboard |
| 184 | //! on a touch device. Described as text with a "YYYY-MM-DD" hint, all three are |
| 185 | //! lost. |
| 186 | //! |
| 187 | //! Two members and not one or five, from a count rather than from symmetry: 13 |
| 188 | //! sites of `date` and 13 of `datetime-local` across the MNW server and |
| 189 | //! goingson, and zero of `time`, `month` or `week`. The wire format each takes |
| 190 | //! is named here as [`DATE_FORMAT`] and [`DATETIME_FORMAT`], because a host |
| 191 | //! left to pick its own would disagree with a server silently, and |
| 192 | //! [`FieldKind::temporal`] is the pair asked about once rather than at each |
| 193 | //! renderer. `FieldKind`'s own comment claiming `radio` was the last HTML input |
| 194 | //! type missing was already false when 0.8.1 wrote it; these are what it was |
| 195 | //! missing. |
| 196 | //! |
| 197 | //! What each of the 0.12.0 findings deliberately leaves out is the address — what pressing a |
| 198 | //! header calls, and where an empty state's "Add your first project" button |
| 199 | //! goes. That is the boundary this crate is defined by, and four findings moved |
| 200 | //! across it rather than being answered here. |
| 201 | //! |
| 202 | //! # Where the description stops |
| 203 | //! |
| 204 | //! The bespoke widgets, a day-plan timeline and a kanban board and a calendar, |
| 205 | //! are not describable here and will not become describable. A description |
| 206 | //! expressive enough to produce a timeline is a widget library wearing a |
| 207 | //! description's name. Generate the boring 80% so the bespoke 20% gets the |
| 208 | //! attention. |
| 209 | //! |
| 210 | //! [`Region::Bespoke`] is how that limit is stated rather than hidden. The |
| 211 | //! description names the *place* and the app owns the contents, so a screen |
| 212 | //! containing a timeline is still a whole screen and still routable. Without |
| 213 | //! it, the four goingson screens that make the app worth using would need a |
| 214 | //! second, undescribed path beside the router, and two paths is how a |
| 215 | //! vocabulary starts drifting from its app again. |
| 216 | |
| 217 | |
| 218 | |
| 219 | /// A colour intent this crate refers to but never resolves. |
| 220 | /// |
| 221 | /// The string is the token name `makeover` publishes, so a renderer can look |
| 222 | /// it up without this crate knowing what colour came back. |
| 223 | |
| 224 | /// The `makeover` intent token this resolves against. |
| 225 | ; |
| 226 | |
| 227 | |
| 228 | /// Which way the light falls across a two-tone edge. |
| 229 | /// |
| 230 | /// The whole content of a bevel, once colour and thickness are deferred. The |
| 231 | /// light is always assumed to come from the top left: every consumer measured |
| 232 | /// agreed on that and none of them ever varied it, so it is an invariant here |
| 233 | /// rather than a parameter. |
| 234 | /// |
| 235 | /// # The two corners that belong to both edges |
| 236 | /// |
| 237 | /// Top-right and bottom-left are where the lit run meets the shaded one, and |
| 238 | /// the description's claim is that they belong to *both*. How a renderer says |
| 239 | /// that is its own business, because the answer is bounded by resolution and |
| 240 | /// not by taste: |
| 241 | /// |
| 242 | /// - A terminal cell is roughly 8x17 device pixels, so giving the whole corner |
| 243 | /// to one tone thickens that edge by a cell and reads as one run overrunning |
| 244 | /// the other. A half-cell glyph divides the cell already, so `makeover-tui` |
| 245 | /// splits it and recovers real information. Its box-drawing fallback cannot: |
| 246 | /// a single stroke has no half to give, so there both corners go to dark. |
| 247 | /// - A pixel bevel is a one-point stroke by default, which makes the corner a |
| 248 | /// one-point square. There is nothing to divide — a diagonal seam across one |
| 249 | /// point is sub-pixel, and antialiasing renders it as the blend a mitred join |
| 250 | /// already produces. So `makeover-immediate` mitres and is *not* diverging; |
| 251 | /// it is the same rule at a resolution where the split degenerates. |
| 252 | /// |
| 253 | /// Stated here so the difference reads as a decision rather than as drift. A |
| 254 | /// renderer with room to divide the corner should; one without should mitre or |
| 255 | /// pick the shaded tone, and neither is a bug. |
| 256 | |
| 257 | |
| 258 | /// Lit from the top left: light on top and left, dark on bottom and right. |
| 259 | Raised, |
| 260 | /// The same edge inverted, which is also the pressed state of anything |
| 261 | /// that draws itself [`Bevel::Raised`]. |
| 262 | Inset, |
| 263 | |
| 264 | |
| 265 | |
| 266 | /// The edge intents, as `(top_left, bottom_right)`. |
| 267 | /// |
| 268 | /// Split out from any painting because the inversion *is* the idea, and |
| 269 | /// it is the one part every renderer implements identically. |
| 270 | |
| 271 | pub const |
| 272 | match self |
| 273 | SelfRaised => , |
| 274 | SelfInset => , |
| 275 | |
| 276 | |
| 277 | |
| 278 | /// Pressing inverts. A raised control reads as inset while held. |
| 279 | /// |
| 280 | /// Stated here rather than left to each consumer because a cascade can |
| 281 | /// carry a pressed state and an immediate-mode renderer cannot: audiofiles |
| 282 | /// resolves this per call site, eighteen times. |
| 283 | |
| 284 | pub const |
| 285 | match self |
| 286 | SelfRaised => SelfInset, |
| 287 | SelfInset => SelfRaised, |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | /// One side of a bevel, named by the intent it takes. |
| 293 | |
| 294 | |
| 295 | /// The lit side. |
| 296 | Light, |
| 297 | /// The shadowed side. |
| 298 | Dark, |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | match self |
| 304 | SelfLight => "bevel-light", |
| 305 | SelfDark => "bevel-dark", |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | /// A surface intent a region is filled with. |
| 311 | /// |
| 312 | /// `#[non_exhaustive]`, so a renderer must carry a wildcard arm and a new |
| 313 | /// member is additive rather than breaking. Added 0.4.0, after [`Sunken`] |
| 314 | /// (an additive member, 0.3.0) hard-broke `makeover-tui` and |
| 315 | /// `makeover-immediate` at compile time and left neither able to move until |
| 316 | /// both published. The vocabulary exists to grow and the renderers exist to |
| 317 | /// disagree about how much of it they answer, so growth must not be a |
| 318 | /// lockstep event. The renderer's wildcard is not a hole: [`Fill`] is |
| 319 | /// resolved through a fallible lookup, and a missing intent is answered with |
| 320 | /// structure rather than with a substituted colour. |
| 321 | /// |
| 322 | /// [`Sunken`]: Fill::Sunken |
| 323 | |
| 324 | |
| 325 | |
| 326 | /// The page behind everything. |
| 327 | Page, |
| 328 | /// A surface lifted off the page: cards, controls, menus, toasts. |
| 329 | Raised, |
| 330 | /// A surface floating above the page rather than resting on it. |
| 331 | Overlay, |
| 332 | /// The inside of a well. |
| 333 | Well, |
| 334 | /// A surface set back from the one it sits on, by colour and nothing else. |
| 335 | /// |
| 336 | /// Not a well. A well is a hole with an edge, and the two are authored in |
| 337 | /// opposite directions: `makeover` derives `surface-well` by inverting |
| 338 | /// against the theme's own content colour, while `surface-sunken` is |
| 339 | /// authored and free to sit darker than raised (goingson's does). Naming |
| 340 | /// only the well left the recessed-with-no-edge surface unsayable, which is |
| 341 | /// what an unchosen tab is: it recedes so the chosen one can come forward, |
| 342 | /// and it carries no bevel of its own. |
| 343 | /// |
| 344 | /// Added 0.3.0, from goingson's tab strip, which hand-writes exactly this |
| 345 | /// and could not delete the line because no member described it. |
| 346 | Sunken, |
| 347 | |
| 348 | |
| 349 | // No `fallback` here, deliberately. An earlier cut had `Fill::Well` fall back |
| 350 | // to `Fill::Page` so a consumer on makeover 2.2.0, which has no `surface-well`, |
| 351 | // had something to paint. makeover-tui found that wrong within a day: page is |
| 352 | // the surface a well is usually cut into, so on a terminal that substitution |
| 353 | // produces exactly the invisibility it was meant to prevent, and the right |
| 354 | // answer there is a drawn edge rather than a different colour. |
| 355 | // |
| 356 | // Substituting one intent for another is renderer policy. The description says |
| 357 | // what the region is and stops. |
| 358 | |
| 359 | |
| 360 | |
| 361 | match self |
| 362 | SelfPage => "surface-page", |
| 363 | SelfRaised => "surface-raised", |
| 364 | SelfOverlay => "surface-overlay", |
| 365 | SelfWell => "surface-well", |
| 366 | SelfSunken => "surface-sunken", |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | /// How a region sits relative to the surface behind it. |
| 372 | /// |
| 373 | /// Fill and bevel are named together because naming them apart is what let |
| 374 | /// them disagree. Every consumer measured had at least one region carrying a |
| 375 | /// raised bevel over a recessed fill: audiofiles fixed it in `raised_frame` |
| 376 | /// and recorded the bug in its doc comment, and Balanced Breakfast still had |
| 377 | /// twelve of them a year later. A single name for the pair makes that |
| 378 | /// unrepresentable. |
| 379 | /// `#[non_exhaustive]` for the same reason as [`Fill`], and in the same |
| 380 | /// release: a depth this renderer has no drawing for should cost it a |
| 381 | /// wildcard arm, not a compile error and a wait on someone else's publish. |
| 382 | |
| 383 | |
| 384 | |
| 385 | /// Level with its surroundings. No edge. |
| 386 | Flat, |
| 387 | /// A card laid on the panel it sits in. |
| 388 | Raised, |
| 389 | /// A hole in the panel, with content down inside it. For anything the |
| 390 | /// user looks *into*: a table body, a tag tree, a text field. |
| 391 | Well, |
| 392 | /// Set back from what it sits on, by colour alone. No edge. |
| 393 | /// |
| 394 | /// The one member carrying a fill without a bevel, so a renderer cannot |
| 395 | /// assume the two arrive together. That is deliberate and it is still the |
| 396 | /// pairing rule: both halves come off the same `Depth`, so they cannot |
| 397 | /// disagree, and here one half is legitimately absent. |
| 398 | /// |
| 399 | /// Distinct from [`Depth::Flat`], which has no fill either and inherits. |
| 400 | /// Recessed and level-with are different claims, and only one of them |
| 401 | /// needs a colour. |
| 402 | Sunken, |
| 403 | /// A surface sitting *over* the page rather than in it. A modal, a popover, |
| 404 | /// a menu. |
| 405 | /// |
| 406 | /// Takes elevation and no bevel: a surface overlaying the page is lifted |
| 407 | /// off it, and a surface in the page is cut into it. That is the same |
| 408 | /// pairing rule the rest of the enum holds, applied to the one case where |
| 409 | /// the separation is not an edge at all — the lift and the scrim behind it |
| 410 | /// are already saying where the surface is. |
| 411 | /// |
| 412 | /// Every renderer had the surface before it had this variant. |
| 413 | /// `makeover-tui` carries `Palette::overlay`, `makeover-immediate` gained |
| 414 | /// `Palette::elevation` at 0.10.0, and `makeover-webview` emits |
| 415 | /// `--elevation-overlay`. What was missing was the route from a description |
| 416 | /// to any of them, which is why this is one variant rather than a feature. |
| 417 | Overlay, |
| 418 | |
| 419 | |
| 420 | |
| 421 | /// The edge this depth is drawn with, if it has one. |
| 422 | |
| 423 | pub const |
| 424 | match self |
| 425 | // Sunken joins Flat here, for the opposite reason: Flat has no edge |
| 426 | // because nothing separates it from its surroundings, and Sunken has |
| 427 | // none because its colour is already doing the separating. |
| 428 | SelfFlat | SelfSunken => None, |
| 429 | // A third reason to have no edge, which is why it gets its own arm |
| 430 | // rather than joining the two above: an overlay is separated by the |
| 431 | // lift and by the scrim behind it, so an edge would be a second |
| 432 | // answer to a question already answered. |
| 433 | SelfOverlay => None, |
| 434 | SelfRaised => Some, |
| 435 | SelfWell => Some, |
| 436 | |
| 437 | |
| 438 | |
| 439 | /// The surface this depth is filled with. |
| 440 | /// |
| 441 | /// [`Depth::Flat`] has no fill of its own: it inherits whatever it sits on, |
| 442 | /// which is the difference between level-with and painted-the-same-colour. |
| 443 | |
| 444 | pub const |
| 445 | match self |
| 446 | SelfFlat => None, |
| 447 | SelfRaised => Some, |
| 448 | SelfWell => Some, |
| 449 | SelfSunken => Some, |
| 450 | SelfOverlay => Some, |
| 451 | |
| 452 | |
| 453 | |
| 454 | /// Pressing a raised region reads as a well, and nothing else moves. |
| 455 | /// |
| 456 | /// [`Depth::Overlay`] is untouched along with the rest: an overlay is a |
| 457 | /// surface, not a control, so there is nothing there to press. |
| 458 | |
| 459 | pub const |
| 460 | match self |
| 461 | SelfRaised => SelfWell, |
| 462 | other => other, |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | /// An interaction state a region can be in, beside whatever [`Depth`] it is. |
| 468 | /// |
| 469 | /// Orthogonal to depth on purpose. A disabled button is still [`Depth::Raised`] |
| 470 | /// and a disabled field is still a [`Depth::Well`], so folding either member |
| 471 | /// into `Depth` would make [`Depth::bevel`] and [`Depth::fill`] answer for |
| 472 | /// something that is not a depth, and would leave disabled-button and |
| 473 | /// disabled-field sharing one variant that cannot tell them apart. |
| 474 | /// |
| 475 | /// # Why hover and pressed are not members |
| 476 | /// |
| 477 | /// The line is whether every renderer has the state to express, not whether CSS |
| 478 | /// does. Hover is renderer policy and `makeover-webview` says so in its own |
| 479 | /// header: a terminal and an immediate-mode painter have no pointer hovering |
| 480 | /// over anything, and pressed already arrives through [`Bevel::pressed`] and |
| 481 | /// [`Depth::pressed`], where it belongs, because pressing is a depth inversion |
| 482 | /// rather than a separate condition. |
| 483 | /// |
| 484 | /// Focus and disabled are different in kind. A TUI has a focused widget and a |
| 485 | /// greyed-out one; so does egui. Both were unsayable here, so all three webview |
| 486 | /// consumers supplied them from outside the primitive by out-specifying rules |
| 487 | /// they did not own: goingson alone carries 19 of them, and the MNW server |
| 488 | /// another 21. That is the divergence this crate exists to end, arriving one |
| 489 | /// layer down. |
| 490 | /// |
| 491 | /// # The principle this encodes |
| 492 | /// |
| 493 | /// A primitive owns every state it implies. A renderer that emits a hover rule |
| 494 | /// for a thing owes disabled, focus and the capability answer for that same |
| 495 | /// thing, because anything less exports the completion work to N consumers who |
| 496 | /// will each do it differently. |
| 497 | /// |
| 498 | /// `#[non_exhaustive]` for the reason [`Fill`] and [`Depth`] carry it: growth |
| 499 | /// must not be a lockstep event across the three renderers. |
| 500 | |
| 501 | |
| 502 | |
| 503 | /// Keyboard focus, as distinct from the pointer having landed on something. |
| 504 | /// |
| 505 | /// One ring, not one per primitive. Where the ring sits is [`Depth`]'s |
| 506 | /// question and not a per-component choice: a well takes it inside its own |
| 507 | /// edge and a raised surface takes it outside. That is one decision with |
| 508 | /// two renderings rather than one decision per component, which is how the |
| 509 | /// three apps ended up with three rings. |
| 510 | Focus, |
| 511 | /// Present, visible, and not answering. |
| 512 | /// |
| 513 | /// Not the same as absent, and deliberately not a [`Fill`]: a disabled |
| 514 | /// control keeps the surface it always had and stops responding, so what |
| 515 | /// changes is its content and its interactivity rather than what it is. |
| 516 | Disabled, |
| 517 | |
| 518 | |
| 519 | |
| 520 | /// Whether a region in this state stops answering the pointer. |
| 521 | /// |
| 522 | /// Stated in the description rather than left to each renderer, on the same |
| 523 | /// reasoning as [`Bevel::pressed`]: a cascade carries it for free and an |
| 524 | /// immediate-mode renderer resolves it per call site, so leaving it unsaid |
| 525 | /// means resolving it once per consumer and disagreeing. |
| 526 | |
| 527 | pub const |
| 528 | match self |
| 529 | SelfDisabled => true, |
| 530 | SelfFocus => false, |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | match self |
| 538 | // Already derived by `makeover` from `action.primary`, and unused |
| 539 | // until now for the same reason `hover-surface` was: nothing |
| 540 | // emitted the rule that would consume it. |
| 541 | SelfFocus => "focus-ring", |
| 542 | // Reusing the muted content intent rather than minting a |
| 543 | // `disabled` colour. Disabled is a reduction and not a status, and |
| 544 | // `makeover-webview`'s progress rules already record the reading |
| 545 | // that `content-muted` is what disabled looks like. |
| 546 | SelfDisabled => "content-muted", |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | /// What a region is saying, when it is saying something. |
| 552 | /// |
| 553 | /// The one intent family shared by badges, notices and nothing else. Kept |
| 554 | /// separate from [`Fill`] because a surface is where a thing sits and a tone is |
| 555 | /// what it means, and the three apps agree on the four statuses: |
| 556 | /// `info_banner` / `warning_banner` in audiofiles, `.toast-info` / |
| 557 | /// `.toast-success` / `.toast-error` in goingson, `.toast.success` / |
| 558 | /// `.toast.error` in Balanced Breakfast. |
| 559 | /// |
| 560 | /// The per-tag palette (`category-one` through `category-six`) is deliberately |
| 561 | /// not here. Which colour a *particular* tag takes is app domain, and both |
| 562 | /// webview apps already carry it as a `data-color` attribute. |
| 563 | |
| 564 | |
| 565 | /// No status. Reads as ordinary de-emphasised content. |
| 566 | Neutral, |
| 567 | /// Something worth knowing and nothing to do about it. |
| 568 | Info, |
| 569 | /// Something finished and it worked. |
| 570 | Success, |
| 571 | /// Something the user should look at before continuing. |
| 572 | Warning, |
| 573 | /// Something broken, or something about to be destroyed. |
| 574 | Danger, |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | match self |
| 580 | // Neutral has no status token of its own. It takes the muted |
| 581 | // content intent, which is what both webview apps already spell as |
| 582 | // `data-color="muted"`. |
| 583 | SelfNeutral => "content-muted", |
| 584 | SelfInfo => "info", |
| 585 | SelfSuccess => "success", |
| 586 | SelfWarning => "warning", |
| 587 | SelfDanger => "danger", |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | /// A small labelled thing that sits inside something else. |
| 593 | /// |
| 594 | /// Two members, because the three apps drew three taxonomies and only one line |
| 595 | /// runs through all of them: does it answer a click. audiofiles has |
| 596 | /// `classification_badge` (a label) against `tag_chip`, `tag_chip_removable` |
| 597 | /// and `selectable_tag` (all of which do). Balanced Breakfast has `.tag` and |
| 598 | /// `.badge` against `.tag-chip`. goingson is the one that has to move: its |
| 599 | /// `.tag` and `.badge` are a single CSS rule, so every call site has to be read |
| 600 | /// to decide which of the two it always was. |
| 601 | /// |
| 602 | /// The evidence that a chip is a real concept rather than a badge with a |
| 603 | /// cursor: audiofiles inverts its bevel on press and Balanced Breakfast latches |
| 604 | /// `.tag-chip.active` with the inset bevel. Two independent arrivals at "a chip |
| 605 | /// holds itself down", which is exactly what [`Depth::pressed`] already says. |
| 606 | |
| 607 | |
| 608 | /// Non-interactive status or count. Answers no click. |
| 609 | Badge, |
| 610 | /// An interactive or removable token. Answers a click, and latches if it |
| 611 | /// stands for a filter that is either on or off. |
| 612 | Chip |
| 613 | /// Whether it carries its own remove affordance. |
| 614 | removable: bool, |
| 615 | , |
| 616 | |
| 617 | |
| 618 | |
| 619 | /// Whether this answers a click. |
| 620 | /// |
| 621 | /// The whole difference between the two members, and the reason a renderer |
| 622 | /// with no hover (a touch surface, a terminal) can still tell them apart. |
| 623 | |
| 624 | pub const |
| 625 | matches! |
| 626 | |
| 627 | |
| 628 | /// How it sits, given whether it is currently latched down. |
| 629 | /// |
| 630 | /// A badge is flat: it is a label, and giving it an edge would say it can |
| 631 | /// be pressed. A chip is raised, and inset while latched. |
| 632 | |
| 633 | pub const |
| 634 | match self |
| 635 | SelfBadge => Flat, |
| 636 | SelfChip if latched => Well, |
| 637 | SelfChip => Raised, |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | /// Something the app is telling the user, unprompted. |
| 643 | /// |
| 644 | /// Two concepts, not one with a placement. They differ in more than where they |
| 645 | /// sit: a toast is transient, stacked and self-dismissing, and a banner is |
| 646 | /// persistent, in flow, one per region, and dismissed by fixing the condition |
| 647 | /// it reports. Folding them into one member with a placement parameter would |
| 648 | /// make lifetime, stacking and dismissal all placement-dependent, which is the |
| 649 | /// description leaking renderer policy. |
| 650 | /// |
| 651 | /// All three apps have banners: `info_banner` and `warning_banner` in |
| 652 | /// audiofiles, five of them in goingson (sync, sync-result, vacation-day, |
| 653 | /// timer-active, past-review), `.update-banner` in Balanced Breakfast. The two |
| 654 | /// webview apps also have toasts. So neither member is speculative, and no app |
| 655 | /// gains a concept it lacks except audiofiles, whose renderer may legitimately |
| 656 | /// decline to draw a toast at all. |
| 657 | |
| 658 | |
| 659 | /// Transient, stacked, dismisses itself. |
| 660 | Toast, |
| 661 | /// Persistent, in flow, one per region, dismissed by fixing the cause. |
| 662 | Banner, |
| 663 | |
| 664 | |
| 665 | |
| 666 | /// Whether it goes away on its own. |
| 667 | |
| 668 | pub const |
| 669 | matches! |
| 670 | |
| 671 | |
| 672 | /// How it sits. |
| 673 | /// |
| 674 | /// A toast floats above the page rather than resting on it, which is |
| 675 | /// [`Fill::Overlay`]'s whole reason to exist. A banner is a card in the |
| 676 | /// flow. Both are raised, and they are raised off different things. |
| 677 | |
| 678 | pub const |
| 679 | match self |
| 680 | SelfToast => Overlay, |
| 681 | SelfBanner => Raised, |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | /// The parts of a list row. |
| 687 | /// |
| 688 | /// Four to begin with, taken from Balanced Breakfast, which was the only |
| 689 | /// consumer that had all of them (`row-primary`, `row-secondary`, `row-meta`, |
| 690 | /// `row-actions`). audiofiles has two and no slot structure at all, so it gains |
| 691 | /// meta and actions as real work rather than a rename; goingson moves off |
| 692 | /// `task-row` / `task-cell`. |
| 693 | /// |
| 694 | /// [`Tokens`](Self::Tokens) joined at 0.9.0, and `#[non_exhaustive]` with it. |
| 695 | /// See the crate header for why the two arrived together. |
| 696 | /// |
| 697 | /// # Meta against Tokens |
| 698 | /// |
| 699 | /// The line is whether the thing has its own standing. `Meta` is one short |
| 700 | /// trailing fact about the row, written as text: a count, a size, a date. |
| 701 | /// `Tokens` is a set of small labelled things, each of which can be toned and |
| 702 | /// can answer a click. "3 files" is meta. A status badge that is amber, and a |
| 703 | /// tag you can click to filter by, are tokens. |
| 704 | /// |
| 705 | /// Keeping them apart is what a single widened slot would have foreclosed. A |
| 706 | /// renderer can right-align one string and cannot usefully do the same to a |
| 707 | /// strip of chips, and a fact that is not clickable should not be drawn as |
| 708 | /// though it were. |
| 709 | |
| 710 | |
| 711 | |
| 712 | /// The thing itself. What the row is called. |
| 713 | Primary, |
| 714 | /// Supporting text under the primary. |
| 715 | Secondary, |
| 716 | /// A short trailing fact: a count, a size, a date. |
| 717 | Meta, |
| 718 | /// Controls that act on this row. |
| 719 | Actions, |
| 720 | /// Small labelled things belonging to the row: badges, chips, tags. |
| 721 | /// |
| 722 | /// Each carries its own [`Token`] kind and [`Tone`], so a renderer with no |
| 723 | /// colour still has the kind to work with, and one with no chips still has |
| 724 | /// the label. That is the constrained-consumer test this vocabulary exists |
| 725 | /// to pass, and it is why the tone lives on the token rather than on the |
| 726 | /// part. |
| 727 | Tokens, |
| 728 | /// How much of a set the row's thing has done: a [`Meter`] in the row. |
| 729 | /// |
| 730 | /// Added 0.11.0, `da5666ae`, and it is [`Tokens`](Self::Tokens)'s problem |
| 731 | /// again with a different payload. [`Meter`] arrived at 0.10.0 and closed |
| 732 | /// two of the seven sites that asked for it; the other five sit in rows, and |
| 733 | /// a row holds no nodes by the ruling that a row part may not carry an |
| 734 | /// arbitrary node — the door through which a description becomes a |
| 735 | /// templating language. So the part carries the *description of a bar* |
| 736 | /// rather than a node, exactly as `Tokens` carries tags rather than nodes. |
| 737 | /// |
| 738 | /// Without it a row flattens the proportion into [`Meta`](Self::Meta) as |
| 739 | /// "3/7 subtasks", which keeps both numbers and loses the reading, the same |
| 740 | /// way a toned status badge read as prose before `Tokens`. |
| 741 | Proportion, |
| 742 | |
| 743 | |
| 744 | |
| 745 | /// The content intent the part takes. |
| 746 | |
| 747 | pub const |
| 748 | match self |
| 749 | SelfPrimary => "content", |
| 750 | SelfSecondary => "content-secondary", |
| 751 | SelfMeta => "content-muted", |
| 752 | // Actions carry controls rather than text, so they inherit. |
| 753 | SelfActions => "content", |
| 754 | // So do tokens: each one carries its own tone, and a part-level |
| 755 | // intent underneath it would fight the token that sits on it. |
| 756 | SelfTokens => "content", |
| 757 | // And so does a proportion, for the same reason: the meter carries |
| 758 | // the tone, and it is about the ratio rather than about the row. |
| 759 | SelfProportion => "content", |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | /// How far down the heading tree a title sits. |
| 765 | /// |
| 766 | /// Three, and only the three that are actually headings. The bands those used |
| 767 | /// to be filed with (goingson's `.page-header`, Balanced Breakfast's `.header` |
| 768 | /// and `.detail-header`) are arrangement, not type, and live at |
| 769 | /// [`Region::Band`]. One of them contains no text at all. |
| 770 | |
| 771 | |
| 772 | /// Names the whole screen. One per screen. |
| 773 | Page, |
| 774 | /// Names a block within the screen. |
| 775 | Section, |
| 776 | /// Names a sub-block inside an already-named section. |
| 777 | Subsection, |
| 778 | |
| 779 | |
| 780 | |
| 781 | /// Whether a rule follows the heading. |
| 782 | /// |
| 783 | /// audiofiles' `section_header` draws a separator and its |
| 784 | /// `subsection_label` deliberately does not, which is the only thing |
| 785 | /// distinguishing the two once weight and colour are deferred. |
| 786 | |
| 787 | pub const |
| 788 | matches! |
| 789 | |
| 790 | |
| 791 | |
| 792 | /// A control that picks between things. |
| 793 | /// |
| 794 | /// Three, because three distinct behaviours are in play and collapsing any two |
| 795 | /// loses something. A segmented control picks a value; a tab picks a pane; a |
| 796 | /// toggle picks nothing and simply holds itself on or off. |
| 797 | |
| 798 | |
| 799 | /// Exactly one of N, and the options abut. |
| 800 | Segmented, |
| 801 | /// Independent on or off, on its own. |
| 802 | Toggle, |
| 803 | /// Navigation between panes. The folder semantic. |
| 804 | Tabs, |
| 805 | |
| 806 | |
| 807 | |
| 808 | /// How the chosen option sits. |
| 809 | /// |
| 810 | /// Held in for a segmented control and a toggle, which is the same shape |
| 811 | /// pressing produces and the whole economy of the idiom: one appearance, |
| 812 | /// two reasons to wear it. A tab is the exception, because the selected |
| 813 | /// folder tab comes *forward* to join the pane it opens. |
| 814 | |
| 815 | pub const |
| 816 | match self |
| 817 | SelfSegmented | SelfToggle => Well, |
| 818 | SelfTabs => Raised, |
| 819 | |
| 820 | |
| 821 | |
| 822 | /// How the options that were *not* picked sit. |
| 823 | /// |
| 824 | /// Added 0.3.0. Describing only [`Selector::chosen`] left the unchosen |
| 825 | /// option falling through to [`Depth::Flat`], which says it is level with |
| 826 | /// the strip it sits in, and no renderer emitted anything for it. That is |
| 827 | /// wrong in both directions and goingson proved it: its unchosen tabs are |
| 828 | /// recessed by hand, and being recessed is *why* the chosen one reads as |
| 829 | /// coming forward. Against a flat strip, a raised chosen tab is a bevel |
| 830 | /// drawn on the strip's own colour, which is a much weaker folder effect |
| 831 | /// than the contrast the idiom is named after. |
| 832 | /// |
| 833 | /// Each member is the inverse of its chosen state, which is the whole |
| 834 | /// content of "picked" once colour is deferred: |
| 835 | /// |
| 836 | /// - Tabs recede, so the chosen one comes forward. |
| 837 | /// - A segment and a toggle stand up, so the chosen one is held in. |
| 838 | |
| 839 | pub const |
| 840 | match self |
| 841 | SelfTabs => Sunken, |
| 842 | SelfSegmented | SelfToggle => Raised, |
| 843 | |
| 844 | |
| 845 | |
| 846 | /// Whether the options touch. |
| 847 | /// |
| 848 | /// The gap is the entire difference between a segmented control and a row |
| 849 | /// of buttons that happen to sit near each other, which is what audiofiles' |
| 850 | /// `segmented_control` says in its own comment and why it zeroes the |
| 851 | /// spacing by hand. |
| 852 | |
| 853 | pub const |
| 854 | matches! |
| 855 | |
| 856 | |
| 857 | |
| 858 | /// What is in a region right now. |
| 859 | /// |
| 860 | /// The state, not the shimmer. Whether pending paints a skeleton, a spinner or |
| 861 | /// nothing at all is renderer policy, the same class of decision that got |
| 862 | /// `Fill::fallback` deleted from this crate. goingson and Balanced Breakfast |
| 863 | /// each grew a skeleton with differently-named parts; both keep them, as the |
| 864 | /// webview renderer's expression of [`Readiness::Pending`]. audiofiles has none |
| 865 | /// and needs none, because an immediate-mode renderer simply repaints. |
| 866 | /// |
| 867 | /// # Four states and not two, as of 0.12.0 |
| 868 | /// |
| 869 | /// `703f4cd2`. It named `Ready` and `Pending` and stopped, so a described screen |
| 870 | /// whose list came back empty had to render an empty region or invent its own |
| 871 | /// placeholder text, and neither says what it is. goingson draws one at 27 sites |
| 872 | /// across 12 files and Balanced Breakfast at 9, with a class family that had |
| 873 | /// already drifted into `empty-state`, `empty-state--error`, `error-state` and |
| 874 | /// six more. |
| 875 | /// |
| 876 | /// The four are one axis because they are mutually exclusive: a region shows its |
| 877 | /// content, or a sign that it is coming, or a sign that there is none, or a sign |
| 878 | /// that it broke. Never two. That is the test for one enum against several |
| 879 | /// fields, and it is why this grew rather than a new member arriving beside it. |
| 880 | /// |
| 881 | /// # What is not here |
| 882 | /// |
| 883 | /// **The message.** "No projects yet" is content, and this names a state. It |
| 884 | /// lives with whatever holds the region — in quasi's case a `Slot` — alongside |
| 885 | /// the action that leads out of the emptiness, since an address is the one thing |
| 886 | /// this crate never names. |
| 887 | /// |
| 888 | /// **How much room it gets.** goingson's `--compact`, `--dashboard` and |
| 889 | /// `--padded` are the same state at three sizes, and a size is |
| 890 | /// `makeover-geometry`'s question. Naming them here would be this crate stating |
| 891 | /// values again. |
| 892 | /// |
| 893 | /// **The icon.** Presentation, and each host has its own answer or none. |
| 894 | |
| 895 | |
| 896 | |
| 897 | /// The content is here. |
| 898 | Ready, |
| 899 | /// The content is on its way. |
| 900 | Pending, |
| 901 | /// The content arrived and there is none of it. |
| 902 | /// |
| 903 | /// Not a failure. An empty list is the normal state of a new install, and a |
| 904 | /// renderer that drew it in a danger tone would be reporting a fault where |
| 905 | /// there is none. |
| 906 | Empty, |
| 907 | /// The content did not arrive. |
| 908 | Failed, |
| 909 | |
| 910 | |
| 911 | |
| 912 | /// Whether the region draws its own content, or something standing in for |
| 913 | /// it. |
| 914 | /// |
| 915 | /// The question every renderer asks first, so it is answered once here |
| 916 | /// rather than by a `matches!` in each. A state added later is a stand-in |
| 917 | /// until proven otherwise: falling back to drawing content that may not be |
| 918 | /// there is the worse of the two mistakes. |
| 919 | |
| 920 | pub const |
| 921 | matches! |
| 922 | |
| 923 | |
| 924 | /// What the state means, for a renderer choosing a colour. |
| 925 | /// |
| 926 | /// Derived rather than carried, which is the opposite of [`Meter`] and |
| 927 | /// [`Figure`], and the difference is worth stating: a proportion's meaning |
| 928 | /// depends on what is being counted and only the app knows it, while |
| 929 | /// "nothing here yet" and "this broke" mean the same thing in every app that |
| 930 | /// will ever have them. |
| 931 | |
| 932 | pub const |
| 933 | match self |
| 934 | SelfFailed => Danger, |
| 935 | _ => Neutral, |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | /// How much of a set is done. |
| 941 | /// |
| 942 | /// Added 0.10.0. Nine sites across the two webview apps drew a bar and nothing |
| 943 | /// here named one, so every described screen concatenated the two numbers into |
| 944 | /// its heading text instead: "Subtasks 3/7", "Time Tracking 45m tracked / 30m |
| 945 | /// est, over". Every fact survives that and the reading does not, which is the |
| 946 | /// same loss `RowPart::Tokens` closed when a toned status badge became prose. |
| 947 | /// |
| 948 | /// # Why a pair and not a percentage |
| 949 | /// |
| 950 | /// Both numbers, not the percentage the apps compute from them. The percentage |
| 951 | /// was the obvious shape and it had already been tried: goingson's |
| 952 | /// `Task::time_progress` divides, rounds, and then clamps to 100, which throws |
| 953 | /// away the one case the bar exists to show — 45 minutes tracked against a |
| 954 | /// 30-minute estimate. It carries a separate `is_over_estimate` boolean beside |
| 955 | /// it to recover the fact the clamp dropped. A pair keeps the over-run without a |
| 956 | /// companion flag, and [`percent`](Meter::percent) is still one call away for a |
| 957 | /// renderer that wants it. |
| 958 | /// |
| 959 | /// The pair is also what the apps already have at every site. All seven |
| 960 | /// determinate bars write the ratio into the accessible layer and never the |
| 961 | /// percentage: `title="3/7 subtasks"`, `aria-label="3 of 7 subtasks completed"`, |
| 962 | /// a milestone's own `3/7` span. Given 43 nothing can recover "3 of 7", so a |
| 963 | /// percentage member would have made [`label`](Meter::label) mandatory at every |
| 964 | /// call site, which is the concatenated text this member removes, moved one |
| 965 | /// layer down. |
| 966 | /// |
| 967 | /// # What this is not |
| 968 | /// |
| 969 | /// The progress of an *operation*. Two of the nine sites are that — goingson's |
| 970 | /// focus timer, Balanced Breakfast's feed fetch — and they get nothing here, on |
| 971 | /// purpose. Both are imperative controllers over a live handle, driven by a tick |
| 972 | /// or an event stream, and a description is built once and dropped. Holding one |
| 973 | /// would mean growing a way to update a description between renders, which is a |
| 974 | /// different feature. [`Readiness::Pending`] and a [`Notice::Toast`] carry the |
| 975 | /// honest part. |
| 976 | /// |
| 977 | /// The two cases are distinguishable in the markup rather than by taste: every |
| 978 | /// determinate bar in both apps carries a tone, and neither operation bar |
| 979 | /// carries one. Two codebases drew that line the same way without coordinating. |
| 980 | |
| 981 | |
| 982 | /// How much is done. May exceed [`total`](Self::total), and that is the |
| 983 | /// case worth drawing. |
| 984 | pub done: u32, |
| 985 | /// How much there is to do. Zero means there is no set, not that the set is |
| 986 | /// complete. |
| 987 | pub total: u32, |
| 988 | /// What the proportion means right now. |
| 989 | /// |
| 990 | /// Carried rather than derived, because no renderer can work it out. The |
| 991 | /// same 90% is [`Tone::Success`] on a subtask rollup and [`Tone::Danger`] on |
| 992 | /// a time estimate, and goingson picks between them from `is_over_estimate`, |
| 993 | /// a fact about the data and not about the number. |
| 994 | pub tone: Tone, |
| 995 | /// What is being counted, if the bar says so: "subtasks", "tasks". |
| 996 | /// |
| 997 | /// The noun, not the ratio. A renderer builds "3 of 7 subtasks" from this |
| 998 | /// and the two numbers; handing it the assembled string would put the |
| 999 | /// sentence order in the description, where a terminal at one line and a |
| 1000 | /// tooltip want different ones. |
| 1001 | pub label: , |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | /// A proportion with no tone and no label. |
| 1006 | |
| 1007 | pub const |
| 1008 | Self |
| 1009 | done, |
| 1010 | total, |
| 1011 | tone: Neutral, |
| 1012 | label: None, |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | /// What the proportion means. |
| 1017 | |
| 1018 | pub const |
| 1019 | self.tone = tone; |
| 1020 | self |
| 1021 | |
| 1022 | |
| 1023 | /// What is being counted. |
| 1024 | |
| 1025 | pub const |
| 1026 | self.label = Some; |
| 1027 | self |
| 1028 | |
| 1029 | |
| 1030 | /// How full the bar is, 0 to 100, clamped. |
| 1031 | /// |
| 1032 | /// For drawing, which is the only thing a clamped number is good for. Ask |
| 1033 | /// [`overflowing`](Self::overflowing) before reporting it as a fact, or this |
| 1034 | /// is `time_progress`'s bug again with the clamp moved. |
| 1035 | /// |
| 1036 | /// An empty set reads as 0. Nothing is done, because there is nothing to do |
| 1037 | /// and no bar to fill; the apps guard on the count before drawing at all. |
| 1038 | |
| 1039 | pub const |
| 1040 | if self.total == 0 |
| 1041 | return 0; |
| 1042 | |
| 1043 | let scaled = / self.total as u64; |
| 1044 | if scaled > 100 else |
| 1045 | |
| 1046 | |
| 1047 | /// Whether more is done than there was to do. |
| 1048 | /// |
| 1049 | /// The fact [`percent`](Self::percent) destroys, kept reachable so a |
| 1050 | /// renderer can mark the over-run rather than drawing a full bar and |
| 1051 | /// implying it landed exactly. |
| 1052 | |
| 1053 | pub const |
| 1054 | self.done > self.total |
| 1055 | |
| 1056 | |
| 1057 | /// Whether there is a set at all. |
| 1058 | /// |
| 1059 | /// A meter over nothing is sayable on purpose, for the same reason a field |
| 1060 | /// with no options is: it is what an app with an unloaded count actually |
| 1061 | /// has, and a renderer that shows an empty bar says so on screen rather than |
| 1062 | /// dividing by zero. |
| 1063 | |
| 1064 | pub const |
| 1065 | self.total == 0 |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | /// One figure with a caption: a number and what it counts. |
| 1070 | /// |
| 1071 | /// The dashboard shape. A large value over a small caption, several of them in a |
| 1072 | /// strip: a current streak, a completion rate, a total. Added 0.11.0, |
| 1073 | /// `93c6a174`, after goingson turned out to have five of them across five |
| 1074 | /// screens with five class vocabularies for the one shape — `task-overview-stat`, |
| 1075 | /// `stat-box`, `month-stat-item`, `contact-summary-stat`, `sync-stat`. Four put |
| 1076 | /// the value above the caption and one inverts it, which is drift inside the |
| 1077 | /// shape rather than a second shape. |
| 1078 | /// |
| 1079 | /// # Why the value is text |
| 1080 | /// |
| 1081 | /// "17", "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 1082 | /// formatted, and the formatting is the app's because only it knows whether the |
| 1083 | /// number is a percentage, a duration or a ratio. This carries none of the |
| 1084 | /// arithmetic [`Meter`] carries, and that is the difference between them: a |
| 1085 | /// meter is a proportion a renderer draws, and a figure is a fact a renderer |
| 1086 | /// sets in type. |
| 1087 | /// |
| 1088 | /// # Tone is carried, for [`Meter`]'s reason |
| 1089 | /// |
| 1090 | /// Three of the five sites tone the figure by their own means — `red`/`blue` on |
| 1091 | /// the weekly review, a `${type}` class on the monthly one, `sync-stat-warn` on |
| 1092 | /// sync. So tone is carried at every site that needs it and derived at none, and |
| 1093 | /// no renderer can work out that a streak of zero is worth colouring. |
| 1094 | /// |
| 1095 | /// # What is not here |
| 1096 | /// |
| 1097 | /// Whether the figure answers a click. One of the five is a control — sync's |
| 1098 | /// "Not Applied: 3" opens the list — and an action is not something this crate |
| 1099 | /// can name: nothing here knows what a route is. That belongs beside the figure |
| 1100 | /// in whatever layer holds the actions, the same way a row's activation sits |
| 1101 | /// beside its parts rather than inside them. |
| 1102 | /// |
| 1103 | /// The arrangement is not here either. Several figures in a strip is a set, and |
| 1104 | /// a renderer given them one at a time cannot tell it is looking at one; the |
| 1105 | /// layer that holds the tree is where the set gets said. |
| 1106 | |
| 1107 | |
| 1108 | /// The number, formatted the way the app means it to read. |
| 1109 | pub value: &'a str, |
| 1110 | /// What it counts. The caption under the value. |
| 1111 | pub caption: &'a str, |
| 1112 | /// How the value has moved, if the app is tracking that. |
| 1113 | /// |
| 1114 | /// Added 0.13.0. Text, for [`value`](Self::value)'s reason: only the app |
| 1115 | /// knows whether a move reads as `+12.5%`, `+3` or `2x`, and a renderer |
| 1116 | /// handed a number would have to guess. |
| 1117 | /// |
| 1118 | /// This is what [`tone`](Self::tone) was for and had no consumer of. The MNW |
| 1119 | /// server has four screens whose stat card is a label, a value and a delta, |
| 1120 | /// and the delta is the toned part: the figure itself is an ordinary fact |
| 1121 | /// and it is the movement that reads as good or bad. Without this the delta |
| 1122 | /// has to be folded into the caption, which loses the tone and reads as a |
| 1123 | /// longer caption rather than as a second, smaller line. |
| 1124 | pub change: , |
| 1125 | /// What the figure means right now. [`Tone::Neutral`] is an ordinary fact. |
| 1126 | /// |
| 1127 | /// Applies to [`change`](Self::change) where there is one, since that is the |
| 1128 | /// part that carries the judgement, and to the value where there is not. |
| 1129 | pub tone: Tone, |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | /// A figure that is an ordinary fact. |
| 1134 | |
| 1135 | pub const |
| 1136 | Self |
| 1137 | value, |
| 1138 | caption, |
| 1139 | change: None, |
| 1140 | tone: Neutral, |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | /// How the value has moved. |
| 1145 | |
| 1146 | pub const |
| 1147 | self.change = Some; |
| 1148 | self |
| 1149 | |
| 1150 | |
| 1151 | /// What the figure means. |
| 1152 | |
| 1153 | pub const |
| 1154 | self.tone = tone; |
| 1155 | self |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | /// A named part of a screen. |
| 1160 | /// |
| 1161 | /// The thing `makeover-geometry` deliberately does not name: it names the space |
| 1162 | /// *between* things by relationship, and nothing named the things. Six named |
| 1163 | /// members, taken from what the two webview apps actually use, plus |
| 1164 | /// [`Region::Bespoke`] for the parts no description should reach. Both apps' |
| 1165 | /// `layout.css` currently names exactly two things, `.raised` and `.well`, so |
| 1166 | /// this layer is absent rather than divergent, which makes it the cheapest of |
| 1167 | /// the schemas to add and the easiest to over-build. |
| 1168 | |
| 1169 | |
| 1170 | /// A full-width strip with a title slot and an actions cluster, either of |
| 1171 | /// which may be empty. goingson's `.page-header`, Balanced Breakfast's |
| 1172 | /// `.header` and `.detail-header` are all this, differing only in which |
| 1173 | /// slots they fill. |
| 1174 | Band, |
| 1175 | /// A persistent column beside the content, holding navigation. |
| 1176 | Sidebar, |
| 1177 | /// A region of content with its own scroll. |
| 1178 | Pane, |
| 1179 | /// Two panes side by side, where the left chooses what the right shows. |
| 1180 | Split, |
| 1181 | /// A set of panes, one visible at a time, with a [`Selector::Tabs`] above. |
| 1182 | TabGroup, |
| 1183 | /// Content over a scrim, taking input until dismissed. |
| 1184 | Modal, |
| 1185 | /// A region this crate names the *place* of and nothing else. The app owns |
| 1186 | /// what goes in it. |
| 1187 | /// |
| 1188 | /// The escape hatch, and the thing that keeps the description honest about |
| 1189 | /// its own limits. A day-plan timeline, a kanban board, a calendar and the |
| 1190 | /// paint interaction over the timeline are not describable here and are not |
| 1191 | /// going to become describable: a description expressive enough to produce |
| 1192 | /// a timeline is a widget library wearing a description's name. |
| 1193 | /// |
| 1194 | /// But a screen containing one still has to be a screen. Without this |
| 1195 | /// member the description covers only the boring screens, and the four that |
| 1196 | /// make goingson worth using would need a second, undescribed path beside |
| 1197 | /// the router. Two paths is how the vocabulary starts drifting from the app |
| 1198 | /// again, which is the exact failure this crate exists to end. |
| 1199 | /// |
| 1200 | /// So the description says "a thing called `day-plan` goes here" and stops. |
| 1201 | /// The name is opaque: this crate never interprets it, and no renderer is |
| 1202 | /// expected to know what it means beyond handing the space over. |
| 1203 | Bespoke |
| 1204 | /// What the app calls it. Never interpreted here. |
| 1205 | name: &'a str, |
| 1206 | , |
| 1207 | |
| 1208 | |
| 1209 | |
| 1210 | /// How the region sits on what is behind it. |
| 1211 | |
| 1212 | pub const |
| 1213 | match self |
| 1214 | SelfBand | SelfSidebar | SelfSplit | SelfTabGroup => Flat, |
| 1215 | // A pane is looked into, the same as a table body or a tag tree. |
| 1216 | SelfPane => Well, |
| 1217 | SelfModal => Raised, |
| 1218 | // Flat because it inherits: a bespoke region takes the depth of |
| 1219 | // whatever frames it. An app that wants its timeline in a well puts |
| 1220 | // it in a `Pane`, which composes rather than adding a knob here. |
| 1221 | SelfBespoke => Flat, |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | /// Whether this crate can say anything about the region's contents. |
| 1226 | /// |
| 1227 | /// A renderer walks the description and hands every region it understands |
| 1228 | /// to the right drawing code. This is how it tells the two apart, and the |
| 1229 | /// reason it is a method rather than a `matches!` at each renderer: there |
| 1230 | /// is exactly one opaque member and there should stay exactly one. |
| 1231 | |
| 1232 | pub const |
| 1233 | !matches! |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | /// How a screen is laid out. |
| 1238 | /// |
| 1239 | /// Two, and the second is not a variant of the first. goingson is list-detail, |
| 1240 | /// Balanced Breakfast is sidebar plus content, and neither app has a third. |
| 1241 | /// The tab group is a modifier rather than a member, because goingson uses it |
| 1242 | /// *inside* the same content region rather than instead of one. |
| 1243 | /// |
| 1244 | /// This exists at all because the router has to be able to express a screen |
| 1245 | /// rather than only a control. Discovering the arrangement layer missing after |
| 1246 | /// the renderers exist is a redesign; naming two now is a morning. |
| 1247 | |
| 1248 | |
| 1249 | /// A list that chooses what the detail beside it shows. |
| 1250 | ListDetail |
| 1251 | /// Whether the detail side is a [`Region::TabGroup`]. |
| 1252 | tabbed: bool, |
| 1253 | , |
| 1254 | /// Navigation down the side, content filling the rest. |
| 1255 | SidebarContent, |
| 1256 | |
| 1257 | |
| 1258 | /// What kind of value a form field takes. |
| 1259 | /// |
| 1260 | /// The union of the two vocabularies that diverged, which is what triggered |
| 1261 | /// this crate. They have since converged on their own: both apps now have a |
| 1262 | /// `renderFormField` emitting the same anatomy, and what is left differing is |
| 1263 | /// the kind set, the error shape, and whether the return is a string or a node. |
| 1264 | /// |
| 1265 | /// Validation is deliberately absent. Neither app has a shared story (goingson |
| 1266 | /// validates after collecting the form data, with per-field transform hooks; |
| 1267 | /// Balanced Breakfast has `required` and nothing else), and a schema that |
| 1268 | /// describes fields but not constraints acquires a constraint layer per app, |
| 1269 | /// which is exactly how the current divergence started. Naming it absent is a |
| 1270 | /// decision; leaving it unmentioned would not be. |
| 1271 | /// `#[non_exhaustive]` for the reason [`Fill`] is: renderers match on this and |
| 1272 | /// the set keeps growing, so growth must not be a lockstep event. Email, Url |
| 1273 | /// and Tel arriving in 0.5.0 is the second growth in two releases. |
| 1274 | |
| 1275 | |
| 1276 | |
| 1277 | /// A single line of text. |
| 1278 | Text, |
| 1279 | /// A single line of text that must never be echoed, logged or round-tripped |
| 1280 | /// through anything that might persist it. |
| 1281 | Secret, |
| 1282 | /// A number. |
| 1283 | Number, |
| 1284 | /// An email address. |
| 1285 | /// |
| 1286 | /// Distinct from [`Text`](Self::Text) because the distinction is not |
| 1287 | /// decoration: a webview renderer emits `type="email"`, which on a touch |
| 1288 | /// device changes the keyboard that appears and turns on the platform's own |
| 1289 | /// validation. goingson ships to iOS, so collapsing this into text costs a |
| 1290 | /// keyboard with no `@` on it. |
| 1291 | /// |
| 1292 | /// Added 0.5.0, from goingson's contact form. |
| 1293 | Email, |
| 1294 | /// A URL. Same reasoning as [`Email`](Self::Email). |
| 1295 | /// |
| 1296 | /// Added 0.5.0, from goingson's contact-social and contact-feed forms. |
| 1297 | Url, |
| 1298 | /// A telephone number. Same reasoning as [`Email`](Self::Email), and the |
| 1299 | /// clearest case of it: the keyboard is a numeric pad rather than letters. |
| 1300 | /// |
| 1301 | /// Added 0.5.0, from goingson's contact-phone form. |
| 1302 | Tel, |
| 1303 | /// A calendar day, with no time of day in it. |
| 1304 | /// |
| 1305 | /// [`Email`](Self::Email)'s argument, and it carries further: a webview |
| 1306 | /// emits `type="date"`, which is a native picker, the platform's own |
| 1307 | /// validation, and on a touch device the date keyboard. Described as |
| 1308 | /// [`Text`](Self::Text) with a hint reading "YYYY-MM-DD", all three are |
| 1309 | /// lost and the hint is doing the platform's job in prose. |
| 1310 | /// |
| 1311 | /// The membership test passes on every host without stretching: a webview |
| 1312 | /// and a Tauri app emit the input, egui has a date picker, a terminal |
| 1313 | /// prompts for a day and can validate it, a CLI takes an argument. |
| 1314 | /// |
| 1315 | /// # The value is ISO 8601, `YYYY-MM-DD` |
| 1316 | /// |
| 1317 | /// Named here rather than left to each host, because a host that picks |
| 1318 | /// differently sends a server something it parses differently, and the |
| 1319 | /// failure is silent and per-host. It is `<input type="date">`'s own wire |
| 1320 | /// format, so the webview renderer owes nothing to honour it and the other |
| 1321 | /// hosts have one spelling to meet. [`DATE_FORMAT`] is the constant, and a |
| 1322 | /// test asserts this doc and that constant agree. |
| 1323 | /// |
| 1324 | /// Added 0.15.0, from the MNW server's git access-token expiry |
| 1325 | /// (`user_ssh_keys_tab.html`) and six further sites across the server and |
| 1326 | /// goingson. |
| 1327 | Date, |
| 1328 | /// A calendar day and a time of day together. |
| 1329 | /// |
| 1330 | /// Apart from [`Date`](Self::Date) because the question is different rather |
| 1331 | /// than more precise: "which day does this expire" and "at what moment does |
| 1332 | /// this publish" are asked by different screens and answered by different |
| 1333 | /// controls. A webview emits `type="datetime-local"` for one and |
| 1334 | /// `type="date"` for the other, and a host that collapsed them would ask |
| 1335 | /// half the tree for a precision it does not want. |
| 1336 | /// |
| 1337 | /// Both arrived together on measurement rather than on symmetry: 13 sites |
| 1338 | /// of each across the MNW server and goingson, and **zero** of `time`, |
| 1339 | /// `month` or `week`, which is why those are not here. A member added for a |
| 1340 | /// case nobody has is a member designed against nothing, which is |
| 1341 | /// [`File`](Self::File)'s reasoning about `accept` applied to a whole |
| 1342 | /// member. |
| 1343 | /// |
| 1344 | /// # The value is `YYYY-MM-DDTHH:MM`, local, with no zone |
| 1345 | /// |
| 1346 | /// `<input type="datetime-local">`'s own format, and the "local" is the |
| 1347 | /// load-bearing half: the value carries no offset and no `Z`, so the moment |
| 1348 | /// it names is only fixed once something supplies a zone. That is the app's |
| 1349 | /// business and not the description's. Seconds are absent, which is the |
| 1350 | /// browser's own default and is left as the rule rather than restated as a |
| 1351 | /// constraint. [`DATETIME_FORMAT`] is the constant. |
| 1352 | /// |
| 1353 | /// [`Field::min`] and [`Field::max`] already take "the host's own spelling |
| 1354 | /// of a bound", so a floor of *not in the past* needs nothing new here: it |
| 1355 | /// is a string in this same format. |
| 1356 | /// |
| 1357 | /// Added 0.15.0, from goingson's snooze picker and day planner and the MNW |
| 1358 | /// server's publish-at fields. |
| 1359 | DateTime, |
| 1360 | /// Several lines of text. |
| 1361 | Textarea, |
| 1362 | /// One of a fixed set, offered behind a control that shows one at a time. |
| 1363 | Select, |
| 1364 | /// One of a fixed set, with every option on screen at once. |
| 1365 | /// |
| 1366 | /// Not a presentation of [`Select`](Self::Select), which is the reading to |
| 1367 | /// resist: what differs is a property of the *question*. A choice that is |
| 1368 | /// consequential or irreversible has to be readable without opening |
| 1369 | /// anything, because a closed control shows one option and hides the rest, |
| 1370 | /// and the one it shows is whichever was current before the user had read |
| 1371 | /// the alternatives. audiofiles asks whether a library copies samples into |
| 1372 | /// its store or references them where they lie — which cannot be changed |
| 1373 | /// afterwards — and had already promoted that out of a checkbox by hand, |
| 1374 | /// with a comment giving this reason, before the description could say it. |
| 1375 | /// |
| 1376 | /// It was described here at 0.8.1 as "the one HTML input type this enum was |
| 1377 | /// missing", which was not true then and is not true now: `file` arrived at |
| 1378 | /// 0.11.0 and `date` and `datetime-local` at 0.15.0. Everything here is |
| 1379 | /// still an `<input type=...>`, a `<select>` or a `<textarea>`, and the way |
| 1380 | /// this enum grows is by a site being measured rather than by a list being |
| 1381 | /// completed, so "the last one" is not a claim it should make again. |
| 1382 | /// |
| 1383 | /// Added 0.8.1, from audiofiles' Add Library form. |
| 1384 | Radio, |
| 1385 | /// On or off. |
| 1386 | Checkbox, |
| 1387 | /// A file the user picks from wherever the host keeps files. |
| 1388 | /// |
| 1389 | /// Added 0.11.0, `844b5ae0`, from goingson's project-dashboard attachments |
| 1390 | /// column. It was filed as a router finding — a control whose destination is |
| 1391 | /// a host capability rather than an address — and splitting it is what made |
| 1392 | /// it two answers instead of one member satisfying neither. *Opening* a file |
| 1393 | /// is a one-way handoff and needs no new API. *Picking* one returns a value |
| 1394 | /// into a write, which is a form concern, which is this. |
| 1395 | /// |
| 1396 | /// The membership test passes on every host and not by a stretch: a Tauri |
| 1397 | /// app opens a native picker, a server renders `<input type="file">`, a |
| 1398 | /// terminal prompts for a path, a CLI takes an argument. That is closer to |
| 1399 | /// [`Email`](Self::Email), which exists because it changes the keyboard, |
| 1400 | /// than to anything bespoke. |
| 1401 | /// |
| 1402 | /// It carries no accepted-types list and no multiple flag, and that is |
| 1403 | /// measured rather than deferred: `accept` appears at zero sites in either |
| 1404 | /// app. A member added for a case nobody has is a member designed against |
| 1405 | /// nothing. |
| 1406 | File, |
| 1407 | /// Carried through the form and never shown. |
| 1408 | Hidden, |
| 1409 | |
| 1410 | |
| 1411 | /// The wire format a [`FieldKind::Date`] value takes: ISO 8601, `YYYY-MM-DD`. |
| 1412 | /// |
| 1413 | /// A constant rather than a sentence in a doc comment, because the reason to |
| 1414 | /// name the format at all is that a host picking its own would fail silently |
| 1415 | /// against a server parsing another. A host that cannot emit the native control |
| 1416 | /// still has one spelling to meet, and can say which one it meant. |
| 1417 | pub const DATE_FORMAT: &str = "%Y-%m-%d"; |
| 1418 | |
| 1419 | /// The wire format a [`FieldKind::DateTime`] value takes: `YYYY-MM-DDTHH:MM`, |
| 1420 | /// local, carrying no zone and no seconds. |
| 1421 | /// |
| 1422 | /// [`DATE_FORMAT`]'s sibling and there for its reason. The absent zone is a |
| 1423 | /// property of the value rather than an omission: the moment is not fixed until |
| 1424 | /// something outside the description supplies one. |
| 1425 | pub const DATETIME_FORMAT: &str = "%Y-%m-%dT%H:%M"; |
| 1426 | |
| 1427 | |
| 1428 | /// Whether the value the kind takes is a moment rather than a string. |
| 1429 | /// |
| 1430 | /// Named once here for the reason [`offers_options`](Self::offers_options) |
| 1431 | /// is: two kinds answer yes, and a host that has to parse or format a value |
| 1432 | /// needs to ask without spelling the pair out at each renderer. A third |
| 1433 | /// temporal kind should land here and nowhere else. |
| 1434 | /// |
| 1435 | /// The format each one takes is [`DATE_FORMAT`] and [`DATETIME_FORMAT`]. |
| 1436 | |
| 1437 | pub const |
| 1438 | matches! |
| 1439 | |
| 1440 | |
| 1441 | /// Whether the field is drawn at all. |
| 1442 | |
| 1443 | pub const |
| 1444 | !matches! |
| 1445 | |
| 1446 | |
| 1447 | /// Whether the value must be kept out of logs and diagnostics. |
| 1448 | |
| 1449 | pub const |
| 1450 | matches! |
| 1451 | |
| 1452 | |
| 1453 | /// Where the field's own label sits. |
| 1454 | /// |
| 1455 | /// A checkbox labels itself on the right of the box; everything else takes |
| 1456 | /// a label above. Both webview apps already do this and both special-case |
| 1457 | /// it inline, which is the tell that it belongs in the description. |
| 1458 | /// |
| 1459 | /// A [`Radio`](Self::Radio) is not one of them, and the near-miss is worth |
| 1460 | /// naming: its *options* each label themselves, but the field still asks a |
| 1461 | /// question above them, so the group takes a label like everything else. |
| 1462 | |
| 1463 | pub const |
| 1464 | matches! |
| 1465 | |
| 1466 | |
| 1467 | /// Whether the kind reads [`Field::options`]. |
| 1468 | /// |
| 1469 | /// Two kinds do, so the pair is named once here rather than spelled out at |
| 1470 | /// each renderer and again in [`Field::options`]' own doc, where "every |
| 1471 | /// kind but `Select`" was true for exactly one release. A third |
| 1472 | /// option-taking kind should land here and nowhere else. |
| 1473 | |
| 1474 | pub const |
| 1475 | matches! |
| 1476 | |
| 1477 | |
| 1478 | |
| 1479 | /// One option offered by a field [`FieldKind::offers_options`] accepts. |
| 1480 | /// |
| 1481 | /// Two strings, because the submitted value and the read label are different |
| 1482 | /// facts and every renderer that has tried to collapse them has had to |
| 1483 | /// un-collapse them later. `makeover-webview` invented this shape writing its |
| 1484 | /// form emitter and it is taken here unchanged; moving it down rather than |
| 1485 | /// re-deriving it is the point, since the second and third renderers were each |
| 1486 | /// going to arrive at a near-miss of it. |
| 1487 | |
| 1488 | |
| 1489 | /// What is submitted. |
| 1490 | pub value: &'a str, |
| 1491 | /// What is read. |
| 1492 | pub label: &'a str, |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | /// An option whose submitted value is also its label. |
| 1497 | |
| 1498 | pub const |
| 1499 | Self |
| 1500 | value, |
| 1501 | label: value, |
| 1502 | |
| 1503 | |
| 1504 | |
| 1505 | |
| 1506 | /// One field of a form. |
| 1507 | /// |
| 1508 | /// Borrowed rather than owned: a description is built, read once by a renderer, |
| 1509 | /// and dropped. Nothing here outlives the screen it describes. |
| 1510 | /// |
| 1511 | /// # What it carries, and what it does not |
| 1512 | /// |
| 1513 | /// Stated here so the next renderer does not re-ask, which is what the first |
| 1514 | /// two both did. It carries everything a renderer needs to *draw* the field: |
| 1515 | /// its kind, what it is called, what it is asked for, its standing help, what |
| 1516 | /// is wrong with it now, whether it is compulsory, whether it hides behind a |
| 1517 | /// disclosure, its ghost text, and the options it offers. |
| 1518 | /// |
| 1519 | /// It does not carry the **current value**, and it is not going to. That is the |
| 1520 | /// one thing here that is genuinely renderer state: a webview reads it back out |
| 1521 | /// of the DOM, an immediate-mode renderer holds a `&mut` to the app's own field |
| 1522 | /// and writes through it, and a terminal keeps an edit buffer. A description |
| 1523 | /// that carried the value would have to carry a way to write it back, at which |
| 1524 | /// point it is a form model and no longer a description. |
| 1525 | /// |
| 1526 | /// **Constraints** are here and enforcement is not, which is one line rather |
| 1527 | /// than two. [`required`], [`max_length`], [`min`] and [`max`] are facts about |
| 1528 | /// the *question*, so a renderer can emit its host's idiom for each — an HTML |
| 1529 | /// attribute, a marked label, a clamped spinner — and the platform helps the |
| 1530 | /// user before anything is submitted. Deciding that a value is wrong stays with |
| 1531 | /// whoever validated, and [`error`] is that decision arriving back. |
| 1532 | /// |
| 1533 | /// The set stops before `pattern`, and stops there on both tests at once. A |
| 1534 | /// regex has an honest answer in a webview and none anywhere else: egui would |
| 1535 | /// have to run it per keystroke and decide what a half-typed value means, which |
| 1536 | /// is enforcement wearing description's clothes. And it is one site in goingson |
| 1537 | /// and none in Balanced Breakfast, against 8 and 1 for `maxlength`. Measured |
| 1538 | /// 2026-08-09, `2cbad3e2`. |
| 1539 | /// |
| 1540 | /// [`error`]: Field::error |
| 1541 | /// [`required`]: Field::required |
| 1542 | /// [`max_length`]: Field::max_length |
| 1543 | /// [`min`]: Field::min |
| 1544 | /// [`max`]: Field::max |
| 1545 | |
| 1546 | |
| 1547 | /// What kind of value it takes. |
| 1548 | pub kind: FieldKind, |
| 1549 | /// The name the value is submitted under. |
| 1550 | pub name: &'a str, |
| 1551 | /// What the user is asked for. |
| 1552 | pub label: &'a str, |
| 1553 | /// Standing help, shown whether or not anything is wrong. |
| 1554 | pub hint: , |
| 1555 | /// What is currently wrong with the value. |
| 1556 | pub error: , |
| 1557 | /// Ghost text shown while the field is empty. |
| 1558 | /// |
| 1559 | /// User-facing text, and it sits with `label` and `hint` rather than with |
| 1560 | /// the value because it is a property of the *question* and not of the |
| 1561 | /// answer. It lived renderer-side in `makeover-webview` until 0.8.0 for one |
| 1562 | /// reason and it was not a reading on where it belonged: adding a field to |
| 1563 | /// a published struct is a breaking change. |
| 1564 | /// |
| 1565 | /// Not a substitute for a label. A field labelled only by its placeholder |
| 1566 | /// loses its label the moment anything is typed, and no renderer here can |
| 1567 | /// make that not happen, so the description keeps both. |
| 1568 | pub placeholder: , |
| 1569 | /// The options offered, in the order they are offered. |
| 1570 | /// |
| 1571 | /// Empty for every kind [`FieldKind::offers_options`] rejects. A field |
| 1572 | /// described with no options is sayable on purpose: it is what an app with |
| 1573 | /// an unfinished-loading option list actually has, and a renderer showing |
| 1574 | /// an empty control says so on screen rather than in a log. |
| 1575 | /// |
| 1576 | /// Which option is *current* is not here. That is the value, and the value |
| 1577 | /// is renderer state. |
| 1578 | pub options: &'a [], |
| 1579 | /// Whether the form refuses to submit without it. |
| 1580 | pub required: bool, |
| 1581 | /// The longest the value may be, in characters. |
| 1582 | /// |
| 1583 | /// Added 0.11.0 with [`min`](Self::min) and [`max`](Self::max), joining |
| 1584 | /// [`required`](Self::required), which had been the only constraint here |
| 1585 | /// since before the crate wrote down that it carried none. |
| 1586 | pub max_length: , |
| 1587 | /// The lowest value accepted, as the host would write it. |
| 1588 | /// |
| 1589 | /// Text rather than a number, because the bound is only a number for some |
| 1590 | /// of the kinds that take one. goingson's own sites are `min="1"` on a |
| 1591 | /// duration and `min="2026-08-09T14:30"` on a datetime, and a numeric member |
| 1592 | /// could say the first and not the second. The [`kind`](Self::kind) already |
| 1593 | /// says how to read it, the same way it does for the value. |
| 1594 | pub min: , |
| 1595 | /// The highest value accepted, as the host would write it. See |
| 1596 | /// [`min`](Self::min). |
| 1597 | pub max: , |
| 1598 | /// Whether the field lives behind a "more options" disclosure. |
| 1599 | pub extended: bool, |
| 1600 | |
| 1601 | |
| 1602 | |
| 1603 | /// A plain required-nothing field of the given kind. |
| 1604 | |
| 1605 | pub const |
| 1606 | Self |
| 1607 | kind, |
| 1608 | name, |
| 1609 | label, |
| 1610 | hint: None, |
| 1611 | error: None, |
| 1612 | placeholder: None, |
| 1613 | options: &, |
| 1614 | required: false, |
| 1615 | max_length: None, |
| 1616 | min: None, |
| 1617 | max: None, |
| 1618 | extended: false, |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | /// A select offering the given options. |
| 1623 | /// |
| 1624 | /// One of the two kinds under-described by [`Field::new`], so it gets a |
| 1625 | /// constructor rather than leaving every call site to remember that a |
| 1626 | /// select with an empty `options` renders as an empty select. |
| 1627 | |
| 1628 | pub const |
| 1629 | Selfoffering |
| 1630 | |
| 1631 | |
| 1632 | /// A radio group offering the given options. |
| 1633 | /// |
| 1634 | /// The other. Same hazard as [`select`](Self::select) and a worse one: a |
| 1635 | /// radio group with no options draws nothing at all, so a call site that |
| 1636 | /// forgot them has an empty rectangle rather than a visibly empty control. |
| 1637 | |
| 1638 | pub const |
| 1639 | Selfoffering |
| 1640 | |
| 1641 | |
| 1642 | /// The shared body of the two constructors that take options. |
| 1643 | /// |
| 1644 | /// Private, and keyed on the kind rather than exposed, because the two |
| 1645 | /// public names are the point: a call site says which question it is |
| 1646 | /// asking, not which flag it is setting. |
| 1647 | const |
| 1648 | kind: FieldKind, |
| 1649 | name: &'a str, |
| 1650 | label: &'a str, |
| 1651 | options: &'a [], |
| 1652 | |
| 1653 | Self |
| 1654 | options, |
| 1655 | ..Selfnew |
| 1656 | |
| 1657 | |
| 1658 | |
| 1659 | /// Whether the field is currently reporting a problem. |
| 1660 | /// |
| 1661 | /// Read this rather than testing `error.is_some()` at each renderer: the |
| 1662 | /// error state has to mark the field's whole group and not only the |
| 1663 | /// message, because a renderer with no descendant selectors (egui, a |
| 1664 | /// terminal) cannot find the group from the message. goingson already marks |
| 1665 | /// the group and Balanced Breakfast does not, so goingson's shape is the |
| 1666 | /// one taken here. |
| 1667 | |
| 1668 | pub const |
| 1669 | self.error.is_some |
| 1670 | |
| 1671 | |
| 1672 | |
| 1673 | /// How much room a column asks for. |
| 1674 | /// |
| 1675 | /// An intent, so the actual floor stays with `makeover-geometry`. goingson's |
| 1676 | /// task table spells these as `minmax(200px, 1fr)`, `140px` and content-sized; |
| 1677 | /// only the first three words of that survive deferral. |
| 1678 | /// `#[non_exhaustive]`, for the reason [`Fill`] and [`FieldKind`] are: a |
| 1679 | /// renderer matches on this and a vocabulary that grows must not break every |
| 1680 | /// renderer when it does. |
| 1681 | |
| 1682 | |
| 1683 | |
| 1684 | /// Takes what it needs and no more. |
| 1685 | Content, |
| 1686 | /// A fixed share, the same at every width. |
| 1687 | Fixed, |
| 1688 | /// Absorbs whatever is left over. |
| 1689 | Fill, |
| 1690 | |
| 1691 | |
| 1692 | /// What a column is worth when there is not room for all of them. |
| 1693 | /// |
| 1694 | /// Ordered: [`Priority::Optional`] drops first, [`Priority::Essential`] never |
| 1695 | /// drops. This replaces addressing columns by position, which is what both |
| 1696 | /// webview apps do today and is a live bug rather than only verbosity. goingson |
| 1697 | /// hides mobile columns with `nth-child(n+5)` against a seven-column table, so |
| 1698 | /// inserting a column silently hides the wrong one. |
| 1699 | /// `#[non_exhaustive]`, same reasoning as [`Width`]. Note the ordering is the |
| 1700 | /// whole point of the type, so a new tier has to be declared in its place in |
| 1701 | /// the sequence rather than appended. |
| 1702 | |
| 1703 | |
| 1704 | |
| 1705 | /// Dropped first. |
| 1706 | Optional, |
| 1707 | /// Dropped once the optional columns are gone. |
| 1708 | Secondary, |
| 1709 | /// Never dropped. Without it the row does not identify itself. |
| 1710 | Essential, |
| 1711 | |
| 1712 | |
| 1713 | /// One column of a table. |
| 1714 | /// |
| 1715 | /// Described once. The grid track, the cell order and the drop behaviour are |
| 1716 | /// all derived from this, rather than being three hand-written encodings that |
| 1717 | /// must agree and are never checked against each other. |
| 1718 | |
| 1719 | |
| 1720 | /// The heading, and the name the cell is addressed by. |
| 1721 | pub name: &'a str, |
| 1722 | /// How much room it asks for. |
| 1723 | pub width: Width, |
| 1724 | /// What it is worth when room runs out. |
| 1725 | pub priority: Priority, |
| 1726 | /// Whether the user can reorder the table by this column. |
| 1727 | /// |
| 1728 | /// `ce620871`. What reordering *calls* is not here — that is an address, and |
| 1729 | /// this crate names none — so a host pairs this with the route the way it |
| 1730 | /// pairs a row's parts with the row's activation. This says the affordance |
| 1731 | /// exists, which is what a renderer needs to draw a header a user can press |
| 1732 | /// rather than a heading they cannot. |
| 1733 | pub sortable: bool, |
| 1734 | /// Which way the table is ordered by this column, if it is. |
| 1735 | /// |
| 1736 | /// `None` on every column but the one in force. A renderer draws the caret |
| 1737 | /// from this and a webview sets `aria-sort`, which is why it is per column |
| 1738 | /// rather than a single fact on the table: the host idiom is a property of |
| 1739 | /// the header cell. |
| 1740 | /// |
| 1741 | /// Independent of [`sortable`](Self::sortable) rather than implied by it, |
| 1742 | /// because both combinations mean something. A column sorted and not |
| 1743 | /// sortable is a list ordered by a key the user cannot change, which is a |
| 1744 | /// real thing to describe and a caret worth drawing. |
| 1745 | pub sorted: , |
| 1746 | |
| 1747 | |
| 1748 | /// Which way a column is ordered. |
| 1749 | /// |
| 1750 | /// Two, because there is no third. "Unsorted" is [`Column::sorted`] being |
| 1751 | /// `None`, and folding it in here would be the same absence said twice. |
| 1752 | |
| 1753 | |
| 1754 | /// Smallest, earliest or first alphabetically at the top. |
| 1755 | Ascending, |
| 1756 | /// The other way. |
| 1757 | Descending, |
| 1758 | |
| 1759 | |
| 1760 | |
| 1761 | /// The other direction, for a header that flips when pressed. |
| 1762 | |
| 1763 | pub const |
| 1764 | match self |
| 1765 | SelfAscending => SelfDescending, |
| 1766 | SelfDescending => SelfAscending, |
| 1767 | |
| 1768 | |
| 1769 | |
| 1770 | /// What a webview writes into `aria-sort`. |
| 1771 | /// |
| 1772 | /// Named here rather than in the webview renderer because a terminal and an |
| 1773 | /// immediate-mode painter both want the same two words for a caret's label, |
| 1774 | /// and three renderers picking their own is the drift this crate ends. |
| 1775 | |
| 1776 | pub const |
| 1777 | match self |
| 1778 | SelfAscending => "ascending", |
| 1779 | SelfDescending => "descending", |
| 1780 | |
| 1781 | |
| 1782 | |
| 1783 | |
| 1784 | |
| 1785 | /// A column that absorbs slack and drops after the optional ones. |
| 1786 | |
| 1787 | pub const |
| 1788 | Self |
| 1789 | name, |
| 1790 | width: Fill, |
| 1791 | priority: Secondary, |
| 1792 | sortable: false, |
| 1793 | sorted: None, |
| 1794 | |
| 1795 | |
| 1796 | |
| 1797 | /// Whether this column survives at the given cutoff. |
| 1798 | /// |
| 1799 | /// A renderer narrows by raising the cutoff, and never by counting |
| 1800 | /// positions. |
| 1801 | |
| 1802 | pub const |
| 1803 | >= |
| 1804 | |
| 1805 | |
| 1806 | |
| 1807 | /// What a table cell holds. |
| 1808 | /// |
| 1809 | /// [`RowPart`] for tables, and it exists for the same reason: a part that |
| 1810 | /// carries a control is not text, and a renderer with one class for the whole |
| 1811 | /// cell paints it as though it were. `makeover-webview` emitted a single |
| 1812 | /// `.cell` until 0.25.0, so a button in a cell inherited the cell's content |
| 1813 | /// colour, which is the exact drift [`RowPart::intent`] prevents for rows and |
| 1814 | /// prevented for nothing here. |
| 1815 | /// |
| 1816 | /// Four members, and the count is what quasi's `Cell` was measured to carry: |
| 1817 | /// a value, tokens (33 cells across 22 server templates), actions (30 rows |
| 1818 | /// carrying a control, 5 beside a value) and a link (35 cells across 18 |
| 1819 | /// templates). Nothing was added past what something holds. |
| 1820 | /// |
| 1821 | /// `#[non_exhaustive]` for [`RowPart`]'s reason: growth here must not be a |
| 1822 | /// lockstep event across three renderers. |
| 1823 | /// |
| 1824 | /// # No hover-reveal |
| 1825 | /// |
| 1826 | /// [`RowPart`] carried a `revealed_on_hover` until 0.13.0 retired it, and this |
| 1827 | /// enum never gets one. A cell's actions are shown at rest in every consumer |
| 1828 | /// measured, and a member nothing uses is one three renderers owe an answer |
| 1829 | /// for. |
| 1830 | |
| 1831 | |
| 1832 | |
| 1833 | /// The cell's own text. |
| 1834 | Value, |
| 1835 | /// Small labelled things in the cell: a status badge, a chip. |
| 1836 | Tokens, |
| 1837 | /// Controls that act on what the row is about. |
| 1838 | Actions, |
| 1839 | /// The cell's value, where the value is itself a link. |
| 1840 | Link, |
| 1841 | |
| 1842 | |
| 1843 | |
| 1844 | /// The content intent the part takes. |
| 1845 | /// |
| 1846 | /// One part is text and three are not, so three answer with the intent |
| 1847 | /// inheriting already gives. That is [`RowPart::intent`]'s shape with the |
| 1848 | /// text side narrower: a cell's secondary and muted readings are the |
| 1849 | /// column's business, not the cell's. |
| 1850 | |
| 1851 | pub const |
| 1852 | match self |
| 1853 | SelfValue => "content", |
| 1854 | // A token carries its own tone, and a part-level intent underneath |
| 1855 | // it would fight the token sitting on it. |
| 1856 | SelfTokens => "content", |
| 1857 | // Actions carry controls rather than text. |
| 1858 | SelfActions => "content", |
| 1859 | // A link takes the action colour from the control it is, rather |
| 1860 | // than the cell's text colour from the cell it sits in. |
| 1861 | SelfLink => "content", |
| 1862 | |
| 1863 | |
| 1864 | |
| 1865 | |
| 1866 | |
| 1867 | |
| 1868 | use *; |
| 1869 | |
| 1870 | |
| 1871 | |
| 1872 | // Mutually exclusive is the test for one enum against several fields: a |
| 1873 | // region shows its content, or that it is coming, or that there is none, |
| 1874 | // or that it broke. Never two. |
| 1875 | assert!; |
| 1876 | for state in |
| 1877 | assert!; |
| 1878 | |
| 1879 | |
| 1880 | |
| 1881 | |
| 1882 | |
| 1883 | // An empty list is the normal state of a new install. Drawing it in a |
| 1884 | // danger tone reports a fault where there is none, and this is the one |
| 1885 | // place the distinction is carried. |
| 1886 | assert_eq!; |
| 1887 | assert_eq!; |
| 1888 | assert_eq!; |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | |
| 1893 | // Both combinations mean something, which is why the two fields are |
| 1894 | // independent rather than one implying the other. A list ordered by a |
| 1895 | // key the user cannot change is a real thing with a caret worth drawing. |
| 1896 | let fixed = Column |
| 1897 | sorted: Some, |
| 1898 | ..new |
| 1899 | ; |
| 1900 | |
| 1901 | assert!; |
| 1902 | assert_eq!; |
| 1903 | |
| 1904 | let offered = Column |
| 1905 | sortable: true, |
| 1906 | ..new |
| 1907 | ; |
| 1908 | assert_eq!; |
| 1909 | |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | assert_eq!; |
| 1914 | assert_eq!; |
| 1915 | assert_eq!; |
| 1916 | |
| 1917 | |
| 1918 | |
| 1919 | |
| 1920 | // Three of goingson's five sites tone the figure by their own means, so |
| 1921 | // tone is carried at every site that needs it and derived at none. The |
| 1922 | // same reasoning `Meter` reached, from a different direction. |
| 1923 | let streak = new.tone; |
| 1924 | assert_eq!; |
| 1925 | assert_eq!; |
| 1926 | |
| 1927 | |
| 1928 | |
| 1929 | |
| 1930 | // 0.13.0. The MNW server's stat card is a label, a value and a delta, |
| 1931 | // across four screens, and the delta is what reads as good or bad. Tone |
| 1932 | // had no consumer before this: the figure itself is an ordinary fact. |
| 1933 | let views = new |
| 1934 | .change |
| 1935 | .tone; |
| 1936 | assert_eq!; |
| 1937 | assert_eq!; |
| 1938 | |
| 1939 | // A figure with nothing to compare against says so by having no change, |
| 1940 | // rather than by carrying an empty string a renderer has to test for. |
| 1941 | assert_eq!; |
| 1942 | |
| 1943 | |
| 1944 | |
| 1945 | |
| 1946 | // "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 1947 | // formatted, and that is the line between this and `Meter`: a meter is |
| 1948 | // a proportion a renderer draws, a figure is a fact it sets in type. |
| 1949 | for value in |
| 1950 | assert_eq!; |
| 1951 | |
| 1952 | |
| 1953 | |
| 1954 | |
| 1955 | |
| 1956 | // The meter carries the tone, so a part-level intent underneath would |
| 1957 | // fight it. Same answer `Tokens` needed, for the same reason. |
| 1958 | assert_eq!; |
| 1959 | |
| 1960 | |
| 1961 | |
| 1962 | |
| 1963 | // It is a control the user operates, unlike `Hidden`, and it does not |
| 1964 | // pick from a list the description carries, unlike `Select`. |
| 1965 | assert!; |
| 1966 | assert!; |
| 1967 | assert!; |
| 1968 | |
| 1969 | |
| 1970 | |
| 1971 | |
| 1972 | // The whole model: the description carries the rule, the renderer emits |
| 1973 | // its host's idiom, and `error` is what arrives back when someone |
| 1974 | // validated. Nothing here decides a value is wrong. |
| 1975 | let field = Field |
| 1976 | max_length: Some, |
| 1977 | min: Some, |
| 1978 | max: Some, |
| 1979 | required: true, |
| 1980 | ..new |
| 1981 | ; |
| 1982 | assert!; |
| 1983 | |
| 1984 | // A bound is text because it is only a number for some of the kinds |
| 1985 | // that take one. goingson has both shapes live. |
| 1986 | let when = Field |
| 1987 | min: Some, |
| 1988 | ..new |
| 1989 | ; |
| 1990 | assert_eq!; |
| 1991 | |
| 1992 | |
| 1993 | |
| 1994 | |
| 1995 | // The whole reason this is a pair. goingson's `Task::time_progress` |
| 1996 | // clamps to 100 and then carries `is_over_estimate` beside it to say |
| 1997 | // what the clamp dropped; a meter says both from one fact. |
| 1998 | let over = new; |
| 1999 | assert_eq!; |
| 2000 | assert!; |
| 2001 | |
| 2002 | let exact = new; |
| 2003 | assert_eq!; |
| 2004 | assert!; |
| 2005 | |
| 2006 | |
| 2007 | |
| 2008 | |
| 2009 | // Sayable on purpose, so it has to be answerable. A meter over an |
| 2010 | // unloaded count is what an app actually has for a frame. |
| 2011 | let none = new; |
| 2012 | assert_eq!; |
| 2013 | assert!; |
| 2014 | assert!; |
| 2015 | |
| 2016 | |
| 2017 | |
| 2018 | |
| 2019 | // Given 43 nothing can recover "3 of 7", which is why the numbers are |
| 2020 | // carried and the label names only the noun. |
| 2021 | let m = new.label; |
| 2022 | assert_eq!; |
| 2023 | assert_eq!; |
| 2024 | assert_eq!; |
| 2025 | |
| 2026 | |
| 2027 | |
| 2028 | |
| 2029 | // The same fullness means opposite things on two of goingson's bars, |
| 2030 | // and only the app knows which. |
| 2031 | let subtasks = new.tone; |
| 2032 | let estimate = new.tone; |
| 2033 | assert_eq!; |
| 2034 | assert_ne!; |
| 2035 | // Untoned by default: a bar says nothing about status until something |
| 2036 | // says so, the same way a row is not selectable until told. |
| 2037 | assert_eq!; |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | |
| 2042 | // done * 100 in u32 would wrap somewhere past 42 million. Counts that |
| 2043 | // size are not tasks, but a description layer that silently reports 3% |
| 2044 | // for a full bar is worse than one that is slow. |
| 2045 | let big = new; |
| 2046 | assert_eq!; |
| 2047 | assert!; |
| 2048 | |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | let = Raised.edges; |
| 2053 | let = Inset.edges; |
| 2054 | assert_eq!; |
| 2055 | assert_eq!; |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 | for b in |
| 2061 | assert_eq!; |
| 2062 | |
| 2063 | |
| 2064 | |
| 2065 | |
| 2066 | |
| 2067 | // The bug this vocabulary exists to make unrepresentable. |
| 2068 | assert_eq!; |
| 2069 | assert_eq!; |
| 2070 | assert_eq!; |
| 2071 | assert_ne!; |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | // The reason State is its own axis and not a Depth member: a disabled |
| 2077 | // button and a disabled field are both disabled and are not the same |
| 2078 | // shape, which one shared variant could not have said. |
| 2079 | assert_eq!; |
| 2080 | assert_eq!; |
| 2081 | assert!; |
| 2082 | |
| 2083 | |
| 2084 | |
| 2085 | |
| 2086 | // Focus is a thing you can still click. Getting this backwards is how |
| 2087 | // a focus ring ends up on something inert. |
| 2088 | assert!; |
| 2089 | assert!; |
| 2090 | |
| 2091 | |
| 2092 | |
| 2093 | |
| 2094 | // Neither needs a new token, so this costs no `makeover` release. |
| 2095 | assert_eq!; |
| 2096 | assert_eq!; |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 | |
| 2101 | assert_eq!; |
| 2102 | assert_eq!; |
| 2103 | |
| 2104 | |
| 2105 | |
| 2106 | |
| 2107 | // The one member carrying a fill without a bevel. A renderer that |
| 2108 | // assumes the two arrive together drops the fill silently, which is |
| 2109 | // exactly what makeover-webview did before 0.3.0. |
| 2110 | assert_eq!; |
| 2111 | assert_eq!; |
| 2112 | |
| 2113 | |
| 2114 | |
| 2115 | |
| 2116 | // Both edgeless, and only one of them needs a colour. Collapsing them |
| 2117 | // is what left an unchosen tab unsayable. |
| 2118 | assert_eq!; |
| 2119 | assert_ne!; |
| 2120 | |
| 2121 | |
| 2122 | |
| 2123 | |
| 2124 | // Authored in opposite directions: makeover derives surface-well by |
| 2125 | // inverting against the theme's content colour, while surface-sunken is |
| 2126 | // authored and may sit darker than raised. |
| 2127 | assert_ne!; |
| 2128 | assert_eq!; |
| 2129 | assert_eq!; |
| 2130 | |
| 2131 | |
| 2132 | |
| 2133 | |
| 2134 | // The gap 0.3.0 closed. Before it, only `chosen` existed and the |
| 2135 | // unchosen option fell through to Flat at every renderer. |
| 2136 | for s in |
| 2137 | assert_ne! |
| 2138 | s.chosen, |
| 2139 | s.unchosen, |
| 2140 | "{s:?} cannot tell picked from unpicked" |
| 2141 | ; |
| 2142 | |
| 2143 | |
| 2144 | |
| 2145 | |
| 2146 | |
| 2147 | // Tabs recede so the chosen one comes forward; a segment and a toggle |
| 2148 | // stand up so the chosen one is held in. That inversion is the whole |
| 2149 | // content of "picked" once colour is deferred, and it is why the three |
| 2150 | // are not one member with a flag. |
| 2151 | assert_eq!; |
| 2152 | assert_eq!; |
| 2153 | |
| 2154 | for s in |
| 2155 | assert_eq!; |
| 2156 | assert_eq!; |
| 2157 | // Held in is what pressing produces: one appearance, two reasons. |
| 2158 | assert_eq!; |
| 2159 | |
| 2160 | |
| 2161 | |
| 2162 | |
| 2163 | |
| 2164 | assert_eq!; |
| 2165 | assert_eq! |
| 2166 | Raised.pressed.bevel, |
| 2167 | Raised.bevel.map |
| 2168 | ; |
| 2169 | // Only raised regions respond to being pressed. |
| 2170 | assert_eq!; |
| 2171 | assert_eq!; |
| 2172 | // An overlay is a surface, not a control. |
| 2173 | assert_eq!; |
| 2174 | |
| 2175 | |
| 2176 | |
| 2177 | |
| 2178 | // The wave-2 rule: a surface over the page takes elevation, a surface |
| 2179 | // in the page takes a bevel. Both halves come off the one Depth, so |
| 2180 | // they cannot disagree. |
| 2181 | assert_eq!; |
| 2182 | assert_eq!; |
| 2183 | |
| 2184 | // Three depths have no bevel and they are not the same claim. Flat has |
| 2185 | // nothing to separate from, Sunken's colour is doing the separating, |
| 2186 | // and an overlay is separated by the lift. |
| 2187 | assert_ne!; |
| 2188 | assert_ne!; |
| 2189 | |
| 2190 | |
| 2191 | |
| 2192 | |
| 2193 | assert_eq!; |
| 2194 | assert_eq!; |
| 2195 | assert_eq!; |
| 2196 | assert_eq!; |
| 2197 | // No value ever leaves this crate. |
| 2198 | for t in |
| 2199 | Light.token, |
| 2200 | Dark.token, |
| 2201 | Danger.token, |
| 2202 | Neutral.token, |
| 2203 | Focus.token, |
| 2204 | Disabled.token, |
| 2205 | ] |
| 2206 | assert!; |
| 2207 | assert! |
| 2208 | !t.chars.next.unwrap.is_ascii_digit, |
| 2209 | "{t} is a value" |
| 2210 | ; |
| 2211 | |
| 2212 | |
| 2213 | |
| 2214 | |
| 2215 | |
| 2216 | // The one line that runs through all three apps' taxonomies. |
| 2217 | assert!; |
| 2218 | assert!; |
| 2219 | assert!; |
| 2220 | |
| 2221 | // A badge is a label, so giving it an edge would lie about it. |
| 2222 | assert_eq!; |
| 2223 | assert_eq!; |
| 2224 | |
| 2225 | // A latched chip wears the same shape a pressed one does. |
| 2226 | let chip = Chip ; |
| 2227 | assert_eq!; |
| 2228 | assert_eq!; |
| 2229 | |
| 2230 | |
| 2231 | |
| 2232 | |
| 2233 | assert!; |
| 2234 | assert!; |
| 2235 | // A toast floats above the page; a banner rests in the flow. |
| 2236 | assert_eq!; |
| 2237 | assert_eq!; |
| 2238 | |
| 2239 | |
| 2240 | |
| 2241 | |
| 2242 | // `revealed_on_hover` was asserted here until 0.13.0 retired it. It said |
| 2243 | // a row's actions stay hidden until hover, which stopped being true when |
| 2244 | // makeover-webview 0.23.0 showed them at rest, and nothing had consumed |
| 2245 | // it for a release either way. |
| 2246 | assert_eq!; |
| 2247 | assert_eq!; |
| 2248 | assert_eq!; |
| 2249 | |
| 2250 | |
| 2251 | |
| 2252 | |
| 2253 | // Each token carries its own tone, so a part-level intent underneath |
| 2254 | // would fight the thing sitting on it. Same reasoning as actions, which |
| 2255 | // is why they answer alike. |
| 2256 | assert_eq!; |
| 2257 | assert_eq!; |
| 2258 | |
| 2259 | |
| 2260 | |
| 2261 | |
| 2262 | // The pair is named once so a host with parsing to do asks here rather |
| 2263 | // than spelling it out, which is `offers_options`' reason. |
| 2264 | assert!; |
| 2265 | assert!; |
| 2266 | |
| 2267 | for kind in |
| 2268 | Text, |
| 2269 | Secret, |
| 2270 | Number, |
| 2271 | Email, |
| 2272 | Url, |
| 2273 | Tel, |
| 2274 | Textarea, |
| 2275 | Select, |
| 2276 | Radio, |
| 2277 | Checkbox, |
| 2278 | File, |
| 2279 | Hidden, |
| 2280 | ] |
| 2281 | assert!; |
| 2282 | |
| 2283 | |
| 2284 | |
| 2285 | |
| 2286 | |
| 2287 | // The formats are the whole reason the members are worth naming apart |
| 2288 | // from text, so the doc comments and the constants have to agree. A |
| 2289 | // host reading one and meeting the other is the silent failure. |
| 2290 | assert_eq!; |
| 2291 | assert!; |
| 2292 | |
| 2293 | assert_eq!; |
| 2294 | assert! |
| 2295 | DATETIME_FORMAT.starts_with, |
| 2296 | "a moment starts with the day it is on" |
| 2297 | ; |
| 2298 | // Local, and that is a property of the value rather than an omission. |
| 2299 | assert!; |
| 2300 | assert!; |
| 2301 | assert!; |
| 2302 | |
| 2303 | |
| 2304 | |
| 2305 | |
| 2306 | // Neither is a checkbox and neither is a fixed set, so both fall where |
| 2307 | // text does. Asserted because a new kind lands in three predicates and |
| 2308 | // only one of them is the interesting one. |
| 2309 | for kind in |
| 2310 | assert!; |
| 2311 | assert!; |
| 2312 | assert!; |
| 2313 | assert!; |
| 2314 | |
| 2315 | |
| 2316 | |
| 2317 | |
| 2318 | |
| 2319 | // The table half of what RowPart::intent does for rows. A cell holding |
| 2320 | // a control and a cell holding text answered alike until 0.14.0, and a |
| 2321 | // control in a cell took the cell's text colour. |
| 2322 | assert_eq!; |
| 2323 | |
| 2324 | for part in |
| 2325 | // Each for its own reason -- a token carries its tone, an action is |
| 2326 | // a control, a link takes the action colour -- and all three reach |
| 2327 | // the intent inheriting already gives. |
| 2328 | assert_eq!; |
| 2329 | |
| 2330 | |
| 2331 | |
| 2332 | |
| 2333 | |
| 2334 | for part in |
| 2335 | Value, |
| 2336 | Tokens, |
| 2337 | Actions, |
| 2338 | Link, |
| 2339 | ] |
| 2340 | let intent = part.intent; |
| 2341 | assert!; |
| 2342 | assert!; |
| 2343 | |
| 2344 | |
| 2345 | |
| 2346 | |
| 2347 | |
| 2348 | assert!; |
| 2349 | assert!; |
| 2350 | assert!; |
| 2351 | |
| 2352 | |
| 2353 | |
| 2354 | |
| 2355 | assert_eq!; |
| 2356 | assert_eq!; |
| 2357 | // The exception, and the whole folder semantic: the open tab joins its |
| 2358 | // pane rather than sinking away from it. |
| 2359 | assert_eq!; |
| 2360 | |
| 2361 | // A held-in segment is indistinguishable from a pressed raised one, |
| 2362 | // which is the economy the light model buys over a colour swap. |
| 2363 | assert_eq!; |
| 2364 | |
| 2365 | // A toggle stands alone; the other two are built out of parts that |
| 2366 | // touch. |
| 2367 | assert!; |
| 2368 | assert!; |
| 2369 | assert!; |
| 2370 | |
| 2371 | |
| 2372 | |
| 2373 | |
| 2374 | assert_eq!; |
| 2375 | assert_eq!; |
| 2376 | for r in |
| 2377 | Band, |
| 2378 | Sidebar, |
| 2379 | Split, |
| 2380 | TabGroup, |
| 2381 | ] |
| 2382 | assert_eq!; |
| 2383 | |
| 2384 | |
| 2385 | |
| 2386 | |
| 2387 | |
| 2388 | // The escape hatch is one member and stays one member. If a second |
| 2389 | // undescribed region ever appears, the description has started |
| 2390 | // conceding rather than deferring. |
| 2391 | for r in |
| 2392 | Band, |
| 2393 | Sidebar, |
| 2394 | Pane, |
| 2395 | Split, |
| 2396 | TabGroup, |
| 2397 | Modal, |
| 2398 | ] |
| 2399 | assert!; |
| 2400 | |
| 2401 | assert!; |
| 2402 | |
| 2403 | |
| 2404 | |
| 2405 | |
| 2406 | // The app owns the contents, not the placement. An app that wants its |
| 2407 | // timeline in a well frames it in a Pane. |
| 2408 | assert_eq!; |
| 2409 | assert_eq!; |
| 2410 | |
| 2411 | |
| 2412 | |
| 2413 | |
| 2414 | // The argument the member exists for: goingson's day-plan has to be |
| 2415 | // routable, or the description covers only the boring screens and the |
| 2416 | // interesting four need a second path beside the router. |
| 2417 | let day_plan = |
| 2418 | Band, |
| 2419 | Bespoke , |
| 2420 | Sidebar, |
| 2421 | ]; |
| 2422 | assert_eq!; |
| 2423 | assert_eq!; |
| 2424 | |
| 2425 | |
| 2426 | |
| 2427 | |
| 2428 | let secret = new; |
| 2429 | assert!; |
| 2430 | assert!; |
| 2431 | |
| 2432 | assert!; |
| 2433 | // Nothing else is confidential, or the marker means nothing. |
| 2434 | for k in |
| 2435 | Text, |
| 2436 | Number, |
| 2437 | Textarea, |
| 2438 | Select, |
| 2439 | Checkbox, |
| 2440 | Hidden, |
| 2441 | ] |
| 2442 | assert!; |
| 2443 | |
| 2444 | |
| 2445 | // Only a checkbox carries its own label. |
| 2446 | assert!; |
| 2447 | assert!; |
| 2448 | |
| 2449 | |
| 2450 | |
| 2451 | |
| 2452 | let text = new; |
| 2453 | assert!; |
| 2454 | assert_eq!; |
| 2455 | |
| 2456 | let sizes = ; |
| 2457 | let select = select; |
| 2458 | assert_eq!; |
| 2459 | assert_eq!; |
| 2460 | |
| 2461 | |
| 2462 | |
| 2463 | |
| 2464 | // The whole reason it is two strings. `plain` is the case where they |
| 2465 | // coincide, and it is a shorthand rather than the general shape. |
| 2466 | let plain = plain; |
| 2467 | assert_eq!; |
| 2468 | |
| 2469 | let spelled = Choice |
| 2470 | value: "7", |
| 2471 | label: "One week", |
| 2472 | ; |
| 2473 | assert_ne!; |
| 2474 | |
| 2475 | |
| 2476 | |
| 2477 | |
| 2478 | // Both offer a fixed set and both read `options`, so the two |
| 2479 | // constructors differ in exactly one thing. That one thing is the |
| 2480 | // point: a renderer decides whether the alternatives are readable |
| 2481 | // without opening anything, and it can only decide that if the |
| 2482 | // description said which question was asked. |
| 2483 | let styles = |
| 2484 | Choice |
| 2485 | value: "copy", |
| 2486 | label: "Copy samples in", |
| 2487 | , |
| 2488 | Choice |
| 2489 | value: "reference", |
| 2490 | label: "Reference in place", |
| 2491 | , |
| 2492 | ]; |
| 2493 | let radio = radio; |
| 2494 | let select = select; |
| 2495 | |
| 2496 | assert_eq!; |
| 2497 | assert_ne!; |
| 2498 | assert_eq!; |
| 2499 | assert_eq! |
| 2500 | Field |
| 2501 | kind: select.kind, |
| 2502 | ..radio |
| 2503 | , |
| 2504 | select |
| 2505 | ; |
| 2506 | |
| 2507 | |
| 2508 | |
| 2509 | |
| 2510 | // The renderers branch on this rather than on a list of their own, so |
| 2511 | // a kind added without a decision here renders its options nowhere. |
| 2512 | assert!; |
| 2513 | assert!; |
| 2514 | for kind in |
| 2515 | Text, |
| 2516 | Secret, |
| 2517 | Number, |
| 2518 | Email, |
| 2519 | Url, |
| 2520 | Tel, |
| 2521 | Textarea, |
| 2522 | Checkbox, |
| 2523 | Hidden, |
| 2524 | ] |
| 2525 | assert!; |
| 2526 | |
| 2527 | |
| 2528 | |
| 2529 | |
| 2530 | |
| 2531 | // The near-miss: each option is labelled beside its own button, so a |
| 2532 | // renderer could plausibly read the group as self-labelling and drop |
| 2533 | // the question. Checkbox is the only kind that does that. |
| 2534 | assert!; |
| 2535 | assert!; |
| 2536 | |
| 2537 | |
| 2538 | |
| 2539 | |
| 2540 | // An app whose option list has not loaded has exactly this. Making it |
| 2541 | // unrepresentable would push the state somewhere less visible, and a |
| 2542 | // renderer drawing an empty select reports it on screen. |
| 2543 | let loading = select; |
| 2544 | assert!; |
| 2545 | |
| 2546 | |
| 2547 | |
| 2548 | |
| 2549 | // The line 0.8.0 drew. Placeholder and options are properties of what |
| 2550 | // is being asked; the current value is what came back, and no field |
| 2551 | // here holds one. |
| 2552 | let f = Field |
| 2553 | placeholder: Some, |
| 2554 | ..new |
| 2555 | ; |
| 2556 | assert_eq!; |
| 2557 | // A placeholder is not a label, and having one does not excuse the |
| 2558 | // field from carrying the other. |
| 2559 | assert_eq!; |
| 2560 | |
| 2561 | |
| 2562 | |
| 2563 | |
| 2564 | let mut f = new; |
| 2565 | assert!; |
| 2566 | f.error = Some; |
| 2567 | assert!; |
| 2568 | |
| 2569 | |
| 2570 | |
| 2571 | |
| 2572 | let cols = |
| 2573 | Column |
| 2574 | width: Fill, |
| 2575 | priority: Essential, |
| 2576 | ..new |
| 2577 | , |
| 2578 | Column |
| 2579 | width: Fixed, |
| 2580 | priority: Secondary, |
| 2581 | ..new |
| 2582 | , |
| 2583 | Column |
| 2584 | width: Fixed, |
| 2585 | priority: Optional, |
| 2586 | ..new |
| 2587 | , |
| 2588 | ]; |
| 2589 | |
| 2590 | // Widest: everything survives. |
| 2591 | assert_eq! |
| 2592 | cols.iter |
| 2593 | .filter |
| 2594 | .count, |
| 2595 | 3 |
| 2596 | ; |
| 2597 | // Narrower: the optional column goes first. |
| 2598 | let kept: = cols |
| 2599 | .iter |
| 2600 | .filter |
| 2601 | .map |
| 2602 | .collect; |
| 2603 | assert_eq!; |
| 2604 | // Narrowest: only what identifies the row. |
| 2605 | let kept: = cols |
| 2606 | .iter |
| 2607 | .filter |
| 2608 | .map |
| 2609 | .collect; |
| 2610 | assert_eq!; |
| 2611 | |
| 2612 | |
| 2613 | |
| 2614 | |
| 2615 | // The bug the ordinal form has and this form cannot: goingson hides |
| 2616 | // `nth-child(n+5)` against a seven-column table, so a column inserted |
| 2617 | // anywhere to the left silently hides a different one. |
| 2618 | let before = |
| 2619 | new, |
| 2620 | Column |
| 2621 | width: Fixed, |
| 2622 | priority: Optional, |
| 2623 | ..new |
| 2624 | , |
| 2625 | ]; |
| 2626 | let after = |
| 2627 | new, |
| 2628 | new, // inserted |
| 2629 | Column |
| 2630 | width: Fixed, |
| 2631 | priority: Optional, |
| 2632 | ..new |
| 2633 | , |
| 2634 | ]; |
| 2635 | |
| 2636 | |
| 2637 | cols.iter |
| 2638 | .filter |
| 2639 | .map |
| 2640 | .collect |
| 2641 | |
| 2642 | assert_eq!; |
| 2643 | assert_eq!; |
| 2644 | |
| 2645 | |
| 2646 | |
| 2647 | |
| 2648 | // goingson uses the tab group inside the content region rather than |
| 2649 | // instead of one, so it is not a third arrangement. |
| 2650 | let go = ListDetail ; |
| 2651 | let plain = ListDetail ; |
| 2652 | assert_ne!; |
| 2653 | assert_ne!; |
| 2654 | |
| 2655 | |
| 2656 | |
| 2657 | |
| 2658 | // Two members and no third. If a skeleton ever appears in this enum, |
| 2659 | // the deferral rule has been broken. |
| 2660 | assert_ne!; |
| 2661 | |
| 2662 | |
| 2663 |