Revisions card: the heading elides before the Accept and Reject buttons

The card's heading and buttons sat in two nested rows that a narrow pane
shrank evenly, so Reject was cut to an ellipsis. One row now holds the
change bar, the heading link filling the room the buttons leave and
eliding there, and the buttons at their whole width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-29 22:08:15 +00:00
1 parent 0f7dff8d63
commit a6a70f8d42
3 files changed
+42 -18

No files matched your search

+15 -18
View File
@@ -4,12 +4,12 @@ use craft_behavior::{Metrics, Sense};
use craft_theme::variant::Variant;
use craft_ui::buttons::{Button, Link};
use craft_ui::contract::{
Common, Component, Container, ContainerProps, Cx, MeasureCx, NoValue, Outcome, Pad, PaintUi, Pattern, Props, Role, RowAlign, Show as _,
ShowContainer as _, Sizing, clicked,
Common, Component, Container, ContainerProps, Cx, MeasureCx, NoValue, Outcome, Pad, PaintUi, Pattern, Props, Role, Show as _, ShowContainer as _,
Sizing, clicked,
};
use craft_ui::display::{Shade, Text};
use craft_ui::layout_components::{Row, Stack};
use craft_ui::primitives::PaintShape;
use craft_ui::primitives::{PaintShape, Wrap};
use craft_ui::runtime::env::{Env, Label};
use craft_ui::style::{ComponentStyle, StyleColor, StyleCx, SurfaceKind, TypeRole};
use egui::{CornerRadius, Response, Ui, Vec2};
@@ -97,21 +97,18 @@ impl<'a> RevisionsPanel<'a> {
RevisionKind::Changed => &words.changed,
};
RevisionCard::new().show(ui, |ui, _| {
Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
ChangeBar::new(kind.clone(), revision.kind).show(ui);
if clicked(&Link::new(revision.heading.clone()).show(ui)) {
actions.push(RevisionAction::Go(index));
}
});
Row::new().show(ui, |ui, _| {
if clicked(&Button::new(words.accept.clone()).variant(Variant::PRIMARY).show(ui)) {
actions.push(RevisionAction::Accept(index));
}
if clicked(&Button::new(words.reject.clone()).show(ui)) {
actions.push(RevisionAction::Reject(index));
}
});
// The heading takes the room the buttons leave and elides in it, so Accept and Reject stay whole.
Row::new().fill_width().show(ui, |ui, _| {
ChangeBar::new(kind.clone(), revision.kind).show(ui);
if clicked(&Link::new(revision.heading.clone()).wrap(Wrap::Elide).sizing(Sizing::FillWidth).show(ui)) {
actions.push(RevisionAction::Go(index));
}
if clicked(&Button::new(words.accept.clone()).variant(Variant::PRIMARY).show(ui)) {
actions.push(RevisionAction::Accept(index));
}
if clicked(&Button::new(words.reject.clone()).show(ui)) {
actions.push(RevisionAction::Reject(index));
}
});
for detail in revision.details.iter().take(DETAIL_LINES) {
Text::new(words.detail_line.fill(&[("detail", detail.as_str())])).role(TypeRole::Caption).shade(Shade::Muted).show(ui);
+1
View File
@@ -5,4 +5,5 @@ pub(crate) mod balloons;
pub(crate) mod collab;
pub(crate) mod comments;
pub(crate) mod note_popup;
pub(crate) mod revisions;
pub(crate) mod signature;
+26
View File
@@ -0,0 +1,26 @@
//! The Revisions panel's cards in a narrow pane.
use craft_review::ui::RevisionsPanel;
use craft_review::{Revision, RevisionKind};
use craft_ui::contract::Show as _;
use craft_ui::testing::{Fixture, trial};
use egui::{Rect, Vec2};
/// The bounds of the card's Reject button with the panel in a room `width` wide.
fn reject_in(width: f32) -> Rect {
let changes = vec![Revision { kind: RevisionKind::Inserted, heading: "Slide inserted after 1".into(), details: vec!["What we'll cover".into()] }];
let mut fixture = Fixture::new(move |ui| {
let _ = RevisionsPanel::new("Revisions", "Budget v2.pptx", &changes).show(ui);
});
fixture.room(Vec2::new(width, 400.0)).settle();
fixture.by_label("Reject").expect("the card's Reject button").rect
}
/// A heading too long for a narrow pane elides: the card's buttons keep their whole width.
#[trial]
fn a_long_heading_leaves_the_card_buttons_whole() {
let wide = reject_in(900.0);
let narrow = reject_in(220.0);
assert!(narrow.width() >= wide.width() - 0.5, "Reject keeps its width: {narrow:?} against {wide:?}");
assert!(narrow.right() <= 220.5, "Reject stays inside the pane: {narrow:?}");
}