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
{{ message }}
This repository was archived by the owner on May 15, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+46-37Lines changed: 46 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,11 @@ class App extends Component {
54
54
55
55
This will give you a dat.GUI controller which can perform live mutations to the `data` in the `App` component's state.
56
56
57
-
## Components
57
+
## Docs
58
58
59
59
### `DatGui`
60
60
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.
62
62
63
63
#### props
64
64
@@ -75,86 +75,95 @@ This is the main container component for your GUI.
75
75
*`className` - The class name to set on the `DatGui` div
76
76
*`style` - The style object to set on the `DatGui` div
77
77
78
-
### `DatBoolean`
78
+
### Components
79
79
80
-
todo
80
+
All of the `react-dat-gui` components should be rendered as children of your `DatGui` parent component.
81
81
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.
83
87
84
88
##### required
85
89
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
+
86
96
##### optional
87
97
88
-
### `DatButton`
98
+
*`label: string` - the label for the controller eg., `<DatString path='message' label='Message' />`
89
99
90
-
todo
100
+
#### `DatBoolean`
91
101
92
-
#### props
102
+
Used for controlling boolean values. Renders a checkbox input element.
93
103
94
-
##### required
104
+
####`DatButton`
95
105
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.
97
107
98
-
###`DatColor`
108
+
##### props
99
109
100
-
todo
110
+
###### required
101
111
102
-
#### props
112
+
*`onClick :func` - the function to perform with the rendered element is clicked
103
113
104
-
##### required
114
+
####`DatColor`
105
115
106
-
##### optional
116
+
Uses [`react-color`](https://github.com/casesandberg/react-color/) to render a color picker component that will control color values.
107
117
108
-
### `DatFolder`
118
+
####`DatFolder`
109
119
110
-
todo
120
+
Component which wraps other components to render them within an expandable/collapsable nested folder.
111
121
112
-
#### props
122
+
#####props
113
123
114
-
##### required
124
+
######required
115
125
116
-
##### optional
126
+
*`title: string` - The folder title eg., `<DatFolder title='MyAwesomeFolder' />`
127
+
*`children: array` - The child components to render
117
128
118
129
### DatNumber
119
130
120
131
A number component for updating numeric values. Will render a slider if `min`, `max` and `step` props are supplied.
121
132
122
-
#### props
133
+
#####props
123
134
124
-
#####required
135
+
###### optional
125
136
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
127
140
128
141
### `DatPresets`
129
142
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.
131
144
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.
133
146
134
-
##### required
147
+
##### props
135
148
136
-
##### optional
149
+
###### required
150
+
151
+
*`options: array` - An array of objects, each in the format `{ 'presetName': ...data, ...preset }`
137
152
138
153
### `DatSelect`
139
154
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.
141
156
142
-
#### props
157
+
#####props
143
158
144
-
##### required
159
+
######required
145
160
146
-
##### optional
161
+
*`options: array` - A simple array of options to select from eg., `<DatSelect path='fruits' options={['apple', 'orange', 'pear']} />`
147
162
148
163
### `DatString`
149
164
150
165
A simple text input component that can be used to mutate strings.
151
166
152
-
#### props
153
-
154
-
##### required
155
-
156
-
##### optional
157
-
158
167
## What's missing
159
168
160
169
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