|
1 | 1 | # React dat.GUI
|
2 | 2 |
|
3 |
| -Currently very much under construction. |
| 3 | +This is a fully[*](#whats-missing) featured React port of Google's esteemed [dat.GUI](https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage) controller library. It comes packed with all the core components you'll need to cleanly integrate a `dat.GUI` into your React app. |
| 4 | + |
| 5 | +For those that haven't used or seen dat.GUI before, it's basically an object mutation GUI. It's used extensively in canvas or WebGL rendering demos/apps for libraries such as [three.js](http://threejs.org) but it can also be used to build browser based editing software. |
4 | 6 |
|
5 | 7 | ## Demo
|
6 | 8 |
|
7 |
| -https://react-dat-gui.herokuapp.com/ |
| 9 | +http://rohandeshpande.com/react-dat-gui |
8 | 10 |
|
9 | 11 | ## Installation
|
10 | 12 |
|
11 | 13 | ```
|
12 |
| -npm install react-dat-gui --save |
| 14 | +npm i -S react-dat-gui |
| 15 | +
|
13 | 16 | ```
|
14 | 17 |
|
15 | 18 | ## Usage
|
16 | 19 |
|
| 20 | +First you'll need a wrapper component which will handle the updates from your dat.GUI, this component should pass the data for the GUI to control as well as an `onUpdate` function to the `DatGui` container component as props. These props are then passed down to all children. |
| 21 | + |
17 | 22 | ```
|
18 |
| -<Dat data={this.state.data} onUpdate={this.handleUpdate}> |
19 |
| - <DatString path="string" label="String" /> |
20 |
| - <DatNumber path="number" label="Number" min={0} max={100} step={1} /> |
21 |
| - <DatBoolean path="boolean" label="Boolean" /> |
22 |
| - <DatButton label="Button" onClick={this.handleClick} /> |
23 |
| -</Dat> |
| 23 | +// TODO code sample |
24 | 24 | ```
|
25 | 25 |
|
26 |
| -## CSS |
27 | 26 |
|
28 |
| - * SCSS: `./src/Dat.scss` |
29 |
| - * CSS: `./lib/Dat.css` |
30 |
| - * CSS minified: `./build/react-dat-gui.min.css` |
| 27 | +Any updates will update the state of the `DatGui` component and trigger whatever else needs to happen in your `onUpdate` method. |
| 28 | + |
| 29 | +## Components |
| 30 | + |
| 31 | +### DatGui |
| 32 | + |
| 33 | +This is the main container component for your GUI. |
| 34 | + |
| 35 | +### `DatString` |
| 36 | + |
| 37 | +A simple string component that can be used |
| 38 | + |
| 39 | +### DatNumber |
| 40 | + |
| 41 | +A number component, for updating numeric values. |
| 42 | + |
| 43 | +#### props |
| 44 | + |
| 45 | +## What's missing |
| 46 | + |
| 47 | +There are still a few features from the original implementation missing from this package. These are mainly related to saving and loading data as well as local storage. For the first, I think the fact that this is now an npm module sort of goes against it handling this sort of stuff. Google's original concept was basically a plug and play controller that could do everything, however in module form, it's expected that you'll most likely be integrating this with an existing application. In that case, you'll probably have pretty specific needs around how you would like to save/load data into your GUI. Local storage however is in the roadmap and will probably be done very soon. |
| 48 | + |
| 49 | +## Roadmap |
| 50 | +* Loading and storing both default and preset data via `localStorage` |
| 51 | +* Time travel with undo/redo buttons (edited) |
0 commit comments