Last active
August 29, 2015 14:24
-
-
Save pjanik/c2c57819ec977e8a9518 to your computer and use it in GitHub Desktop.
Lab React interactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class PressureInteractive extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
properties: { | |
temperature: 200 | |
} | |
outputs: { | |
pressure: 0 | |
} | |
}; | |
} | |
onStart() { | |
this.refs.lab.script.start(); | |
} | |
onStop() { | |
this.refs.lab.script.stop(); | |
} | |
onPressureChange(e) { | |
// (This won't work, we would need to use React helpers) | |
this.setState({properties: {pressure: e.target.value}}); | |
} | |
render() { | |
return ( | |
<div className="interactive"> | |
<LabFrameTop about="..."/> | |
// this.props.interactiveDef - Lab JSON | |
<LabComponent ref="lab" interactiveDef={this.props.interactiveDef} outputs={this.state.outputs} properties={this.state.properties}/> | |
<div>Pressure value: {this.state.outputs.pressure}</div> | |
<div>Temperature<input type="text" value={this.state.properties.pressure} onChange={this.onPressureChange}/></div> | |
<LabFrameBottom onStart={this.onStart} onStop={this.onStop}/> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment