Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Mar 20, 2024
1 parent 86da36d commit ff7dcf8
Showing 1 changed file with 82 additions and 3 deletions.
85 changes: 82 additions & 3 deletions __app/component/CopyToClipboard/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,86 @@
# 1. Happy Flow
# 1. Happy Flow

## a) Passing string for copy

```js
<CopyToClipboard
elementToBeCopy="Fe-pilot library offers component like scanner, voice search, autofill otp, phonebook, share and many more for a small/medium/large size web based applications"
/>
```

## b) Passing element for copy

```js
<CopyToClipboard
elementToBeCopy={`
<div>
<CopyToClipboard />
<div>
`}
/>
```
> [!Tip]
> You can also pass ref variable

## c) Passing child

```js
<CopyToClipboard
elementToBeCopy={`
<div>
<CopyToClipboard />
<div>
`}
>
Click Me to Copy
</CopyToClipboard>
```

## 2. Success CallBack Fn along with success msg

```js
const successCb = ({ msgType, msg, data }) => {
console.log(msgType); // Success
console.log(msg); // Copied Successfully
console.log(data); // Fe-pilot library offers component like scanner, voice search, autofill otp, phonebook, share
}
```

```js
<CopyToClipboard
elementToBeCopy="Password field is not contained in a form: (More info: "
elementToBeCopy={`Fe-pilot library offers component like scanner, voice search, autofill otp, phonebook, share`}
successCb={successCb}
successMsg="Copied Successfully"
/>
```
```
> [!Note]
Define **successCb** fn and your will get an object in param contains the property ```msgType```, ```msg```, ```data```

## 3. Failure CallBack Fn along with failure msg
```js
const failureCb = ({ msgType, msg }) => {
console.log(msgType); // UN_SUPPORTED_FEATURE
console.log(msg); // Your device is not supporting Copy feature

OR

console.log(msgType); // ERROR
console.log(msg); // Unable to copy the text
}
```
```js
<CopyToClipboard
elementToBeCopy={`Fe-pilot library offers component like scanner, voice search, autofill otp, phonebook, share`}
failureCb={failureCb}
failureMsg={{
unSupported: 'Your device is not supporting Copy feature',
error: 'Unable to copy the text',
}}
/>
```
> [!Note]
> Define **failureCb** fn and your will get an object in param contains the property ```msgType```, ```msg```
> [!Important]
Failure can happend due to multiple reasons, due to that reason ```failureMsg``` is an object having different kind of error property according to the error can occur in component

0 comments on commit ff7dcf8

Please sign in to comment.