-
Notifications
You must be signed in to change notification settings - Fork 58
feat: Adds uui-button-copy-text #985
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
feat: Adds uui-button-copy-text #985
Conversation
npm run new-package
|
Hi there @warrenbuckley, thank you for this contribution! 👍 While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
|
I am open for discussion and feedback to improve this |
|
I may need some pointers or advice with the tests please @nielslyngsoe or @iOvergaard |
iOvergaard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I am not sure how to fix the tests. It says the browser asked for permission to copy but the user denied it, so we probably need Playwright to launch the browser with a special parameter to allow non-user interaction...?
Important to me is that we can use this inside the <umb-code-block> element in the Backoffice. Did you try and test it there yet?
Co-authored-by: Jacob Overgaard <[email protected]>
Co-authored-by: Jacob Overgaard <[email protected]>
…mbraco.UI into feature/uui-copy
…e tests minimal due to the permisions problem with the clipboard API running headless
I wouldn't know how to do that @iOvergaard as its over in the CMS repo, is there something I can do to try/test this out then? |
You can run |
… before this would work properly as it had not registered the webcoponents that it depends upon
I am not sure this is explicitly needed in my opinion @iOvergaard as the default slot can be swapped out, as shown in examples and screenshot of a story. <uui-input id="inputToCopy" placeholder="Type something">
<uui-copy copy-from="inputToCopy" slot="append" compact>
<uui-icon name="copy"></uui-icon>
</uui-copy>
</uui-input>Or <uui-copy value="Custom slot content">Custom Copy Text</uui-copy>
<uui-copy value="Different Icon"><uui-icon name=""></uui-icon> COPY ME</uui-copy> |
Flows the label prop down into the UUI-button for the aria-label for the uui-button used inside uui-copy
|
Ready for a re-review and see what you think @iOvergaard |
iOvergaard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally, this is exactly what we want to have. I have included some suggestions based on feedback from the team at HQ to optimize the package and the component even further. Please let me know if you would like to take it to the finish line or if we should take over.
|
A note off-topic regarding drag handle: I noticed one of these libraries had a copy button as well (as inspiration): Not sure how relevant it is, but some props can probably be inherited from |
|
|
@iOvergaard it would be great if we had a As the copy of color in color picker and this could share this feature 😊 and in copy from table cell:
In fact I think the can be replace with this component. |
|
@bjarnef Maybe, but do you think it is worth any effort to wrap the one-liner that is |
|
@iOvergaard it did a bit more here: https://github.com/Georgegriff/copy-component/blob/main/CopyComponent.js#L2C8-L9 but I think it is mainly for older browsers not supporting Perhaps I haven't checked what happens if copy fails though. Can we have something like this? E.g. in Nuxt/Vue and the example above in React use composables. I have seen similar hooks in various libraries, but not sure if they were built on Lit. Anyway I guess we could have a similar function returning |




Description
Adds a button to trigger copying content to the clipboard, by two approaches:
textproperty on uui-copy to contain the text content you want to copy to the clipboardcopy-fromproperty will look for HTML element with that ID and use the text contentvalueproperty then assume we want to get the value of an input field such as uui-inputNote
This is heavily inspired by Shoelace.style copy button
https://github.com/shoelace-style/shoelace/blob/next/src/components/copy-button/copy-button.component.ts
Types of changes
Motivation and context
How to test?
I believe the stories should cover some scenarios
Screenshots (if appropriate)
Checklist