ui-panels footer: DialogButtonLook::Filled shows Cancel, Other, Alternate and Alternative as the filled neutral button (buttons::FILLED, now public: surface.control with no edge, state.hover under the pointer) beside the accented answer. Footer story and trial under Filled

This commit is contained in:
bflatastic
2026-11-24 19:38:28 +07:00
parent 7cb5edfda4
commit 34e96f9325
4 changed files with 44 additions and 6 deletions
+9 -3
View File
@@ -392,6 +392,9 @@ pub enum DialogButtonLook {
/// PdfCraft's: Cancel and an Alternate answer (Don't Save, No) are plain text (the ghost look) beside the accented
/// accepting button, as production's prompts show them.
Quiet,
/// VectorCraft's: every button but the accepting and the destructive one is a filled neutral tile with no edge
/// (`buttons::FILLED`).
Filled,
}
/// What a dialog button means; it decides the button's look and its place in the row.
@@ -719,7 +722,7 @@ impl FooterBar {
let armed_for = Env::of(&*ui).get::<ArmedFor>().0;
let default_at = buttons.iter().position(|button| button.role == DialogRole::Accept && button.live(armed_for));
let least = if column { LeastWidth::DialogSideButton } else { LeastWidth::DialogButton };
let quiet = Env::of(ui).get::<DialogButtonLook>() == DialogButtonLook::Quiet;
let look = Env::of(ui).get::<DialogButtonLook>();
let place = |ui: &mut Ui, shown: &mut Shown| {
for at in display_order(&roles, os == Os::Windows, column) {
let button = &buttons[at];
@@ -727,8 +730,11 @@ impl FooterBar {
DialogRole::Accept => Variant::PRIMARY,
DialogRole::Destructive => Variant::DANGER,
// Production shows Cancel and Don't Save as plain text beside the accented answer.
DialogRole::Cancel | DialogRole::Alternate if quiet => Variant::GHOST,
DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => Variant::SECONDARY,
DialogRole::Cancel | DialogRole::Alternate if look == DialogButtonLook::Quiet => Variant::GHOST,
DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => match look {
DialogButtonLook::Filled => crate::buttons::FILLED,
DialogButtonLook::Standard | DialogButtonLook::Quiet => Variant::SECONDARY,
},
};
let live = button.live(armed_for);
let mut widget = Button::new(button.label.clone()).variant(variant).enabled(live).least_width(least);
@@ -1,8 +1,9 @@
//! Stories of the footer actions.
use super::{DropAction, FooterAction, FooterBar};
use super::{DialogButtonLook, DialogRole, DropAction, FooterAction, FooterBar, FooterButton};
use crate::buttons::IconButton;
use crate::contract::{PopupKind, Props as _, Show as _, ShowContainer as _};
use crate::runtime::env::with_env;
use crate::story_kit::sample::words;
use crate::testing::{Drive, StoryData, StoryOutput, story};
use craft_behavior::IconId;
@@ -24,6 +25,25 @@ fn footer_actions(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
FooterBar::actions(actions).show_footer(ui).into()
}
/// The dialog buttons of an app that sets `DialogButtonLook::Filled` at its root: Cancel, the Alternate answer and
/// another outcome are filled neutral tiles with no edge beside the accented OK, at rest, under the pointer and pressed.
#[story(FooterBar, covers = [], drive = Drive::Never, title = "Filled dialog buttons")]
fn footer_filled_buttons(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
let buttons = [
FooterButton::new("Reset", DialogRole::Other),
FooterButton::new("Don't Save", DialogRole::Alternate),
FooterButton::new("Cancel", DialogRole::Cancel),
FooterButton::new("OK", DialogRole::Accept),
];
with_env(
ui,
|overrides| {
overrides.values.set(DialogButtonLook::Filled);
},
|ui| FooterBar::buttons(buttons).show_footer(ui).into(),
)
}
#[story(DropAction<u8>, covers = [Default], drive = Drive::Never)]
fn drop_action(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
DropAction::new(|_: &u8| true)
+11
View File
@@ -738,6 +738,17 @@ fn a_footer_cancel_is_a_ghost_button_beside_the_accent_answer() {
assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}");
}
/// VectorCraft's dialogs (`DialogButtonLook::Filled`) show Cancel and Don't Save as filled neutral tiles beside the
/// accented answer, not as outlines.
#[trial]
fn a_footer_cancel_is_a_filled_button_beside_the_accent_answer() {
use craft_theme::Variant;
let seen = footer_variants(Some(craft_ui::sections::DialogButtonLook::Filled));
assert!(seen.contains(&craft_ui::buttons::FILLED), "Cancel is a filled button: {seen:?}");
assert!(seen.contains(&Variant::PRIMARY), "Save is the accented button: {seen:?}");
assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}");
}
/// The left edges of a Save anyway / Save as… / Cancel prompt's buttons on Linux, with the Alternate's role set to
/// `role` when it names one.
fn alternate_edges(role: Option<DialogRole>) -> (f32, f32, f32) {
+3 -2
View File
@@ -91,8 +91,9 @@ pub enum PushButtonLook {
Filled,
}
/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`].
pub(crate) const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral);
/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`]: `surface.control` with no edge at
/// rest.
pub const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral);
/// The variant a push or split button that asks for none takes in `env` (`Component::default_variant`): the filled one
/// under [`PushButtonLook::Filled`], outside a ribbon.