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

Added Copy Image Functionality and added icons to buttons #124

Merged
merged 8 commits into from
Feb 9, 2023

Conversation

max-programming
Copy link
Contributor

This PR adds a copy button that copies the image to the clipboard and also shows a toast if it's copied or not.

Unfortunately copying images does not work on Firefox

@vercel
Copy link

vercel bot commented Jan 1, 2023

@max-programming is attempting to deploy a commit to the Github Contributions Chart Team on Vercel.

A member of the Team first needs to authorize it.

@max-programming max-programming changed the title Added Copy Image Functionality Added Copy Image Functionality and added icons to buttons Jan 1, 2023
@max-programming
Copy link
Contributor Author

With the latest commit, this is how the buttons look like
image

@vercel
Copy link

vercel bot commented Jan 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
github-contributions-chart ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 29, 2023 at 3:24PM (UTC)

Copy link
Owner

@sallar sallar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There is an issue in Safari though:

Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Can we check why this happens?

@max-programming
Copy link
Contributor Author

@sallar I think that happens because most probably it's not supported on Safari as well.

toast("🎉 Copied image!");
console.log("copied successfully");
} else {
toast("Sorry, copying image is not supported on this browser");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can fallback to this solution: https://copee.ceriously.com

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. Thanks

Copy link
Contributor Author

@max-programming max-programming Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle Does copee helps with copying images to clipboard? Or just text?
Or do you want me to change this and use try...catch instead

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sallar Check it now

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven’t tried with an image blob but I suspect it won’t work now that I think about it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@max-programming @styfle I think it's not that it's not supported, the issue is that the time delay between the click and the copy call is too long and safari blocks it, the blob needs to be ready when the user clicks the button

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IconDownload,
IconShare,
IconBrandTwitter
} from "@tabler/icons";
Copy link

@styfle styfle Jan 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there a lot of icons in this package?

This could cause the bundle to include every icon.

See https://nextjs.org/blog/next-13-1#import-resolution-for-smaller-bundles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look if I can make the change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle I can't find another way to import these icons. Would you like to use a different icon library instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the react-icons library which seems more performant. (Using Tabler Icons under the hood)
This is the build command output

Route (pages)                              Size     First Load JS
┌ ○ /                                      14.3 kB        93.4 kB
├   /_app                                  0 B            79.1 kB
├ ○ /404                                   181 B          79.3 kB
├ λ /api/v1/[username]                     0 B            79.1 kB
└ λ /api/v1/tweetMedia                     0 B            79.1 kB
+ First Load JS shared by all              80.9 kB
  ├ chunks/framework-114634acb84f8baa.js   45.4 kB
  ├ chunks/main-ee0cf4b7f81d7c24.js        27.1 kB
  ├ chunks/pages/_app-3adada8895e66558.js  5.82 kB
  ├ chunks/webpack-ee7e63bc15b31913.js     815 B
  └ css/671175cd27e07421.css               1.81 kB

@sallar sallar changed the base branch from master to icons-copy February 9, 2023 12:12
@sallar sallar merged commit 9472eb1 into sallar:icons-copy Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants