To install Sharer from NPM, run the following command:
npm i @patelka2211/sharer
Alternatively, you can visit this page and configure Sharer to work the best way and directly in your website using a HTML <script>
tag. Or simply paste the below given code as high as possible in your website or web app's <head>
tag .
<!-- Sharer scripts start -->
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/DynamicColors.js"></script>
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/Dominar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html2canvas.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/Sharer.js"></script>
<script
defer
id="sharer-utility-js"
class="activate-button"
src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/utility.js"
></script>
<!-- Sharer scripts end -->
/**
* Opens the Sharer with the specified options.
* @param option — Optional configuration for the Sharer.
*/
function openSharer(option?: { url?: string; text?: string }): void;
/**
* Closes the Sharer.
*
* @returns {void}
*/
function closeSharer(): void;
/**
* Sets Sharer color.
*
* @param {string | undefined} newColor - The new color value.
* @returns {object} An object containing open and close functions.
* @property {function} open - The function to open the Sharer.
* @property {function} close - The function to close the Sharer.
*/
function setColor(newColor?: string): object;
Sharer button is an object containing activate
and deactivate
functions.
const button: {
activate: () => void;
deactivate: () => void;
};
You can use method chaining in setColor
function.
Suppose you need to set color theme of Sharer and then you immediately want to open Sharer, you can do this using method chaining with just single line of code.
// The given example code will set color theme to "#2596D1" and will open Sharer.
// There is only one line of code present in the given example. It looks like 4 lines of code because it is formatted, to make sure it is easily readable.
setColor("#2596D1").open({
url: "https://kpverse.in/",
text: "The official KPVERSE website.",
});
© 2023 Kartavya Patel. All rights reserved.