add example

pull/1/head
yann300 6 years ago
parent 2f8253bddc
commit 854e743b2d
  1. 14
      src/app/ui/landing-page/landing-page.js

@ -90,10 +90,13 @@ export class LandingPage extends BaseApi {
}
render () {
let load = function (service, item) {
let load = function (service, item, examples) {
let compilerImport = new CompilerImport()
let fileProviders = globalRegistry.get('fileproviders').api
modalDialogCustom.prompt(`Import from ${service}`, 'Enter the ' + item + ' you would like to load.', null, (target) => {
const msg = yo`<div><span>Enter the ${item} you would like to load.</span>
<div>e.g ${examples.map((url) => { return yo`<div>${url}</div>` })}</div></div>`
modalDialogCustom.prompt(`Import from ${service}`, msg, null, (target) => {
if (target !== '') {
compilerImport.import(
target,
@ -104,6 +107,7 @@ export class LandingPage extends BaseApi {
} else {
if (fileProviders[type]) {
fileProviders[type].addReadOnly(cleanUrl, content, url)
globalRegistry.get('verticalicon').api.select('fileExplorers')
}
}
}
@ -212,9 +216,9 @@ export class LandingPage extends BaseApi {
<p class="mb-1">Import From:</p>
<div class="btn-group">
<button class="btn btn-sm btn-secondary" onclick=${() => { importFromGist() }}>Gist</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Github', 'Github URL') }}>Github</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Swarm', 'bzz-raw URL') }}>Swarm</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Ipfs', 'ipfs URL') }}>Ipfs</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Github', 'Github URL', ['https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/crowdsale/Crowdsale.sol', 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol', 'github:OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol#v2.1.2']) }}>Github</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Swarm', 'bzz-raw URL', ['bzz-raw://<swarm-hash>']) }}>Swarm</button>
<button class="btn btn-sm btn-secondary" onclick=${() => { load('Ipfs', 'ipfs URL', ['ipfs://<ipfs-hash>']) }}>Ipfs</button>
</div><!-- end of btn-group -->
</div><!-- end of div.file -->
</div><!-- end of #col1 -->

Loading…
Cancel
Save