• This repository has been archived on 29/May/2020
  • Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Beautiful modern share buttons

Social Likes Next

Build Status npm

Beautiful share buttons for social networks: Facebook, Twitter, Google+, Pinterest, Telegram, LinkedIn, Vkontakte and Odnoklassniki.


See the demo!

Features

  • Easy to install.
  • Beautiful and all in one style (with three different skins).
  • Won’t explode your page’s layout.

This is a modern version of the Social Likes for jQuery. Main distinctions:

  • No jQuery dependency.
  • No counters.
  • No single button mode.
  • SVG icons.
  • Supports IE11+.

Installation and configuration

Installation from npm

It’s recommended to install the social-likes-next from npm:

npm install --save social-likes-next

And use a bundler like Webpack or Browserify:

// ES6
import 'social-likes-next';
import 'social-likes-next/lib/social-likes_flat.css';  // Flat skin
// import 'social-likes-next/lib/social-likes_light.css';  // Light skin
// import 'social-likes-next/lib/social-likes_birman.css';  // Birman skin

// ES5
require('social-likes-next');
require('social-likes-next/lib/social-likes_flat.css');  // Flat skin
// require('social-likes-next/lib/social-likes_light.css');  // Light skin
// require('social-likes-next/lib/social-likes_birman.css');  // Birman skin

Installation from CDN

You can also use jsDelivr or unpkg:

  1. Add a script to your the bottom of your HTML’s <body>:
<script src="https://cdn.jsdelivr.net/npm/social-likes-next/dist/social-likes.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/social-likes-next/dist/social-likes.min.js"></script>
  1. Add a stylesheet.

Choose one of the CSS files:

  • social-likes_flat.css: Flat skin;
  • social-likes_light.css: Light skin;
  • social-likes_birman.css: Birman skin.

And add it to your HTML’s <head>:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-likes-next/dist/social-likes_flat.css">
<!-- or -->
<link rel="stylesheet" href="https://unpkg.com/social-likes-next/dist/social-likes_flat.css">

Adding button to your page

Add this HTML where you want to have share buttons:

<div class="social-likes">
	<div data-service="facebook" title="Share link on Facebook">Facebook</div>
	<div data-service="twitter" title="Share link on Twitter">Twitter</div>
	<div data-service="plusone" title="Share link on Google+">Google+</div>
	<!-- <div data-service="pinterest" title="Share link on Pinterest" data-media="image link, required">Pinterest</div> -->
	<!-- <div data-service="vkontakte" title="Share link on Vkontakte">Vkontakte</div> -->
	<!-- <div data-service="odnoklassniki" title="Share link on Odnoklassniki">Odnoklassniki</div> -->
</div>

You can modify the labels or remove them.

Advanced configuration

Layout

Default

All buttons in a row.

<div class="social-likes">
	<div data-service="facebook" title="Share link on Facebook">Facebook</div>
	...
</div>

Vertical

All buttons in a column.

<div class="social-likes social-likes_vertical">
	<div data-service="facebook" title="Share link on Facebook">Facebook</div>
	...
</div>

Options

url

URL of a shareable page. Current page by default.

title

Title for Twitter and Vkontakte. Current page’s title by default.

Examples:

<div class="social-likes" data-url="http://landscapists.info/" data-title="Landscapists of Russia"></div>

or:

<div class="social-likes">
	<div data-service="twitter" title="Share link on Twitter" data-title="Landscapists of Russia">Twitter</div></div>

Services specific options

Twitter

You can specify via (site’s or your own Twitter) and related (any other Twitter you want to advertise) on Twitter button:

<div data-service="twitter" data-via="sapegin" data-related="Landscapists">Twitter</div>

Pinterest

You should specify an image URL via data-media attribute on Pinterest button:

<div data-service="pinterest" data-media="http://example.com/image/url.jpg">Pinterest</div>

Manual initialization

Could be useful on dynamic (AJAX) websites.

<div id="share">
	<div data-service="facebook">Facebook</div>
	...
</div>
import socialLikes from 'social-likes-next';
socialLikes(document.getElementById('share'));

You can also specify options:

import socialLikes from 'social-likes-next';
socialLikes(document.getElementById('share'), {
	url: 'http://landscapists.info/',
	title: 'Landscapists of Russia',
});

Dynamic URL changing

You can dynamically replace URL, title and Pinterest image without reinitialization.

<div id="share2" class="social-likes" data-url="http://example.com/" data-title="My example">
	<div data-service="facebook">Facebook</div>
	...
</div>
socialLikes(document.getElementById('share2'), {
	url: 'http://github.com/',
	title: 'GitHub',
	data: {
		media: 'http://birdwatcher.ru/i/userpic.jpg'  // Image for Pinterest button
	}
});

Adding your own button

Define socialLikesButtons object:

var socialLikesButtons = {
	github: {
		icon: 'M8 .173C3.58.173...',
		clickUrl: 'http://github.com/sapegin'
	}
};

