diff --git a/dapps/templates/demo/app/components/blockchain.js b/dapps/templates/demo/app/components/blockchain.js index 66841e4c2..6f407c306 100644 --- a/dapps/templates/demo/app/components/blockchain.js +++ b/dapps/templates/demo/app/components/blockchain.js @@ -1,7 +1,7 @@ import EmbarkJS from 'Embark/EmbarkJS'; import SimpleStorage from '../../embarkArtifacts/contracts/SimpleStorage'; import React from 'react'; -import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap'; +import {Form, FormGroup, Input, HelpBlock, Button, FormText} from 'reactstrap'; class Blockchain extends React.Component { @@ -51,24 +51,25 @@ class Blockchain extends React.Component { render() { return (

1. Set the value in the blockchain

-
this.checkEnter(e, this.setValue)}> - - this.checkEnter(e, this.setValue)}> + + this.handleChange(e)}/> - - Once you set the value, the transaction will need to be mined and then the value will be updated - on the blockchain. + + Once you set the value, the transaction will need to be mined and then the value will be updated + on the blockchain.

2. Get the current value

-
+ - current value is {this.state.valueGet} - - Click the button to get the current value. The initial value is 100. + + Click the button to get the current value. The initial value is 100. + {this.state.valueGet && this.state.valueGet !== 0 && +

Current value is {this.state.valueGet}

}
diff --git a/dapps/templates/demo/app/components/ens.js b/dapps/templates/demo/app/components/ens.js index 1afaf5100..06eb9d3ad 100644 --- a/dapps/templates/demo/app/components/ens.js +++ b/dapps/templates/demo/app/components/ens.js @@ -1,9 +1,7 @@ /*global web3*/ import EmbarkJS from 'Embark/EmbarkJS'; import React from 'react'; -import { Alert, Form, FormGroup, FormControl, Button } from 'react-bootstrap'; - -window.EmbarkJS = EmbarkJS; +import { Alert, Form, FormGroup, Input, Button } from 'reactstrap'; class ENS extends React.Component { @@ -35,7 +33,7 @@ class ENS extends React.Component { this.setState({ addressRegister: web3.eth.defaultAccount, valueLookup: web3.eth.defaultAccount - }) + }); }); } @@ -115,53 +113,54 @@ class ENS extends React.Component { render() { return ( - {this.state.globalError && {this.state.globalError}} + {this.state.globalError && {this.state.globalError}}

Resolve a name

-
this.checkEnter(e, this.resolveName)}> - + this.checkEnter(e, this.resolveName)}> + {this.state.responseResolve && - + Resolved address: {this.state.responseResolve} } - this.handleChange('valueResolve', e)}/> - +

Lookup an address

-
this.checkEnter(e, this.lookupAddress)}> - + this.checkEnter(e, this.lookupAddress)}> + {this.state.responseLookup && - + Looked up domain: {this.state.responseLookup} } - this.handleChange('valueLookup', e)}/> - +

Register subdomain

-
this.checkEnter(e, this.registerSubDomain)}> + this.checkEnter(e, this.registerSubDomain)}> {this.state.responseRegister && - + {this.state.responseRegister} } - this.handleChange('valueRegister', e)}/> - this.handleChange('addressRegister', e)}/> - +
+ this.handleChange('addressRegister', e)}/> + +
diff --git a/dapps/templates/demo/app/components/storage.js b/dapps/templates/demo/app/components/storage.js index 0de4815c8..78a90f247 100644 --- a/dapps/templates/demo/app/components/storage.js +++ b/dapps/templates/demo/app/components/storage.js @@ -1,6 +1,6 @@ import EmbarkJS from 'Embark/EmbarkJS'; -import React from 'react'; -import {Alert, Form, FormGroup, FormControl, HelpBlock, Button} from 'react-bootstrap'; +import React, {Fragment} from 'react'; +import {Alert, Form, FormGroup, Input, FormText, Button} from 'reactstrap'; class Storage extends React.Component { @@ -19,7 +19,7 @@ class Storage extends React.Component { logs: [], storageError: '', valueRegister: '', - valueResolver: '', + valueResolver: '' }; } @@ -101,7 +101,7 @@ class Storage extends React.Component { }); } - loadFile(e) { + loadFile(_e) { let _url = EmbarkJS.Storage.getUrl(this.state.imageToDownload); this.setState({url: _url}); this.addToLog("EmbarkJS.Storage.getUrl('" + this.state.imageToDownload + "')"); @@ -116,7 +116,7 @@ class Storage extends React.Component { let isRegisterError = false; if (err) { isRegisterError = true; - responseRegister = "Name Register Error: " + (err.message || err) + responseRegister = "Name Register Error: " + (err.message || err); } else { responseRegister = name; } @@ -138,7 +138,7 @@ class Storage extends React.Component { let isResolverError = false; if (err) { isResolverError = true; - responseResolver = "Name Resolve Error: " + (err.message || err) + responseResolver = "Name Resolve Error: " + (err.message || err); } else { responseResolver = path; } @@ -157,101 +157,101 @@ class Storage extends React.Component { render() { return - { - !this.props.enabled ? - - The node you are using does not support IPFS. Please ensure CORS is setup for the IPFS - node. - : '' - } - { - this.state.storageError !== '' ? - {this.state.storageError} - : '' - } + {this.props.enabled && + + The node you are using does not support IPFS. Please ensure CORS is setup for the IPFS + node. + } + + {this.state.storageError !== '' && + {this.state.storageError}} +

Save text to storage

-
this.checkEnter(e, this.setText)}> - - this.checkEnter(e, this.setText)}> + + this.handleChange(e, 'textToSave')}/> - - generated Hash: {this.state.generatedHash} + + {this.state.generatedHash && Generated Hash: {this.state.generatedHash}}

Load text from storage given an hash

-
this.checkEnter(e, this.loadHash)}> - - this.checkEnter(e, this.loadHash)}> + + this.handleChange(e, 'loadText')}/> - - result: {this.state.storedText} + + {this.state.storedText && Result: {this.state.storedText}}

