Skip to content

Commit 264ee6b

Browse files
committed
chore(docs): Changelog & Readme updates, fix redundant types
1 parent c0209da commit 264ee6b

File tree

3 files changed

+28
-42
lines changed

3 files changed

+28
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 1.6.0 (Jan 23, 2017)
4+
5+
- Feature: Allow restricting by axis. (#40, thanks @dnissley-al)
6+
37
### 1.5.0 (Jan 23, 2017)
48

59
- Bugfix: Persist SyntheticEvents when needed (#45, #46)

README.md

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ Using [npm](https://www.npmjs.com/):
2323

2424
### Usage
2525

26-
```javascript
27-
var Resizable = require('react-resizable').Resizable; // or,
28-
var ResizableBox = require('react-resizable').ResizableBox;
26+
```js
27+
const Resizable = require('react-resizable').Resizable; // or,
28+
const ResizableBox = require('react-resizable').ResizableBox;
2929

30-
// Using ES6 transpiler
30+
// ES6
3131
import { Resizable, ResizableBox } from 'react-resizable';
3232

33-
...
34-
render: function() {
33+
// ...
34+
render() {
3535
return (
3636
<ResizableBox width={200} height={200} draggableOpts={{...}}
3737
minConstraints={[100, 100]} maxConstraints={[300, 300]}>
@@ -41,41 +41,24 @@ render: function() {
4141
}
4242
```
4343

44-
### `<Resizable>` Options
45-
46-
```js
47-
{
48-
// Functions
49-
onResizeStop: React.PropTypes.func,
50-
onResizeStart: React.PropTypes.func,
51-
onResize: React.PropTypes.func,
52-
53-
width: React.PropTypes.number.isRequired,
54-
height: React.PropTypes.number.isRequired,
55-
// If you change this, be sure to update your css
56-
handleSize: React.PropTypes.array,
57-
// These will be passed wholesale to react-draggable
58-
draggableOpts: React.PropTypes.object
59-
}
60-
```
44+
### Props
6145

62-
### `<ResizableBox>` Options
46+
These props apply to both `<Resizable>` and `<ResizableBox>`.
6347

6448
```js
6549
{
66-
// Preserves aspect ratio (default: false)
67-
lockAspectRatio: React.PropTypes.bool,
68-
69-
// Restricts resizing to a particular axis (default: 'both')
70-
axis: React.PropTypes.oneOf(['both', 'x', 'y', 'none']),
71-
72-
// Constaints coords, pass [x,y]
73-
minConstraints: React.PropTypes.arrayOf(React.PropTypes.number),
74-
maxConstraints: React.PropTypes.arrayOf(React.PropTypes.number),
75-
76-
// Initial width/height - otherwise use CSS
77-
height: React.PropTypes.number,
78-
width: React.PropTypes.number
79-
}
80-
```
50+
children: React.Element<any>,
51+
width: number,
52+
height: number,
53+
// If you change this, be sure to update your css
54+
handleSize: [number, number] = [10, 10],
55+
lockAspectRatio: boolean = false,
56+
axis: 'both' | 'x' | 'y' | 'none' = 'both',
57+
minConstraints: [number, number] = [10, 10],
58+
maxConstraints: [number, number] = [Infinity, Infinity],
59+
onResizeStop?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
60+
onResizeStart?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
61+
onResize?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
62+
draggableOpts?: ?Object
63+
};
8164
```

lib/ResizableBox.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {default as React, PropTypes} from 'react';
33
import Resizable from './Resizable';
44
import type {Props as ResizableProps} from './Resizable';
55

6-
type Props = {width: number, height: number};
76
type State = {width: number, height: number};
87
type Size = {width: number, height: number};
98
type ResizeData = {element: Element, size: Size};
@@ -14,7 +13,7 @@ export default class ResizableBox extends React.Component {
1413
height: PropTypes.number,
1514
width: PropTypes.number
1615
};
17-
props: Props & ResizableProps;
16+
props: ResizableProps;
1817

1918
static defaultProps = {
2019
handleSize: [20,20]
@@ -36,7 +35,7 @@ export default class ResizableBox extends React.Component {
3635
}
3736
};
3837

39-
componentWillReceiveProps(nextProps: typeof ResizableBox.prototype.props) {
38+
componentWillReceiveProps(nextProps: ResizableProps) {
4039
if (nextProps.width !== this.props.width || nextProps.height !== this.props.height) {
4140
this.setState({
4241
width: nextProps.width,

0 commit comments

Comments
 (0)