shareon-pulsanti-condivisio.../README.md

94 lines
3.1 KiB
Markdown
Raw Normal View History

2020-03-25 16:32:25 +01:00
# shareon
2020-03-26 00:38:54 +01:00
<img src="https://raw.githubusercontent.com/googlefonts/noto-emoji/master/png/128/emoji_u1f4ef.png" align="right" alt="Postal Horn emoji" width="96" height="96">
2020-03-25 16:32:25 +01:00
2020-03-25 16:45:04 +01:00
Lightweight, stylish and ethical share buttons.
2020-03-25 16:32:25 +01:00
2020-07-04 23:02:35 +02:00
- **Small.** Dependency-free. CSS+JS bundle is only 6 KB minified and gzipped.
2020-03-26 00:47:45 +01:00
- **Stylish.** Uses official vector logos and colors with no visual mess.
2020-06-26 17:32:02 +02:00
- **Ethical.** Embeds no tracking code. JS is required only for the setup.
2020-03-25 16:32:25 +01:00
2020-07-06 10:35:02 +02:00
<img src="https://raw.githubusercontent.com/NickKaramoff/shareon/master/docs/screen01@2x.png" height="156" width="416" alt="shareon example">
2020-03-26 00:38:54 +01:00
----
2020-03-26 22:01:29 +01:00
Observe the live demo here: [shareon.js.org](https://shareon.js.org)
2020-03-26 00:38:54 +01:00
## Install
Include the link to shareon's JS and CSS in your website:
```html
<link href="https://cdn.jsdelivr.net/npm/shareon@1.2.1/dist/shareon.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/shareon@1.2.1/dist/shareon.min.js" type="text/javascript"></script>
2020-03-26 00:38:54 +01:00
```
or install it via NPM use it in a JS file that you will bundle:
```sh
npm install shareon
# or
yarn add shareon
```
```js
require('shareon');
```
2020-03-26 00:44:31 +01:00
## Usage
2020-03-26 00:47:45 +01:00
> shareon was heavily inspired by [Likely](https://ilyabirman.net/projects/likely/),
and has a backwards-compatible API (excluding themes and sizes).
2020-03-26 00:44:31 +01:00
Create a container with class `shareon` and populate it with elements, whose
classes match the names of social networks:
2020-03-25 16:32:25 +01:00
2020-03-26 00:25:17 +01:00
```html
<div class="shareon">
<a class="facebook"></a>
<a class="linkedin"></a>
2020-03-26 00:44:31 +01:00
<a class="messenger"></a>
2020-03-26 22:45:42 +01:00
<a class="odnoklassniki"></a>
2020-03-26 00:44:31 +01:00
<a class="pinterest"></a>
<a class="pocket"></a>
<button class="reddit"></button>
2020-06-26 17:27:59 +02:00
<button class="telegram"></button>
<button class="twitter"></button>
<button class="viber"></button>
2020-06-26 17:27:59 +02:00
<button class="vkontakte"></button>
<button class="whatsapp"></button>
2020-03-26 00:44:31 +01:00
</div>
```
2020-03-26 01:43:16 +01:00
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.
2020-06-26 17:32:02 +02:00
By default, the URL and the title of the page will be used in sharing dialogs.
2020-03-26 00:44:31 +01:00
To change this, you can use the `data-url` and `data-title` attributes. Use them
2020-03-26 01:43:16 +01:00
on the whole container or on the specific buttons:
2020-03-26 00:44:31 +01:00
```html
<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
2020-03-26 01:43:16 +01:00
- add `data-via` to a Twitter button to mention a user
2020-03-26 00:44:31 +01:00
Here are all the custom parameters in their glory:
```html
<div class="shareon" data-url="https://example.com/custom-url">
<a class="facebook" data-title="Custom Facebook title"></a>
2020-03-26 00:25:17 +01:00
<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>
2020-03-25 16:32:25 +01:00
</div>
```