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-quickmenu

v1.0.1

Published

[See the live demo on playground ↗](https://react-quickmenu.vercel.app/playground)

Downloads

3

Readme

Playground

See the live demo on playground ↗

Gif Adı


Installation - Quick Start

To add React Quick Menu to your project, follow these steps:

Installation via NPM

React Quick Menu can be easily integrated into your project via NPM (Node Package Manager). Open your terminal or command prompt in the root directory of your project and run the following command:

npm install react-quickmenu --save

The above command will download the React Quick Menu package to your project and add it to your dependencies.

Usage

After adding the package to your project, you can start using React Quick Menu. First, you'll need to integrate the Context Menu provider into your project. To do this, add the ContextMenuProvider component to a top-level component in your project.

import { ContextMenuProvider } from "react-quickmenu";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <ContextMenuProvider theme={"dark"}>
    <App />
  </ContextMenuProvider>
);

Next, you can define the context menu using the ContextMenuWrapper component within any component where you want to use the context menu.

import { ContextMenuWrapper, ContextMenu, ContextMenuItem } from 'react-quickmenu';

const MyComponent = () => {
  const contextMenu = (
    <ContextMenu id={0}>
        <ContextMenuItem text="MenuItem 1" onClick={() => alert("MenuItem 1 clicked")} />
        <ContextMenuItem text="MenuItem 2" onClick={() => alert("MenuItem 2 clicked")} />
    </ContextMenu>
  );

  return (
    <ContextMenuWrapper contextMenu={contextMenu}>
      <div>
        {/* Content */}
      </div>
    </ContextMenuWrapper>
  );
};

API Reference

This section provides detailed information about the components and props available in the React Quick Menu package.

ContextMenuProvider

The ContextMenuProvider component is used to provide context menu functionality to the entire application. It should be rendered at the root of your application.

Props

  • theme (optional): Specifies the theme to be applied to the context menu. (Default: light)

ContextMenuWrapper

The ContextMenuWrapper component is used to wrap any component where you want to display a context menu. It defines the area where the context menu will appear when triggered.

Props

  • contextMenu: The context menu content to be displayed.
  • children: The child components within the wrapper where the context menu can be triggered.

ContextMenu

The ContextMenu component defines a context menu group. It can contain ContextMenuItem and ExpandingContextMenuItem components.

Props

  • id: A unique identifier for the context menu group.

NOTE

The first ContextMenu component must have id set to 0. Subsequent ContextMenu components added after it should have IDs incremented by 1, such as 1, 2, 3, and so on.

Do this ✅

    <ContextMenu id={0}>
        <ContextMenuItem text="MenuItem 1" onClick={() => alert("MenuItem 1 clicked")} />
        <ContextMenuItem text="MenuItem 2" onClick={() => alert("MenuItem 2 clicked")} />

        <ExpandingContextMenuItem text="MenuItem 3">
            <ContextMenu id={1}>
                <ContextMenuItem text="MenuItem 1" onClick={() => alert("MenuItem 1 clicked")} />
                <ContextMenuItem text="MenuItem 2" onClick={() => alert("MenuItem 2 clicked")} />
            </ContextMenu>
        </ExpandingContextMenuItem>
    </ContextMenu>

Avoid doing this ❌

    <ContextMenu id={1}>
        <ContextMenuItem text="MenuItem 1" onClick={() => alert("MenuItem 1 clicked")} />
        <ContextMenuItem text="MenuItem 2" onClick={() => alert("MenuItem 2 clicked")} />

        <ExpandingContextMenuItem text="MenuItem 3">
            <ContextMenu id={3}>
                <ContextMenuItem text="MenuItem 1" onClick={() => alert("MenuItem 1 clicked")} />
                <ContextMenuItem text="MenuItem 2" onClick={() => alert("MenuItem 2 clicked")} />
            </ContextMenu>
        </ExpandingContextMenuItem>
    </ContextMenu>

ContextMenuItem

The ContextMenuItem component represents a single item in the context menu.

Props

  • text: The text to be displayed for the menu item.
  • onClick: The function to be called when the menu item is clicked.
  • disabled (optional): Specifies whether the menu item is disabled.

ExpandingContextMenuItem

The ExpandingContextMenuItem component represents a menu item that can expand to show additional items when clicked. This component can be nested to create a multi-level menu and must have a ContextMenu component as a child.

Props

  • text: The text to be displayed for the menu item.
  • disabled (optional): Specifies whether the menu item is disabled.