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 ba6f3bd..5de7bf2 100644 Binary files a/wichtl.db and b/wichtl.db differ