Upload file to storage

-
+ - this.handleFileUpload(e)}/> - - generated hash: {this.state.fileHash} + + {this.state.fileHash && Generated hash: {this.state.fileHash}}

Get file or image from storage

-
this.checkEnter(e, this.loadFile)}> - - this.checkEnter(e, this.loadFile)}> + + this.handleChange(e, 'imageToDownload')}/> - - file available at: {this.state.url} - + + {this.state.url && + + File available at: {this.state.url} + + file image + } - {!this.isIpfs() && The 2 functions below are only available with IPFS} + {!this.isIpfs() && The 2 functions below are only available with IPFS}

Register to IPNS

-
this.checkEnter(e, this.ipnsRegister)}> - - this.checkEnter(e, this.ipnsRegister)}> + + this.handleChange(e, 'valueRegister')}/> - - It will take around 1 minute + It will take around 1 minute {this.state.responseRegister && - + {this.state.responseRegister} }

Resolve name

-
this.checkEnter(e, this.ipnsResolve)}> - - this.checkEnter(e, this.ipnsResolve)}> + + this.handleChange(e, 'valueResolver')}/> - - It will take around 1 minute + It will take around 1 minute {this.state.responseResolver && - + {this.state.responseResolver} } diff --git a/dapps/templates/demo/app/components/whisper.js b/dapps/templates/demo/app/components/whisper.js index 982276062..5895f5a56 100644 --- a/dapps/templates/demo/app/components/whisper.js +++ b/dapps/templates/demo/app/components/whisper.js @@ -1,6 +1,6 @@ import EmbarkJS from 'Embark/EmbarkJS'; import React from 'react'; -import {Alert, Form, FormGroup, FormControl, Button} from 'react-bootstrap'; +import {Alert, Form, FormGroup, Input, Button, FormText} from 'reactstrap'; class Whisper extends React.Component { @@ -80,28 +80,25 @@ class Whisper extends React.Component { return ( { - !this.props.enabled ? + !this.props.enabled && - The node you are using does not support Whisper - The node uses an unsupported version of Whisper - : '' - } + The node you are using does not support Whisper + The node uses an unsupported version of Whisper + }

Listen To channel

- this.checkEnter(e, this.listenToChannel)}> - - this.checkEnter(e, this.listenToChannel)}> + + this.handleChange(e, 'listenTo')}/> - - {!this.state.listenToChannelIsValid &&

Channel has to be at least 4 characters long

} + + {!this.state.listenToChannelIsValid && Channel has to be at least 4 characters long}
- {this.state.subscribedChannels.map((item, i) => { - return

Subscribed to {item}. Now try sending a message

- })} + {this.state.subscribedChannels.map((item, i) =>

Subscribed to {item}. Now try sending a message

)}
-

messages received:

