Format index.html
This commit is contained in:
parent
ee6b1efd6b
commit
f8c5635a65
1 changed files with 136 additions and 99 deletions
79
index.html
79
index.html
|
@ -1,8 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Fuel App</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
|
@ -12,13 +12,25 @@ body {
|
|||
font-size: 18px;
|
||||
color: #444;
|
||||
padding: 0 10px;
|
||||
font-family: ui-rounded, 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, Manjari, Nunito, 'Arial Rounded MT', 'Arial Rounded MT Bold', Calibri, source-sans-pro, sans-serif;
|
||||
font-family: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand,
|
||||
Comfortaa, Manjari, Nunito, "Arial Rounded MT",
|
||||
"Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif;
|
||||
width: fit-content;
|
||||
}
|
||||
h1,h2,h3{ line-height:1.2 }
|
||||
header { text-align: center }
|
||||
label { font-weight: bold }
|
||||
p { margin: 1em 0 0 }
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
line-height: 1.2;
|
||||
}
|
||||
header {
|
||||
text-align: center;
|
||||
}
|
||||
label {
|
||||
font-weight: bold;
|
||||
}
|
||||
p {
|
||||
margin: 1em 0 0;
|
||||
}
|
||||
#app {
|
||||
background: ghostwhite;
|
||||
padding: 1em 1em 0.5em;
|
||||
|
@ -49,7 +61,7 @@ body {
|
|||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>⛽<br>Fuel App</h1>
|
||||
<h1>⛽<br />Fuel App</h1>
|
||||
</header>
|
||||
|
||||
<div id="app">
|
||||
|
@ -57,23 +69,26 @@ body {
|
|||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const el = document.getElementById('app');
|
||||
const el = document.getElementById("app");
|
||||
if (el) {
|
||||
const timer = setTimeout(function() { console.log('ran'); el.textContent = "Loading…" }, 500);
|
||||
const timer = setTimeout(function () {
|
||||
console.log("ran");
|
||||
el.textContent = "Loading…";
|
||||
}, 500);
|
||||
el.dataset.timer = timer;
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
import { reactive, html } from './arrow.min.js';
|
||||
import { reactive, html } from "./arrow.min.js";
|
||||
|
||||
const data = reactive({
|
||||
price: 194.9,
|
||||
economy: 7.4,
|
||||
distance: 1050
|
||||
distance: 1050,
|
||||
});
|
||||
|
||||
function calculate() {
|
||||
return data.distance / 100.0 * data.economy * data.price / 100.0;
|
||||
return ((data.distance / 100.0) * data.economy * data.price) / 100.0;
|
||||
}
|
||||
|
||||
function updateValue(e) {
|
||||
|
@ -85,29 +100,51 @@ function updateValue(e) {
|
|||
}
|
||||
}
|
||||
|
||||
const app = document.getElementById('app');
|
||||
const app = document.getElementById("app");
|
||||
clearTimeout(parseInt(app.dataset.timer, 10));
|
||||
app.replaceChildren(); // Clear loading text
|
||||
|
||||
html`
|
||||
<form>
|
||||
<label for="price">Price</label>
|
||||
<input @input="${updateValue}" type="number" step="0.1" name="price" id="price" size="6" value="${() => data.price}">
|
||||
<input
|
||||
@input="${updateValue}"
|
||||
type="number"
|
||||
step="0.1"
|
||||
name="price"
|
||||
id="price"
|
||||
size="6"
|
||||
value="${() => data.price}"
|
||||
/>
|
||||
<span><span class="unit">¢/l</span></span>
|
||||
|
||||
<label for="economy">Consumption</label>
|
||||
<input @input="${updateValue}" type="number" name="economy" id="economy" step="0.1" size="6" value="${() => data.economy}">
|
||||
<input
|
||||
@input="${updateValue}"
|
||||
type="number"
|
||||
name="economy"
|
||||
id="economy"
|
||||
step="0.1"
|
||||
size="6"
|
||||
value="${() => data.economy}"
|
||||
/>
|
||||
<span><span class="unit">l/100km</span></span>
|
||||
|
||||
<label for="distance">Distance</label>
|
||||
<input @input="${updateValue}" type="number" name="distance" id="distance" step="1" size="6" value="${() => data.distance}">
|
||||
<input
|
||||
@input="${updateValue}"
|
||||
type="number"
|
||||
name="distance"
|
||||
id="distance"
|
||||
step="1"
|
||||
size="6"
|
||||
value="${() => data.distance}"
|
||||
/>
|
||||
<span><span class="unit">km</span></span>
|
||||
</form>
|
||||
|
||||
<p class="total">
|
||||
$${() => calculate().toFixed(2)}
|
||||
</p>
|
||||
`(app)
|
||||
<p class="total">$${() => calculate().toFixed(2)}</p>
|
||||
`(app);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue