Giter Site home page Giter Site logo

alexandrshy / vue-share-buttons Goto Github PK

View Code? Open in Web Editor NEW
51.0 1.0 16.0 2.68 MB

πŸ”—A set of social buttons for Vue.js

License: MIT License

JavaScript 2.62% Vue 92.70% SCSS 4.67%
vue vuejs vue2 vuejs2 vue-components component share share-link share-buttons social-buttons

vue-share-buttons's Introduction

vue-share-buttons

Vue component for placing buttons in your project using which you can share anything. If vue-share-buttons doesn't have a social network for you, just make a Pull request or create new issue for me

Menu

Installation

Install using npm

npm i vue-share-buttons

Link to NPM

Install using Yarn

yarn add vue-share-buttons

Link to Yarn

Icons

For icons, I use simpleicons

Usage

You need to import each social button separately. For example, you want to use the share button on Twitter. To do this you need:

Import component

import TwitterButton from "vue-share-buttons/src/components/TwitterButton";

const app = new Vue({
  el: "#app",
  components: {
    TwitterButton,
  },
});

Add the button to your template

<div id="app">
  <twitter-button
    url="https://github.com/"
    description="GitHub is where people build software."
  />
</div>

And we get the button

vue-share-buttons-twitter

Options

Below are the options you can pass to create your own button.

Buttons with a counter

Facebook, LinkedIn

Option Type's Default Description
url String document.location.href URL-address you want to share
btnText String Facebook, LinkedIn, etc. Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
hasCounter Boolean false Presence of a counter with the number of share
digitsCounter Number 0 The number of decimal places in the counter
keyCounter String '' Counter ID (note, it must be unique if you use several buttons with a counter for the same social network on the same page)
customIcon String '' Custom imag

Odnoklassniki

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
btnText String Odnoklassniki Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
hasCounter Boolean false Presence of a counter with the number of share
digitsCounter Number 0 The number of decimal places in the counter
customIcon String '' Custom image
sharePic String '' Link to image instead of favicon

Tumblr

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
title String '' Title you want to share
btnText String Tumblr, Vkontakte Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
hasCounter Boolean false Presence of a counter with the number of share
digitsCounter Number 0 The number of decimal places in the counter
keyCounter String '' Counter ID (note, it must be unique if you use several buttons with a counter for the same social network on the same page)
customIcon String '' Custom image

Vkontakte

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
title String '' Title you want to share
btnText String Tumblr, Vkontakte Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
hasCounter Boolean false Presence of a counter with the number of share
digitsCounter Number 0 The number of decimal places in the counter
sharePic String '' Link to image instead of favicon
customIcon String '' Custom image

Pinterest

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
picture String '' Picture you want to share
btnText String Pinterest Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
hasCounter Boolean false Presence of a counter with the number of share
digitsCounter Number 0 The number of decimal places in the counter
keyCounter String '' Counter ID (note, it must be unique if you use several buttons with a counter for the same social network on the same page)
customIcon String '' Custom image

Buttons without a counter

Twitter, Hatena, Instapaper, LiveJournal

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
btnText String Twitter, Hatena, Instapaper, LiveJournal Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
customIcon String '' Custom image

Digg, Xing, Pocket

Option Type's Default Description
url String document.location.href URL-address you want to share
btnText String Digg, Xing, Pocket Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
customIcon String '' Custom image

Blogger

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
title String '' Title you want to share
btnText String Blogger Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
customIcon String '' Custom image

Reddit, Renren

Option Type's Default Description
url String document.location.href URL-address you want to share
title String '' Title you want to share
btnText String Reddit, Renren Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
customIcon String '' Custom image

Weibo

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
picture String '' Picture you want to share
title String '' Title you want to share
btnText String Weibo Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
isBlank Boolean true Open the "share on social networks" frame in a new window
modalWidth Number 500 If the property "isBlank" is set to false, you can set the width of the modal window the "share on social networks"
modalHeight Number 500 If the property "isBlank" is set to false, you can set the height of the modal window the "share on social networks"
customIcon String '' Custom image

Buttons for instant messengers

Facebook Messenger

Option Type's Default Description
appID String '' A unique identifier for the application
url String document.location.href URL-address you want to share
btnText String Facebook Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
customIcon String '' Custom image

Viber, WhatsApp

Option Type's Default Description
url String document.location.href URL-address you want to share
btnText String Viber, WhatsApp Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
customIcon String '' Custom image

Telegram

Option Type's Default Description
url String document.location.href URL-address you want to share
description String document.title Messages you want to share
btnText String Telegram Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
customIcon String '' Custom image

Send a message via email

