Git Product home page Git Product logo

simple-share's Introduction

simple-share

Fast configurator for sharing to facebook, vkontakte, ok.ru, twitter + YA.metrika support

RU and EN description + JSDoc also available in share.js file

Usage

  • Add/import share.js file to your project
  • Create new instance:
let share = new Share({/* options */});
  • Use .create and .open methods

Options

Name Type Description Default
url String url to share
title String site title
image String image url
description String site description
metrics Object yandex metrics object (?)
prefix String prefix for metrics goal 'share_'
width Number popup width 600
height Number popup height 600
isCanvas Boolean Set to true, if your game (based on canvas) can't open links false
mode String '_blank' or '', also can take any windowName value ''
library String Read below 'vanilla'
id Number if 'vanilla' choosen, pass metrics id

Available library values

vanilla, vue, react

Available social media names

vk, fb, tw, ok

Methods

.create

You can use it to generate raw link as string w/o opening and metrics call

Example: Share.create('vk')

.open

Use it to generate link, open new window for share and call metrics.

Metrics works only if metrics option is passed

Example: Share.open('vk')

YA.metrika support

You can use script in vanilla js, react, vue, etc.

vanilla
  • Set 'vanilla' mode
  • Pass ym to metrics
  • Function: this.metrics(thid.id,'reachGoal',`${this.prefix}${name}`)
Vue + vue-yandex-metrika
  • Set 'vue' mode
  • Pass this.$metrika to metrics
  • Function: this.metrics.reachGoal(`${this.prefix}${name}`)
React + react-yandex-metrika
  • Set 'react' mode
  • Pass ym (your variable from import ym from 'react-yandex-metrika';) to metrics
  • Function: this.metrics('reachGoal','${this.prefix}${name}')

simple-share's People

Contributors

tabmk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.