Add some CSS:

.social-likes__icon_github {
	color: #333;
}
.social-likes__widget_github:hover,
.social-likes__widget_github:active,
.social-likes__widget_github:focus {
	background: #333;
	border-color: #333;
}

And use it like any other button:

<div data-service="github">GitHub</div>

See sources (src folder) for available options and class names and contrib folder for custom buttons examples.

FAQ

Likes or shares?

This plugin allows your users to “share” the content of your website. (Un)fortunately¹ real “likes” are possible only when you use original Facebook, Google+, etc. buttons.

¹ I believe that “shares” are much better and valuable than “likes” because they’re more visible in feed and users could add they’re own comments to links they share. “Like” costs nothing.

Why there’s no counters?

Twitter counter API was disabled by Twitter in November 2015, they’ve also removed the counter from their native share button.

I believe that all other major social networks will follow Twitter and remove counters from their share buttons in the future.

Counters (as well as native share buttons) make your site slower because every counter adds an extra HTTP request to a new host. Social Likes Next doesn’t add any additional HTTP requests if you bundle its scripts and styles with your site’s JavaScript and CSS.

Why only IE11+ is supported?

Microsoft don’t support older versions of Internet Explorer since January 2016 so it’s a great opportunity for us, developers, to do the same.

How to change title, description and image?

You can use Open Graph. It works for Facebook, Twitter, Google+, Pinterest and Vkontakte).

You can add additional Twitter data using Twitter Card. You have to approve every type of Twitter Card.

<meta property="og:type" content="article">
<meta property="og:url" content="{page_url}">
<meta property="og:title" content="{title}">
<meta property="og:description" content="{description}">
<meta property="og:image" content="{image_url}">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@SiteTwitter">
<meta name="twitter:creator" content="@sapegin">

See also Facebook’s sharing tips.

If you’re experiencing any problems with meta data try Open Graph Debugger and Twitter Card Validator.

Troubleshooting

The buttons don’t work, displayed without design or don’t displayed at all

First look at your browser’s console.

If you don’t see any errors check the following:

  1. social-likes.js is included and the path is correct.

  2. social-likes_flat.css or social-likes_light.css or social-likes_birman.css is included in the of your page and the path is correct.

So you need your page to look like this:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Welcome to my site!</title>
	<link href="social-likes_birman.css" rel="stylesheet">
	...
	<script src="social-likes.js"></script>
	...

Release History

The changelog can be found on the Releases page.

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Author


License

The MIT License, see the included license.md file.

More Repositories

1

jest-cheat-sheet

Jest cheat sheet
5,071
star
2

mrm

Codemods for your project config files
JavaScript
1,612
star
3

grunt-webfont

SVG to webfont converter for Grunt
JavaScript
1,104
star
4

social-likes

Beautiful social “like” buttons with counters for jQuery.
CSS
1,089
star
5

shipit

Minimalistic SSH deployment
Shell
558
star
6

dotfiles

My macOS environment: zsh, Git, Visual Studio Code, etc.
Shell
463
star
7

jquery.mosaicflow

Pinterest like responsive image grid that doesn’t suck
HTML
307
star
8

grunt-bower-concat

Bower components concatenator for Grunt
JavaScript
219
star
9

react-components

List of React components I use and recommend
193
star
10

washingcode-book

📖 Book on clean code for frontend developers
JavaScript
175
star
11

stack-styled

Stacking layouts for React
TypeScript
141
star
12

richtypo.js

Typography enhancer for Node.js
TypeScript
123
star
13

fledermaus

Batman’s toolbelt for static site generation
JavaScript
78
star
14

q-i

Node.js objects inspector with color highlighting
JavaScript
62
star
15

react-spaceman

React component to manage whitespace
TypeScript
61
star
16

proselint

Proselint wrapper with a friendly reporter
JavaScript
60
star
17

squirrelsong

Low contrast light & dark themes
Vim Script
51
star
18

react-group

Render React children with a separator
JavaScript
48
star
19

textlint-rule-terminology

Textlint rule to check correct terms spelling
TypeScript
47
star
20

react-weather

React/alt/ES6/Webpack demo app
JavaScript
41
star
21

blog.sapegin.me

My tech blog
TypeScript
38
star
22

bower-update

DEPRECATED. Updates Bower components to the really latest versions.
JavaScript
37
star
23

mrm-core

Utilities to make tasks for Mrm
JavaScript
33
star
24

frontend-pull-request-checklist

Frontend pull request checklist
33
star
25

mrm-tasks

Mrm tasks: codemods for your config files
JavaScript
32
star
26

sweet

Simplest Web Engine Ever, The
JavaScript
29
star
27

fontoptim

Generates CSS with WOFF(2) fonts embedded as Base64
HTML
25
star
28

squirrelstrap

Set of Grunt templates for faster front-end web development
PHP
22
star
29

