mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
494 B
25 lines
494 B
6 years ago
|
<script>
|
||
|
let c = 0;
|
||
|
let f = 32;
|
||
|
|
||
|
function setBothFromC(value) {
|
||
|
c = +value;
|
||
1 year ago
|
f = +(32 + (9 / 5) * c).toFixed(1);
|
||
6 years ago
|
}
|
||
|
|
||
|
function setBothFromF(value) {
|
||
|
f = +value;
|
||
1 year ago
|
c = +((5 / 9) * (f - 32)).toFixed(1);
|
||
6 years ago
|
}
|
||
|
</script>
|
||
4 years ago
|
|
||
|
<!-- https://eugenkiss.github.io/7guis/tasks/#temp -->
|
||
1 year ago
|
<input value={c} on:input={(e) => setBothFromC(e.target.value)} type="number" /> °C =
|
||
|
<input value={f} on:input={(e) => setBothFromF(e.target.value)} type="number" /> °F
|
||
4 years ago
|
|
||
|
<style>
|
||
|
input {
|
||
|
width: 5em;
|
||
|
}
|
||
3 years ago
|
</style>
|