Git Product home page Git Product logo

sharer's Introduction

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


© 2023 Kartavya Patel. All rights reserved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.