Skip to content

Latest commit

 

History

History
164 lines (129 loc) · 6.25 KB

README.md

File metadata and controls

164 lines (129 loc) · 6.25 KB

SocialShareJS

This is a simple libray to make your web page shareable fast and easy. Its allow to include the social share link of the major social network to your page.

See the demo here: https://assisfery.github.io/SocialShareJS/index.html

CDN repository: https://www.jsdelivr.com/package/gh/assisfery/SocialShareJS

Install

Just include the social-share.css and social-share.js files.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/assisfery/SocialShareJS@1.4/social-share.min.css">
<script src="https://cdn.jsdelivr.net/gh/assisfery/SocialShareJS@1.4/social-share.min.js"></script>

Dependences

The SocialShareJS don't dependents of none library, but its uses the FontAwesome 5 Fonts, so make sure you have included it in your web page.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js"></script>

Get Started

To have the social share buttons just put the class ss-box in one or more of you containers

<div class="ss-box"></div>

Selected Social

If you want to select specifics social share network just add the data-ss-social attribute in your container.

<div class="ss-box" data-ss-social="facebook, pinterest"></div>

Change Link

For defaults the SocialShareJs put the atual page location as share link but you can change it just including the data-ss-link attribute in your container.

<div class="ss-box" data-ss-link="https://www.google.com/"></div>

Custom Query String

In some of social network shares you could want to put a query string available just to specific social network, so to do that just include
data-ss-_NAME_OF_SOCIAL_MEDIA = "key1:value1, key2:value2" attribute,

for example

include data-ss-messenger = "app_id:123456", so it will include the query string &app_id=123456 in messenger share link, or
include data-ss-email = "subject:SocialShareJS is amazing", it will include the query string &subject=Email Subject in
email share link.

<div class="ss-box" data-ss-social="messenger, pinterest, email" data-ss-messenger="app_id: 123456" data-ss-email="subject:SocialShareJS is amazing"></div>

Responsive check

Some of buttons (like: share native ,messenger, viber and sms) perhaps not work on desktop OS, but its works in mobile OS like Android and IOS, so may be necessary to show that buttons only in mobile screen.

To solve that problem you could include the class ss-responsive on your container.

<div class="ss-box ss-responsive"></div>

Customizations

Hide Social Network Name

If you want to show just the icons without the name of Social Network just include data-ss-content attribute with value false.

<div class="ss-box" data-ss-content="false"></div>
Rounded buttons

If you want to make button with circle shape just include the class ss-circle in ss-box container.

<div class="ss-box ss-circle" data-ss-content="false"></div>
Flat buttons

If you want to make button without rounded border just include the class ss-flat in ss-box container.

<div class="ss-box ss-flat"></div>
Pill buttons

If you want to make button with pill shape effect just include the class ss-pill in ss-box container.

<div class="ss-box ss-pill"></div>
Button with Shadows

If you want to put shadow in button just include the class ss-shadow in ss-box container.

<div class="ss-box ss-shadow"></div>
Hide Icons

If you dont want to show the icons of Social Network just include data-ss-icon attribute with value false.

<div class="ss-box" data-ss-icon="false"></div>
Change Icons

If you want to change the icon class of any Social Network to another icon of you preference or icon of others packages just include the data-ss-icon-class with value social_name1: icon_class1, social_name2: iconclass2

for example:

include data-ss-icon-class="facebook:fab fa-facebook-messenger,email:fas fa-sms" so it will put the icon fab fa-facebook-messenger instead the facebook default icon and it will put the icon fas fa-sms instead the email default icon.

<div class="ss-box" data-ss-social="facebook, email" data-ss-icon-class="facebook:fab fa-facebook-messenger,email:fas fa-sms"></div>

Hover Effects

Grow

Include ss-grow in your container to make button grow when the mouse is hover.

<div class="ss-box ss-grow" data-ss-social="facebook"></div>
Shrink

Include ss-shrink in your container to make button shrink when the mouse is hover.

<div class="ss-box ss-shrink" data-ss-social="facebook"></div>
Rotate

Include ss-rotate in your container to make button rotate when the mouse is hover.

<div class="ss-box ss-rotate" data-ss-social="facebook"></div>
Float

Include ss-float in your container to make button float when the mouse is hover.

<div class="ss-box ss-float" data-ss-social="facebook"></div>

JavaScript Utils

If you want to create a share box in JavaScript you can use the follow function.

SocialShare.createShareBox(_elements, _link = null, _socials =  null, _showIcon = true, _showContent = true, _clearContainer = true);
  • _elements - the dom elements where the socials buttons will be created
  • _link - the link/content will be shared, by default will be the current window location
  • _showIcon - the social button icon will be presented or not
  • _showContent - the social button name/label will be presented or not
  • _clearContainer - clear or not the elements before create the buttons

For example

SocialShare.createShareBox("#newShareBox", "https://github.com/assisfery/SocialShareJS", "facebook, twitter, email, sms, viber");
Just Move On...

If you want to customize the share buttons like you want just do it adding css effect in your code.

.ss-btn {
  /* your code */
}