mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
Dialog footer: Cancel is a ghost button beside the accent answer, as production (trial a_footer_cancel_is_a_ghost_button_beside_the_accent_answer)
This commit is contained in:
@@ -640,7 +640,9 @@ impl FooterBar {
|
||||
let variant = match button.role {
|
||||
DialogRole::Accept => Variant::PRIMARY,
|
||||
DialogRole::Destructive => Variant::DANGER,
|
||||
DialogRole::Cancel | DialogRole::Other | DialogRole::Alternative => Variant::SECONDARY,
|
||||
// Production shows Cancel as plain text beside the accented answer.
|
||||
DialogRole::Cancel => Variant::GHOST,
|
||||
DialogRole::Other | DialogRole::Alternative => Variant::SECONDARY,
|
||||
};
|
||||
let mut widget = Button::new(button.label.clone()).variant(variant).enabled(button.enabled).least_width(least);
|
||||
if column {
|
||||
|
||||
@@ -457,3 +457,20 @@ fn a_space_between_row_in_a_dialog_keeps_its_children_apart_at_both_edges() {
|
||||
let dialog = fixture.by_role(craft_ui::contract::Role::DIALOG).first().map(|d| d.rect).expect("the dialog is shown");
|
||||
assert!(dialog.max.x - remove.max.x < 40.0, "Remove sits at the row's end edge: {remove:?} in {dialog:?}");
|
||||
}
|
||||
|
||||
/// Production's dialogs show Cancel as plain text beside the accented answer: a footer's Cancel is a ghost button, not
|
||||
/// an outlined one.
|
||||
#[trial]
|
||||
fn a_footer_cancel_is_a_ghost_button_beside_the_accent_answer() {
|
||||
use craft_theme::Variant;
|
||||
let mut fixture = Fixture::new(|ui| {
|
||||
let _ = StandardPrompt::custom("Revert?")
|
||||
.button(craft_ui::dialog::PromptChoice::Proceed, "Revert")
|
||||
.button(craft_ui::dialog::PromptChoice::Cancel, "Cancel")
|
||||
.show(ui);
|
||||
});
|
||||
fixture.settle();
|
||||
let seen = fixture.styles_of(std::any::type_name::<craft_ui::buttons::Button<'static>>());
|
||||
assert!(seen.iter().any(|style| style.variant == Variant::GHOST), "Cancel is a ghost button: {:?}", seen.iter().map(|s| s.variant).collect::<Vec<_>>());
|
||||
assert!(!seen.iter().any(|style| style.variant == Variant::SECONDARY), "no outlined button in the footer");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user