Skip to content

Latest commit

 

History

History
164 lines (144 loc) · 3.23 KB

File metadata and controls

164 lines (144 loc) · 3.23 KB

CopyToClipboard

The Component has the capability to copy any value like (Element, String, Number)

Demo

A minimal Demo Link

Usage/Examples

Value Used as a Description
CopyToClipboard ✅ Component Can be used as Component
copyToClipboard ✅ Service Can be used as Service
1. Here's an example of basic usage with Default Import:
// Default import will return a Component
import CopyToClipboard from 'fe-pilot/CopyToClipboard';

<CopyToClipboard elementToBeCopy={`<div>Element to be Copy<div>`} />
2. Here's an example of basic usage with Multiple Import:
import { CopyToClipboard, copyToClipboard } from 'fe-pilot/CopyToClipboard';

// Used as a Component
<CopyToClipboard elementToBeCopy={`<div>Element to be Copy<div>`} />

// Used as a Service
copyToClipboard({ elementToBeCopy={`Element to be Copy`} });
3. Here's an example of a advance usage:
import { CopyToClipboard } from 'fe-pilot/CopyToClipboard';

const successCb = (response) => {
  console.log("success response:", response);
}

const failureCb = (response) => {
  console.log("failure response:", response);
}

return (
  <CopyToClipboard
    successCb={successCb}
    failureCb={failureCb}
    elementToBeCopy={`A string text To Copy`}
  >
    Pass clickable element (button, anchor, string, icon etc)
  </CopyToClipboard>
);

Props

Props Type Description Response
successCb Function It will be called on success
  {
      data: "Can be array/object/string/number",
      msgType: "SUCCESSFUL",
      msg: "A success msg",
      status: "SUCCESS"
  }
        
loadingCb Function It will be called before success/failure.
  {
    msgType: "LOADING",
    msg: "LOADING...",
    status: "LOADING"
  }
  
failureCb Function It will be called on failure
  {
    msgType: "ERROR",
    msg: "A failed msg",
    status: "FAILURE"
  }
         
Props Type Description Default Values
showForever Boolean To hide/remove unsupported feature, make it false. Default value is true
elementToBeCopy* Element Pass the text/element/number to be copy
---