Skip to content

Conversation

@wesbos
Copy link
Contributor

@wesbos wesbos commented Feb 1, 2023

Fixes #336

@wesbos wesbos requested a review from a team as a code owner February 1, 2023 17:56
Copy link

@macap macap left a comment

Choose a reason for hiding this comment

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

Thank you for contributing, @wesbos!
I've left some minor suggestions.
It would be also nice to see unit test for ClipboardCopy and playwright test for the whole feature.

if (typeof children === 'undefined' || children === null) {
return
}
navigator.clipboard.writeText(children.toString())
Copy link

Choose a reason for hiding this comment

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

I'd consider waiting for permission returned from writeText resolves or rejects, and handle potential rejection.

style={{
cursor: 'pointer',
scale: copied ? `1.15` : `1`,
transition: 'scale 0.2s ease-in-out'
Copy link

Choose a reason for hiding this comment

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

I'd suggest defining styles in scss file, to keep it consistent with other components

return keyCodeEventValues.find(
keyCodeEvent =>
keyCodeEvent.code === keyCode.code && keyCodeEvent.key === keyCode.key
keyCodeEvent.code === keyCode.code || keyCodeEvent.key === keyCode.key
Copy link

Choose a reason for hiding this comment

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

Would you consider removing that change here, and keep it in #338? That would make tracking it easier

setCopied(true)
setTimeout(() => {
setCopied(false)
}, 200)
Copy link

Choose a reason for hiding this comment

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

I think it would be nice to clear it on component unmount, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for an animation, so it needs to zoom out after quickly. Otherwise they would just stay scaled up until the component unmounts

@wesbos
Copy link
Contributor Author

wesbos commented Feb 3, 2023

Thanks - I really don’t have a ton of time for this, just hoping to restate the functionality the site had before I sold it. If it needs multiple components and tests just to write a string to clipboard, I guess we will just need to do without

@toptal toptal deleted a comment Apr 24, 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.

Copy to clipboard functionality lost

2 participants