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

Add copy to clipboard functionality #182

Merged
merged 3 commits into from
Apr 13, 2020
Merged

Add copy to clipboard functionality #182

merged 3 commits into from
Apr 13, 2020

Conversation

XhmikosR
Copy link
Member

@XhmikosR XhmikosR commented Mar 25, 2020

TODO:

  • change btn-clipboard text on success
  • figure out how to handle the error case
  • maybe move inline JS to a common file
  • make sure the SCSS changes are fine

Fixes #3.

Preview: https://deploy-preview-182--bootstrap-icons.netlify.com/

@XhmikosR XhmikosR added the docs Improvements or additions to documentation label Mar 25, 2020
@XhmikosR XhmikosR mentioned this pull request Mar 25, 2020
@XhmikosR XhmikosR force-pushed the xmr-copy-to-clipboard branch 4 times, most recently from 883c6e9 to dedf297 Compare March 31, 2020 08:52
@XhmikosR
Copy link
Member Author

I made some progress. Basically the only thing left is how to handle the error case. The error message is big and won't look good if we use it as the button's text.

Any ideas welcome 🙂

@XhmikosR
Copy link
Member Author

@mdo: thoughts?

@mdo
Copy link
Member

mdo commented Apr 1, 2020

Looks good when it works! What's the long error message we have, and can it be shortened?

@XhmikosR
Copy link
Member Author

XhmikosR commented Apr 2, 2020

What do you mean with "When it works"? When doesn't it work for you? :)

The error message is https://github.com/twbs/icons/pull/182/files#diff-421b283055e51a6d67742686e9fdc865R88

In this case, I was thinking maybe just select the code and don't show any error. Or we have a new paragraph/div bellow the snippet and we show it in case of an error?

You can experiment with this by changing the error handler https://github.com/twbs/icons/pull/182/files#diff-421b283055e51a6d67742686e9fdc865R86 to success temporarily and clicking the copy button

@XhmikosR
Copy link
Member Author

XhmikosR commented Apr 5, 2020

I pushed a patch for the error case. To try it, just change clipboard.on('error' to clipboard.on('success'

@MartijnCuppens
Copy link
Member

Do we still need Clipboard.js? Can't we just rely on native js?

@XhmikosR
Copy link
Member Author

XhmikosR commented Apr 5, 2020 via email

@XhmikosR XhmikosR marked this pull request as ready for review April 10, 2020 06:19
@XhmikosR XhmikosR added this to Inbox in v1.0.0-alpha4 via automation Apr 10, 2020
@XhmikosR XhmikosR merged commit ee909ff into master Apr 13, 2020
v1.0.0-alpha4 automation moved this from Inbox to Done Apr 13, 2020
@XhmikosR XhmikosR deleted the xmr-copy-to-clipboard branch April 13, 2020 18:18
@bastienmoulia
Copy link
Contributor

Big fan of the feature, but not the current UI.

Can't find it at first because it's over the code:

image

@XhmikosR
Copy link
Member Author

I guess we could try showing when copying over the SVGs. PRs welcome and please open a new issue to track the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
No open projects
v1.0.0-alpha4
  
Done
Development

Successfully merging this pull request may close these issues.

Copy to clipboard
4 participants