textlint-rule-stop-words

Textlint rule to find filler words, buzzwords and clichés
JavaScript
22
star
30

expect-react-shallow

JSX assertions with Chai-like API (based on unexpected-react-shallow)
JavaScript
20
star
31

grunt-fingerprint

Assets versioning task for Grunt
JavaScript
19
star
32

picturebeaver

WSH script for batch optimization PNG/JPEG/GIF images using optipng/jpegtran/gifsicle utilities.
19
star
33

csso-stylus

CSSO plugin for Stylus.
CoffeeScript
16
star
34

grunt-fontoptim

Generates CSS with WOFF(2) fonts embedded as Base64
JavaScript
16
star
35

morning.photos

My photo gallery
TypeScript
15
star
36

user-meta

Read user name, email and URL from .npmrc or .gitconfig
JavaScript
14
star
37

grunt-shower-markdown

Grunt task that generates Shower presentations from Markdown source
JavaScript
14
star
38

grunt-imgo

Image optimization for Grunt using imgo
JavaScript
13
star
39

csscolors

All named CSS colors on a single page
HTML
12
star
40

cddcourse

Component-driven development course
JavaScript
12
star
41

PEW

Photoshop Export Workflow: simple Photoshop scripts for file saving automation
JavaScript
12
star
42

sapegin.me

My home page and blog
TypeScript
12
star
43

grunt-stylus

DEPRECATED. Stylus task for Grunt
JavaScript
11
star
44

rtl-article-2019

Modern React testing: Jest and Enzyme
JavaScript
11
star
45

react-pixel-gif

1×1 pixel GIF component for React
JavaScript
9
star
46

react-text-stats

React/alt/ES6/Webpack/Jest demo app
JavaScript
8
star
47

coffeetimer

Basic filter coffee timer web app
TypeScript
8
star
48

react-pagify-preset-bootstrap

Bootstrap preset for react-pagify
JavaScript
8
star
49

grunt-article-examples

Тестовый Грант-проект
JavaScript
8
star
50

hello-box-flex-stack

“Say hello to Box, Flex and Stack: layouts in the component era” talk slides
JavaScript
7
star
51

cypress-article-2020

Modern React testing article examples: Cypress and Cypress Testing Library
JavaScript
6
star
52

enzyme-article-2019

Modern React testing: Jest and Enzyme
JavaScript
6
star
53

textlint-rule-apostrophe

Textlint rule to check correct apostrophe usage
JavaScript
5
star
54

hashnav

Simplest JavaScript hash navigation.
JavaScript
5
star
55

writing-style

English style guide
5
star
56

smpltmpl

Simple templates for Node.js based on ECMAScript template literals syntax
JavaScript
5
star
57

textlint-rule-title-case

Textlint rule to ensure that titles are using AP/APA style
JavaScript
5
star
58

every.morning.photos

My Instagram photos made on this day
TypeScript
5
star
59

lightroom-book-ru

Разумный рабочий процесс в Lightroom
5
star
60

textlint-rule-diacritics

Textlint rule to check correct usage of diacritics
JavaScript
4
star
61

til

Today I learned
4
star
62

grunt-talk-examples

Примеры к докладу про Grunt
PHP
4
star
63

deabsdeep

Recursively replace absolute paths in objects and arrays with ~
JavaScript
3
star
64

slides

Slides from my talks
HTML
3
star
65

package-repo-url

Returns GitHub repository URL based on package.json.
JavaScript
3
star
66

jquery-nicehover

jQuery delayed hover event
JavaScript
2
star
67

instagram-poster

Script to post photos to Instagram
JavaScript
2
star
68

egghead-typescript-webpack-css-modules

How to use CSS Modules with TypeScript and webpack
JavaScript
2
star
69

SublimeGruntWatch

Grunt Watch plugin for Sublime Text 2
Python
2
star
70

social-share-services

Social share sites data: icon, popup URL, etc.
JavaScript
2
star
71

grunt-sweet

Sweet task for Grunt
HTML
2
star
72

jscodestyle

What JavaScript code style is the most popular
HTML
2
star
73

git-default-branch

Returns Git default branch name
JavaScript
2
star
74

vscode-just-blame

VS Code extension to show Git Blame annotations, inspired by JetBrains editors 🪲
TypeScript
1
star
75

fingerprinter

Generic assests fingerprint generator
CSS
1
star
76

cv

My résumé
HTML
1
star
77

wp-typohelper

Russian typography for WordPress
PHP
1
star
78

vscode-new-file-now

Visual Studio Code extension to create new files from the command palette 🆕
TypeScript
1
star
79

vitest-cheat-sheet

Vitest cheat sheet
1
star
80

home-assistant-config

My Home Assistant config
Python
1
star
81

gatsby-lessons

Egghead lessons on Gatsby
CSS
1
star
82

fog.morning.photos

Is it foggy in Berlin?
TypeScript
1
star