-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
feature: copyable
field option
#3468
Conversation
Code Climate has analyzed commit ecab4d5 and detected 0 issues on this pull request. View more on Code Climate. |
We changed quite a lot in existing components or added new ones. Should we cover those changes with specs? |
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.
Thank you for all your effort here, @Nevelito!
I've been testing it locally, and it's already working as expected.
Let's make some visual adjustments and apply the same design used in the Docs (check it here).
Specifically:
- Display the empty clipboard on hover, without the text.
- After a click, display the same clipboard with a checkmark inside it.
Later, we could add a title to the icon and display it on hover.
I've also included some comments about the code.
Let me know if you have any questions.
app/components/avo/fields/country_field/index_component.html.erb
Outdated
Show resolved
Hide resolved
Let's do a system spec at the end that tests the copyable functionality, not component specific. |
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.
Let's use the configurations that https://www.stimulus-components.com/docs/stimulus-clipboard already supports
setTimeout(() => { | ||
this.iconTarget.classList.remove('hidden') | ||
this.iconCopiedTarget.classList.add('hidden') | ||
}, 2000) |
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.
I think this can be configured with data-clipboard-success-duration-value
From: https://www.stimulus-components.com/docs/stimulus-clipboard
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.
It is not that easy, It works with data-clipboard-success-content-value (this work only with plain text) , we want to show another object so we can not probably use data-clipboard-success-duration-value. I tried use that but it do not work.
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.
Thank you for this contribution @Nevelito it's looking great!
I just pushed some commits to complete the PR.
TODO:
|
Description
The
copyable
option enables users to copy the field's value to their clipboard. When set totrue
, a clipboard icon appears when hovering over the field value, allowing easy copying. This feature can be particularly useful for fields such as unique identifiers, URLs, or other text-based content that users may frequently need to copy.Fixes #2769
copyable.mp4
Checklist: