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

v0.2.6

Published

Check out the [demo](https://codesandbox.io/s/react-resizeable-examples-vsdcj?file=/src/app.js).

Downloads

1,721

Readme

react-resizeable

Check out the demo.

A react library that allows you to place custom resizeable grid components throughout your codebase.

react-resizeable exports two components, Resizeable, the parent container and, Child, the wrapper for any children. See demo for examples.

Features

⏳ Saves you time by handling all the annoying event listeners for you.

⭐️ Flexibility to use proper semantic HTML (both components accept an as prop!)

🐑 Simplicity -- no need to pass multiple breakpoints, if each child has a minWidth we'll handle the wrap for you!

Requirement

To use react-resizeable, you must use styled-component > 4.1 as it is a peer dependency.

Installation

$ yarn add react-resizeable
// or
$ npm i react-resizeable

Example

NOTE: most arguments are provided defaults (see Full API below) with the only required one being width on the <Child> component, however it is strongly recommended to include minWidth as well. (see demo for additional examples).

import React from 'react';
import { Resizeable, Child } from 'react-resizeable';

const SomeComponent = () => (
    <Resizeable height="100vh" as="main">
      <Child resize={{
        width: '50%',
        minWidth: '300px'
        resizeable: true,
        resizeDir: 'both'
      }}>
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit
        </p>
      </Child>
      <Child resize={{
        as: 'article',
        width: '50%',
        minWidth: '300px',
        height: '450px',
        minHeight: '350px'
      }}>
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit
        </p>
      </Child>
    </Resizeable>
)

export default SomeComponent;

Full API

<Parent />

Props:

interface ResizeableProps {
  flexDirection?: 'row' | 'column';
  height?: string;
  as?: keyof JSX.IntrinsicElements;
}

Defaults:

 {
   flexDirection: 'row',
   height: '100%',
   as: 'div',
 }

<Child />

Note:

  • <Child /> includes a forwardRef wrapper, so feel free to pass it a ref if need be.
  • all additional props passed to child are forwarded to the styled component so you could pass a style prop to override things if you were so inclined.

Props:

interface ChildProps {
  resize: {
    width: string;
    resizeDir?: 'none' | 'both' | 'horizontal' | 'vertical' | 'initial' | 'inherit';
    resizeable?: boolean;
    minWidth?: string;
    height?: string;
    minHeight?: string;
    as?: keyof JSX.IntrinsicElements;
  };
}

Defaults:

  resize: {
    width: 'n/a',
    resizeable: false,
    resizeDir: 'n/a',
    as: 'div',
    minWidth: 'min-content',
    height: '100%',
    minHeight: '100%',
  }

License

MIT Licensed

Contributors

This project follows the all-contributors specification. Contributions of any kind welcome!