Skip to content
This repository was archived by the owner on May 15, 2022. It is now read-only.

Commit e3a05b0

Browse files
author
rohandeshpande
committed
Added more fleshed out docs for components
1 parent 6df865e commit e3a05b0

File tree

1 file changed

+46
-37
lines changed

1 file changed

+46
-37
lines changed

README.md

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class App extends Component {
5454

5555
This will give you a dat.GUI controller which can perform live mutations to the `data` in the `App` component's state.
5656

57-
## Components
57+
## Docs
5858

5959
### `DatGui`
6060

61-
This is the main container component for your GUI.
61+
This is the main container component for your GUI and is the default export from the package.
6262

6363
#### props
6464

@@ -75,86 +75,95 @@ This is the main container component for your GUI.
7575
* `className` - The class name to set on the `DatGui` div
7676
* `style` - The style object to set on the `DatGui` div
7777

78-
### `DatBoolean`
78+
### Components
7979

80-
todo
80+
All of the `react-dat-gui` components should be rendered as children of your `DatGui` parent component.
8181

82-
#### props
82+
#### Common props
83+
84+
These components will have a number of props implicitly passed to them via the `DatGui` parent component's `renderChildren` method, but can also require other props to be passed explicitly to them.
85+
86+
Below are docs for the required and optional props you can pass to each component. Check the `renderChildren` method of `src/index.js` to see which other props are passed down implicitly.
8387

8488
##### required
8589

90+
* `path: string` - the path to the value within the `data` object which the component will control, eg., considering your object was `{ foo: 'bar' }`: `<DatString path='foo' />`
91+
* Note, this prop is not required for the following components
92+
* `DatButton`
93+
* `DatFolder`
94+
* `DatPresets`
95+
8696
##### optional
8797

88-
### `DatButton`
98+
* `label: string` - the label for the controller eg., `<DatString path='message' label='Message' />`
8999

90-
todo
100+
#### `DatBoolean`
91101

92-
#### props
102+
Used for controlling boolean values. Renders a checkbox input element.
93103

94-
##### required
104+
#### `DatButton`
95105

96-
##### optional
106+
Can be used for performing any kind of function. Simply pass an `onClick` prop to the component and it will fire whenever the rendered element is clicked.
97107

98-
### `DatColor`
108+
##### props
99109

100-
todo
110+
###### required
101111

102-
#### props
112+
* `onClick :func` - the function to perform with the rendered element is clicked
103113

104-
##### required
114+
#### `DatColor`
105115

106-
##### optional
116+
Uses [`react-color`](https://github.com/casesandberg/react-color/) to render a color picker component that will control color values.
107117

108-
### `DatFolder`
118+
#### `DatFolder`
109119

110-
todo
120+
Component which wraps other components to render them within an expandable/collapsable nested folder.
111121

112-
#### props
122+
##### props
113123

114-
##### required
124+
###### required
115125

116-
##### optional
126+
* `title: string` - The folder title eg., `<DatFolder title='MyAwesomeFolder' />`
127+
* `children: array` - The child components to render
117128

118129
### DatNumber
119130

120131
A number component for updating numeric values. Will render a slider if `min`, `max` and `step` props are supplied.
121132

122-
#### props
133+
##### props
123134

124-
##### required
135+
###### optional
125136

126-
##### optional
137+
* `min: number` - The minimum range for the number
138+
* `max: number` - The maximum range for the number
139+
* `step: number` - The amount the number should increment each tick
127140

128141
### `DatPresets`
129142

130-
todo
143+
Presets for the object which your `DatGui` is controlling can be supplied to this component as items in its `options` prop. A select field will be rendered which will allow you to easily switch between the presets.
131144

132-
#### props
145+
Each item in this array will need to be in the format `{ 'presetName': ...data, ...preset }` where `...data` is your initial data and `...preset` is your preset.
133146

134-
##### required
147+
##### props
135148

136-
##### optional
149+
###### required
150+
151+
* `options: array` - An array of objects, each in the format `{ 'presetName': ...data, ...preset }`
137152

138153
### `DatSelect`
139154

140-
todo
155+
A select component for updating a value with one of the options supplied via the `options` prop. The original value from the `path` will always be added to the passed options array as the first item.
141156

142-
#### props
157+
##### props
143158

144-
##### required
159+
###### required
145160

146-
##### optional
161+
* `options: array` - A simple array of options to select from eg., `<DatSelect path='fruits' options={['apple', 'orange', 'pear']} />`
147162

148163
### `DatString`
149164

150165
A simple text input component that can be used to mutate strings.
151166

152-
#### props
153-
154-
##### required
155-
156-
##### optional
157-
158167
## What's missing
159168

160169
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.

0 commit comments

Comments
 (0)