GithubHelp home page GithubHelp logo

vinayasathyanarayana / shareon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kytta/shareon

0.0 0.0 0.0 706 KB

๐Ÿ“ฏ Lightweight, stylish and ethical share buttons for popular social networks

Home Page: https://shareon.js.org

License: MIT License

JavaScript 9.51% TypeScript 16.43% CSS 74.06%

shareon's Introduction

shareon

Postal Horn emoji

Lightweight, stylish and ethical share buttons.

  • Small. Dependency-free. CSS+JS bundle is only 6 KB minified and gzipped.
  • Stylish. Uses official vector logos and colors with no visual mess.
  • Ethical. Embeds no tracking code. JS is required only for the setup.

shareon example


Observe the live demo here: shareon.js.org

Install

Include the link to shareon's JS and CSS in your website:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/shareon.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/shareon.min.js" type="text/javascript"></script>

or install it via NPM use it in a JS file that you will bundle:

npm install shareon
# or
yarn add shareon
require('shareon');

Usage

shareon was heavily inspired by Likely, and has a backwards-compatible API (excluding themes and sizes).

Create a container with class shareon and populate it with elements, whose classes match the names of social networks:

<div class="shareon">
    <a class="facebook"></a>
    <a class="linkedin"></a>
    <a class="messenger"></a>
    <a class="odnoklassniki"></a>
    <a class="pinterest"></a>
    <a class="pocket"></a>
    <button class="reddit"></button>
    <button class="telegram"></button>
    <button class="twitter"></button>
    <button class="viber"></button>
    <button class="vkontakte"></button>
    <button class="whatsapp"></button>
</div>

If you use <a>, the buttons will get a href-attribute to them. In other cases they will get a listener on click event, so you can use <button>s if you wish.

By default, the URL and the title of the page will be used in sharing dialogs. To change this, you can use the data-url and data-title attributes. Use them on the whole container or on the specific buttons:

<div class="shareon" data-url="https://example.com">
    <a class="facebook" data-title="Custom Facebook title"></a>
    <a class="twitter" data-title="Custom Twitter title"></a>
</div>

Apart from the URL and title, some networks support extra parameters:

  • add data-media to an Odnoklassniki, Pinterest, or VK button to customize the pinned picture
  • add data-text to a WhatsApp, Telegram or Viber button to add custom message text
  • add data-via to a Twitter button to mention a user

Here are all the custom parameters in their glory:

<div class="shareon" data-url="https://example.com/custom-url">
    <a class="facebook" data-title="Custom Facebook title"></a>
    <a class="messenger" data-url="https://my-cool-website.com"></a>
    <a class="pinterest" data-media="https://picsum.photos/500">Pin</a>
    <a class="telegram" data-text="Check this out!"></a>
    <a class="twitter" data-via="MyNickname"></a>
    <a class="whatsapp">Send</a>
</div>

shareon's People

Contributors

kytta avatar

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.