feat(example): Copy svg to clipboard #4
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks a bunch for developing this super fun library. While using your repo's example app for a recent project of mine I needed to copy the drawn svg element into Sketch to build out a design.
I thought it'd be super handy to have a copy to clipboard button so that you can copy and paste directly into a design tool like Figma/Sketch. Check out a gif below.
I tried to make the feature code idiomatic of how you've been building it using your state library (a neat little rabbit hole of investigation) while making sure not to add any extra dependencies.
I wasn't sure precisely whether I could include the async util fn for clipboard copying to the createState object. First I tried simply putting it an
action
but the proxy to the data was revoked. I then tried using the asyncs example in the docs, but couldn't figure out how to directly invoke the async function usingon
event chains.So, I settled on just dispatching the action after the async clipboard utility returned the appropriate message.
I also created a small accessible alert component for letting the user know the result of the copy request. It color adjusts appropriately for light and dark mode.
Hopefully this might be of interest for adding to the example, let me know. If not, thanks again for building these libraries. 👍