feat(ui): implement invite link copy with feedback

Add copy-to-clipboard functionality for event invite links with
visual feedback. The copy button now uses the Clipboard API via
JavaScript eval to copy the link and displays a green checkmark
icon for 2 seconds on successful copy.
This commit is contained in:
mlackner 2025-11-21 00:13:49 +01:00
parent f351cd83e2
commit 1b5f820363
3 changed files with 34 additions and 1 deletions

View File

@ -1033,6 +1033,9 @@
.text-green-400 { .text-green-400 {
color: var(--color-green-400); color: var(--color-green-400);
} }
.text-green-500 {
color: var(--color-green-500);
}
.text-green-600 { .text-green-600 {
color: var(--color-green-600); color: var(--color-green-600);
} }

View File

@ -18,6 +18,8 @@ pub fn EventPage(id: i32) -> Element {
let mut edit_date = use_signal(|| false); let mut edit_date = use_signal(|| false);
let mut new_budget = use_signal(|| String::new()); let mut new_budget = use_signal(|| String::new());
let mut new_date = use_signal(|| String::new()); let mut new_date = use_signal(|| String::new());
let mut show_copy_feedback = use_signal(|| false);
let mut show_notification = use_signal(|| false);
let navigator = use_navigator(); let navigator = use_navigator();
let invite_link = use_memo(move || { let invite_link = use_memo(move || {
@ -76,12 +78,40 @@ pub fn EventPage(id: i32) -> Element {
button { button {
class: "p-2 text-slate-400 hover:text-white transition-colors", class: "p-2 text-slate-400 hover:text-white transition-colors",
title: "Kopieren", title: "Kopieren",
onclick: move |_| {
let link = link.clone();
async move {
let mut eval = document::eval(r#"
let link = await dioxus.recv();
try {
await navigator.clipboard.writeText(link);
return true;
} catch (e) {
console.error(e);
return false;
}
"#);
eval.send(link).unwrap();
if let Ok(serde_json::Value::Bool(true)) = eval.recv().await {
show_copy_feedback.set(true);
let mut eval = document::eval(r#"
await new Promise(resolve => setTimeout(resolve, 2000));
"#);
let _ = eval.await;
show_copy_feedback.set(false);
}
}
},
if show_copy_feedback() {
svg { class: "w-5 h-5 text-green-500", fill: "none", stroke: "currentColor", view_box: "0 0 24 24", path { stroke_linecap: "round", stroke_linejoin: "round", stroke_width: "2", d: "M5 13l4 4L19 7" } }
} else {
svg { class: "w-5 h-5", fill: "none", stroke: "currentColor", view_box: "0 0 24 24", path { stroke_linecap: "round", stroke_linejoin: "round", stroke_width: "2", d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" } } svg { class: "w-5 h-5", fill: "none", stroke: "currentColor", view_box: "0 0 24 24", path { stroke_linecap: "round", stroke_linejoin: "round", stroke_width: "2", d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" } }
} }
} }
} }
} }
} }
}
// Administrative Controls (only for admins) // Administrative Controls (only for admins)
if is_admin() { if is_admin() {

BIN
wichtl.db

Binary file not shown.