Coder Social home page Coder Social logo

estevanmaito / sharect Goto Github PK

View Code? Open in Web Editor NEW
219.0 7.0 20.0 2.46 MB

๐Ÿ”— A lightweight JavaScript library to let users share their text selections to social networks.

Home Page: https://estevanmaito.github.io/sharect/

License: MIT License

JavaScript 89.40% HTML 10.60%
share facebook-share social-network javascript-library twitter-share text selection medium

sharect's Issues

Remove mobile tooltip

During tests I realized that Sharect would not work well with the default way mobile OS's treat text selection on browsers, as it already shows various options, including share the selection.

Email sharing please

Describe the solution you'd like
Would like to be able to share via email with the subject line auto-populated with link to page and message auto-populated with selected text.

On mobile, show share options in bottom bar

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
Sharect doesn't work on mobile now because on those systems when you select text, the OS already creates a tooltip. It's possible to still give the user the options to share, but it must be done in another, maybe without a tooltip.

Describe alternatives you've considered
The image below shows a common approach that websites give users to share the entire article.
bottom share navigation

The idea is really the same.

Enable this plugin only on given element or id or class not on body

This plugin do not work for a given particular id or class or html element. or am I missing something.

Say I wan to enable this plugin only on div having id say id1 but not on id having value id2 etc. same is true for class as well.

Would you suggest, how to achieve that.

Add tests and reach 100% coverage

Is your feature request related to a problem? Please describe.
It's not related to a problem... yet.

Describe the solution you'd like
Tests will accelerate the development of new features and bring confidence to contributors and users.

Describe alternatives you've considered
There's no alternatives to consider. We test, or we test.

Change Facebook share method so appId is not required anymore

Is your feature request related to a problem? Please describe.
It is overkill to create an app just to get and ID to just create a share button. Then you need to add the following code to your page, that will download another script.

<script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'YOUR-APP-ID',
        xfbml      : true,
        version    : 'v3.2'
      });
      FB.AppEvents.logPageView();
    };

    (function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = "https://connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
  </script>

Describe the solution you'd like
Open a pop-up with the following URL, just like we already do with Twitter share.

https://www.facebook.com/sharer/sharer.php?
  u=[current-url]
  &quote=[selected-text]

Sharect in WordPress

Hi Estevan
I have long wanted to make a simple wp plugin and place it in the worldpress directory.
https://github.com/nektobit/wp-sharect
How do you like this idea? Naturally, I can support users who have problems with the wordpress side.
If you think that you should not use your library this way, I will delete the repository without question :)

Extend the API so it's possible to add other sharing options

Is your feature request related to a problem? Please describe.
Well, problem is a hard word ๐Ÿ˜
Today, if someone would like to create another button, let's say, for sharing on Reddit, they would need to change the source code to, at least:

  • add a redditConfig property to hold the SVG icon and the url
  • create a function, probably createRedditButton
  • append it to _icons property

This way, the Reddit button would appear in the tooltip.

Describe the solution you'd like
First of all, the current way used to create buttons isn't very DRY. This could be improved.
A new method could be added to the current chain (config and init), like createShareButton or createCustomShareButton (just ideas), that would accept an SVG icon and a function responsible for the click event.
These options would be appended to the default _icons property and then rendered from init.

Describe alternatives you've considered
I didn't considered alternatives and would like to hear opinions on this. I don't think we should add more options to the core, as I don't think the mean user would use them. With the proposed approach, developers whose projects request more social share buttons could add whatever other functionalities they want.

Possible to accommodate for '%' signs?

Highlighting a snippet of text containing a percentage doesn't work with Twitter text share - would it be possible to accommodate for special characters? This would be particularly useful for content containing lots of stats.

2.0 Docs

  • Give examples of appendCustomShareButton (Reddit, Hacker News, Linkedin) #11
  • What changed in 2.0? (Twitter username, Facebook true by default and no appId required #13)
  • New way of importing/installing
  • Site: create live examples

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.