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-super-dropdown

v1.2.9

Published

Non-prescriptive React.js dropdown toolkit

Downloads

34

Readme

React Super Dropdown

Non-prescriptive React.js dropdown toolkit.

This is a fork of react-simple-dropdown.

With the following enhancements:

  • Updated ES2015 source syntax
  • Removed need for external stylesheet to be used
  • Added ability to use custom tag names for the trigger and menu elements. With react-simple-dropdown the trigger and menu may only be rendered using div tags. With this component you can use ul, a, or even any custom components you like. This is useful if you are using a ready-made theme.
  • Menu is not rendered if dropdown is closed - instead of it just being hidden by css.

Installation

This module is designed for use with Browserify (but should work with anything CommonJS compatible). You can easily install it with npm:

npm install react-super-dropdown

How to use

This module provides three React components that you can use as a basis for any kind of dropdown menu:

  • DropdownTrigger: The element that will cause your dropdown to appear when clicked.
  • DropdownContents: Contains the "filling" of your dropdown. Generally, this is a list of links.
  • Dropdown: The base element for your dropdown. This contains both the DropdownTrigger and the DropdownContents, and handles communication between them.

Keep in mind that DropdownTrigger and DropdownContent must be direct children of Dropdown. Here's a quick example:

import React, { Component } from 'react';
import Dropdown, { DropdownTrigger, DropdownContent } from 'react-super-dropdown';

class MyDropdown extends Component {
  render () {
    return (
      <Dropdown>
        <DropdownTrigger tagName='a'>Profile</DropdownTrigger>
        <DropdownContent tagName='ul'>
          <li>
            <a href="/profile">Profile</a>
          </li>
          <li>
            <a href="/favorites">Favorites</a>
          </li>
          <li>
            <a href="/logout">Log Out</a>
          </li>
        </DropdownContent>
      </Dropdown>
    );
  }
}

Options

Options can be passed to Dropdown as props.A list of available options can be found below. These must be passed to the containing Dropdown component.

Property | Type | Description ----- | ----- | ----- active | boolean | Manually show/hide the DropdownContent. Make sure to unset this or the dropdown will stay open. onShow | function | Callback for when DropdownContent is shown. onHide | function | Callback for when DropdownContent is hidden.

DropdownContent and DropdownTrigger components can also be passed the following options as props:

Property | Type | Description ----- | ----- | ----- tagName | string/component | tagName or component to be used for rendered element