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** is absent on purpose rather than pending: neither app has a |
| 44 | //! shared story, and a schema describing fields but not constraints acquires a |
| 45 | //! constraint layer per app, which is how the divergence this crate exists to |
| 46 | //! end got started. |
| 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 | //! # Where the description stops |
| 68 | //! |
| 69 | //! The bespoke widgets, a day-plan timeline and a kanban board and a calendar, |
| 70 | //! are not describable here and will not become describable. A description |
| 71 | //! expressive enough to produce a timeline is a widget library wearing a |
| 72 | //! description's name. Generate the boring 80% so the bespoke 20% gets the |
| 73 | //! attention. |
| 74 | //! |
| 75 | //! [`Region::Bespoke`] is how that limit is stated rather than hidden. The |
| 76 | //! description names the *place* and the app owns the contents, so a screen |
| 77 | //! containing a timeline is still a whole screen and still routable. Without |
| 78 | //! it, the four goingson screens that make the app worth using would need a |
| 79 | //! second, undescribed path beside the router, and two paths is how a |
| 80 | //! vocabulary starts drifting from its app again. |
| 81 | |
| 82 | |
| 83 | |
| 84 | /// A colour intent this crate refers to but never resolves. |
| 85 | /// |
| 86 | /// The string is the token name `makeover` publishes, so a renderer can look |
| 87 | /// it up without this crate knowing what colour came back. |
| 88 | |
| 89 | /// The `makeover` intent token this resolves against. |
| 90 | ; |
| 91 | |
| 92 | |
| 93 | /// Which way the light falls across a two-tone edge. |
| 94 | /// |
| 95 | /// The whole content of a bevel, once colour and thickness are deferred. The |
| 96 | /// light is always assumed to come from the top left: every consumer measured |
| 97 | /// agreed on that and none of them ever varied it, so it is an invariant here |
| 98 | /// rather than a parameter. |
| 99 | /// |
| 100 | /// # The two corners that belong to both edges |
| 101 | /// |
| 102 | /// Top-right and bottom-left are where the lit run meets the shaded one, and |
| 103 | /// the description's claim is that they belong to *both*. How a renderer says |
| 104 | /// that is its own business, because the answer is bounded by resolution and |
| 105 | /// not by taste: |
| 106 | /// |
| 107 | /// - A terminal cell is roughly 8x17 device pixels, so giving the whole corner |
| 108 | /// to one tone thickens that edge by a cell and reads as one run overrunning |
| 109 | /// the other. A half-cell glyph divides the cell already, so `makeover-tui` |
| 110 | /// splits it and recovers real information. Its box-drawing fallback cannot: |
| 111 | /// a single stroke has no half to give, so there both corners go to dark. |
| 112 | /// - A pixel bevel is a one-point stroke by default, which makes the corner a |
| 113 | /// one-point square. There is nothing to divide — a diagonal seam across one |
| 114 | /// point is sub-pixel, and antialiasing renders it as the blend a mitred join |
| 115 | /// already produces. So `makeover-immediate` mitres and is *not* diverging; |
| 116 | /// it is the same rule at a resolution where the split degenerates. |
| 117 | /// |
| 118 | /// Stated here so the difference reads as a decision rather than as drift. A |
| 119 | /// renderer with room to divide the corner should; one without should mitre or |
| 120 | /// pick the shaded tone, and neither is a bug. |
| 121 | |
| 122 | |
| 123 | /// Lit from the top left: light on top and left, dark on bottom and right. |
| 124 | Raised, |
| 125 | /// The same edge inverted, which is also the pressed state of anything |
| 126 | /// that draws itself [`Bevel::Raised`]. |
| 127 | Inset, |
| 128 | |
| 129 | |
| 130 | |
| 131 | /// The edge intents, as `(top_left, bottom_right)`. |
| 132 | /// |
| 133 | /// Split out from any painting because the inversion *is* the idea, and |
| 134 | /// it is the one part every renderer implements identically. |
| 135 | |
| 136 | pub const |
| 137 | match self |
| 138 | SelfRaised => , |
| 139 | SelfInset => , |
| 140 | |
| 141 | |
| 142 | |
| 143 | /// Pressing inverts. A raised control reads as inset while held. |
| 144 | /// |
| 145 | /// Stated here rather than left to each consumer because a cascade can |
| 146 | /// carry a pressed state and an immediate-mode renderer cannot: audiofiles |
| 147 | /// resolves this per call site, eighteen times. |
| 148 | |
| 149 | pub const |
| 150 | match self |
| 151 | SelfRaised => SelfInset, |
| 152 | SelfInset => SelfRaised, |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | /// One side of a bevel, named by the intent it takes. |
| 158 | |
| 159 | |
| 160 | /// The lit side. |
| 161 | Light, |
| 162 | /// The shadowed side. |
| 163 | Dark, |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | match self |
| 169 | SelfLight => "bevel-light", |
| 170 | SelfDark => "bevel-dark", |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | /// A surface intent a region is filled with. |
| 176 | /// |
| 177 | /// `#[non_exhaustive]`, so a renderer must carry a wildcard arm and a new |
| 178 | /// member is additive rather than breaking. Added 0.4.0, after [`Sunken`] |
| 179 | /// (an additive member, 0.3.0) hard-broke `makeover-tui` and |
| 180 | /// `makeover-immediate` at compile time and left neither able to move until |
| 181 | /// both published. The vocabulary exists to grow and the renderers exist to |
| 182 | /// disagree about how much of it they answer, so growth must not be a |
| 183 | /// lockstep event. The renderer's wildcard is not a hole: [`Fill`] is |
| 184 | /// resolved through a fallible lookup, and a missing intent is answered with |
| 185 | /// structure rather than with a substituted colour. |
| 186 | /// |
| 187 | /// [`Sunken`]: Fill::Sunken |
| 188 | |
| 189 | |
| 190 | |
| 191 | /// The page behind everything. |
| 192 | Page, |
| 193 | /// A surface lifted off the page: cards, controls, menus, toasts. |
| 194 | Raised, |
| 195 | /// A surface floating above the page rather than resting on it. |
| 196 | Overlay, |
| 197 | /// The inside of a well. |
| 198 | Well, |
| 199 | /// A surface set back from the one it sits on, by colour and nothing else. |
| 200 | /// |
| 201 | /// Not a well. A well is a hole with an edge, and the two are authored in |
| 202 | /// opposite directions: `makeover` derives `surface-well` by inverting |
| 203 | /// against the theme's own content colour, while `surface-sunken` is |
| 204 | /// authored and free to sit darker than raised (goingson's does). Naming |
| 205 | /// only the well left the recessed-with-no-edge surface unsayable, which is |
| 206 | /// what an unchosen tab is: it recedes so the chosen one can come forward, |
| 207 | /// and it carries no bevel of its own. |
| 208 | /// |
| 209 | /// Added 0.3.0, from goingson's tab strip, which hand-writes exactly this |
| 210 | /// and could not delete the line because no member described it. |
| 211 | Sunken, |
| 212 | |
| 213 | |
| 214 | // No `fallback` here, deliberately. An earlier cut had `Fill::Well` fall back |
| 215 | // to `Fill::Page` so a consumer on makeover 2.2.0, which has no `surface-well`, |
| 216 | // had something to paint. makeover-tui found that wrong within a day: page is |
| 217 | // the surface a well is usually cut into, so on a terminal that substitution |
| 218 | // produces exactly the invisibility it was meant to prevent, and the right |
| 219 | // answer there is a drawn edge rather than a different colour. |
| 220 | // |
| 221 | // Substituting one intent for another is renderer policy. The description says |
| 222 | // what the region is and stops. |
| 223 | |
| 224 | |
| 225 | |
| 226 | match self |
| 227 | SelfPage => "surface-page", |
| 228 | SelfRaised => "surface-raised", |
| 229 | SelfOverlay => "surface-overlay", |
| 230 | SelfWell => "surface-well", |
| 231 | SelfSunken => "surface-sunken", |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | /// How a region sits relative to the surface behind it. |
| 237 | /// |
| 238 | /// Fill and bevel are named together because naming them apart is what let |
| 239 | /// them disagree. Every consumer measured had at least one region carrying a |
| 240 | /// raised bevel over a recessed fill: audiofiles fixed it in `raised_frame` |
| 241 | /// and recorded the bug in its doc comment, and Balanced Breakfast still had |
| 242 | /// twelve of them a year later. A single name for the pair makes that |
| 243 | /// unrepresentable. |
| 244 | /// `#[non_exhaustive]` for the same reason as [`Fill`], and in the same |
| 245 | /// release: a depth this renderer has no drawing for should cost it a |
| 246 | /// wildcard arm, not a compile error and a wait on someone else's publish. |
| 247 | |
| 248 | |
| 249 | |
| 250 | /// Level with its surroundings. No edge. |
| 251 | Flat, |
| 252 | /// A card laid on the panel it sits in. |
| 253 | Raised, |
| 254 | /// A hole in the panel, with content down inside it. For anything the |
| 255 | /// user looks *into*: a table body, a tag tree, a text field. |
| 256 | Well, |
| 257 | /// Set back from what it sits on, by colour alone. No edge. |
| 258 | /// |
| 259 | /// The one member carrying a fill without a bevel, so a renderer cannot |
| 260 | /// assume the two arrive together. That is deliberate and it is still the |
| 261 | /// pairing rule: both halves come off the same `Depth`, so they cannot |
| 262 | /// disagree, and here one half is legitimately absent. |
| 263 | /// |
| 264 | /// Distinct from [`Depth::Flat`], which has no fill either and inherits. |
| 265 | /// Recessed and level-with are different claims, and only one of them |
| 266 | /// needs a colour. |
| 267 | Sunken, |
| 268 | |
| 269 | |
| 270 | |
| 271 | /// The edge this depth is drawn with, if it has one. |
| 272 | |
| 273 | pub const |
| 274 | match self |
| 275 | // Sunken joins Flat here, for the opposite reason: Flat has no edge |
| 276 | // because nothing separates it from its surroundings, and Sunken has |
| 277 | // none because its colour is already doing the separating. |
| 278 | SelfFlat | SelfSunken => None, |
| 279 | SelfRaised => Some, |
| 280 | SelfWell => Some, |
| 281 | |
| 282 | |
| 283 | |
| 284 | /// The surface this depth is filled with. |
| 285 | /// |
| 286 | /// [`Depth::Flat`] has no fill of its own: it inherits whatever it sits on, |
| 287 | /// which is the difference between level-with and painted-the-same-colour. |
| 288 | |
| 289 | pub const |
| 290 | match self |
| 291 | SelfFlat => None, |
| 292 | SelfRaised => Some, |
| 293 | SelfWell => Some, |
| 294 | SelfSunken => Some, |
| 295 | |
| 296 | |
| 297 | |
| 298 | /// Pressing a raised region reads as a well, and nothing else moves. |
| 299 | |
| 300 | pub const |
| 301 | match self |
| 302 | SelfRaised => SelfWell, |
| 303 | other => other, |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | /// An interaction state a region can be in, beside whatever [`Depth`] it is. |
| 309 | /// |
| 310 | /// Orthogonal to depth on purpose. A disabled button is still [`Depth::Raised`] |
| 311 | /// and a disabled field is still a [`Depth::Well`], so folding either member |
| 312 | /// into `Depth` would make [`Depth::bevel`] and [`Depth::fill`] answer for |
| 313 | /// something that is not a depth, and would leave disabled-button and |
| 314 | /// disabled-field sharing one variant that cannot tell them apart. |
| 315 | /// |
| 316 | /// # Why hover and pressed are not members |
| 317 | /// |
| 318 | /// The line is whether every renderer has the state to express, not whether CSS |
| 319 | /// does. Hover is renderer policy and `makeover-webview` says so in its own |
| 320 | /// header: a terminal and an immediate-mode painter have no pointer hovering |
| 321 | /// over anything, and pressed already arrives through [`Bevel::pressed`] and |
| 322 | /// [`Depth::pressed`], where it belongs, because pressing is a depth inversion |
| 323 | /// rather than a separate condition. |
| 324 | /// |
| 325 | /// Focus and disabled are different in kind. A TUI has a focused widget and a |
| 326 | /// greyed-out one; so does egui. Both were unsayable here, so all three webview |
| 327 | /// consumers supplied them from outside the primitive by out-specifying rules |
| 328 | /// they did not own: goingson alone carries 19 of them, and the MNW server |
| 329 | /// another 21. That is the divergence this crate exists to end, arriving one |
| 330 | /// layer down. |
| 331 | /// |
| 332 | /// # The principle this encodes |
| 333 | /// |
| 334 | /// A primitive owns every state it implies. A renderer that emits a hover rule |
| 335 | /// for a thing owes disabled, focus and the capability answer for that same |
| 336 | /// thing, because anything less exports the completion work to N consumers who |
| 337 | /// will each do it differently. |
| 338 | /// |
| 339 | /// `#[non_exhaustive]` for the reason [`Fill`] and [`Depth`] carry it: growth |
| 340 | /// must not be a lockstep event across the three renderers. |
| 341 | |
| 342 | |
| 343 | |
| 344 | /// Keyboard focus, as distinct from the pointer having landed on something. |
| 345 | /// |
| 346 | /// One ring, not one per primitive. Where the ring sits is [`Depth`]'s |
| 347 | /// question and not a per-component choice: a well takes it inside its own |
| 348 | /// edge and a raised surface takes it outside. That is one decision with |
| 349 | /// two renderings rather than one decision per component, which is how the |
| 350 | /// three apps ended up with three rings. |
| 351 | Focus, |
| 352 | /// Present, visible, and not answering. |
| 353 | /// |
| 354 | /// Not the same as absent, and deliberately not a [`Fill`]: a disabled |
| 355 | /// control keeps the surface it always had and stops responding, so what |
| 356 | /// changes is its content and its interactivity rather than what it is. |
| 357 | Disabled, |
| 358 | |
| 359 | |
| 360 | |
| 361 | /// Whether a region in this state stops answering the pointer. |
| 362 | /// |
| 363 | /// Stated in the description rather than left to each renderer, on the same |
| 364 | /// reasoning as [`Bevel::pressed`]: a cascade carries it for free and an |
| 365 | /// immediate-mode renderer resolves it per call site, so leaving it unsaid |
| 366 | /// means resolving it once per consumer and disagreeing. |
| 367 | |
| 368 | pub const |
| 369 | match self |
| 370 | SelfDisabled => true, |
| 371 | SelfFocus => false, |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | match self |
| 379 | // Already derived by `makeover` from `action.primary`, and unused |
| 380 | // until now for the same reason `hover-surface` was: nothing |
| 381 | // emitted the rule that would consume it. |
| 382 | SelfFocus => "focus-ring", |
| 383 | // Reusing the muted content intent rather than minting a |
| 384 | // `disabled` colour. Disabled is a reduction and not a status, and |
| 385 | // `makeover-webview`'s progress rules already record the reading |
| 386 | // that `content-muted` is what disabled looks like. |
| 387 | SelfDisabled => "content-muted", |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | /// What a region is saying, when it is saying something. |
| 393 | /// |
| 394 | /// The one intent family shared by badges, notices and nothing else. Kept |
| 395 | /// separate from [`Fill`] because a surface is where a thing sits and a tone is |
| 396 | /// what it means, and the three apps agree on the four statuses: |
| 397 | /// `info_banner` / `warning_banner` in audiofiles, `.toast-info` / |
| 398 | /// `.toast-success` / `.toast-error` in goingson, `.toast.success` / |
| 399 | /// `.toast.error` in Balanced Breakfast. |
| 400 | /// |
| 401 | /// The per-tag palette (`category-one` through `category-six`) is deliberately |
| 402 | /// not here. Which colour a *particular* tag takes is app domain, and both |
| 403 | /// webview apps already carry it as a `data-color` attribute. |
| 404 | |
| 405 | |
| 406 | /// No status. Reads as ordinary de-emphasised content. |
| 407 | Neutral, |
| 408 | /// Something worth knowing and nothing to do about it. |
| 409 | Info, |
| 410 | /// Something finished and it worked. |
| 411 | Success, |
| 412 | /// Something the user should look at before continuing. |
| 413 | Warning, |
| 414 | /// Something broken, or something about to be destroyed. |
| 415 | Danger, |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | match self |
| 421 | // Neutral has no status token of its own. It takes the muted |
| 422 | // content intent, which is what both webview apps already spell as |
| 423 | // `data-color="muted"`. |
| 424 | SelfNeutral => "content-muted", |
| 425 | SelfInfo => "info", |
| 426 | SelfSuccess => "success", |
| 427 | SelfWarning => "warning", |
| 428 | SelfDanger => "danger", |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | /// A small labelled thing that sits inside something else. |
| 434 | /// |
| 435 | /// Two members, because the three apps drew three taxonomies and only one line |
| 436 | /// runs through all of them: does it answer a click. audiofiles has |
| 437 | /// `classification_badge` (a label) against `tag_chip`, `tag_chip_removable` |
| 438 | /// and `selectable_tag` (all of which do). Balanced Breakfast has `.tag` and |
| 439 | /// `.badge` against `.tag-chip`. goingson is the one that has to move: its |
| 440 | /// `.tag` and `.badge` are a single CSS rule, so every call site has to be read |
| 441 | /// to decide which of the two it always was. |
| 442 | /// |
| 443 | /// The evidence that a chip is a real concept rather than a badge with a |
| 444 | /// cursor: audiofiles inverts its bevel on press and Balanced Breakfast latches |
| 445 | /// `.tag-chip.active` with the inset bevel. Two independent arrivals at "a chip |
| 446 | /// holds itself down", which is exactly what [`Depth::pressed`] already says. |
| 447 | |
| 448 | |
| 449 | /// Non-interactive status or count. Answers no click. |
| 450 | Badge, |
| 451 | /// An interactive or removable token. Answers a click, and latches if it |
| 452 | /// stands for a filter that is either on or off. |
| 453 | Chip |
| 454 | /// Whether it carries its own remove affordance. |
| 455 | removable: bool, |
| 456 | , |
| 457 | |
| 458 | |
| 459 | |
| 460 | /// Whether this answers a click. |
| 461 | /// |
| 462 | /// The whole difference between the two members, and the reason a renderer |
| 463 | /// with no hover (a touch surface, a terminal) can still tell them apart. |
| 464 | |
| 465 | pub const |
| 466 | matches! |
| 467 | |
| 468 | |
| 469 | /// How it sits, given whether it is currently latched down. |
| 470 | /// |
| 471 | /// A badge is flat: it is a label, and giving it an edge would say it can |
| 472 | /// be pressed. A chip is raised, and inset while latched. |
| 473 | |
| 474 | pub const |
| 475 | match self |
| 476 | SelfBadge => Flat, |
| 477 | SelfChip if latched => Well, |
| 478 | SelfChip => Raised, |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | /// Something the app is telling the user, unprompted. |
| 484 | /// |
| 485 | /// Two concepts, not one with a placement. They differ in more than where they |
| 486 | /// sit: a toast is transient, stacked and self-dismissing, and a banner is |
| 487 | /// persistent, in flow, one per region, and dismissed by fixing the condition |
| 488 | /// it reports. Folding them into one member with a placement parameter would |
| 489 | /// make lifetime, stacking and dismissal all placement-dependent, which is the |
| 490 | /// description leaking renderer policy. |
| 491 | /// |
| 492 | /// All three apps have banners: `info_banner` and `warning_banner` in |
| 493 | /// audiofiles, five of them in goingson (sync, sync-result, vacation-day, |
| 494 | /// timer-active, past-review), `.update-banner` in Balanced Breakfast. The two |
| 495 | /// webview apps also have toasts. So neither member is speculative, and no app |
| 496 | /// gains a concept it lacks except audiofiles, whose renderer may legitimately |
| 497 | /// decline to draw a toast at all. |
| 498 | |
| 499 | |
| 500 | /// Transient, stacked, dismisses itself. |
| 501 | Toast, |
| 502 | /// Persistent, in flow, one per region, dismissed by fixing the cause. |
| 503 | Banner, |
| 504 | |
| 505 | |
| 506 | |
| 507 | /// Whether it goes away on its own. |
| 508 | |
| 509 | pub const |
| 510 | matches! |
| 511 | |
| 512 | |
| 513 | /// How it sits. |
| 514 | /// |
| 515 | /// A toast floats above the page rather than resting on it, which is |
| 516 | /// [`Fill::Overlay`]'s whole reason to exist. A banner is a card in the |
| 517 | /// flow. Both are raised, and they are raised off different things. |
| 518 | |
| 519 | pub const |
| 520 | match self |
| 521 | SelfToast => Overlay, |
| 522 | SelfBanner => Raised, |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | /// The parts of a list row. |
| 528 | /// |
| 529 | /// Four, taken from Balanced Breakfast, which is the only consumer that had all |
| 530 | /// of them (`row-primary`, `row-secondary`, `row-meta`, `row-actions`). |
| 531 | /// audiofiles has two and no slot structure at all, so it gains meta and |
| 532 | /// actions as real work rather than a rename; goingson moves off |
| 533 | /// `task-row` / `task-cell`. |
| 534 | |
| 535 | |
| 536 | /// The thing itself. What the row is called. |
| 537 | Primary, |
| 538 | /// Supporting text under the primary. |
| 539 | Secondary, |
| 540 | /// A short trailing fact: a count, a size, a date. |
| 541 | Meta, |
| 542 | /// Controls that act on this row. |
| 543 | Actions, |
| 544 | |
| 545 | |
| 546 | |
| 547 | /// Whether the part stays hidden until the row is hovered or focused. |
| 548 | /// |
| 549 | /// Behaviour of the part, not app policy: Balanced Breakfast and goingson |
| 550 | /// grew the same hover-reveal on their actions independently and neither |
| 551 | /// applies it to anything else. |
| 552 | /// |
| 553 | /// A renderer with no hover shows it always. That is a renderer decision |
| 554 | /// and this returning `true` does not forbid it. |
| 555 | |
| 556 | pub const |
| 557 | matches! |
| 558 | |
| 559 | |
| 560 | /// The content intent the part takes. |
| 561 | |
| 562 | pub const |
| 563 | match self |
| 564 | SelfPrimary => "content", |
| 565 | SelfSecondary => "content-secondary", |
| 566 | SelfMeta => "content-muted", |
| 567 | // Actions carry controls rather than text, so they inherit. |
| 568 | SelfActions => "content", |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | /// How far down the heading tree a title sits. |
| 574 | /// |
| 575 | /// Three, and only the three that are actually headings. The bands those used |
| 576 | /// to be filed with (goingson's `.page-header`, Balanced Breakfast's `.header` |
| 577 | /// and `.detail-header`) are arrangement, not type, and live at |
| 578 | /// [`Region::Band`]. One of them contains no text at all. |
| 579 | |
| 580 | |
| 581 | /// Names the whole screen. One per screen. |
| 582 | Page, |
| 583 | /// Names a block within the screen. |
| 584 | Section, |
| 585 | /// Names a sub-block inside an already-named section. |
| 586 | Subsection, |
| 587 | |
| 588 | |
| 589 | |
| 590 | /// Whether a rule follows the heading. |
| 591 | /// |
| 592 | /// audiofiles' `section_header` draws a separator and its |
| 593 | /// `subsection_label` deliberately does not, which is the only thing |
| 594 | /// distinguishing the two once weight and colour are deferred. |
| 595 | |
| 596 | pub const |
| 597 | matches! |
| 598 | |
| 599 | |
| 600 | |
| 601 | /// A control that picks between things. |
| 602 | /// |
| 603 | /// Three, because three distinct behaviours are in play and collapsing any two |
| 604 | /// loses something. A segmented control picks a value; a tab picks a pane; a |
| 605 | /// toggle picks nothing and simply holds itself on or off. |
| 606 | |
| 607 | |
| 608 | /// Exactly one of N, and the options abut. |
| 609 | Segmented, |
| 610 | /// Independent on or off, on its own. |
| 611 | Toggle, |
| 612 | /// Navigation between panes. The folder semantic. |
| 613 | Tabs, |
| 614 | |
| 615 | |
| 616 | |
| 617 | /// How the chosen option sits. |
| 618 | /// |
| 619 | /// Held in for a segmented control and a toggle, which is the same shape |
| 620 | /// pressing produces and the whole economy of the idiom: one appearance, |
| 621 | /// two reasons to wear it. A tab is the exception, because the selected |
| 622 | /// folder tab comes *forward* to join the pane it opens. |
| 623 | |
| 624 | pub const |
| 625 | match self |
| 626 | SelfSegmented | SelfToggle => Well, |
| 627 | SelfTabs => Raised, |
| 628 | |
| 629 | |
| 630 | |
| 631 | /// How the options that were *not* picked sit. |
| 632 | /// |
| 633 | /// Added 0.3.0. Describing only [`Selector::chosen`] left the unchosen |
| 634 | /// option falling through to [`Depth::Flat`], which says it is level with |
| 635 | /// the strip it sits in, and no renderer emitted anything for it. That is |
| 636 | /// wrong in both directions and goingson proved it: its unchosen tabs are |
| 637 | /// recessed by hand, and being recessed is *why* the chosen one reads as |
| 638 | /// coming forward. Against a flat strip, a raised chosen tab is a bevel |
| 639 | /// drawn on the strip's own colour, which is a much weaker folder effect |
| 640 | /// than the contrast the idiom is named after. |
| 641 | /// |
| 642 | /// Each member is the inverse of its chosen state, which is the whole |
| 643 | /// content of "picked" once colour is deferred: |
| 644 | /// |
| 645 | /// - Tabs recede, so the chosen one comes forward. |
| 646 | /// - A segment and a toggle stand up, so the chosen one is held in. |
| 647 | |
| 648 | pub const |
| 649 | match self |
| 650 | SelfTabs => Sunken, |
| 651 | SelfSegmented | SelfToggle => Raised, |
| 652 | |
| 653 | |
| 654 | |
| 655 | /// Whether the options touch. |
| 656 | /// |
| 657 | /// The gap is the entire difference between a segmented control and a row |
| 658 | /// of buttons that happen to sit near each other, which is what audiofiles' |
| 659 | /// `segmented_control` says in its own comment and why it zeroes the |
| 660 | /// spacing by hand. |
| 661 | |
| 662 | pub const |
| 663 | matches! |
| 664 | |
| 665 | |
| 666 | |
| 667 | /// Whether the content of a region has arrived. |
| 668 | /// |
| 669 | /// The state, not the shimmer. Whether pending paints a skeleton, a spinner or |
| 670 | /// nothing at all is renderer policy, the same class of decision that got |
| 671 | /// `Fill::fallback` deleted from this crate. goingson and Balanced Breakfast |
| 672 | /// each grew a skeleton with differently-named parts; both keep them, as the |
| 673 | /// webview renderer's expression of [`Readiness::Pending`]. audiofiles has none |
| 674 | /// and needs none, because an immediate-mode renderer simply repaints. |
| 675 | |
| 676 | |
| 677 | /// The content is here. |
| 678 | Ready, |
| 679 | /// The content is on its way. |
| 680 | Pending, |
| 681 | |
| 682 | |
| 683 | /// A named part of a screen. |
| 684 | /// |
| 685 | /// The thing `makeover-geometry` deliberately does not name: it names the space |
| 686 | /// *between* things by relationship, and nothing named the things. Six named |
| 687 | /// members, taken from what the two webview apps actually use, plus |
| 688 | /// [`Region::Bespoke`] for the parts no description should reach. Both apps' |
| 689 | /// `layout.css` currently names exactly two things, `.raised` and `.well`, so |
| 690 | /// this layer is absent rather than divergent, which makes it the cheapest of |
| 691 | /// the schemas to add and the easiest to over-build. |
| 692 | |
| 693 | |
| 694 | /// A full-width strip with a title slot and an actions cluster, either of |
| 695 | /// which may be empty. goingson's `.page-header`, Balanced Breakfast's |
| 696 | /// `.header` and `.detail-header` are all this, differing only in which |
| 697 | /// slots they fill. |
| 698 | Band, |
| 699 | /// A persistent column beside the content, holding navigation. |
| 700 | Sidebar, |
| 701 | /// A region of content with its own scroll. |
| 702 | Pane, |
| 703 | /// Two panes side by side, where the left chooses what the right shows. |
| 704 | Split, |
| 705 | /// A set of panes, one visible at a time, with a [`Selector::Tabs`] above. |
| 706 | TabGroup, |
| 707 | /// Content over a scrim, taking input until dismissed. |
| 708 | Modal, |
| 709 | /// A region this crate names the *place* of and nothing else. The app owns |
| 710 | /// what goes in it. |
| 711 | /// |
| 712 | /// The escape hatch, and the thing that keeps the description honest about |
| 713 | /// its own limits. A day-plan timeline, a kanban board, a calendar and the |
| 714 | /// paint interaction over the timeline are not describable here and are not |
| 715 | /// going to become describable: a description expressive enough to produce |
| 716 | /// a timeline is a widget library wearing a description's name. |
| 717 | /// |
| 718 | /// But a screen containing one still has to be a screen. Without this |
| 719 | /// member the description covers only the boring screens, and the four that |
| 720 | /// make goingson worth using would need a second, undescribed path beside |
| 721 | /// the router. Two paths is how the vocabulary starts drifting from the app |
| 722 | /// again, which is the exact failure this crate exists to end. |
| 723 | /// |
| 724 | /// So the description says "a thing called `day-plan` goes here" and stops. |
| 725 | /// The name is opaque: this crate never interprets it, and no renderer is |
| 726 | /// expected to know what it means beyond handing the space over. |
| 727 | Bespoke |
| 728 | /// What the app calls it. Never interpreted here. |
| 729 | name: &'a str, |
| 730 | , |
| 731 | |
| 732 | |
| 733 | |
| 734 | /// How the region sits on what is behind it. |
| 735 | |
| 736 | pub const |
| 737 | match self |
| 738 | SelfBand | SelfSidebar | SelfSplit | SelfTabGroup => Flat, |
| 739 | // A pane is looked into, the same as a table body or a tag tree. |
| 740 | SelfPane => Well, |
| 741 | SelfModal => Raised, |
| 742 | // Flat because it inherits: a bespoke region takes the depth of |
| 743 | // whatever frames it. An app that wants its timeline in a well puts |
| 744 | // it in a `Pane`, which composes rather than adding a knob here. |
| 745 | SelfBespoke => Flat, |
| 746 | |
| 747 | |
| 748 | |
| 749 | /// Whether this crate can say anything about the region's contents. |
| 750 | /// |
| 751 | /// A renderer walks the description and hands every region it understands |
| 752 | /// to the right drawing code. This is how it tells the two apart, and the |
| 753 | /// reason it is a method rather than a `matches!` at each renderer: there |
| 754 | /// is exactly one opaque member and there should stay exactly one. |
| 755 | |
| 756 | pub const |
| 757 | !matches! |
| 758 | |
| 759 | |
| 760 | |
| 761 | /// How a screen is laid out. |
| 762 | /// |
| 763 | /// Two, and the second is not a variant of the first. goingson is list-detail, |
| 764 | /// Balanced Breakfast is sidebar plus content, and neither app has a third. |
| 765 | /// The tab group is a modifier rather than a member, because goingson uses it |
| 766 | /// *inside* the same content region rather than instead of one. |
| 767 | /// |
| 768 | /// This exists at all because the router has to be able to express a screen |
| 769 | /// rather than only a control. Discovering the arrangement layer missing after |
| 770 | /// the renderers exist is a redesign; naming two now is a morning. |
| 771 | |
| 772 | |
| 773 | /// A list that chooses what the detail beside it shows. |
| 774 | ListDetail |
| 775 | /// Whether the detail side is a [`Region::TabGroup`]. |
| 776 | tabbed: bool, |
| 777 | , |
| 778 | /// Navigation down the side, content filling the rest. |
| 779 | SidebarContent, |
| 780 | |
| 781 | |
| 782 | /// What kind of value a form field takes. |
| 783 | /// |
| 784 | /// The union of the two vocabularies that diverged, which is what triggered |
| 785 | /// this crate. They have since converged on their own: both apps now have a |
| 786 | /// `renderFormField` emitting the same anatomy, and what is left differing is |
| 787 | /// the kind set, the error shape, and whether the return is a string or a node. |
| 788 | /// |
| 789 | /// Validation is deliberately absent. Neither app has a shared story (goingson |
| 790 | /// validates after collecting the form data, with per-field transform hooks; |
| 791 | /// Balanced Breakfast has `required` and nothing else), and a schema that |
| 792 | /// describes fields but not constraints acquires a constraint layer per app, |
| 793 | /// which is exactly how the current divergence started. Naming it absent is a |
| 794 | /// decision; leaving it unmentioned would not be. |
| 795 | /// `#[non_exhaustive]` for the reason [`Fill`] is: renderers match on this and |
| 796 | /// the set keeps growing, so growth must not be a lockstep event. Email, Url |
| 797 | /// and Tel arriving in 0.5.0 is the second growth in two releases. |
| 798 | |
| 799 | |
| 800 | |
| 801 | /// A single line of text. |
| 802 | Text, |
| 803 | /// A single line of text that must never be echoed, logged or round-tripped |
| 804 | /// through anything that might persist it. |
| 805 | Secret, |
| 806 | /// A number. |
| 807 | Number, |
| 808 | /// An email address. |
| 809 | /// |
| 810 | /// Distinct from [`Text`](Self::Text) because the distinction is not |
| 811 | /// decoration: a webview renderer emits `type="email"`, which on a touch |
| 812 | /// device changes the keyboard that appears and turns on the platform's own |
| 813 | /// validation. goingson ships to iOS, so collapsing this into text costs a |
| 814 | /// keyboard with no `@` on it. |
| 815 | /// |
| 816 | /// Added 0.5.0, from goingson's contact form. |
| 817 | Email, |
| 818 | /// A URL. Same reasoning as [`Email`](Self::Email). |
| 819 | /// |
| 820 | /// Added 0.5.0, from goingson's contact-social and contact-feed forms. |
| 821 | Url, |
| 822 | /// A telephone number. Same reasoning as [`Email`](Self::Email), and the |
| 823 | /// clearest case of it: the keyboard is a numeric pad rather than letters. |
| 824 | /// |
| 825 | /// Added 0.5.0, from goingson's contact-phone form. |
| 826 | Tel, |
| 827 | /// Several lines of text. |
| 828 | Textarea, |
| 829 | /// One of a fixed set. |
| 830 | Select, |
| 831 | /// On or off. |
| 832 | Checkbox, |
| 833 | /// Carried through the form and never shown. |
| 834 | Hidden, |
| 835 | |
| 836 | |
| 837 | |
| 838 | /// Whether the field is drawn at all. |
| 839 | |
| 840 | pub const |
| 841 | !matches! |
| 842 | |
| 843 | |
| 844 | /// Whether the value must be kept out of logs and diagnostics. |
| 845 | |
| 846 | pub const |
| 847 | matches! |
| 848 | |
| 849 | |
| 850 | /// Where the field's own label sits. |
| 851 | /// |
| 852 | /// A checkbox labels itself on the right of the box; everything else takes |
| 853 | /// a label above. Both webview apps already do this and both special-case |
| 854 | /// it inline, which is the tell that it belongs in the description. |
| 855 | |
| 856 | pub const |
| 857 | matches! |
| 858 | |
| 859 | |
| 860 | |
| 861 | /// One field of a form. |
| 862 | /// |
| 863 | /// Borrowed rather than owned: a description is built, read once by a renderer, |
| 864 | /// and dropped. Nothing here outlives the screen it describes. |
| 865 | |
| 866 | |
| 867 | /// What kind of value it takes. |
| 868 | pub kind: FieldKind, |
| 869 | /// The name the value is submitted under. |
| 870 | pub name: &'a str, |
| 871 | /// What the user is asked for. |
| 872 | pub label: &'a str, |
| 873 | /// Standing help, shown whether or not anything is wrong. |
| 874 | pub hint: , |
| 875 | /// What is currently wrong with the value. |
| 876 | pub error: , |
| 877 | /// Whether the form refuses to submit without it. |
| 878 | pub required: bool, |
| 879 | /// Whether the field lives behind a "more options" disclosure. |
| 880 | pub extended: bool, |
| 881 | |
| 882 | |
| 883 | |
| 884 | /// A plain required-nothing field of the given kind. |
| 885 | |
| 886 | pub const |
| 887 | Self |
| 888 | kind, |
| 889 | name, |
| 890 | label, |
| 891 | hint: None, |
| 892 | error: None, |
| 893 | required: false, |
| 894 | extended: false, |
| 895 | |
| 896 | |
| 897 | |
| 898 | /// Whether the field is currently reporting a problem. |
| 899 | /// |
| 900 | /// Read this rather than testing `error.is_some()` at each renderer: the |
| 901 | /// error state has to mark the field's whole group and not only the |
| 902 | /// message, because a renderer with no descendant selectors (egui, a |
| 903 | /// terminal) cannot find the group from the message. goingson already marks |
| 904 | /// the group and Balanced Breakfast does not, so goingson's shape is the |
| 905 | /// one taken here. |
| 906 | |
| 907 | pub const |
| 908 | self.error.is_some |
| 909 | |
| 910 | |
| 911 | |
| 912 | /// How much room a column asks for. |
| 913 | /// |
| 914 | /// An intent, so the actual floor stays with `makeover-geometry`. goingson's |
| 915 | /// task table spells these as `minmax(200px, 1fr)`, `140px` and content-sized; |
| 916 | /// only the first three words of that survive deferral. |
| 917 | /// `#[non_exhaustive]`, for the reason [`Fill`] and [`FieldKind`] are: a |
| 918 | /// renderer matches on this and a vocabulary that grows must not break every |
| 919 | /// renderer when it does. |
| 920 | |
| 921 | |
| 922 | |
| 923 | /// Takes what it needs and no more. |
| 924 | Content, |
| 925 | /// A fixed share, the same at every width. |
| 926 | Fixed, |
| 927 | /// Absorbs whatever is left over. |
| 928 | Fill, |
| 929 | |
| 930 | |
| 931 | /// What a column is worth when there is not room for all of them. |
| 932 | /// |
| 933 | /// Ordered: [`Priority::Optional`] drops first, [`Priority::Essential`] never |
| 934 | /// drops. This replaces addressing columns by position, which is what both |
| 935 | /// webview apps do today and is a live bug rather than only verbosity. goingson |
| 936 | /// hides mobile columns with `nth-child(n+5)` against a seven-column table, so |
| 937 | /// inserting a column silently hides the wrong one. |
| 938 | /// `#[non_exhaustive]`, same reasoning as [`Width`]. Note the ordering is the |
| 939 | /// whole point of the type, so a new tier has to be declared in its place in |
| 940 | /// the sequence rather than appended. |
| 941 | |
| 942 | |
| 943 | |
| 944 | /// Dropped first. |
| 945 | Optional, |
| 946 | /// Dropped once the optional columns are gone. |
| 947 | Secondary, |
| 948 | /// Never dropped. Without it the row does not identify itself. |
| 949 | Essential, |
| 950 | |
| 951 | |
| 952 | /// One column of a table. |
| 953 | /// |
| 954 | /// Described once. The grid track, the cell order and the drop behaviour are |
| 955 | /// all derived from this, rather than being three hand-written encodings that |
| 956 | /// must agree and are never checked against each other. |
| 957 | |
| 958 | |
| 959 | /// The heading, and the name the cell is addressed by. |
| 960 | pub name: &'a str, |
| 961 | /// How much room it asks for. |
| 962 | pub width: Width, |
| 963 | /// What it is worth when room runs out. |
| 964 | pub priority: Priority, |
| 965 | |
| 966 | |
| 967 | |
| 968 | /// A column that absorbs slack and drops after the optional ones. |
| 969 | |
| 970 | pub const |
| 971 | Self |
| 972 | name, |
| 973 | width: Fill, |
| 974 | priority: Secondary, |
| 975 | |
| 976 | |
| 977 | |
| 978 | /// Whether this column survives at the given cutoff. |
| 979 | /// |
| 980 | /// A renderer narrows by raising the cutoff, and never by counting |
| 981 | /// positions. |
| 982 | |
| 983 | pub const |
| 984 | >= |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | use *; |
| 991 | |
| 992 | |
| 993 | |
| 994 | let = Raised.edges; |
| 995 | let = Inset.edges; |
| 996 | assert_eq!; |
| 997 | assert_eq!; |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | for b in |
| 1003 | assert_eq!; |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | // The bug this vocabulary exists to make unrepresentable. |
| 1010 | assert_eq!; |
| 1011 | assert_eq!; |
| 1012 | assert_eq!; |
| 1013 | assert_ne!; |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | // The reason State is its own axis and not a Depth member: a disabled |
| 1019 | // button and a disabled field are both disabled and are not the same |
| 1020 | // shape, which one shared variant could not have said. |
| 1021 | assert_eq!; |
| 1022 | assert_eq!; |
| 1023 | assert!; |
| 1024 | |
| 1025 | |
| 1026 | |
| 1027 | |
| 1028 | // Focus is a thing you can still click. Getting this backwards is how |
| 1029 | // a focus ring ends up on something inert. |
| 1030 | assert!; |
| 1031 | assert!; |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | |
| 1036 | // Neither needs a new token, so this costs no `makeover` release. |
| 1037 | assert_eq!; |
| 1038 | assert_eq!; |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | assert_eq!; |
| 1044 | assert_eq!; |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | // The one member carrying a fill without a bevel. A renderer that |
| 1050 | // assumes the two arrive together drops the fill silently, which is |
| 1051 | // exactly what makeover-webview did before 0.3.0. |
| 1052 | assert_eq!; |
| 1053 | assert_eq!; |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | // Both edgeless, and only one of them needs a colour. Collapsing them |
| 1059 | // is what left an unchosen tab unsayable. |
| 1060 | assert_eq!; |
| 1061 | assert_ne!; |
| 1062 | |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | // Authored in opposite directions: makeover derives surface-well by |
| 1067 | // inverting against the theme's content colour, while surface-sunken is |
| 1068 | // authored and may sit darker than raised. |
| 1069 | assert_ne!; |
| 1070 | assert_eq!; |
| 1071 | assert_eq!; |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | // The gap 0.3.0 closed. Before it, only `chosen` existed and the |
| 1077 | // unchosen option fell through to Flat at every renderer. |
| 1078 | for s in |
| 1079 | assert_ne! |
| 1080 | s.chosen, |
| 1081 | s.unchosen, |
| 1082 | "{s:?} cannot tell picked from unpicked" |
| 1083 | ; |
| 1084 | |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | // Tabs recede so the chosen one comes forward; a segment and a toggle |
| 1090 | // stand up so the chosen one is held in. That inversion is the whole |
| 1091 | // content of "picked" once colour is deferred, and it is why the three |
| 1092 | // are not one member with a flag. |
| 1093 | assert_eq!; |
| 1094 | assert_eq!; |
| 1095 | |
| 1096 | for s in |
| 1097 | assert_eq!; |
| 1098 | assert_eq!; |
| 1099 | // Held in is what pressing produces: one appearance, two reasons. |
| 1100 | assert_eq!; |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | assert_eq!; |
| 1107 | assert_eq! |
| 1108 | Raised.pressed.bevel, |
| 1109 | Raised.bevel.map |
| 1110 | ; |
| 1111 | // Only raised regions respond to being pressed. |
| 1112 | assert_eq!; |
| 1113 | assert_eq!; |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | assert_eq!; |
| 1119 | assert_eq!; |
| 1120 | assert_eq!; |
| 1121 | assert_eq!; |
| 1122 | // No value ever leaves this crate. |
| 1123 | for t in |
| 1124 | Light.token, |
| 1125 | Dark.token, |
| 1126 | Danger.token, |
| 1127 | Neutral.token, |
| 1128 | Focus.token, |
| 1129 | Disabled.token, |
| 1130 | ] |
| 1131 | assert!; |
| 1132 | assert! |
| 1133 | !t.chars.next.unwrap.is_ascii_digit, |
| 1134 | "{t} is a value" |
| 1135 | ; |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | // The one line that runs through all three apps' taxonomies. |
| 1142 | assert!; |
| 1143 | assert!; |
| 1144 | assert!; |
| 1145 | |
| 1146 | // A badge is a label, so giving it an edge would lie about it. |
| 1147 | assert_eq!; |
| 1148 | assert_eq!; |
| 1149 | |
| 1150 | // A latched chip wears the same shape a pressed one does. |
| 1151 | let chip = Chip ; |
| 1152 | assert_eq!; |
| 1153 | assert_eq!; |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | assert!; |
| 1159 | assert!; |
| 1160 | // A toast floats above the page; a banner rests in the flow. |
| 1161 | assert_eq!; |
| 1162 | assert_eq!; |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | for p in |
| 1168 | assert!; |
| 1169 | |
| 1170 | assert!; |
| 1171 | // Emphasis falls off down the row, and never rises again. |
| 1172 | assert_eq!; |
| 1173 | assert_eq!; |
| 1174 | assert_eq!; |
| 1175 | |
| 1176 | |
| 1177 | |
| 1178 | |
| 1179 | assert!; |
| 1180 | assert!; |
| 1181 | assert!; |
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | |
| 1186 | assert_eq!; |
| 1187 | assert_eq!; |
| 1188 | // The exception, and the whole folder semantic: the open tab joins its |
| 1189 | // pane rather than sinking away from it. |
| 1190 | assert_eq!; |
| 1191 | |
| 1192 | // A held-in segment is indistinguishable from a pressed raised one, |
| 1193 | // which is the economy the light model buys over a colour swap. |
| 1194 | assert_eq!; |
| 1195 | |
| 1196 | // A toggle stands alone; the other two are built out of parts that |
| 1197 | // touch. |
| 1198 | assert!; |
| 1199 | assert!; |
| 1200 | assert!; |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | assert_eq!; |
| 1206 | assert_eq!; |
| 1207 | for r in |
| 1208 | Band, |
| 1209 | Sidebar, |
| 1210 | Split, |
| 1211 | TabGroup, |
| 1212 | ] |
| 1213 | assert_eq!; |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | // The escape hatch is one member and stays one member. If a second |
| 1220 | // undescribed region ever appears, the description has started |
| 1221 | // conceding rather than deferring. |
| 1222 | for r in |
| 1223 | Band, |
| 1224 | Sidebar, |
| 1225 | Pane, |
| 1226 | Split, |
| 1227 | TabGroup, |
| 1228 | Modal, |
| 1229 | ] |
| 1230 | assert!; |
| 1231 | |
| 1232 | assert!; |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | // The app owns the contents, not the placement. An app that wants its |
| 1238 | // timeline in a well frames it in a Pane. |
| 1239 | assert_eq!; |
| 1240 | assert_eq!; |
| 1241 | |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | // The argument the member exists for: goingson's day-plan has to be |
| 1246 | // routable, or the description covers only the boring screens and the |
| 1247 | // interesting four need a second path beside the router. |
| 1248 | let day_plan = |
| 1249 | Band, |
| 1250 | Bespoke , |
| 1251 | Sidebar, |
| 1252 | ]; |
| 1253 | assert_eq!; |
| 1254 | assert_eq!; |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | let secret = new; |
| 1260 | assert!; |
| 1261 | assert!; |
| 1262 | |
| 1263 | assert!; |
| 1264 | // Nothing else is confidential, or the marker means nothing. |
| 1265 | for k in |
| 1266 | Text, |
| 1267 | Number, |
| 1268 | Textarea, |
| 1269 | Select, |
| 1270 | Checkbox, |
| 1271 | Hidden, |
| 1272 | ] |
| 1273 | assert!; |
| 1274 | |
| 1275 | |
| 1276 | // Only a checkbox carries its own label. |
| 1277 | assert!; |
| 1278 | assert!; |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | let mut f = new; |
| 1284 | assert!; |
| 1285 | f.error = Some; |
| 1286 | assert!; |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | let cols = |
| 1292 | Column |
| 1293 | name: "Title", |
| 1294 | width: Fill, |
| 1295 | priority: Essential, |
| 1296 | , |
| 1297 | Column |
| 1298 | name: "Due", |
| 1299 | width: Fixed, |
| 1300 | priority: Secondary, |
| 1301 | , |
| 1302 | Column |
| 1303 | name: "Estimate", |
| 1304 | width: Fixed, |
| 1305 | priority: Optional, |
| 1306 | , |
| 1307 | ]; |
| 1308 | |
| 1309 | // Widest: everything survives. |
| 1310 | assert_eq! |
| 1311 | cols.iter |
| 1312 | .filter |
| 1313 | .count, |
| 1314 | 3 |
| 1315 | ; |
| 1316 | // Narrower: the optional column goes first. |
| 1317 | let kept: = cols |
| 1318 | .iter |
| 1319 | .filter |
| 1320 | .map |
| 1321 | .collect; |
| 1322 | assert_eq!; |
| 1323 | // Narrowest: only what identifies the row. |
| 1324 | let kept: = cols |
| 1325 | .iter |
| 1326 | .filter |
| 1327 | .map |
| 1328 | .collect; |
| 1329 | assert_eq!; |
| 1330 | |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | // The bug the ordinal form has and this form cannot: goingson hides |
| 1335 | // `nth-child(n+5)` against a seven-column table, so a column inserted |
| 1336 | // anywhere to the left silently hides a different one. |
| 1337 | let before = |
| 1338 | new, |
| 1339 | Column |
| 1340 | name: "Estimate", |
| 1341 | width: Fixed, |
| 1342 | priority: Optional, |
| 1343 | , |
| 1344 | ]; |
| 1345 | let after = |
| 1346 | new, |
| 1347 | new, // inserted |
| 1348 | Column |
| 1349 | name: "Estimate", |
| 1350 | width: Fixed, |
| 1351 | priority: Optional, |
| 1352 | , |
| 1353 | ]; |
| 1354 | |
| 1355 | |
| 1356 | cols.iter |
| 1357 | .filter |
| 1358 | .map |
| 1359 | .collect |
| 1360 | |
| 1361 | assert_eq!; |
| 1362 | assert_eq!; |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | // goingson uses the tab group inside the content region rather than |
| 1368 | // instead of one, so it is not a third arrangement. |
| 1369 | let go = ListDetail ; |
| 1370 | let plain = ListDetail ; |
| 1371 | assert_ne!; |
| 1372 | assert_ne!; |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | // Two members and no third. If a skeleton ever appears in this enum, |
| 1378 | // the deferral rule has been broken. |
| 1379 | assert_ne!; |
| 1380 | |
| 1381 | |
| 1382 |