on d3602c2 help sign in
bridge/src/Root.js
79 lines 1.9 kB history raw
1import 'babel-polyfill' // required for @ledgerhq/hw-transport-u2f
3import React from 'react'
4import ReactDOM from 'react-dom'
6import Bridge from './Bridge'
7import Walletgen from './walletgen/Walletgen'
8import { AppNavigation } from './components/AppNavigation'
10import './style/index.css'
11import './walletgen/styles/index.css'
13class Root extends React.Component {
14 constructor(props) {
15 super(props)
17 this.state = {
18 appView: "bridge"
19 }
21 this.setView = this.setView.bind(this)
22 }
24 componentDidMount() {
25 let styles = document.getElementsByTagName('style')
27 for (var i = 0; i < styles.length; i++) {
28 if (i < 7) styles[i].classList.add('css-bridge');
29 if (i >= 7) {
30 styles[i].classList.add('css-walletgen');
31 styles[i].disabled = true;
32 }
33 }
34 }
36 setView(appView) {
37 if (appView === "bridge") {
38 document.querySelectorAll('.css-walletgen').forEach(s => s.disabled = true)
39 document.querySelectorAll('.css-bridge').forEach(s => s.disabled = false)
40 } else if (appView === "walletgen") {
41 document.querySelectorAll('.css-walletgen').forEach(s => s.disabled = false)
42 document.querySelectorAll('.css-bridge').forEach(s => s.disabled = true)
43 }
45 this.setState({
46 appView
47 })
48 }
50 render() {
51 let appComponent = null;
53 if (this.state.appView === "walletgen") {
54 appComponent = <Walletgen
55 appView={this.state.appView}
56 setView={this.setView} />
57 }
59 if (this.state.appView === "bridge") {
60 appComponent = <Bridge
61 appView={this.state.appView}
62 setView={this.setView} />
63 }
65 return (
66 <React.Fragment>
67 {appComponent}
68 <AppNavigation
69 setView={this.setView}
70 appView={this.state.appView}
71 />
72 </React.Fragment>
73 )
74 }
77export {
78 Root