0.2.8 • Published 2 years ago

split-pane-react-fixed v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

中文

split-pane-react-fixed

Resizable split panes for React.js.Check out the live demo. Different themes.

Features

  • 💪Simple api and support for multiple panels.
  • 🔥Supports vertical & horizontal layouts and fluid pane.
  • 🎉Use controlled component mode, flexible use.
  • 😎React16.8 version at least, and React18 version at the same time.
  • 👷‍♂️Support flexible and convenient customization of sash.

reference

split-pane-react

Installing

# use npm
npm install split-pane-react-fixed

# or if you use yarn
yarn add split-pane-react-fixed

Example Usage

import React, { useState } from 'react';
import SplitPane, { Pane } from 'split-pane-react-fixed';
import 'split-pane-react-fixed/esm/themes/default.css';

function style (color) {
  return {
    height: '100%',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: color
  };
}

function App () {
  const [sizes, setSizes] = useState([100, '30%', 'auto']);

  return (
    <div style={{ height: 500 }}>
      <SplitPane
        split='vertical'
        sizes={sizes}
        onChange={setSizes}
      >
        <Pane minSize={50} maxSize='50%'>
          <div style={style('#ddd')}>
            pane1
          </div>
        </Pane>
        <div style={style('#ccc')}>
          pane2
        </div>
        <div style={style('#eee')}>
          pane3
        </div>
      </SplitPane>
    </div>
  );
};

props

SplitPane

PropertyDescriptionTypeDefault
splitDetermine layout of panes.'vertical' |'horizontal''vertical'
sizesCollection of different panel sizes,Only support controlled mode, so it's required(string | number)[][]
resizerSizeSpecify the size for resizernumber4
allowResizeShould allowed to resizedbooleantrue
classNamesplit pane custom class namestringvoid
sashRenderUser defined sliding axis function(index: number, active: boolean) => voidvoid
performanceModeHigh performance mode to avoid excessive pressure on the browserbooleanfalse
onChangeCallback of size change(sizes: number[],e:MouseEvent) => voidvoid
onDragStartThis callback is invoked when a drag starts(e:MouseEvent) => voidvoid
onDragEndThis callback is invoked when a drag ends(e:MouseEvent) => voidvoid
onSashMouseEnterThis callback is invoked when mouse in sash(e:MouseEvent,index:number)=>voidvoid

Pane

PropertyDescriptionTypeDefault
classNamepane class namestringvoid
minSizeLimit the minimum size of the panelstring | numbervoid
maxSizeLimit the maximum size of this panelstring|numbervoid
primaryThe size of the pane will not be changed firstbooleanfalse

themes

You can use the sashRender parameter to configure the theme you need:

  • The default theme style refers to vscode style
  • At the same time, we have built in a theme similar to sublime
  • Other demo themes.

License

split-pane-react licensed under MIT.

PS: I would love to know if you're using split-pane-react. If you have any use problems, you can raise the issue, and I will repair them as soon as possible. The project will always be maintained. If you have a good idea, you can propose a merge. If this component helps you, please leave your star. Those who need it will be very grateful.

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago