• Stars
    star
    158
  • Rank 232,001 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

A pure JS plugin to generate a share bar for social media, used by Globo.com.

Travis Build Status Coverage Status

share-bar

A pure JS plugin to generate a share bar for social media, used by Globo.com.

Table of Contents

Browser Support

All โœ” 3.6+ โœ” 9+ โœ” 29+ โœ” 5+ โœ”

How to Install

Install through NPM:

npm install @globocom/share-bar

How to Use

Once you added the CSS and JS from the plugin on the page, you can simply do:

new ShareBar({'facebookAppId': 'APP_ID'});

APP_ID can be automatically pulled from the page if you're using Facebook meta tags (meta tag open graph), but we strongly recommend you to pass it manually.

Also, place the following markup where you want the share-bar to be:

<div class="share-bar"
    data-title="Content Title"
    data-url="Content URL"
    data-image-url="http://lorempixel.com/1080/700/"
    data-hashtags="#example #sharebar">
</div>

Take a look at our demo.

Options

The plugin also offers a few options for customization.

Selector

Allows to alter the default selector.

Default: .share-bar

new ShareBar({selector: '.meu-seletor'});

Theme

Allows to alter the default theme, using these options: natural, dark, minimal and minimal light.

Default: 'natural'

new ShareBar({theme: 'dark'});

classPopup

Allows to alter the CSS class when opening the share popup windows. This is only necessary when the default class is already in use.

Default: 'share-popup'

new ShareBar({classPopup: 'class-popup'});

buttonWidth

Allows to alter the reserved width for small buttons. This property does not change the actual button width, it only uses it to calculate how many buttons can fit in the share bar.

Default: 34

new ShareBar({buttonWidth: 50});

buttonFullWidth

Allows to alter the reserved width for expanded buttons. This property does not change the actual button width, it only uses it to calculate how many buttons can fit in the share bar.

Default: 110

new ShareBar({buttonFullWidth: 150});

buttonPadding

Allows to alter the reserved left padding for buttons. This property does not change the actual button width, it only uses it to calculate how many buttons can fit in the share bar.

Default: 4

new ShareBar({buttonPadding: 4});

maxSocialButtons

Allows to alter the maximum quantity of social networks visible in the share bar. This is only necessary if you want to show more than 6 social networks in the bar.

Default: 6

new ShareBar({maxSocialButtons: 10});

networks

Allows to alter the visible social networks in the share bar. This is the property you use to show or hide social network buttons in the share bar.

Default:

[
  'facebook',
  'twitter',
  'whatsapp',
  'google',
  'linkedin',
  'pinterest',
  'email'
]

Customize it like this:

new ShareBar({
  'networks': [
    'facebook',
    'twitter',
    function createSampleButton(container, buttonClass) {
      var data = this.getMetadataFromElement(container);
      buttonClass = buttonClass || '';

      this.createButton(
        container, 'sample', buttonClass,
        'http://www.sample.com/sample-sharer.php?u=' + data['url']
      );
    }
  ]
});

Note: The WhatsApp icon is only visible on screens with less than 768px of width and are touch capable.

context

Allows to alter the render context of the bar. This information is sent via utm_medium in the URL. This is useful when you have more than one sharebar on the page and you want to filter the actions on Google Analytics.

Default: 'desktop'

new ShareBar({context: 'mobile'});

campaign

Allows to alter the campaign metadata of the bar. This information is sent via utm_campaign in the URL. This is useful when you have more than one sharebar on the page and you want to filter the actions on Google Analytics.

Default: 'share-bar'

new ShareBar({campaign: 'custom-campaign'});

onCreateBar

A callback that fires when you create the bar. It receives the created bar as a parameter.

Default: function (bar) { return false; }

new ShareBar({
  onCreateBar: function (bar) {
    alert(bar.innerHTML);
  }
});

onCreateButton

A callback that fires after a share button is created. It receives the created button as a parameter.

Default: function (button) { return false; }

new ShareBar({
  onCreateBar: function (button) {
    alert(button.innerHTML);
  }
});

onShare

A callback that fires after a share button is clicked. It receives the clicked button as a parameter.

Default: function (button) { return false; }

new ShareBar({
  onShare: function (button) {
    alert(button.innerHTML);
  }
});

createBar

It's possible to call createBar to create the bar manually anytime you want.

const sharebar = new ShareBar({maxSocialButtons: 10});
sharebar.createBar(document.querySelector('.minha-barra'));

Note: For this to work, you need to have the HTML element shown above with the data-attributes already set.

Contributing

This project depends on NodeJS and NPM.

To install the project dependencies use:

$ make setup

To run the tests:

$ make test

To run a local server for local development use:

$ make run

Icons

The icons used in this project are SVGs embedded in the JavaScript.

Adding more icons to the project:

1 - Add your SVG to the image path

$ mv ~/caminho/da/imagem.svg caminho/do/share/src/img/

