You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: improve README with correct links and better structure
- Fix demo link to point to /examples/ instead of /index.html
- Add npm and build status badges
- Add Table of Contents
- Add prominent "Extracting Styles" section (common issue)
- Add transformScale prop to documentation
- Format compatibility as table
- Update file links to full GitHub URLs
- Add License section
[**View the Demo**](https://react-grid-layout.github.io/react-resizable/examples/)
4
8
5
9
A simple widget that can be resized via one or more handles.
6
10
7
11
You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
8
12
9
-
See the example and associated code in [ExampleLayout](/examples/ExampleLayout.js) and
10
-
[ResizableBox](/lib/ResizableBox.js) for more details.
13
+
See the example and associated code in [ExampleLayout](https://github.com/react-grid-layout/react-resizable/blob/master/examples/ExampleLayout.js) and
14
+
[ResizableBox](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js) for more details.
15
+
16
+
## Table of Contents
17
+
18
+
-[Installation](#installation)
19
+
-[Compatibility](#compatibility)
20
+
-[Usage](#usage)
21
+
-[Resizable](#resizable)
22
+
-[ResizableBox](#resizablebox)
23
+
-[Props](#props)
24
+
-[Extracting Styles](#extracting-styles)
25
+
-[Custom Resize Handles](#resize-handle)
26
+
27
+
## Installation
28
+
29
+
```bash
30
+
$ npm install --save react-resizable
31
+
```
32
+
33
+
## Extracting Styles
34
+
35
+
You **must** include the associated styles in your application, otherwise the resize handles will not be visible and will not work properly.
11
36
12
-
Make sure you use the associated styles in [/css/styles.css](/css/styles.css), as without them, you will have
13
-
problems with handle placement and visibility.
37
+
```js
38
+
// In your JS/TS entry point:
39
+
import'react-resizable/css/styles.css';
40
+
```
14
41
15
-
You can pass options directly to the underlying `DraggableCore` instance by using the prop `draggableOpts`.
16
-
See the [demo](/examples/TestLayout.js) for more on this.
42
+
Or import it in your CSS:
17
43
18
-
### Installation
44
+
```css
45
+
@import'react-resizable/css/styles.css';
46
+
```
19
47
20
-
$ npm install --save react-resizable
48
+
If you're using a bundler that doesn't support CSS imports, you can find the styles at `node_modules/react-resizable/css/styles.css` and include them manually.
21
49
22
-
###Compatibility
50
+
## Compatibility
23
51
24
-
[React-Resizable 3.x](/CHANGELOG.md#3.0.0) is compatible with React `>= 16.3`.
25
-
React-Resizable 2.x has been skipped.
26
-
[React-Resizable 1.x](/CHANGELOG.md#1.11.1) is compatible with React `14-17`.
*[`<Resizable>`](/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its
33
-
callbacks and setting its props.
34
-
*[`<ResizableBox>`](/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
62
+
*[`<Resizable>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its callbacks and setting its props.
63
+
*[`<ResizableBox>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
// If `transform: scale(n)` is set on the parent, this should be set to `n`.
155
+
transformScale?: number =1
119
156
};
120
157
```
121
158
@@ -129,27 +166,29 @@ The following props can also be used on `<ResizableBox>`:
129
166
130
167
If a `width` or `height` is passed to `<ResizableBox>`'s `style` prop, it will be ignored as it is required for internal function.
131
168
132
-
#### Resize Handle
169
+
You can pass options directly to the underlying `DraggableCore` instance by using the prop `draggableOpts`. See the [demo](https://react-grid-layout.github.io/react-resizable/examples/) for more on this.
170
+
171
+
## Resize Handle
133
172
134
-
If you override the resize handle, we expect that any `ref` passed to your new handle with represent the underlying DOM element.
173
+
If you override the resize handle, we expect that any `ref` passed to your new handle will represent the underlying DOM element.
135
174
136
175
This is required, as `react-resizable` must be able to access the underlying DOM node to attach handlers and measure position deltas.
137
176
138
177
There are a few ways to do this:
139
178
140
-
##### Native DOM Element
179
+
### Native DOM Element
141
180
142
181
This requires no special treatment.
143
182
144
183
```js
145
184
<Resizable handle={<div className="foo"/>} />
146
185
```
147
186
148
-
##### Custom React Component
187
+
### Custom React Component
149
188
150
189
You must [forward the ref](https://reactjs.org/docs/forwarding-refs.html) and props to the underlying DOM element.
You can define a function as a handle, which will simply receive an axis (see above `ResizeHandleAxis` type) and ref. This may be more clear to read, depending on your coding style.
0 commit comments