This isn't really a share button, this is a button that allows you to open the software to send an email message, but it may be useful for you πŸ™ƒ

Option Type's Default Description
url String document.location.href URL-address you want to share
btnText String Email Text to be written on your button
hasIcon Boolean true Presence of social network icon in the button
subject String document.title Email subject
customIcon String '' Custom image

Full list of social networks

  • Blogger
  • Digg
  • Email
  • Facebook
  • Facebook Messenger
  • Hatena
  • Instapaper
  • LinkedIn
  • LiveJournal
  • Odnoklassniki
  • Pinterest
  • Pocket
  • Reddit
  • Renren
  • Telegram
  • Tumblr
  • Twitter
  • Viber
  • Vkontakte
  • Weibo
  • WhatsApp
  • Xing

Not worked

  • Facebook counter
  • LinkedIn counter

Example

<twitter-button v-bind:isBlank="false" btnText />

Twitter button with icon

Live Demo

<twitter-button class="share-button--circle" v-bind:hasIcon="false" />

Twitter circle button

Live Demo

<twitter-button v-bind:hasIcon="false" class="share-button--outline" />

Twitter outline button without icon

Live Demo

<twitter-button class="share-button--circle share-button--outline" btnText />

Twitter outline and circle button with icon

Live Demo

<facebook-button class="share-button--outline" hasCounter />

Twitter outline button with icon and counter

Live Demo

<facebook-button
  class="share-button--painted"
  url="https://github.com/"
  hasCounter
/>

Twitter painted button with icon and counter

Live Demo

Author

This component was developed by Alexander Shulaev for personal purposes and submitted to Open Source, if it will help someone I will be very happy about it😊

Link

SVG-icon by Simple Icons

Roadmap

  • Implement a workflow with automatic version update and automatic publication of changes in npm via GitHub action

License

The MIT License (MIT)

vue-share-buttons's People

Contributors

alexandrshy avatar antono avatar dependabot[bot] avatar moondef avatar neongc avatar neongh avatar spekulatius avatar unlimittt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue-share-buttons's Issues

Cannot read property 'share_count' of undefined

Expected Behavior

All the examples should work without errors

Actual Behavior

Some of the examples does not work and return the error below:

TypeError
Cannot read property 'share_count' of undefined
window.<computed>
https://88yq86vzk2.csb.app/node_modules/vue-share-buttons/src/components/FacebookButton.vue?3fb6e918:77:36
(anonymous function)
https://graph.facebook.com/?id=https%3A%2F%2F88yq86vzk2.csb.app%2F&callback=Facebook_172:1:6

Steps to Reproduce the Problem

From one of the examples at https://www.npmjs.com/package/vue-share-buttons , the one with <facebook-button class="share-button--outline" hasCounter />:

  1. https://codesandbox.io/s/88yq86vzk2?fontsize=14&file=/src/main.js

Request For Medium Button

This is not acutually a problem but a feature request.
I Want a Button for Medium, it will really go well.
Thanks

Whatsappbutton wrong documentation

Code from WhatsAppButton.vue

props: {
    shareUrl: { type: String, default: getDocumentHref },
    btnText: { type: String, default: "WhatsApp" },
    hasIcon: { type: Boolean, default: true }
  },

Issue

the whatsapp button has the property shareUrl instead of the url property like almost every other share button.

In the README it says that it has the url property. This is wrong as the code above shows

So in the README the documentation for Whatsapp should be changed to shareUrl

Need to wrap each button in span?

Hello @Alexandrshy

I tried to implement your lib in a project of mine. I've noticed, I had to wrap each button in a span to work correctly. Without, only the first button was displayed. Any idea what is causing this?

My code:

    <facebook-button
        isBlank="false"
        btnText="Post"
    />
    <twitter-button
        isBlank="false"
        btnText="Tweet"
    />
    <reddit-button
        isBlank="false"
        btnText="Post"
    />

Expected Behavior

image

Actual Behavior

image

Work around:

        <span>
          <facebook-button
            isBlank="false"
            btnText="Post"
        />
        </span>
        <span>
          <twitter-button
            isBlank="false"
            btnText="Tweet"
        />
        </span>
        <span>
          <reddit-button
            isBlank="false"
            btnText="Post"
        />
        </span>

Maybe I'm doing something wrong? While it looks pretty straight forward I'm not sure...

Cheers,
Peter

This is not work in nuxt

Expected Behavior

Work in nuxtjs

Actual Behavior

Doesn't work in nuxtjs, display error Cannot find module

Steps to Reproduce the Problem

Wrong file name

Expected Behavior

File path: src/VueShareButtons.vue

Actual Behavior

File path: src/VueShareBttons.vue

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.