npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

github-reaction-button

v1.1.15

Published

reaction button that stores data in github issue comments

Downloads

31

Readme

github-reaction-button

Reaction button that stores reaction data in github issues.

TODO

  • [x] Custom renderer
  • [ ] Test code
  • [ ] Function to add comment text by user
  • [ ] Embed url in comment

Demo

https://yusukeshibata.github.io/github-reaction-button/

screenshot

Install

<script src="https://unpkg.com/github-reaction-button/dist/githubreactionbutton.js"></script>

or from npm

npm install github-reaction-button

Usage

const reaction = new GithubReactionButton({

  // required config
  client_id: 'Github Application Client ID',
  client_secret: 'Github Application Client Secret',
  repo: 'Github repo',
  owner: 'Github repo owner',
  issue: 1, // issue number
  id: 'unique_id_to_record_reaction',

  // optional config(please set if your embedding URL is different from redirect_uri)
  redirect_uri: 'Redirect URI you set on Github Application setting'

})
reaction.render('reaction-container') // container element's id

// render to other element(you can override config with second argument)
reaction.render('reaction-container2', { id: 'unique_id_2' })

Usage as react component

import GithubReactionButton from 'github-reaction-button'

const Reaction = new GithubReactionButton({ ... })

render() {
  // config will be override with component's props
  return (<Reaction.component id='test-1' />)
}

Options

  • client_id String

    Required. Github Application Client ID.

  • client_secret String

    Required. Github Application Client Secret.

  • repo String

    Required. Github repository.

  • issue Number

    Required. Github issue number to store user's reaction.

  • owner String

    Required. Github repository owner. Can be personal user or organization.

  • id String

    Required. Embeding reaction component's unique id.

  • redirect_uri String

    Default: location.href.

    Specify redirect uri if your App's redirect_uri you set on Github application setting isn't same as embedding url.

  • renderer React component

    Default: Default render

    // all props set on `Reaction.component` will be passed to this.props
    const CustomComponent = ({ error, busy, count, reaction, ...props }) => (
      <span style={{
        color: error ? 'red' : busy ? 'gray' : !!reaction ? 'red' : 'black'
      }} {...props}> &hearts; {count} </span>)
    
    <Reaction.component renderer={CustomComponent} id='test-1' />

Instance Methods

  • init()

    If your redirect_uri isn't the URL you installed the button, you can call this method to redirect back to the URI and complete authorization process.

    await reaction.init()
  • render(String/HTMLElement, config_to_override)

    Render reaction component. Second arg override config values set on constructor.

    applied_config = { ...config_set_on_constructor, ...config_to_override }
  • get component()

    React component. Component's props will override the config you set on constructor.

    <Reaction.component id='test-1' />

LICENSE

MIT