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-page-split

v0.0.7

Published

React components & hooks for page splitting.

Downloads

359

Readme

react-page-split

npm CI Status License

React components & hooks for page splitting.

Demo

| IE / Edge | Firefox | Chrome | Opera | |:----:|:---:|:---:|:---:| | Edge | 29+ | 32+ | 20+ |

Installation

npm install --save react-page-split

Examples

Basic

Advanced

  • Nested
    • Demonstrates nesting page splits within one another.
  • Preset Sizes
    • Demonstrates specifying initial sizes for each panel.
  • Resizes
    • Demonstrates the difference in Proportional, Cascade, ReverseCascade, and Limit resizes.
  • Boundaries
    • Demonstrates setting a min-width and max-width on a panel.
  • Divider on Hover
    • Demonstrates a divider that is 11px wide, but appears 1px wide until hovered.
  • Divider with Buttons
    • Demonstrates embedding a <button> on a custom divider.
  • Events
    • Demonstrates listening to the events published when a divider is dragged.
  • Expand Collapse
    • Demonstrates expanding & collapsing panels on <button> click.

Usage

import {
    HorizontalPageSplit,
    VerticalPageSplit
} from 'react-page-split';
import 'react-page-split/style.css';

function Example() {
    return (
        <HorizontalPageSplit widths={['20%', '50%', '30%']}>
            <VerticalPageSplit>
                <div>Top left</div>
                <div>Middle left</div>
                <div>Bottom left</div>
            </VerticalPageSplit>

            <div>Middle</div>

            <VerticalPageSplit heights={['25%', '75%']}>
                <div>Top right</div>
                <div>Bottom right</div>
            </VerticalPageSplit>
        </HorizontalPageSplit>
    )
}

Example

Resizes

There are four defined resizes that occur when dragging a divider. The default is for panels to be resized at a Proportional rate.

A custom Resize can also be provided.

Demo

Proportional

A Proportional resize affects all panels across the axis at a proportionally equal rate.

Proportional resize

import {
    HorizontalPageSplit,
    Proportional
} from 'react-page-split';
import 'react-page-split/style.css';

function CascadeBehaviourExample() {
    return (
        <HorizontalPageSplit resize={Proportional}>
            <div>A</div>
            <div>B</div>
            <div>C</div>
            <div>D</div>
        </HorizontalPageSplit>
    )
}

Cascade

A Cascade resize cascades across all panels along the axis, starting with the closest panel.

Cascade resize

import {
    HorizontalPageSplit,
    Cascade
} from 'react-page-split';
import 'react-page-split/style.css';

function CascadeBehaviourExample() {
    return (
        <HorizontalPageSplit resize={Cascade}>
            <div>A</div>
            <div>B</div>
            <div>C</div>
            <div>D</div>
        </HorizontalPageSplit>
    )
}

Reverse Cascade

A ReverseCascade resize cascades across all panels along the axis, starting with the furthest panel.

Reverse cascade resize

import {
    HorizontalPageSplit,
    ReverseCascade
} from 'react-page-split';
import 'react-page-split/style.css';

function CascadeReverseBehaviourExample() {
    return (
        <HorizontalPageSplit resize={ReverseCascade}>
            <div>A</div>
            <div>B</div>
            <div>C</div>
            <div>D</div>
        </HorizontalPageSplit>
    )
}

Limit

A Limit resize causes a resize to be limited within panels adjacent to the dragged divider.

Limit resize

import {
    HorizontalPageSplit,
    Limit
} from 'react-page-split';
import 'react-page-split/style.css';

function LimitBehaviourExample() {
    return (
        <HorizontalPageSplit resize={Limit}>
            <div>A</div>
            <div>B</div>
            <div>C</div>
            <div>D</div>
        </HorizontalPageSplit>
    )
}

Customization

All parts of the library may be customized, either via CSS or via the API.

Hooks

The hooks allow you to apply the necessary styles, classes, and event listeners to any element.

import {
    DividerProps,
    HorizontalPageSplit,
    useDivider
} from 'react-page-split';
import 'react-page-split/style.css';

function CustomDividerExample() {
    return (
        <HorizontalPageSplit divider={CustomDivider}>
            <div>A</div>
            <div>B</div>
        </HorizontalPageSplit>
    )
}

function CustomDivider(props: DividerProps<HTMLDivElement>) {
    const {
        index,
        ...rest
    } = props;

    const {
        children,
        ...dividerProps
    } = useDivider({
        className: 'custom-divider',
        ...rest
    });

    return (
        <div {...dividerProps}>
            <span>Divider #{index + 1}</span>
            {children}
            <button>My custom button</button>
        </div>
    );
}

Components

The components take various props that allow you to embed custom behaviour.

import {
    HorizontalDivider,
    HorizontalDividerProps,
    HorizontalPageSplit
} from 'react-page-split';
import 'react-page-split/style.css';

function CustomDividerExample() {
    return (
        <HorizontalPageSplit divider={CustomDivider}>
            <div>A</div>
            <div>B</div>
        </HorizontalPageSplit>
    )
}

function CustomDivider(props: HorizontalDividerProps) {
    const {
        index,
        children,
        ...rest
    } = props;

    return (
        <HorizontalDivider className="custom-divider" index={index} {...rest}>
            <span>Divider #{index + 1}</span>
            {children}
            <button>My custom button</button>
        </HorizontalDivider>
    );
}

Contributing

Bug reports and pull requests are welcome on GitHub.

License

This project is available under the terms of the ISC license. See the LICENSE file for the copyright information and licensing terms.