Skip to content

Commit a59a2c0

Browse files
committed
docs: big changes to documentation structure and initial story
1 parent dd1c4ff commit a59a2c0

File tree

4 files changed

+96
-182
lines changed

4 files changed

+96
-182
lines changed

README.md

Lines changed: 19 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is intended to be **the** simple, reliable, configurable, and elegant solution to having splittable, draggable and collapsible panes in your React application.
44

5-
<a href="https://react-collapse-pane.zurg.dev" target="_blank"><img src="logo.svg" alt="logo" style="width:100%"/></a>
5+
<a href="https://collapse-pane.zurg.dev" target="_blank"><img src="logo.svg" alt="logo" style="width:100%"/></a>
66
<p align="center">
77
<a href="https://github.com/b-zurg/react-collapse-pane/pulls">
88
<img alt="prs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
@@ -35,7 +35,8 @@ This is intended to be **the** simple, reliable, configurable, and elegant solut
3535

3636
</p>
3737

38-
## [[click for storybook demo]](https://react-collapse-pane.zurg.dev/)
38+
## [[click for storybook demo]](https://storybook.collapse-pane.zurg.dev/)
39+
## [[click for documentation site]](https://collapse-pane.zurg.dev/)
3940

4041
# Getting Started :rocket:
4142

@@ -57,13 +58,12 @@ If you're using Typescript the `SplitPaneProps`, as well as a few other helper t
5758
```ts
5859
import { SplitPane, SplitPaneProps, ResizerOptions, CollapseOptions, SplitPaneHooks } from "react-collapse-pane";
5960
```
60-
# Usage 🗻
61+
# Quick Start Usage :fire:
6162

62-
## The Basics 📘
63+
The only component you must interact with is `SplitPane`. This serves as a wrapper for all of the children you wish to lay out.
6364

64-
The only component you must interact with is `SplitPane`. This serves as a wrapper for the children you wish to layout in a panel form.
65+
All you're required to give is a `split` prop which can be either `"horizontal"` or `"vertical"`. This identifies what the orientation of the split panel will be.
6566

66-
Here's a basic example:
6767
```tsx
6868
<SplitPane split="vertical">
6969
<div>This is the first div</div>
@@ -73,147 +73,40 @@ Here's a basic example:
7373
</SplitPane>
7474
```
7575

76-
This will split the children. The children can be any valid React child. If a child is `null` it will be excluded from being split or displayed.
76+
What you just did is make a splittable panel layout!
7777

78-
**Note!** :eyes: There is no limit to the number of divs you have as children. The `SplitPane` will split them all accordingly.
78+
## Congrats! That was easy! :grin:
7979

80-
## Styling the Resizer 💅
80+
This basically splits the children vertically (i.e. full-height split). The children can be any valid React child. If a child is `null` it will be excluded from being split or displayed.
8181

82-
By default there is a 1px divider that starts out `rgba(120, 120, 120, 0.3)` and transitions to `rgba(120, 120, 120, 0.6)` on hover. Having a grey color with an alpha value means that it will look nice on both light and dark backgrounds.
82+
By default there is a 1px divider with a grabbable surface of 1rem width or height (depending on the split).
8383

84-
This is easily replaceable with the `css` and `hoverCss` options. No need to worry about pseudo selectors, transitions, animations or anything. You just have to indicate what the divider should look like **before** and **after**. This is accomplished by having two separate divs, one of which fades out and the other which fades in.
8584

86-
**Note** 🚨 The css props must be valid `React.CSSProperties` objects.
85+
There is also no limit to the number of divs you have as children. The `SplitPane` will split them all accordingly.
8786

88-
The sizer also has a grabbable surface that spans the height (or length) of the split and has a default grabbable surface of `1rem`. This is changeable by the `grabberSize` option which can be set to any valid CSS size value for `width` or `height`.
87+
## But what about collapsing the panels, styling the resizer, or RTL support? :sob:
8988

90-
**Note!** :eyes: As per default React CSS, a number will be interpreted as a `px` value.
89+
This library supports all of these things and more!
9190

