Last active
June 11, 2017 13:44
-
-
Save TimonVS/9fb8d48899884efb4f00c7701851d4a1 to your computer and use it in GitHub Desktop.
Electron workshop - step 2
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Cryptocoin Tracker</title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<div id="app"></div> | |
</body> | |
<script> | |
// You can also require other files to run in this process | |
require('./renderer.js') | |
</script> | |
</html> |
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
const app = document.getElementById('app') | |
const getPrices = () => { | |
return fetch( | |
'https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC&tsyms=USD,EUR' | |
).then(res => { | |
return res.json() | |
}) | |
} | |
const update = () => { | |
getPrices().then(res => { | |
const html = Object.entries(res) | |
.map(currency => { | |
return `<div class="currency-row"> | |
<h2 class="currency-title">${currency[0]}</h2> | |
€ ${currency[1].EUR}<br /> | |
$ ${currency[1].USD} | |
</div>` | |
}) | |
.join('') | |
app.innerHTML = html | |
}) | |
} | |
update() | |
setInterval(update, 2000) |
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
@import 'https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css'; | |
body { | |
font-family: sans-serif; | |
} | |
.currency-row { | |
width: 100%; | |
padding: 10px; | |
} | |
.currency-row:nth-child(odd) { | |
background-color: #f0f0f0; | |
} | |
.currency-title { | |
margin: 0; | |
margin-bottom: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment