forked from eclipse-opendut/opendut
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue-289: add toast for clipboard copy button
- Loading branch information
Showing
10 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use leptos::{create_action, window, Action}; | ||
use crate::components::{use_toaster, Toast}; | ||
|
||
pub fn copy_with_feedback() -> Action<String, ()> { | ||
create_action(move |clipboard_text: &String| { | ||
let toaster = use_toaster(); | ||
let test = clipboard_text.clone(); | ||
async move { | ||
let clipboard = window().navigator().clipboard(); | ||
let clipboard_promise = clipboard.write_text(&test); | ||
match wasm_bindgen_futures::JsFuture::from(clipboard_promise).await { | ||
Ok(_) => { | ||
toaster.toast( | ||
Toast::builder() | ||
.simple("Successfully copied Setup-String.") | ||
.success(), | ||
); | ||
} | ||
Err(_) => { | ||
toaster.toast( | ||
Toast::builder() | ||
.simple("Error while copying Setup-String.") | ||
.error(), | ||
); | ||
} | ||
}; | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ pub fn join_with_comma_spans(elements: Vec<View>) -> Vec<View> { | |
} | ||
} | ||
elements_with_separator | ||
} | ||
} |