embark-area-51/templates/demo/app/dapp.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

import React from 'react';
import ReactDOM from 'react-dom';
import { Tabs, Tab } from 'react-bootstrap';
2018-01-03 17:42:48 +00:00
import EmbarkJS from 'Embark/EmbarkJS';
import Blockchain from './components/blockchain';
import Whisper from './components/whisper';
2018-01-03 17:42:48 +00:00
2018-01-12 21:33:16 +00:00
import './dapp.css';
class App extends React.Component {
constructor(props) {
super(props);
2015-05-24 13:07:19 +00:00
this.state = {
whisperEnabled: false
2017-10-25 10:19:24 +00:00
}
}
2017-10-25 10:19:24 +00:00
componentDidMount(){
// TODO Verify if whisper & swarm are available
this.setState({
whisperEnabled: false
2017-01-26 11:29:17 +00:00
});
}
2017-01-26 11:29:17 +00:00
_renderStatus(title, available){
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
return <React.Fragment>
{title}
<span className={className}></span>
</React.Fragment>;
2017-10-25 10:19:24 +00:00
}
2017-01-26 11:29:17 +00:00
render(){
return (<div><h3>Embark - Usage Example</h3>
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
<Tab eventKey={1} title="Blockchain">
<Blockchain />
</Tab>
<Tab eventKey={2} title="Decentralized Storage (IPFS)">
Tab 2 content
</Tab>
<Tab eventKey={3} title={this._renderStatus('P2P communication (Whisper/Orbit)', this.state.whisperEnabled)}>
<Whisper enabled={this.state.whisperEnabled} />
</Tab>
</Tabs>
</div>);
}
}
2017-01-26 11:29:17 +00:00
ReactDOM.render(<App></App>, document.getElementById('app'));