From 1b5f820363229a0436a7ac84c145682d1faf8590 Mon Sep 17 00:00:00 2001 From: mlackner Date: Fri, 21 Nov 2025 00:13:49 +0100 Subject: [PATCH] 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. --- assets/tailwind.css | 3 +++ src/views/event_page.rs | 32 +++++++++++++++++++++++++++++++- wichtl.db | Bin 36864 -> 36864 bytes 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/assets/tailwind.css b/assets/tailwind.css index 4775f83..4d805d3 100644 --- a/assets/tailwind.css +++ b/assets/tailwind.css @@ -1033,6 +1033,9 @@ .text-green-400 { color: var(--color-green-400); } + .text-green-500 { + color: var(--color-green-500); + } .text-green-600 { color: var(--color-green-600); } diff --git a/src/views/event_page.rs b/src/views/event_page.rs index 43c9cb4..c8f1a60 100644 --- a/src/views/event_page.rs +++ b/src/views/event_page.rs @@ -18,6 +18,8 @@ pub fn EventPage(id: i32) -> Element { let mut edit_date = use_signal(|| false); let mut new_budget = 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 invite_link = use_memo(move || { @@ -76,7 +78,35 @@ pub fn EventPage(id: i32) -> Element { button { class: "p-2 text-slate-400 hover:text-white transition-colors", title: "Kopieren", - 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" } } + 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" } } + } } } } diff --git a/wichtl.db b/wichtl.db index ba6f3bd2bc78af372c9963b89df174dfd59ab7dc..5de7bf2375815f787ce78073f6556470a7d34d32 100644 GIT binary patch delta 60 zcmZozz|^pSX@WGP!$cWpMu&|FUG|KLn_t_1@mEY_W#DAwWMNML(TvPY?D1d*6Ej;J Jkip5w0s!r}3)27q delta 60 zcmZozz|^pSX@WGP%|sbzMw^WZUG|KTn_t_1@mGvwW#DAwWMPj0(TvP2?BQSr6Ej;F Jkip5w1OVuc3!?x4