From 1a45839699b100e5ec1f8216150a80500c5ca75b Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Tue, 25 Aug 2026 20:25:49 +0200 Subject: [PATCH] Alternative.disabled: announced but not yet takeable The button renders disabled (title 'Not yet') and submit_answer refuses the alternative server-side - lysbue's disabled flag, back as content, for advertising a path before it works. Co-Authored-By: Claude Fable 5 --- src/app.rs | 15 ++++++++++++++- src/content.rs | 5 +++++ style/main.css | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 43ec1c8..6bcdb70 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1177,7 +1177,17 @@ fn AlternativeCard( children=move |e| view! {

{e}

} /> - {if is_gateway { + {if alternative.disabled { + // Advertised, not yet takeable: the label + // stays (it says what will be possible), + // the button doesn't act. + view! { + + } + .into_any() + } else if is_gateway { let href = alternative.action.clone().unwrap_or_default(); view! { {button_label.clone()} @@ -1860,6 +1870,9 @@ pub async fn submit_answer( .iter() .find(|a| a.name == alternative) .ok_or_else(|| ServerFnError::new("unknown alternative"))?; + if alt.disabled { + return Err(ServerFnError::new("this alternative isn't open yet")); + } let next = alt.action.clone(); let record_as = alt.record_as.clone(); diff --git a/src/content.rs b/src/content.rs index 10fe99f..2652e8f 100644 --- a/src/content.rs +++ b/src/content.rs @@ -111,6 +111,11 @@ pub struct Alternative { pub description: String, #[serde(default)] pub action: Option, + /// Shown but not takeable yet - the button renders disabled and the + /// server refuses the submission. For advertising a path before it + /// works (lysbue had the same flag). + #[serde(default)] + pub disabled: bool, #[serde(default)] pub consequence: Vec, #[serde(default)] diff --git a/style/main.css b/style/main.css index d1bfae1..b74c2c3 100644 --- a/style/main.css +++ b/style/main.css @@ -675,6 +675,13 @@ textarea:focus { cursor: wait; } +/* A content-disabled alternative (`disabled: true`): announced, not + yet takeable - reads as a promise, not as a stuck form. */ +.alt-submit.soon:disabled { + cursor: not-allowed; + opacity: 0.6; +} + .gate-card { text-align: center; }