Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

copy to clipboard feature added #2551

Merged
merged 3 commits into from
Dec 31, 2022

Conversation

ChinmayMhatre
Copy link
Member

@ChinmayMhatre ChinmayMhatre commented Dec 31, 2022

Fixes Issue

Closes #2521

Changes proposed

Added the copy to clipboard button to the code blocks in the quick start page.
https://linkfree.eddiehub.io/docs/quickstart

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Screenshots

image
image
image

@github-actions github-actions bot added the large Pull request with more than 30 changed lines label Dec 31, 2022
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

It's great having you contribute to this project

Welcome to the community 🤓

If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.

}, 1500);
})
.catch((err) => {
console.log(err);
Copy link
Member

Choose a reason for hiding this comment

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

We are using async/await and try/catch

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh okay, I'll fix that

Copy link
Member

Choose a reason for hiding this comment

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

thank you 👍

@@ -0,0 +1,51 @@
import React, { useState } from "react";

const ClipboardCopy = ({ copyText, children }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need copyText and children? They look the same

Copy link
Member Author

Choose a reason for hiding this comment

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

The children have the code blocks commas in the start and end. Should I use slice to remove the firsts 5 and the last three characters? Then We could probably use the children prop itself

Copy link
Member

Choose a reason for hiding this comment

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

Oh good point 🤔 I think yes, because I am keen to try and use the same code, so there is not duplicate and not the risk of the code being different and causing bugs for people.

It would probably be safer to separate on the line breaks and remove the first line and last line - because it might not always be 5 characters at the beginning

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good point 🤔 I think yes, because I am keen to try and use the same code, so there is not duplicate and not the risk of the code being different and causing bugs for people.

It would probably be safer to separate on the line breaks and remove the first line and last line - because it might not always be 5 characters at the beginning

Oh yeah, That is a way better option. Could you tell me how would I convert the children prop to string. I can't seem to find the method to get the text from the object

Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried before, but after a Google I found this https://github.com/fernandopasik/react-children-utilities

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll give it a go, thanks!

Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

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

Looks good, I left some inline questions

@ChinmayMhatre
Copy link
Member Author

Hey Eddie! I fixed it 🕺

@eddiejaoude
Copy link
Member

Looks good @ChinmayMhatre 👍 I will have a play with it later on and then we can get it merged

Thank you!

@ChinmayMhatre
Copy link
Member Author

Looks good @ChinmayMhatre 👍 I will have a play with it later on and then we can get it merged

Thank you!

Awesome! Maybe later on we could move the wrapper component to a utils folder. Could create an issue later on, a green square for a first timer.

Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

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

Looks great 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
large Pull request with more than 30 changed lines waiting-for-reviewers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DOCS] Add a copy code button for all code blocks in Quickstart
2 participants