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

solid-resizable

v1.0.3

Published

A `Resizable` component to resize its content by dragging handles on its edges.

Downloads

4

Readme

solid-resizable

A Resizable component to resize its content by dragging handles on its edges.

Installation

To install the solid-resizable package, simply use your preferred package manager:

yarn add solid-resizable

or

pnpm add solid-resizable

Importing

You can import the Resizable component into your project like this:

import Resizable from 'solid-resizable';

Example Usage

Here is an example of how to use the Resizable component:

<Resizable
  leftHandle={true}
  rightHandle={<CustomHandle />}
  topHandle={false}
  bottomHandle={true}
  onResizeStart={(direction) => {
    console.log(`Resize started in the ${direction} direction`)
  }}
  onResizeStop={(direction) => {
    console.log(`Resize stopped in the ${direction} direction`)
  }}
  onResize={(direction, width, height, widthDelta, heightDelta) => {
    console.log(`Resizing in the ${direction} direction`);
    console.log(`New Size: ${width}x${height}`);
    console.log(`Delta: ${widthDelta}x${heightDelta}`);
  }}
  debounce={200}
>
  <ContentComponent />
</Resizable>

Props

leftHandle

  • Type: boolean | JSX.Element
  • Description: Whether to show a handle on the left side or a custom JSX element for the handle.

rightHandle

  • Type: boolean | JSX.Element
  • Description: Whether to show a handle on the right side or a custom JSX element for the handle.

topHandle

  • Type: boolean | JSX.Element
  • Description: Whether to show a handle on the top side or a custom JSX element for the handle.

bottomHandle

  • Type: boolean | JSX.Element
  • Description: Whether to show a handle on the bottom side or a custom JSX element for the handle.

onResizeStart

  • Type: (direction: ResizeDirection) => void
  • Description: Callback function when resizing starts.
  • Parameters:
    • direction: The direction in which resizing is happening.

onResizeStop

  • Type: (direction: ResizeDirection) => void
  • Description: Callback function when resizing ends.
  • Parameters:
    • direction: The direction in which resizing is happening.

onResize

  • Type: (direction: ResizeDirection, width: number, height: number, widthDelta: number, heightDelta: number) => void
  • Description: Callback function during resizing.
  • Parameters:
    • direction: The direction in which resizing is happening.
    • width: The new width of the resizable element.
    • height: The new height of the resizable element.
    • widthDelta: The change in width.
    • heightDelta: The change in height.

style

  • Type: Omit<Omit<JSX.CSSProperties, 'display'>, 'flex-direction'>
  • Description: Custom styles for the resizable element.
    • Note: display and flex-direction are not allowed.

debounce

  • Type: number
  • Description: Debounce delay for the resize events. Default is 1.

children

  • Type: JSX.Element
  • Description: The content to be rendered inside the resizable element.

ResizeDirection

  • Type: 'top' | 'bottom' | 'left' | 'right'
  • Description: Defines the direction in which resizing can happen.

Custom Handle Example

You can pass a custom JSX element to be used as a handle:

const CustomHandle = () => <div className="custom-handle">||</div>;

<Resizable
  rightHandle={<CustomHandle />}
>
  <ContentComponent />
</Resizable>

Events

Resizing Events

  • onResizeStart: Triggered when resizing starts.
  • onResizeStop: Triggered when resizing stops.
  • onResize: Triggered during resizing to provide updated size information.

Styling

You can pass custom styles to the Resizable component using the style prop. Note that display and flex-direction properties are not allowed to be set via the style prop. You can also specify min-width, max-width, min-height, and max-height to set bounds for resizability.

<Resizable
  style={{
    border: '2px dashed red',
    'min-width': '100px',
    'max-width: '500px',
    'min-height': '100px',
    'max-height': '500px'
  }}
>
  <ContentComponent />
</Resizable>

Performance

The debounce prop can be used to control the frequency of resize event callbacks. By default, this delay is set to 1 millisecond.

<Resizable debounce={100}>
  <ContentComponent />
</Resizable>