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-expand-collapse

v0.2.0

Published

A simple and customizable expand-collapse react component for the web.

Downloads

592

Readme

react-expand-collapse

A simple and customizable expand-collapse react component for the web.

  • Customizable - Easy to customize button state and text.
  • Lightweight - Less than 5kb of size. No dependencies other than prop-types.

Demo

Demo Link

Installation

npm install react-expand-collapse

Usage

Important: Make sure to include the css file or feel free to create your own.

import React from 'react';
import ExpandCollapse from 'react-expand-collapse';

class MovieInfo extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
        <h4>Inception</h4>
        <ExpandCollapse
          previewHeight="88px"
        >
          Visionary filmmaker Christopher Nolan (Memento, The Dark Knight) writes and directs this psychological sci-fi action film about a thief who possesses the power to enter into the dreams of others. Dom Cobb (Leonardo DiCaprio) doesn't steal things, he steals ideas. By projecting himself deep into the subconscious of his targets, he can glean information that even the best computer hackers can't get to. In the world of corporate espionage, Cobb is the ultimate weapon. But even weapons have their weakness, and when Cobb loses everything, he's forced to embark on one final mission in a desperate quest for redemption. This time, Cobb won't be harvesting an idea, but sowing one. Should he and his team of specialists succeed, they will have discovered a new frontier in the art of psychic espionage. They've planned everything to perfection, and they have all the tools to get the job done. Their mission is complicated, however, by the sudden appearance of a malevolent foe that seems to know exactly what they're up to, and precisely how to stop them. ~ Jason Buchanan, Rovi
        </ExpandCollapse>
      </div>
    );
  }
}

API

| Prop | Type | Default | Description | -------------- | ------------- | ------------- | ------------- | | previewHeight | string | Required | The height of component in collapsed state. | | children | node | Required | Element to render inside the component. | | className | string | '' | A custom class will be applied to the root of ExpandCollapse. | | expanded | bool | false | If true, the component is in expanded state. If false, it is in collapsed state. | | expandText | string | Expand | The text shown in expanded state. | | collapseText | string | Collapse | The text shown in collapsed state. | | collapse | bool | true | If true, the component can be collapsed. If false, once it is expanded, it cannot be collapsed. | | ellipsis | bool | true | If true, the expandText will have a prefix of ellipsisText prop. If false, no prefix will appear. | | ellipsisText | string | '...' | The text to show before expandText text. | | onExpandClick | func | null | Invoked when the user clicks on expand button | | onCollapseClick | func | null | Invoked when the user clicks on collapse button | | onClick | func | null | Invoked when the user clicks on button |

License

MIT