Skip to content

Commit 71261bd

Browse files
authored
Merge pull request #4 from LeetCode-OpenSource/improve-doc
Improve doc
2 parents 44c042a + ba734d4 commit 71261bd

File tree

1 file changed

+86
-63
lines changed

1 file changed

+86
-63
lines changed

README.md

Lines changed: 86 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# react-simple-resizer · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/LeetCode-OpenSource/react-simple-resizer/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier) [![npm version](https://img.shields.io/npm/v/react-simple-resizer.svg?style=flat)](https://www.npmjs.com/package/react-simple-resizer)
22

33

4-
An intuitive React component set for multi-column resizing. It is easy to use and it also can [customize the behavior of resizing](#customize-resize-behavior) in a very simple way. Working on every modern browser [which](https://caniuse.com/#feat=flexbox) support [flexible box layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout).
4+
An intuitive React component set for multi-column(row) resizing. You could [customize the behavior of resizing](#customize-resize-behavior) in a very simple way. Works in every modern browser [which](https://caniuse.com/#feat=flexbox) supports [flexible box layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout).
55

66
#### Table of Contents
77
- [Installation](#installation)
@@ -11,7 +11,6 @@ An intuitive React component set for multi-column resizing. It is easy to use an
1111
- [Section](#section-)
1212
- [Bar](#bar-)
1313
- [Customize resize behavior](#customize-resize-behavior)
14-
- [Demos](#demos)
1514
- [Contributing](#contributing)
1615

1716
## Installation
@@ -26,7 +25,8 @@ npm install react-simple-resizer
2625
```
2726

2827
## Examples
29-
We have create several demos on CodeSandbox, check the [Demos](#demos) to see more. Here is the minimal example for two column layout:
28+
29+
Here is a minimal example for two-column layout:
3030
```jsx
3131
import React from 'react';
3232
import { Container, Section, Bar } from 'react-simple-resizer';
@@ -40,10 +40,21 @@ export default () => (
4040
);
4141
```
4242

43+
We have created several demos on CodeSandbox, check demos below:
44+
45+
- [Simple demo](https://codesandbox.io/s/qkw1rxxq29)
46+
- [Make Section collapsible](https://codesandbox.io/s/1vpy7kz5j3)
47+
- [Multiple Section linkage effects](https://codesandbox.io/s/r51pv3qzpm)
48+
4349
## Components
4450

4551
### \<Container \/\>
46-
Literally, as the container of the other components.
52+
53+
Literally, it's the container of the other components.
54+
55+
```typescript
56+
import { Container } from 'react-simple-resizer';
57+
```
4758

4859
#### Props
4960
```typescript
@@ -56,17 +67,22 @@ interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
5667
afterResizing?: () => void;
5768
}
5869
```
59-
##### vertical
60-
> Determine that whether using vertical layout or not, default is `false`.
6170

62-
##### onActivate
63-
> Triggered when any [`Bar`](#bar-) activated. i.e, [onMouseDown](https://developer.mozilla.org/en/docs/Web/Events/mousedown) or [onTouchStart](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart).
71+
##### `vertical`
72+
73+
Determine whether using vertical layout or not, default is `false`.
74+
75+
##### `onActivate`
76+
77+
Triggered when any [`Bar`](#bar-) is activated. i.e, [onMouseDown](https://developer.mozilla.org/en/docs/Web/Events/mousedown) or [onTouchStart](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart).
78+
79+
##### `beforeApplyResizer`
6480

65-
##### beforeApplyResizer
66-
> Used to [customize resize behavior](#customize-resize-behavior). In this method, you __don't__ need to call [`applyResizer`](#applyresizer) to apply the resize result. Please note that you should not do any side effect on this method. If you want to do something after the resizing, see [`afterResizing`](#afterresizing) below.
81+
Used to [customize resize behavior](#customize-resize-behavior). In this method, you __don't__ need to call [`applyResizer`](#applyresizer) to apply the resize result. Please note that you should not do any side effect on this method. If you want to do something after resizing, see [`afterResizing`](#afterresizing) below.
6782

68-
##### afterResizing
69-
> Triggered after a <a name="resizing-section">__resizing section__</a> is completed. Which means that it will be triggered after the [onMouseUp](https://developer.mozilla.org/en-US/docs/Web/Events/mouseup) and [onTouchEnd](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) events. If you want to do something after each time the size of section has changed, using the [`onSizeChanged`](#onsizechanged) props on the [`Section`](#section-) instead.
83+
##### `afterResizing`
84+
85+
Triggered after a <a name="resizing-section">__resizing section__</a> is completed, which means that it will be triggered after [onMouseUp](https://developer.mozilla.org/en-US/docs/Web/Events/mouseup) and [onTouchEnd](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) events. If you want to do something after size of section has changed, use [`onSizeChanged`](#onsizechanged) props on the [`Section`](#section-) instead.
7086

7187
#### Instance properties
7288
```typescript
@@ -77,14 +93,19 @@ class Container extends React.PureComponent<ContainerProps> {
7793
public applyResizer(resizer: Resizer): void
7894
}
7995
```
80-
##### getResizer
81-
> Used to get the newest [`Resizer`](#customize-resize-behavior). But any change won't apply unless you pass the `Resizer` to `applyResizer`.
96+
##### `getResizer`
97+
Used to get newest [`Resizer`](#customize-resize-behavior). But any change won't apply unless you pass the `Resizer` to `applyResizer`.
8298

83-
##### applyResizer
84-
> Apply the passed `Resizer` to `Container`.
99+
##### `applyResizer`
100+
Apply the passed `Resizer` to `Container`.
85101

86102
---
87103
### \<Section \/\>
104+
105+
```typescript
106+
import { Section } from 'react-simple-resizer';
107+
```
108+
88109
#### Props
89110
```typescript
90111
import { HTMLAttributes, RefObject } from 'react';
@@ -99,29 +120,34 @@ interface SectionProps extends HTMLAttributes<HTMLDivElement> {
99120
innerRef?: RefObject<HTMLDivElement>;
100121
}
101122
```
102-
##### size
103-
> Used to set the `Section`'s size. If `size` exists, `Section` will ignore the value of `defaultSize`, `maxSize` and `minSize`.
123+
##### `size`
124+
Used to set `Section`'s size. If `size` is set, `Section` will ignore the value of `defaultSize`, `maxSize` and `minSize`.
104125

105-
##### defaultSize
106-
> Used to set the default size of `Section`.
126+
##### `defaultSize`
127+
Used to set default size of `Section`.
107128

108-
##### maxSize
109-
> Used to set the max size of `Section`.
129+
##### `maxSize`
130+
Used to set max size of `Section`.
110131

111-
##### minSize
112-
> Used to set the min size of `Section`.
132+
##### `minSize`
133+
Used to set min size of `Section`.
113134

114-
##### disableResponsive
115-
> Each `Section` is responsive as default, unless `size` is exists. the responsive means that the `Section`'s size is related with `Container`'s size, if `Container`'s size turn smaller, the `Section`'s size also turn smaller automatically. Otherwise, the changes of `Container` size won't affect the `Section` that `disableResponsive` is `true`.
135+
##### `disableResponsive`
136+
Each `Section` is responsive as default, unless `size` exists. The `responsive` here means that `Section`'s size is related with `Container`'s size, if `Container`'s size turn smaller, the `Section`'s size also turn smaller automatically. Otherwise, changes of `Container` size won't affect the `Section` when `disableResponsive` is `true`.
116137

117-
##### onSizeChanged
118-
> Will be triggered each time the size has changed.
138+
##### `onSizeChanged`
139+
Will be triggered each time its size has changed.
119140

120-
##### innerRef
121-
> Used to get the actual DOM ref of `Section`.
141+
##### `innerRef`
142+
Used to get the actual DOM ref of `Section`.
122143

123144
---
124145
### \<Bar \/\>
146+
147+
```typescript
148+
import { Bar } from 'react-simple-resizer';
149+
```
150+
125151
#### Props
126152
```typescript
127153
import { HTMLAttributes, RefObject } from 'react';
@@ -141,25 +167,25 @@ interface BarProps extends HTMLAttributes<HTMLDivElement> {
141167
innerRef?: RefObject<HTMLDivElement>;
142168
}
143169
```
144-
##### size
145-
> Required, used to set the size of the `Bar`.
170+
##### `size`
171+
Required, used to set the size of `Bar`.
146172

147-
##### expandInteractiveArea
148-
> Used to expanding the interactive area of the `Bar`.
173+
##### `expandInteractiveArea`
174+
Used to expand interactive area of `Bar`.
149175

150-
##### onStatusChanged
151-
> Triggered when the state of the `Bar` has changed.
176+
##### `onStatusChanged`
177+
Triggered when the state of `Bar` has changed.
152178

153-
##### onClick
154-
> Triggered if not moving events. The main different with original `onClick` event is that __there is no parameters__ on _this_ `onClick`. You could also use it as a touch event on mobile platform, without 300ms click delay.
179+
##### `onClick`
180+
Triggered if there's no "move" events. The main difference between it and original `onClick` event is that __there is no parameters__ on _this_ `onClick`. You could also use it as a touch event on mobile platform, without 300ms click delay.
155181

156-
##### innerRef
157-
> Used to get the actual DOM ref of `Bar`.
182+
##### `innerRef`
183+
Used to get the actual DOM ref of `Bar`.
158184

159185
## Customize resize behavior
160-
If you want to customize the behavior of resizing, then the `Resizer` is what you need to know.
186+
If you want to customize behavior of resizing, then you have to know how to use `Resizer`.
161187

162-
> There is two ways to get the `Resizer`. One is the method [`beforeApplyResizer`](#beforeapplyresizer) defined on the __props__ of `Container`, and the other is the method [`getResizer`](#getresizer) defined on the __instance__ of `Container`
188+
There is two ways to get the `Resizer`. One is [`beforeApplyResizer`](#beforeapplyresizer) defined on the __props__ of `Container`, and the other is [`getResizer`](#getresizer) defined on the __instance__ of `Container`.
163189

164190
```typescript
165191
interface Resizer {
@@ -173,36 +199,33 @@ interface Resizer {
173199
}
174200
```
175201

176-
##### resizeSection
177-
> Used to set the size of the nth `Section`.
178-
> In multi-column layout, there is not only one `Bar` could change the `Section`'s size. Therefor, you could use `preferMoveLeftBar` to try to use the left side `Bar` to resizing.
202+
##### `resizeSection`
203+
Used to set size of the nth `Section`.
204+
In multi-column layout, there're several `Bar`s could change the `Section`'s size. Therefore, you could try to use the left side `Bar` to resizing by setting `preferMoveLeftBar`.
179205

180-
##### moveBar
181-
> Used to move the nth `Bar` to resizing.
182-
> If the value of A is negative, move `Bar` to the left. Once [`vertical`](#vertical) is `true`, move up.
206+
##### `moveBar`
207+
Used to move the nth `Bar` to resizing.
208+
If the value of A is negative, move `Bar` to the left. When [`vertical`](#vertical) is `true`, move up.
183209

184-
##### discard
185-
> Discard resizing at this time.
210+
##### `discard`
211+
Discard resizing at this time.
186212

187-
##### isSectionResized
188-
> Used to determine whether the nth `Section`'s size is changed at current [resizing section](#user-content-resizing-section) or not.
213+
##### `isSectionResized`
214+
Used to determine whether the nth `Section`'s size is changed at current [resizing section](#user-content-resizing-section) or not.
189215

190-
##### isBarActivated
191-
> Used to determine whether the nth `Bar` is active or not.
216+
##### `isBarActivated`
217+
Used to determine whether the nth `Bar` is active or not.
192218

193-
##### getSectionSize
194-
> Used to get the size of the nth `Section`. if there is no nth `Section`, return `-1`.
219+
##### `getSectionSize`
220+
Used to get size of the nth `Section`. if there is no nth `Section`, return `-1`.
221+
222+
##### `getTotalSize`
223+
Used to get total size of all `Section`.
195224

196-
##### getTotalSize
197-
> Used to get the total size of the `Section`.
198225

199-
## Demos
200-
- [Simple demo](https://codesandbox.io/s/qkw1rxxq29)
201-
- [Make Section collapsible](https://codesandbox.io/s/1vpy7kz5j3)
202-
- [Multiple Section linkage effects](https://codesandbox.io/s/r51pv3qzpm)
203226

204227
## Contributing
205228
The main purpose of this repository is to continue to evolve react-simple-resizer, making it faster, smaller and easier to use. We are grateful to the community for contributing bugfixes and improvements.
206229

207230
#### About Demo
208-
Feel free to let us know that you have create some new customized resize behavior. If you want, you could make a PR to let more people see your works. Also, if you find some behavior that you can not create, let us know too.
231+
Feel free to let us know that you have created some new customized resize behavior. You could create a PR to let more people see your works. Also, if you find some behaviors that you cannot create, let us know too.

0 commit comments

Comments
 (0)