2 - Generate the SVG icons again with Grunt

$ grunt icon

3 - Alter the CSS and Fonts to accomplish the desired look

4 - If you want, add a callback function to the button

Version

To generate a new tag version, use this:

$ grunt bump

License

The MIT License (MIT)

Copyright (c) 2019 globo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

m3u8

Python m3u8 Parser for HTTP Live Streaming (HLS) Transmissions
Python
1,907
star
2

megadraft

Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility
JavaScript
1,210
star
3

secDevLabs

A laboratory for learning secure web and mobile development in a practical manner.
PHP
869
star
4

huskyCI

Performing security tests inside your CI
Go
561
star
5

react-native-draftjs-render

React Native render for draft.js model
JavaScript
386
star
6

database-as-a-service

Database as a service (DBaaS) that allows users to quickly and easily deploy and manage database instances using cloud infrastructure
Python
361
star
7

gitlab-ci-monitor

A simple dashboard for monitoring GitLab CI builds. Alpha version.
JavaScript
174
star
8

sawpf

Salve a web, por favor
JavaScript
154
star
9

GloboDNS

Api to manage Bind Name Server
Ruby
138
star
10

opensource

Conheรงa os projetos Open Source na Globo.com
JavaScript
133
star
11

slo-generator

Easy setup a service level objective using prometheus
Go
128
star
12

destaque

Destaque is a simple slideshow plugin with built-in parallax effect.
JavaScript
125
star
13

dojo

Dojos realizados na Globo.com ao longo dos รบltimos anos.
JavaScript
120
star
14

hlsclient

Python HLS Client
TypeScript
105
star
15

tornado-es

A tornado-powered python library that provides asynchronous access to elasticsearch
Python
96
star
16

GloboNetworkAPI

API to automate IP Networking management, resource allocation and provisioning.
Python
83
star
17

tapioca

Tapioca is a small and flexible micro-framework on top of Tornado. It provides a simpler way to create RESTful API's.
Python
77
star
18

prettylog

Logs for human beings
Go
64
star
19

redis-healthy

It retrieves metrics, periodically, from Redis (or sentinel) and send them to Logstash
Go
63
star
20

nautilus.js

[separated fork] Async JavaScript loader & dependency manager in ~600B [gziped]
JavaScript
59
star
21

loopback-jsonschema

Adds JSON Schema support to LoopBack
JavaScript
57
star
22

echo-prometheus

Middleware for echo v4 to instrument all handlers as metrics
Go
52
star
23

functions

An Open Source Serverless Platform
JavaScript
49
star
24

content-gateway-ruby

An easy way to get external content with two cache levels. The first is a performance cache and second is the stale
Ruby
45
star
25

kong-plugin-proxy-cache

A Proxy Caching plugin for Kong makes it fast and easy to configure caching of responses and serving of those cached responses in Redis
Lua
45
star
26

pluct

A JSON Hyper Schema client that allows hypermedia navigation and resource validation
Python
39
star
27

react-native-ua

React Native module for Urban Airship
Objective-C
38
star
28

tornado-cors

Makes it easier to add CORS support to tornado apps.
Python
38
star
29

alchemetrics

Elixir metrics reporter and collector
Elixir
35
star
30

responsive-hub

JavaScript goodies for Responsive Design
JavaScript
34
star
31

alf

Python OAuth2 Client
Python
32
star
32

derpconf

derpconf abstracts loading configuration files for your app.
Python
31
star
33

glog-cli

Python
28
star
34

gifv-player

Javascript library for playing video files with gif fallback
JavaScript
25
star
35

huskyCI-dashboard

Frontend to display data from huskyCI analyses
JavaScript
23
star
36

vault

Admin webapp for Openstack's Keystone and Swift
Python
22
star
37

go-buffer

Asynchronous data buffer for Go applications
Go
22
star
38

gothumbor

Golang client for Thumbor Image Service
Go
22
star
39

gsenha

GSenha is a password manager designed to avoid information leakage in the case of a compromise.
JavaScript
22
star
40

go-redis-prometheus

go-redis hook to export Prometheus metrics
Go
21
star
41

go-redis-opentracing

go-redis hook to collect OpenTracing spans
Go
21
star
42

letrilizar

Transforme citaรงรตes em imagens e compartilhe!
JavaScript
21
star
43

gsh

GSH is an OpenID Connect-compatible authentication system for systems using OpenSSH servers
Go
21
star
44

GloboNetworkAPI-WebUI

Web UI to GloboNetworkAPI
Python
21
star
45

galf

Go OAuth2 Client
Go
20
star
46

azkaban-cli

CLI for Azkaban 3 API access and flow upload.
Python
20
star
47

gitlab-lint

An open source gitlab linting utility
Go
19
star
48

zabbix-scripts

A collection of scripts to ease Zabbix administration
Python
19
star
49