+
Messages received:
{this.state.messageList.map((item, i) =>

{item}

)}
@@ -111,17 +108,20 @@ class Whisper extends React.Component {

Send Message

this.checkEnter(e, this.sendMessage)}> - this.handleChange(e, 'channel')}/> - this.handleChange(e, 'message')}/> - +
+ this.handleChange(e, 'message')}/> + +
diff --git a/dapps/templates/demo/app/dapp.css b/dapps/templates/demo/app/dapp.css index 401124e86..5b0e7e3ef 100644 --- a/dapps/templates/demo/app/dapp.css +++ b/dapps/templates/demo/app/dapp.css @@ -55,3 +55,19 @@ input.form-control { .alert-result { margin-left: 0; } + +.small-input { + width: 200px; +} + +.inline-input-btn .form-control { + margin: 0; + width: 200px; + border-radius: 0.25rem 0 0 0.25rem; + float: left; + border-right: 0; +} + +.inline-input-btn .btn { + border-radius: 0 0.25rem 0.25rem 0; +} diff --git a/dapps/templates/demo/app/dapp.js b/dapps/templates/demo/app/dapp.js index 9dc060795..2161dd942 100644 --- a/dapps/templates/demo/app/dapp.js +++ b/dapps/templates/demo/app/dapp.js @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import {Tabs, Tab} from 'react-bootstrap'; +import {TabContent, TabPane, Nav, NavItem, NavLink} from 'reactstrap'; +import classnames from 'classnames'; import EmbarkJS from 'Embark/EmbarkJS'; import Blockchain from './components/blockchain'; @@ -8,18 +9,16 @@ import Whisper from './components/whisper'; import Storage from './components/storage'; import ENS from './components/ens'; +import 'bootstrap/dist/css/bootstrap.css'; import './dapp.css'; class App extends React.Component { - constructor(props) { super(props); - this.handleSelect = this.handleSelect.bind(this); - this.state = { error: null, - activeKey: 1, + activeKey: '1', whisperEnabled: false, storageEnabled: false, blockchainEnabled: false @@ -56,35 +55,59 @@ class App extends React.Component { } handleSelect(key) { - this.setState({ activeKey: key }); + this.setState({activeKey: key}); } render() { const ensEnabled = EmbarkJS.Names.currentNameSystems && EmbarkJS.Names.isAvailable(); if (this.state.error) { return (
-
Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:
+
Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask + to connect to the ethereum network: +
{this.state.error}
); } return (

Embark - Usage Example

- - + + + - - + + - - + + - - + + - - + +
); } } -ReactDOM.render(, document.getElementById('app')); +ReactDOM.render(, document.getElementById('app')); diff --git a/dapps/templates/demo/app/index.html b/dapps/templates/demo/app/index.html index f48217752..13a0edd92 100644 --- a/dapps/templates/demo/app/index.html +++ b/dapps/templates/demo/app/index.html @@ -1,7 +1,6 @@ Embark - SimpleStorage Demo -
diff --git a/dapps/templates/demo/package.json b/dapps/templates/demo/package.json index de4a7bb90..99a6be99a 100644 --- a/dapps/templates/demo/package.json +++ b/dapps/templates/demo/package.json @@ -34,11 +34,12 @@ }, "devDependencies": { "bootstrap": "4.3.1", + "classnames": "2.2.6", "embark": "^4.1.0", "embark-reset": "^4.1.0", "npm-run-all": "4.1.5", "react": "16.7.0", - "react-bootstrap": "0.32.4", + "reactstrap": "8.0.1", "react-dom": "16.7.0", "rimraf": "3.0.0" } diff --git a/yarn.lock b/yarn.lock index 0dd6e5cb6..ba4018d74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17715,6 +17715,21 @@ reactstrap@6.5.0, reactstrap@^6.5.0: react-popper "^0.10.4" react-transition-group "^2.3.1" +reactstrap@8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/reactstrap/-/reactstrap-8.0.1.tgz#0b663c8195f540bc1d6d5dbcbcf73cab56fe7c79" + integrity sha512-GvUWEL+a2+3npK1OxTXcNBMHXX4x6uc1KQRzK7yAOl+8sAHTRWqjunvMUfny3oDh8yKVzgqpqQlWWvs1B2HR9A== + dependencies: + "@babel/runtime" "^7.2.0" + classnames "^2.2.3" + lodash.isfunction "^3.0.9" + lodash.isobject "^3.0.2" + lodash.tonumber "^4.0.3" + prop-types "^15.5.8" + react-lifecycles-compat "^3.0.4" + react-popper "^1.3.3" + react-transition-group "^2.3.1" + read-cmd-shim@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz#2d5d157786a37c055d22077c32c53f8329e91c7b"