summaryrefslogtreecommitdiffstats
path: root/src/components/mod.rs
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-07-07 23:55:43 -0600
committerColin Reeder <colin@vpzom.click>2020-07-07 23:55:43 -0600
commitad306994f663550731f0c6a519f645b0d22cbc0a (patch)
tree4de1bd0a9e573702d00a08c2868ab41c10257774 /src/components/mod.rs
parente993e8615558507c49ee239cf5b60704ff77e1b5 (diff)
Disable action buttons when already performed (#47)
Diffstat (limited to 'src/components/mod.rs')
-rw-r--r--src/components/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 18f227c..2ffd97c 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -21,7 +21,7 @@ pub fn Comment<'comment, 'base_data>(
Some(render::rsx! {
<>
<form method={"POST"} action={format!("/comments/{}/like", comment.id)} style={"display: inline"}>
- <button r#type={"submit"}>{"Like"}</button>
+ <BoolSubmitButton value={comment.your_vote.is_some()} do_text={"Like"} done_text={"Liked"} />
</form>
<a href={format!("/comments/{}", comment.id)}>{"reply"}</a>
</>
@@ -272,3 +272,16 @@ pub fn MaybeFillTextArea<'a>(values: &'a Option<&'a serde_json::Value>, name: &'
</textarea>
}
}
+
+#[render::component]
+pub fn BoolSubmitButton<'a>(value: bool, do_text: &'a str, done_text: &'a str) {
+ if value {
+ render::rsx! {
+ <button disabled={""}>{done_text}</button>
+ }
+ } else {
+ render::rsx! {
+ <button type={"submit"}>{do_text}</button>
+ }
+ }
+}