Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize what is going to be copied / Copy everything together #189

Open
italodeandra opened this issue Apr 4, 2021 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@italodeandra
Copy link

Hi team,

First of all, thanks for the library. I'm already a "helper" of Zustand and Valtio, so I really look forward to everything you guys make.

Leva looks really promising, and I'm currently using it on a documentation project I have. So for my use case, instead of copy the JSON of the object, I would like to customize is to return a JSX.

await navigator.clipboard.writeText(JSON.stringify({ [key]: value ?? '' }))

I already understand how it works, but first I would like to know if you are open for PR so for that I'll first share my thoughts.


Customize what is going to be copied

The first feature I want to implement is to pass a function to the input called copy that will receive the same object that is transformed to JSON and what the function returns will be what is copied to the clipboard.

Copy everything together

Add the copy button on the left of the filter. If you click it will copy the entire object that is configured (except the disabled). And if you pass the same function copy to the Leva component, it will have the same behavior as the previous functionality.

I'll also hide it if hideCopyButton is true.


Let me know what you guys think.

italodeandra added a commit to italodeandra/leva that referenced this issue Apr 4, 2021
@italodeandra
Copy link
Author

I already started a POC with both implementations. You can check it on my fork:

italodeandra@4a4c23e

@dbismut
Copy link
Collaborator

dbismut commented Apr 5, 2021

@italodeandra Oh nice! I like the idea. Do you mind creating a PR (even as a draft), so that we can benefit from the CI?

@italodeandra
Copy link
Author

Hey @dbismut,

Just did, you can check it here #193. I hope I didn't break anything, but let me know what needs to be changed.

@dbismut dbismut added the enhancement New feature or request label Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants