generated from metakgp/README.md
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use toast.promise and chirag's styling (#38)
* feat: use toast.promise and chirag's styling * yeet: yeet return
- Loading branch information
1 parent
fdfa875
commit 374866d
Showing
2 changed files
with
7 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { toast } from 'solid-toast'; | ||
|
||
export async function copyLink(e: Event, link: string) { | ||
export function copyLink(e: Event, link: string) { | ||
e.preventDefault(); | ||
|
||
try { | ||
await navigator.clipboard.writeText(link); | ||
toast('Link copied to clipboard.'); | ||
} catch (e) { | ||
toast('Error copying link to the clipboard.', { | ||
className: "toast toast-err" | ||
}); | ||
} | ||
toast.promise(navigator.clipboard.writeText(link), { | ||
loading: "Copying link to clipboard...", | ||
success: "Link copied to clipboard.", | ||
error: "Failed to copy link to clipboard." | ||
}) | ||
} |