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

react-quick-reactions

v2.0.2

Published

A popup emoji-reaction component for React.

Downloads

20

Readme

react-quick-reactions

Try it out: dylandbl.github.io/react-quick-reactions

A lightweight, customizable popup component for quick reactions and emojis, à la GitHub's reaction popup or Facebook's "likes".

Installation

npm install react-quick-reactions

Or with yarn:

yarn add react-quick-reactions

Example use

import { useState } from "react";
import QuickReactions from "react-quick-reactions";

const App = () => {
  const [isVisible, setIsVisible] = useState(false);
  
  return (
    <div className="App">
      <QuickReactions
        reactionsArray={[
          {
            name: "Laughing",
            content: "😂",
          }
        ]}
        isVisible={isVisible}
        onClose={() => setIsVisible(false)}
        onClickReaction={(reaction) => {
          window.alert(reaction.content);
        }}
        trigger={
          <button
            onClick={() => {
              setIsVisible(!isVisible);
            }}
          >
            Show
          </button>
        }
      />
    </div>
  );
}

API

| Prop name | Type | Default value | Description | | --------------------------------- | --------------------------- | ------------- | ----------- | | animation | AnimationType| "fade" | The animation effect used when the popup is displayed. | | changeHeaderOnReactionElemHover | boolean | true | When true, the popup's header updates on emoji mouseover to display the emoji's name. | | closeButton | string \| JSX.Element | - | String or element to replace the default close button. | | disableClickAwayToClose | boolean | - | Disables closing by clicking away from the popup. | | header | string | "Quick reactions" | Alternative default title for popup's header. | | hideCloseButton | boolean | - | Hides the close button. | | hideHeader | boolean | - | Hides the header | | isVisible | boolean | false | Determines popup visibility. | | onClickReaction | (value: ReactionObj) => void | - | Function called when an emoji is clicked. Passes the emoji's ReactionObj. | | onClose | () => void | - | Function called on popup close. | | placement | PlacementType | "bottom-start" | Positions the popup relative to the trigger. | | reactionsArray | ReactionObj[] | - | Array of emojis. | | wide | boolean | - | Makes the popup wide instead of tall. Up to eight emojis wide, by default. | | closeButtonClassName | string | - | Optional classes for the close button span. | | outerDivClassName | string | - | Optional classes for the popup container div. | | reactionElementClassName | string | - | Optional classes for the emoji spans. | | selectionContainerClassName | string | - | Optional classes for the div containing the array of emojis. |

AnimationType

type AnimationType = "drop" | "fade" | "flip" | "zoom" | "none";

PlacementType

type PlacementType =
  | "top-start"
  | "top"
  | "top-end"
  | "left-start"
  | "left"
  | "left-end"
  | "right-start"
  | "right"
  | "right-end"
  | "bottom-start"
  | "bottom"
  | "bottom-end";

ReactionObj

type ReactionObj = {
  id?: string;  // Used as element's #id.
  name: string; // Displayed in popup header.
  content: string | JSX.Element;
};

Example

const emojiArr1 = [
  {
    id: "laughing",
    name: "Laughing",
    content: "😂",
  },
  {
    id: "crying",
    name: "Crying",
    content: "😢",
  },
  {
    id: "thinking",
    name: "Thinking",
    content: "🤔",
  },
  {
    id: "screaming",
    name: "Screaming",
    content: "😱",
  },
];