91+
For more details check out [the documentation](https://collapse-pane.zurg.dev/)
9292

93-
Here's an example:
93+
# Documentation
9494

95-
```tsx
96-
<SplitPane
97-
split="vertical"
98-
resizerOptions={{
99-
css: {
100-
width: '1px',
101-
background: 'rgba(0, 0, 0, 0.1)',
102-
},
103-
hoverCss: {
104-
width: '3px',
105-
background: '1px solid rgba(102, 194, 255, 0.5)',
106-
},
107-
grabberSize: '1rem',
108-
}}
109-
>
110-
<div>This is the first div</div>
111-
<div>This is the second div</div>
112-
</SplitPane>
113-
```
114-
115-
116-
## Using a Collapse Button 🤹‍♀️
117-
118-
This is the killer feature of this library :eyes:
119-
120-
It's a common UX need to want to collapse the left or initial panel to give more room for another part of a site or app. This is easily accomplished by including several `CollapseOptions` as a prop to the `SplitPane`.
121-
122-
* `beforeToggleButton` - the element displayed as the collapse button **before** the panel is collapsed. This is an purely aesthetic component.
123-
* `afterToggleButton` - the element displayed as the collapse button **after** the panel is collapsed. This is an purely aesthetic component.
124-
* `buttonTransition` - the animation applied to the button appear/disappear. Possible options are `zoom`, `grow`, or `fade`
125-
* `buttonTransitionTimeout` - the time (in millisecons) that the animation for the appear/disappear of the button will take place
126-
* `buttonPositionOffset` - a positive or negative number that will either add or subtract the flex-basis (starting at 100) of an invisible div before or after the button. e.g. 50 would make the "before" 150 and the "after" 50
127-
* `collapseDirection` - `'left' | 'right' | 'up' | 'down'` - this is used to indicate the direction that it should collapse. By default collapsing happens left and up for the vertical and horizontal splits respectively. Valid values for a vertical split are `left` or `right` and valid values for a horizontal split are `up` or `down`
128-
* `collapseSize` - the size of the collapsed panel after it has been collapsed
129-
* `collapseTransitionTimeout` - the duration within the collapse animation will take place
130-
* `overlayCss` - the css applied to a div positioned on top of the content.
131-
132-
Here's an example using a `Button` element imported from elsewhere.
133-
134-
```tsx
135-
<SplitPane
136-
split="vertical"
137-
collapseOptions={{
138-
beforeToggleButton: <Button>⬅</Button>,
139-
afterToggleButton: <Button>➡</Button>,
140-
overlayCss: { backgroundColor: "black" },
141-
buttonTransition: "zoom",
142-
buttonPositionOffset: -20,
143-
collapsedSize: 50,
144-
collapseTransitionTimeout: 350,
145-
}}
146-
>
147-
<div>This is a div</div>
148-
<div>This is a second div</div>
149-
<div>This is a third div</div>
150-
<div>This is a fourth div</div>
151-
</SplitPane>
152-
```
153-
154-
**Note!** :eyes: When collapsing a panel, the `minSize` value is used to freeze the width of the collapsed panel to its minimum size and hides the rest of the content. This allows for a smooth collapse animation and is something to keep in mind. Until the animation reaches the min size it will shrink the panel as normal. Try it out for yourself!
95+
Documentation can be found at https://collapse-pane.zurg.dev
15596

97+
If you notice an issue then please make an issue or a PR! All docs are generated from the `docs` folder in the master branch.
15698

157-
## Hooks and Saving State ⚡
15899

159-
The component manages its own state while resizing however also allows an initial state as well as callbacks to save state changes.
160-
161-
These callbacks are in the `hooks` prop:
162-
```ts
163-
onDragStarted?: () => void;
164-
onChange?: (sizes: number[]) => void;
165-
onSaveSizes?: (sizes: number[]) => void;
166-
onCollapse?: (collapsedSizes: Nullable<number>[]) => void;
167-
```
168-
* `onDragStarted` fires as soon as you click down on a resizer and begin moving
169-
* `onSaveSizes` fires when the movement of a resizer is finished and the mouse lifts **OR** when a panel is collapsed - as both of these trigger size changes.
170-
* `onChange` fires on every size change, which can be **quite** often
171-
* `onCollapse` fires whenever a panel is collapsed, and keeps track of the previously collapsed panes
172-
173-
The initial state is passed in with these three props:
174-
175-
```ts
176-
initialSizes?: number[];
177-
minSizes?: number | number[];
178-
collapsedSizes?: Nullable<number>[];
179-
```
180-
* `initialSizes` is the default flex-basis that's given to the panes. This can be a simple ratio if it's the first time the render will happen and there's no saved sizes. e.g. `[1, 2, 1]` would make the second panel twice as big as its siblings. If you're saving state this should be the saved size value on a second render.
181-
* `minSizes` is either (1) a minimum size that's given to **all** the panes, or (2) an array of minimum sizes that's given to each pane in order. Any missing sizes in the array will be assumed default.
182-
* `collapsedSizes` an array of nullable numbers. This keeps track of a pane's size before it was collapsed. If not collapsed it's null. This will determine which panels are collapsed and what to do when they're uncollapsed.
183-
184-
Typically if this is a controlled component you would have state variables for `initialSizes` and `collapsedSizes` and have callbacks on `onSaveSizes` and `onCollapse` that would save the two data points and pass them back into the `SplitPane` on a remount. The `minSizes` would typically never change.
185-
186-
187-
## RTL Support ( Arabic, Hebrew, Farsi ) 🕋
188-
189-
This library easily supports RTL languages by providing a `direction` prop. This is only necessary if you're using RTL and can be left out.
190-
191-
**Note!** 🚨 the `direction` is _only_ applicable if the split is `vertical`
192-
193-
e.g.
194-
```tsx
195-
<div style={{ direction: 'rtl' }}>
196-
<SplitPane
197-
split="vertical"
198-
direction="rtl"
199-
>
200-
<div>اللوحة الأولى</div>
201-
<div>اللوحة الثانية</div>
202-
<div>اللوحة الثالثة</div>
203-
<div>اللوحة الرابعة</div>
204-
</SplitPane>
205-
</div>
206-
```
207100

208-
# Contributing and PRs 💖
101+
# Contributing and PRs :sparkling_heart:
209102

210103
If you would like to contribute please check out the [contributor guide](/CONTRIBUTING.md)
211104

212105
All contributions are welcome! All issues and feature requests are welcome!
213106

214107

215108

216-
# Credit and Attribution 🙏
109+
# Credit and Attribution :pray:
217110

218111
This project did not start off from scratch. The foundation of the project was the excellently written [react-multi-split-pane](https://github.com/neoraider/react-multi-split-pane) library which is itself a typescript rewrite of the [react-split-pane](https://github.com/tomkp/react-split-pane) library.
219112

docs/README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
This is intended to be **the** simple, reliable, configurable, and elegant solution to having splittable, draggable and collapsible panes in your React application.
44

55

6-
## [[click for storybook demo]](https://react-collapse-pane.zurg.dev/)
6+
## [[click for storybook demo]](https://storybook.collapse-pane.zurg.dev/)
77

8-
# Getting Started :rocket:
8+
# Getting Started 🚀
99

1010
Install react-collapse-pane:
11-
```bash
11+
```sh
1212
npm i --save-dev react-collapse-pane
1313
```
14-
```bash
14+
```sh
1515
yarn add --dev react-collapse-pane
1616
```
1717

@@ -25,7 +25,7 @@ If you're using Typescript the `SplitPaneProps`, as well as a few other helper t
2525
```ts
2626
import { SplitPane, SplitPaneProps, ResizerOptions, CollapseOptions, SplitPaneHooks } from "react-collapse-pane";
2727
```
28-
# Usage 🗻
28+
# Usage 👓
2929

3030
## The Basics 📘
3131

@@ -45,19 +45,19 @@ Here's a basic example:
4545

4646
This will split the children. The children can be any valid React child. If a child is `null` it will be excluded from being split or displayed.
4747

48-
**Note!** :eyes: There is no limit to the number of divs you have as children. The `SplitPane` will split them all accordingly.
48+
?> **Note** there is no limit to the number of divs you have as children. The `SplitPane` will split them all accordingly.
4949

5050
## Styling the Resizer 💅
5151

5252
By default there is a 1px divider that starts out `rgba(120, 120, 120, 0.3)` and transitions to `rgba(120, 120, 120, 0.6)` on hover. Having a grey color with an alpha value means that it will look nice on both light and dark backgrounds.
5353

5454
This is easily replaceable with the `css` and `hoverCss` options. No need to worry about pseudo selectors, transitions, animations or anything. You just have to indicate what the divider should look like **before** and **after**. This is accomplished by having two separate divs, one of which fades out and the other which fades in.
5555

56-
**Note** 🚨 The css props must be valid `React.CSSProperties` objects.
56+
!> **Note!** The css props must be valid `React.CSSProperties` objects.
5757

5858
The sizer also has a grabbable surface that spans the height (or length) of the split and has a default grabbable surface of `1rem`. This is changeable by the `grabberSize` option which can be set to any valid CSS size value for `width` or `height`.
5959

60-
**Note!** :eyes: As per default React CSS, a number will be interpreted as a `px` value.
60+
?> As per default React CSS, a number will be interpreted as a `px` value.
6161

6262

6363
Here's an example:
@@ -85,7 +85,7 @@ Here's an example:
8585

8686
## Using a Collapse Button 🤹‍♀️
8787

88-
This is the killer feature of this library :eyes:
88+
!> This is the killer feature of this library :eyes:
8989

9090
It's a common UX need to want to collapse the left or initial panel to give more room for another part of a site or app. This is easily accomplished by including several `CollapseOptions` as a prop to the `SplitPane`.
9191

@@ -121,7 +121,7 @@ Here's an example using a `Button` element imported from elsewhere.
121121
</SplitPane>
122122
```
123123

124-
**Note!** :eyes: When collapsing a panel, the `minSize` value is used to freeze the width of the collapsed panel to its minimum size and hides the rest of the content. This allows for a smooth collapse animation and is something to keep in mind. Until the animation reaches the min size it will shrink the panel as normal. Try it out for yourself!
124+
?> **Note!** :eyes: When collapsing a panel, the `minSize` value is used to freeze the width of the collapsed panel to its minimum size and hides the rest of the content. This allows for a smooth collapse animation and is something to keep in mind. Until the animation reaches the min size it will shrink the panel as normal. Try it out for yourself!
125125

126126

127127
## Hooks and Saving State ⚡
@@ -156,11 +156,10 @@ Typically if this is a controlled component you would have state variables for `
156156

157157
## RTL Support ( Arabic, Hebrew, Farsi ) 🕋
158158

159-
This library easily supports RTL languages by providing a `direction` prop. This is only necessary if you're using RTL and can be left out.
159+
This library easily supports RTL languages by providing a `direction` prop. This is only necessary if you're using RTL.
160160

161161
**Note!** 🚨 the `direction` is _only_ applicable if the split is `vertical`
162162

163-
e.g.
164163
```tsx
165164
<div style={{ direction: 'rtl' }}>
166165
<SplitPane

docs/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Document</title>
5+
<title>react-collapse-pane</title>
66
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
77
<meta name="description" content="Description">
88
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/dark.css">
9+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/dark.css">
10+
<link rel='shortcut icon' type='image/x-icon' href='/icon.svg' />
1011
</head>
1112
<body>
1213
<div id="app"></div>
@@ -17,9 +18,12 @@
1718
coverpage: true,
1819
autoHeader: true,
1920
themeColor: '#ff96d8',
20-
21+
search: 'auto',
22+
search: [ '/' ]
2123
}
2224
</script>
2325
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
26+
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
27+
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
2428
</body>
2529
</html>

0 commit comments

Comments
 (0)