Draw a people-panel nick whole, shrinking it to fit
The panel is `users-width` wide and every row in it is a 14-point mode slot and a nick, so a domain-shaped handle ran past what was left. Cut short it came out as "chadfowler.c…", and two people with the same first eleven letters are the same person to a reader; wrapped, the lozenge stopped reading as a button. So the type size is what gives instead: `:whole-label` puts the label in a FittedBox, measured on one unbounded line and scaled down only by as much as the width demands, so a nick that already fits is drawn at t/text-body like every other label and only the long ones shrink. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
68c21c7 parent: c67777a modified
common/frq/screens/chat.cljc +7 -1 | @@ -1126,7 +1126,13 @@ | ||
| 1126 | 1126 | ;; the names line up whatever mode is in front of them. |
| 1127 | 1127 | [:vbox {:key :mode :width-request 14} |
| 1128 | 1128 | [:dim-label {:label (if (seq prefix) prefix " ")}]] |
| 1129 | - [:button {:label nick :on-click #(actions/open-dm! nick)}]]) | |
| 1129 | + ;; `:whole-label`, because a nick is the whole point of this row: the panel | |
| 1130 | + ;; is `users-width` wide and a domain-shaped handle is wider than what is | |
| 1131 | + ;; left of it beside the mode slot, so ending it at the edge leaves two | |
| 1132 | + ;; people looking like the same person. Where it does not fit it is drawn | |
| 1133 | + ;; smaller, on the one line, rather than cut short or broken in two. | |
| 1134 | + [:button {:label nick :whole-label true | |
| 1135 | + :on-click #(actions/open-dm! nick)}]]) | |
| 1130 | 1136 | |
| 1131 | 1137 | (defn users-panel |
| 1132 | 1138 | "Who is in the channel, beside the conversation. |
| @@ -1126,7 +1126,13 @@ | |||
| 1126 | ;; the names line up whatever mode is in front of them. | 1126 | ;; the names line up whatever mode is in front of them. |
| 1127 | [:vbox {:key :mode :width-request 14} | 1127 | [:vbox {:key :mode :width-request 14} |
| 1128 | [:dim-label {:label (if (seq prefix) prefix " ")}]] | 1128 | [:dim-label {:label (if (seq prefix) prefix " ")}]] |
| 1129 | - [:button {:label nick :on-click #(actions/open-dm! nick)}]]) | 1129 | + ;; `:whole-label`, because a nick is the whole point of this row: the panel |
| 1130 | + ;; is `users-width` wide and a domain-shaped handle is wider than what is | ||
| 1131 | + ;; left of it beside the mode slot, so ending it at the edge leaves two | ||
| 1132 | + ;; people looking like the same person. Where it does not fit it is drawn | ||
| 1133 | + ;; smaller, on the one line, rather than cut short or broken in two. | ||
| 1134 | + [:button {:label nick :whole-label true | ||
| 1135 | + :on-click #(actions/open-dm! nick)}]]) | ||
| 1130 | 1136 | ||
| 1131 | (defn users-panel | 1137 | (defn users-panel |
| 1132 | "Who is in the channel, beside the conversation. | 1138 | "Who is in the channel, beside the conversation. |
modified
flutter/src/frq/hiccup.cljd +26 -9 | @@ -560,15 +560,32 @@ | ||
| 560 | 560 | ;; It only ever comes up because `flexed` below hands a |
| 561 | 561 | ;; button a bounded width — unbounded, this changes |
| 562 | 562 | ;; nothing. |
| 563 | - .child (m/Text (str (:label p "")) | |
| 564 | - .maxLines 1 | |
| 565 | - .softWrap false | |
| 566 | - .overflow m/TextOverflow.ellipsis | |
| 567 | - .style (m/TextStyle | |
| 568 | - .fontSize t/text-body | |
| 569 | - .color fg | |
| 570 | - .height 1.35 | |
| 571 | - .fontWeight m/FontWeight.w500))))))) | |
| 563 | + ;; | |
| 564 | + ;; Unless the caller says the label is the whole point, | |
| 565 | + ;; and then it is the type size that gives instead. The | |
| 566 | + ;; people panel is where that is true: it is a column of | |
| 567 | + ;; nicks, and "chadfowler.c…" and "chadfowler.co…" are | |
| 568 | + ;; the same word to a reader — a name a point or two | |
| 569 | + ;; smaller is still a name, and a name cut short is not. | |
| 570 | + ;; `:whole-label` puts the text in a FittedBox, which | |
| 571 | + ;; measures it on one unbounded line and scales it down | |
| 572 | + ;; only by as much as the width it was given demands: a | |
| 573 | + ;; nick that already fits is drawn at t/text-body like | |
| 574 | + ;; every other, so a short column does not shrink. | |
| 575 | + .child (let [lbl (m/Text (str (:label p "")) | |
| 576 | + .maxLines 1 | |
| 577 | + .softWrap false | |
| 578 | + .overflow m/TextOverflow.ellipsis | |
| 579 | + .style (m/TextStyle | |
| 580 | + .fontSize t/text-body | |
| 581 | + .color fg | |
| 582 | + .height 1.35 | |
| 583 | + .fontWeight m/FontWeight.w500))] | |
| 584 | + (if (:whole-label p) | |
| 585 | + (m/FittedBox .fit m/BoxFit.scaleDown | |
| 586 | + .alignment m/Alignment.centerLeft | |
| 587 | + .child lbl) | |
| 588 | + lbl))))))) | |
| 572 | 589 | |
| 573 | 590 | ;; ----------------------------------------------------------------- widget |
| 574 | 591 | |
| @@ -560,15 +560,32 @@ | |||
| 560 | ;; It only ever comes up because `flexed` below hands a | 560 | ;; It only ever comes up because `flexed` below hands a |
| 561 | ;; button a bounded width — unbounded, this changes | 561 | ;; button a bounded width — unbounded, this changes |
| 562 | ;; nothing. | 562 | ;; nothing. |
| 563 | - .child (m/Text (str (:label p "")) | 563 | + ;; |
| 564 | - .maxLines 1 | 564 | + ;; Unless the caller says the label is the whole point, |
| 565 | - .softWrap false | 565 | + ;; and then it is the type size that gives instead. The |
| 566 | - .overflow m/TextOverflow.ellipsis | 566 | + ;; people panel is where that is true: it is a column of |
| 567 | - .style (m/TextStyle | 567 | + ;; nicks, and "chadfowler.c…" and "chadfowler.co…" are |
| 568 | - .fontSize t/text-body | 568 | + ;; the same word to a reader — a name a point or two |
| 569 | - .color fg | 569 | + ;; smaller is still a name, and a name cut short is not. |
| 570 | - .height 1.35 | 570 | + ;; `:whole-label` puts the text in a FittedBox, which |
| 571 | - .fontWeight m/FontWeight.w500))))))) | 571 | + ;; measures it on one unbounded line and scales it down |
| 572 | + ;; only by as much as the width it was given demands: a | ||
| 573 | + ;; nick that already fits is drawn at t/text-body like | ||
| 574 | + ;; every other, so a short column does not shrink. | ||
| 575 | + .child (let [lbl (m/Text (str (:label p "")) | ||
| 576 | + .maxLines 1 | ||
| 577 | + .softWrap false | ||
| 578 | + .overflow m/TextOverflow.ellipsis | ||
| 579 | + .style (m/TextStyle | ||
| 580 | + .fontSize t/text-body | ||
| 581 | + .color fg | ||
| 582 | + .height 1.35 | ||
| 583 | + .fontWeight m/FontWeight.w500))] | ||
| 584 | + (if (:whole-label p) | ||
| 585 | + (m/FittedBox .fit m/BoxFit.scaleDown | ||
| 586 | + .alignment m/Alignment.centerLeft | ||
| 587 | + .child lbl) | ||
| 588 | + lbl))))))) | ||
| 572 | 589 | ||
| 573 | ;; ----------------------------------------------------------------- widget | 590 | ;; ----------------------------------------------------------------- widget |
| 574 | 591 | ||