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

clappy-button

v0.0.1

Published

The "Like" button evolved for payments.

Downloads

11

Readme

Clappy Button

Introduction

Clappy Button is a web component that can be embedded on any web page that supports JavaScript and HTML.

API

Parameters

<clappy-button> accepts the following HTML attributes as parameters:

  • amountperclap - Each time user claps, total amount will be incremented by this value e.g. "0.01"
  • amountmax - set equal to the user's current spendable balance.
  • currencycode / currencysymbol
    • if currencycode is specified, it will be used as a suffix in the counter e.g. 1 USD
    • if currencysymbol is specified, it will be used as a prefix in the counter e.g. $1
  • theme - "light" and "dark" are the current built-in themes. Alternatively, you can create your own.
  • instanceid - Unique identifier if there are multiple clappy buttons on the same page e.g. post-id-1

Example:

<clappy-button
  amountperclap="0.01"
  amountmax="0.10"
  currencycode="USD"
  currencySymbol="$"
  theme="light"
  instanceid="post-id-1"
></clappy-button>

Note: attributes are case sensitive and must be defined in all lowercase e.g. instanceid is valid, instanceId is invalid.

Events

Communication between your app and Clappy Button is made via Window message events.

Window Message Events emitted from Clappy Button to listen for in your app:

  • clap - sent with each clap. eventData includes with instanceId and amount.
  • loading - sent when user is finished clapping. eventData includes instanceId and amount.

Window Message Events to emit from your app to control Clappy Button animations:

  • success - triggers success animation
  • fail - triggers fail animation

Framework Implementation Examples

React


import { useEffect } from 'react'
import 'clappy-button'

function App() {

  async function confirmPayment(amount) {
    confirm(amount)
      .then(result => {
        window.postMessage({ app: 'clappy-button', event: 'success', instanceId: 'cb1' })
      })
      .catch(error => {
        window.postMessage({ app: 'clappy-button', event: 'fail', instanceId: 'cb1' })
      })
  }

  function handleWindowMessage(message) {
    if (message.data.app === 'clappy-button' && message.data.event === 'loading' && message.data.instanceId === 'cb1') {
      confirmPayment(message.data.eventData.amount)
    }
  };
  useEffect(() => {
    window.addEventListener("message", handleWindowMessage);
    return () => window.removeEventListener('message', handleWindowMessage);
  }, [])
  
  return (
    <div style={{ marginTop: '75px' }}>
      <clappy-button instanceid="cb1" currencysymbol="$" amountperclap="0.01"></clappy-button>
    </div>
  );
}

Custom Theme

Custom theme can be specified using css:

  clappy-button::part(custom-theme) {
    --background: #e6e6e6;
    --counter-background: #000;
    --counter-label: #fff;
    --confetti-primary: #2599ff;
    --confetti-secondary: #fdcb01;
    --hand: #000;
    --loading: #ababab;
    --loading-background: white;
    --success: #4bb543;
    --fail: #fc100d;
    --button-border: transparent;
  }

Contribute

Feature requests, issues and pull requests are welcome!

License

MIT License. See LICENSE.md for more information.

Maintainers

remjx - twitter | website

Donations

coindrop.to/clappy-button << Also built by remjx :)

Follow Clappy Button

Twitter @clappybutton