tornado-prometheus

HTTP metrics for a tornado application
Python
19
star
50

oauth2u

OAuth 2 server implementation
Python
18
star
51

view-port

Viewport-Android is a library that aims to track items from a Recycler View, which remain visible in a given region on the screen (view port), for a minimum time of 250 milliseconds.
Kotlin
18
star
52

mugshot

Ruby
18
star
53

gitlab-lint-react

An open source gitlab linting utility
JavaScript
17
star
54

tornado-alf

Tornado Oauth 2 client
Python
17
star
55

measures

Backstage Measure
Python
17
star
56

pymigration

A generic tool for migrate in python
Python
17
star
57

rtmp2img

rtmp2img: Create images from rtmp urls
Python
17
star
58

gcloud-utils

Global package for Cloud Management in Python
Python
16
star
59

graylog-plugin-oauth2

Oauth2 plugin for graylog project
Java
16
star
60

gcrypt

๐Ÿ” encryption for humans
JavaScript
16
star
61

stewie

System for anomaly detection in mass generic data
Clojure
16
star
62

GloboNetworkAPI-client-python

Python client for GloboNetworkAPI
Python
16
star
63

globomap-api

API abstract used to mapping of infrastructure, services and processes of Globo.com
Python
15
star
64

jquery-eventtracker

jquery.eventtracker is a jQuery plugin wrapper for Google Analytics custom event tracker
JavaScript
14
star
65

go-openstack

Go packages for OpenStack APIs.
Go
14
star
66

simple-virtuoso-migrate

Ontology versioning and migration tool inspired by simple-db-migrate.
Python
14
star
67

dash_timeline_validator

It parses and validate a given MPD about its errors of the timeline.
Ruby
14
star
68

stormdash

A unique dashboard to show simple alerts
JavaScript
14
star
69

iprange

IPRange - Redis as a storage for IP range
Lua
14
star
70

functions-sandbox

Sandbox for Backstage Functions
JavaScript
13
star
71

megadraft-table-plugin

Table Plugin - Megadraft Plugin
JavaScript
13
star
72

docker-openvswitch

Docker image of Open vSwitch with ssh enabled running over supervisord
13
star
73

zookeeper-centos-6

zookeeper RPM package for CentOS 6.
13
star
74

enforcement

Project focused on the implementation of policies in Kubernetes clusters through GitOps.
Python
13
star
75

reliable-request

A golang opinionated library to provide reliable request using hystrix-go, go-cache, and go-resiliency.
Go
13
star
76

tdi

Test Driven Infrastructure. Automates validation of deployed servers.
Ruby
12
star
77

hacktoberfest

Globo Hacktoberfest project
TypeScript
12
star
78

dojo.globo

Dojo na Globo.com
Python
12
star
79

lig4

Lig4 is a board game brought to the web
JavaScript
11
star
80

configurable-http-proxy-redis-backend

Redis Backend for Jupyter's Configurable Proxy
JavaScript
11
star
81

httpclient

A HTTP client in Golang.
Go
11
star
82

globomap-ui

Web Interface to explore Globomap API
JavaScript
11
star
83

benchmark-python-wsgi

Benchmark of Python WSGI Servers
Python
10
star
84

megadraft-related-articles-plugin

Related articles plugin for Megadraft text editor
JavaScript
10
star
85

alchemetrics_web

Collect and report key metrics for a typical web application based on Phoenix and Ecto.
Elixir
10
star
86

generator-megadraft-plugin

Plugin generator for the Megadraft Editor
JavaScript
10
star
87

auror-core

Azkaban Auror core for flow creation
Python
10
star
88

gsenha-api

GSenha-API is a password manager. Its architecture was designed to avoid information leakage in the case of a compromise
Python
9
star
89

url-pinger

URL healthcheck
Python
9
star
90

generic_cache

A Python utility / library to facilitate caching functions results'
Python
9
star
91

alchemetrics_tesla

Tesla middleware to report external call metrics.
Elixir
9
star
92

Globo-Live-Cache

Configuraรงรฃo de caching de vรญdeos ao vivo da Globo.com
Shell
9
star
93

dbaas-cloudstack

A cloudstack adapter to DBaaS
Python
9
star
94

container-broker

Run any Docker-based task in a simple and distributed way
Ruby
8
star
95

zabbix2odbc

Zabbix macro sync for ODBC configuration with support MySQL and Oracle databases.
Python
8
star
96

memcachedapi

memcached service API for tsuru.
Python
8
star
97

aiohttp-prometheus

HTTP metrics for a AIOHTTP Application
Python
8
star
98

dbaas-credentials

A credential manager for dbaas integrations
Python
8
star
99

mongo-go-prometheus

Monitors that export Prometheus metrics for the MongoDB Go driver
Go
8
star
100

tornado-stale-client

An async http client for tornado with stale cache support
Python
7
star