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

Feat: Add Button + JS To Copy Image URL #126

Open
nelsonic opened this issue Sep 25, 2023 · 2 comments
Open

Feat: Add Button + JS To Copy Image URL #126

nelsonic opened this issue Sep 25, 2023 · 2 comments
Labels
chore a tedious but necessary task often paying technical debt enhancement New feature or enhancement of existing functionality needs-design A feature idea that needs some interface design in order to be discussed/built. priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies user-feedback

Comments

@nelsonic
Copy link
Member

At present we are simply displaying the URL when an image is uploaded:

image

It would be very nice to have a copy-to-clipboard button next to the URL as a convenience.

Ref: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
Quite like the icon that MDN are using for this:
image

But happy for anyone else to suggest an alternative.

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality user-feedback priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished chore a tedious but necessary task often paying technical debt T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies needs-design A feature idea that needs some interface design in order to be discussed/built. labels Sep 25, 2023
@nelsonic
Copy link
Member Author

image

@ndrean
Copy link

ndrean commented Sep 27, 2023

I used this way below but it goes to the server to flash (I initially wanted this). This link shows how to change the innerText of the "copy" button into "copied". I found this cool, could for example animate the svg instead, and perhaps more important no round trip to the server for this.

<button
  id="copy-url-btn"
  phx-hook="Url2Clip"
  data-copy-url={file.resized_url}
  class="over:bg-green-200 focus:bg-green-400 p-2 rounded"
 >
    <.icon name="hero-clipboard-document-list" />
</button>

a hook so that you can push a flash

//url2Clip.js
export default {
  mounted() {
    this.el.addEventListener("click", () => {
      navigator.clipboard.writeText(this.el.dataset.copyUrl);
      this.pushEvent("copy-clip", {});
    });
  },
};
# LVLive.ex
 def handle_event("copy-clip", _, socket), do:
    {:noreply, put_flash(socket, :info, "Copied to clipboard")}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt enhancement New feature or enhancement of existing functionality needs-design A feature idea that needs some interface design in order to be discussed/built. priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies user-feedback
Projects
Status: No status
Development

No branches or pull requests

2 participants