@patelka2211/sharer

v1.0.0

Published

Seamlessly Share URLs and Generate SharerQR Codes!

Downloads

4

Readme

Sharer - A URL Sharing Tool for Websites and Web Apps, from KPVERSE


Installation

npm (scoped) npm bundle size (scoped) npm jsDelivr hits (npm scoped)

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 -->

Available APIs

open - type function

/**
 * Opens the Sharer with the specified options.
 * @param option — Optional configuration for the Sharer.
 */
function openSharer(option?: { url?: string; text?: string }): void;

close - type function

/**
 * Closes the Sharer.
 *
 * @returns {void}
 */
function closeSharer(): void;

setColor - type function

/**
 * 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;

button - type object

Sharer button is an object containing activate and deactivate functions.

const button: {
    activate: () => void;
    deactivate: () => void;
};

button.activate - Activates the Sharer button.

button.deactivate - Deactivates the Sharer button.


Method chaining

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.",
});

License

MIT License