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 "copy to clipboard" feature #1521

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shantanusoni72
Copy link

In this pull request, users can now able to copy the song title to the clipboard by simply clicking on its name.

Fixes #1516

Demonstration Video
https://github.com/nukeop/nuclear/assets/75296055/87a86b75-63bc-47b8-90b4-9343f09a010a

@nukeop nukeop added the under review This pull request is being reviewed by maintainers. label Nov 1, 2023
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (e728fde) 71.42% compared to head (b9bfe14) 71.37%.

❗ Current head b9bfe14 differs from pull request most recent head ba64070. Consider uploading reports for the commit ba64070 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1521      +/-   ##
==========================================
- Coverage   71.42%   71.37%   -0.05%     
==========================================
  Files         364      364              
  Lines        6708     6714       +6     
  Branches      474      474              
==========================================
+ Hits         4791     4792       +1     
- Misses       1527     1532       +5     
  Partials      390      390              
Files Coverage Δ
packages/ui/lib/components/TrackInfo/index.tsx 61.53% <16.66%> (-38.47%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

const CopyTextToClipboard = async () => {
const track_element = document.getElementById('track_name');
try {
await navigator.clipboard.writeText(track_element.innerHTML);
Copy link
Owner

Choose a reason for hiding this comment

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

This shouldn't be done this way in React. Instead, you can get the title from the redux store.

try {
await navigator.clipboard.writeText(track_element.innerHTML);
} catch (err) {
console.error('Failed to copy: ', err);
Copy link
Owner

Choose a reason for hiding this comment

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

Don't use console.error, instead you can show a notification toast.

@nukeop
Copy link
Owner

nukeop commented Nov 1, 2023

Hi, thanks for the pull request. Please check the contribution guidelines: https://nukeop.gitbook.io/nuclear/contributing/contribution-guidelines

There are a few things missing but I'm sure if we iterate on it we can get it into a good shape.

  • Please add a test for the feature. You can see examples in the app package. Let me know if you have trouble testing the clipboard contents.
  • Instead of changing the color to green with CSS, it should be possible to know what's going to happen if you click the title. So a good idea would be to add a tooltip that says something like "click to copy". You can search for the word "tooltip" to see examples.
  • The CSS on the title should also change the cursor to pointer when you hover over it, to let the user know this element is clickable. It might also be a good idea to add a button with an icon next to the title, so you can tell there's something interactive there at a glance.

@shantanusoni72
Copy link
Author

Logs:

  1. Green color removed.
  2. Add a pointer when hovering over the name.
  3. Add the "Click to copy" tooltip.
  4. Removed getElementById line.
2023-11-02.08-33-53.mp4

It would be cool to add a notification toast.

@nukeop nukeop removed the under review This pull request is being reviewed by maintainers. label Mar 19, 2024
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.

Ability to copy the song title to clipboard
2 participants