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-resizable-area

v0.4.2

Published

Create a resizable component with percentage width/height support

Downloads

190

Readme

react-resizable-area

Create a resizable component with percentage size support.

Demo

Link

Installation

Install the package using npm:

npm install react-grid-layout

Example

import React from 'react'
import ReactDOM from 'react-dom'
import { ResizableArea } from 'react-resizable-area'

class Main extends React.Component {
  state = {}
  render () {
    return (
      <ResizableArea
        minimumHeight={{px: 0, percent: 50}}
        minimumWidth={{px: 0, percent: 50}}
        initHeight={{px: 0, percent: 80}}
        initWidth={{px: 0, percent: 80}}
        defaultHeight={{px: 0, percent: 80}}
        defaultWidth={{px: 0, percent: 80}}
        maximumHeight={{px: 0, percent: 100}}
        maximumWidth={{px: 0, percent: 100}}
        parentContainer={document.querySelector('.resizable-container')}
        >
        <div
          style={{backgroundColor: '#03a9f4', width: '100%', height: '100%'}}
          ref={e => !this.state.container && this.setState({ container: e })}
          >
          <ResizableArea
            minimumHeight={{px: 0, percent: 10}}
            minimumWidth={{px: 0, percent: 10}}
            initHeight={{px: 20, percent: 50}}
            initWidth={{px: 20, percent: 50}}
            defaultHeight={{px: 0, percent: 50}}
            defaultWidth={{px: 0, percent: 50}}
            maximumHeight={{px: 0, percent: 80}}
            maximumWidth={{px: 0, percent: 80}}
            parentContainer={this.state.container}
            >
            <div style={{backgroundColor: 'white', width: '100%', height: '100%'}}>
            </div>
         </ResizableArea>
        </div>
      </ResizableArea>
    )
  }
}

ReactDOM.render(
  <Main />,
  document.querySelector('.resizable-container')
)

Methods

setSize: { width: { px: number, percent: number }, height: { px: number, percent: number } }

Set size of component directly

Props

id: string

ID of the resizable component

className: string

Extra className of the resizable component

children: node

The component that resized by resizable component

parentContainer: node

The DOM node that CSS prop width & height relative to.

disable: { width: bool, height: bool }

Disable resize on width / height direction

usePercentageResize: { width: bool, height: bool }

Resize the component by changing percentage or px

minimumWidth: { px: number, percent: number }

The minimum width of the component

Present as calc({px}px + {percent}%)

minimumHeight: { px: number, percent: number }

The minimum height of the component

maximumWidth: { px: number, percent: number }

The maximum width of the component

maximumHeight: { px: number, percent: number }

The maximum height of the component

initWidth: { px: number, percent: number }

The initial width of the component

initHeight: { px: number, percent: number }

The initial height of the component

defaultWidth: { px: number, percent: number }

The default width of the component (double click on right edge will reset to this size)

defaultHeight: { px: number, percent: number }

The default height of the component (double click on bottom edge will reset to this size)

onResizing: function ({ width, height })

Callback that fired on component resizing

onResized: function ({ width, height })

Callback that fired on resize completed.