Skip to main content

max / makeover-layout

Say what a row part is worth when the run does not fit RowPart::priority, the default only: a part may say otherwise and a renderer reads the part. This is what a description that has never heard of Priority means, which is every description written before the field existed. Deriving it from the role is the thing this vocabulary has otherwise been moving away from, and it is right here for one reason: the roles already encode this ranking and every consumer already assumes it. Priority::Essential's own doc was written about the primary -- "without it the row does not identify itself" -- before anything read it that way. Actions is Essential and is the interesting one. A control is not a fact, so dropping it does not cost the reader a detail; it costs them the only way to act on the row, and in a terminal it silently removes something focus has already been claimed for. Room comes out of what a row says, never out of what it offers. An unknown member reads as Secondary. Guessing Optional for something this crate has not been taught would make a new member the first thing to vanish.
Author: Max Johnson <me@maxj.phd> · 2026-08-18 00:28 UTC
Signed with PGP, not checked
Commit: 34af86506add0e70660790752c0829a3b199d48e
Parent: 33a6add
2 files changed, +50 insertions, -1 deletion
M Cargo.toml +1 -1
@@ -1,6 +1,6 @@
1 1 [package]
2 2 name = "makeover-layout"
3 - version = "0.28.1"
3 + version = "0.28.2"
4 4 edition = "2024"
5 5 # One copy of this vocabulary per dependency graph, enforced by cargo rather
6 6 # than by remembering. Two versions of a description layer in one build means
M src/lib.rs +49
@@ -1092,6 +1092,39 @@
1092 1092 }
1093 1093
1094 1094 impl RowPart {
1095 + /// What the part is worth when the run does not fit.
1096 + ///
1097 + /// The default only. A part may say otherwise, and a renderer reads the
1098 + /// part rather than the role; this is what a description that has never
1099 + /// heard of [`Priority`] means, which is every description written before
1100 + /// the field existed.
1101 + ///
1102 + /// Deriving it from the role is the thing this vocabulary has otherwise
1103 + /// been moving away from, and it is right here for one reason: the roles
1104 + /// already encode this ranking and every consumer already assumes it.
1105 + /// [`Primary`](Self::Primary) is what the row is called, and
1106 + /// [`Priority::Essential`]'s own doc was written about exactly that --
1107 + /// "without it the row does not identify itself".
1108 + ///
1109 + /// [`Actions`](Self::Actions) is `Essential` and it is the interesting one.
1110 + /// A control is not a fact, so dropping it does not cost the reader a
1111 + /// detail; it costs them the only way to act on the row, and in a terminal
1112 + /// it silently removes something focus had already been claimed for. A
1113 + /// renderer that needs room takes it from what the row *says*, never from
1114 + /// what it *offers*.
1115 + ///
1116 + /// An unknown member reads as [`Priority::Secondary`]: droppable, but not
1117 + /// first, since guessing `Optional` for something this crate has not been
1118 + /// taught would make a new member the first thing to vanish.
1119 + #[must_use]
1120 + pub const fn priority(self) -> Priority {
1121 + match self {
1122 + Self::Primary | Self::Actions => Priority::Essential,
1123 + Self::Meta | Self::Proportion => Priority::Optional,
1124 + _ => Priority::Secondary,
1125 + }
1126 + }
1127 +
1095 1128 /// The content intent the part takes.
1096 1129 #[must_use]
1097 1130 pub const fn intent(self) -> &'static str {
@@ -5056,6 +5089,22 @@
5056 5089 assert_eq!(Paging::more(500).of(400).remaining(), Some(0));
5057 5090 }
5058 5091
5092 + #[test]
5093 + fn a_role_says_what_a_part_is_worth_when_the_run_does_not_fit() {
5094 + // The row still identifies itself after everything droppable has gone,
5095 + // which is the property the ladder exists for.
5096 + assert_eq!(RowPart::Primary.priority(), Priority::Essential);
5097 + // A control is not a fact. Room comes out of what the row says, never
5098 + // out of what it offers.
5099 + assert_eq!(RowPart::Actions.priority(), Priority::Essential);
5100 + assert_eq!(RowPart::Meta.priority(), Priority::Optional);
5101 + assert_eq!(RowPart::Proportion.priority(), Priority::Optional);
5102 + assert_eq!(RowPart::Secondary.priority(), Priority::Secondary);
5103 + // Tokens sit in the middle deliberately: a toned badge is often the
5104 + // most scannable thing in a row, so it does not go first.
5105 + assert_eq!(RowPart::Tokens.priority(), Priority::Secondary);
5106 + }
5107 +
5059 5108 #[test]
5060 5109 fn a_run_is_one_line_unless_the_description_says_two() {
5061 5110 // The default is what every part did before flows existed, so a