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

Commit 2cc79db

Browse files
committed
Slight example refactor
1 parent 10f6399 commit 2cc79db

File tree

2 files changed

+53
-38
lines changed

2 files changed

+53
-38
lines changed

example/components/ReactDatGui.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import DatGui, {
1010
DatString
1111
} from 'react-dat-gui';
1212
import 'react-dat-gui/dist/index.css';
13+
import Stats from './Stats';
1314

1415
/**
1516
* Demonstrates presets that extend the default preset (initial state)
@@ -90,44 +91,7 @@ class DatGUI extends Component {
9091

9192
return (
9293
<main style={{ marginRight: '350px' }}>
93-
<h1>
94-
<b style={{ color: data.color }}>react-dat-gui</b>
95-
</h1>
96-
<h2>Use the controls and watch your changes happen in real time!</h2>
97-
<section>
98-
<div>
99-
<b>String value:</b> {data.string}
100-
</div>
101-
<div>
102-
<b>Slider value:</b> {data.minMaxNumber}
103-
</div>
104-
<div>
105-
<b>Number value:</b> {data.number}
106-
</div>
107-
<div>
108-
<b>Checkbox value:</b> {data.boolean.toString()}
109-
</div>
110-
<div>
111-
<b>Select value:</b> {data.select}
112-
</div>
113-
<div>
114-
<b>Picked color:</b>{' '}
115-
<div
116-
style={{
117-
width: '10px',
118-
height: '10px',
119-
display: 'inline-block',
120-
backgroundColor: data.color
121-
}}
122-
/>
123-
</div>
124-
<div>
125-
<b>Click the button for a random number:</b> {data.random}
126-
</div>
127-
<div>
128-
<b>Nested string value:</b> {data.nested.string}
129-
</div>
130-
</section>
94+
<Stats data={data} />
13195
<DatGui data={data} onUpdate={this.handleUpdate}>
13296
<DatPresets
13397
label="Presets"

example/components/Stats.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
const Stats = ({ data }) => (
5+
<section>
6+
<h1 style={{ fontSize: '2em' }}>
7+
<b style={{ color: data.color }}>react-dat-gui</b>
8+
</h1>
9+
<h2>Use the controls and watch your changes happen in real time!</h2>
10+
<section>
11+
<div>
12+
<b>String value:</b> {data.string}
13+
</div>
14+
<div>
15+
<b>Slider value:</b> {data.minMaxNumber}
16+
</div>
17+
<div>
18+
<b>Number value:</b> {data.number}
19+
</div>
20+
<div>
21+
<b>Checkbox value:</b> {data.boolean.toString()}
22+
</div>
23+
<div>
24+
<b>Select value:</b> {data.select}
25+
</div>
26+
<div>
27+
<b>Picked color:</b>{' '}
28+
<div
29+
style={{
30+
width: '10px',
31+
height: '10px',
32+
display: 'inline-block',
33+
backgroundColor: data.color
34+
}}
35+
/>
36+
</div>
37+
<div>
38+
<b>Click the button for a random number:</b> {data.random}
39+
</div>
40+
<div>
41+
<b>Nested string value:</b> {data.nested.string}
42+
</div>
43+
</section>
44+
</section>
45+
);
46+
47+
Stats.propTypes = {
48+
data: PropTypes.object.isRequired
49+
};
50+
51+
export default Stats;

0 commit comments

Comments
 (0)