Side-menu ink trial: the menu stands on Brand; a Chrome rail reads in text contrast

The port's side-menu ink follows the surface it stands on. The trial now stands its menu on SurfaceKind::Brand, as upstream's side menus do, with both assertions kept, and adds the port's case: on a chrome rail, in light and dark, the icon button takes the rows' ink and that ink reaches text contrast on the chrome.

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 15:18:56 +00:00
1 parent 4259eb1dd7
commit 3562f506fe
1 file changed
+30 -7
+30 -7
View File
@@ -963,10 +963,18 @@ fn a_side_menus_row_shows_the_standard_icon() {
}
/// An icon-only button in a side menu (WordCraft's Back arrow on the File rail) reads in the menu's ink, as a `Button`
/// row's icon does, not in the dark ghost ink that vanished on the brand surface; elsewhere it keeps its own ink.
/// row's icon does, not in the dark ghost ink that vanished on the brand surface; elsewhere it keeps its own ink. A side
/// menu reads in the ink of the surface it stands on: on a chrome rail (DeckCraft's File rail) that ink still reads
/// as text on the chrome.
#[trial]
fn a_side_menus_icon_button_reads_in_the_menus_ink() {
let rest = |side: bool, icon_only: bool| {
use craft_theme::{Contrast, Mode, Rgba, contrast_ratio, text_contrast_min};
use craft_ui::layout_components::Stack;
use craft_ui::style::SurfaceKind;
use craft_ui::testing::style::tokens;
// The button's rest icon ink in `mode`, inside a side menu when `side`, the menu standing on `surface` when given.
let rest = |surface: Option<SurfaceKind>, side: bool, icon_only: bool, mode: Mode| {
let mut fixture = Fixture::new(move |ui| {
let show = |ui: &mut Ui| {
if icon_only {
@@ -975,25 +983,40 @@ fn a_side_menus_icon_button_reads_in_the_menus_ink() {
let _ = Button::new("Print").icon(IconId::new("print")).variant(Variant::GHOST).show(ui);
}
};
let stand = |ui: &mut Ui| match surface {
Some(kind) => {
let _ = Stack::new().surface(kind).show(ui, |ui, _| show(ui));
}
None => show(ui),
};
if side {
with_env(
ui,
|overrides| {
overrides.values.set(ControlPlace::SideMenu);
},
show,
stand,
);
} else {
show(ui);
stand(ui);
}
});
fixture.settle();
fixture.theme(mode, Contrast::Standard).settle();
let kind = if icon_only { std::any::type_name::<IconButton<'static>>() } else { std::any::type_name::<Button<'static>>() };
let style = fixture.styles_of(kind).into_iter().next().expect("the button resolved its style");
style.looks.icons.first().expect("the button has an icon look").color.off.rest.egui()
};
assert_eq!(rest(true, true), rest(true, false), "the icon button takes the ink of the menu's rows");
assert_ne!(rest(true, true), rest(false, true), "outside a side menu it keeps its own ink");
let brand = Some(SurfaceKind::Brand);
assert_eq!(rest(brand, true, true, Mode::Light), rest(brand, true, false, Mode::Light), "the icon button takes the ink of the menu's rows");
assert_ne!(rest(brand, true, true, Mode::Light), rest(None, false, true, Mode::Light), "outside a side menu it keeps its own ink");
let chrome = Some(SurfaceKind::Chrome);
for mode in [Mode::Light, Mode::Dark] {
let ink = rest(chrome, true, true, mode);
assert_eq!(ink, rest(chrome, true, false, mode), "on a chrome rail the icon button takes the ink of the menu's rows in {mode:?}");
let ratio = contrast_ratio(Rgba(ink.to_array()), tokens(mode, Contrast::Standard).color.surface.chrome);
assert!(ratio >= text_contrast_min(Contrast::Standard), "a side menu on chrome reads at {ratio:.2} in {mode:?}");
}
}
/// The command the arrow trial's split button is bound to.