From 2c35aefb7fd9a496832ff0916df37ca8675b76c2 Mon Sep 17 00:00:00 2001 From: glendc Date: Sun, 11 Feb 2024 09:56:29 +0100 Subject: [PATCH] improve ergonomics of thermometer after testing with oldest kid turns out it was a bit hard to click --- site/1/thermometer.html | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/site/1/thermometer.html b/site/1/thermometer.html index f2924bf..d95b4da 100644 --- a/site/1/thermometer.html +++ b/site/1/thermometer.html @@ -146,11 +146,11 @@ } #thermometer tr { - height: 10px; + height: 15px; } #thermometer td { - width: 20px; + width: 80px; } #thermometer tr:last-child>td:nth-child(2) { @@ -173,6 +173,10 @@ background-color: red; } + #thermometer tr>td:nth-child(2) { + width: 20px; + } + #thermometer tr>td:nth-child(3) { width: 30px; text-align: center; @@ -188,6 +192,7 @@ #thermometer tr:last-child>td:first-child { border-bottom: 3px solid black; display: block; + height: 30px; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; } @@ -415,7 +420,7 @@

 

function drawThermometer(exercise, feedback) { let thermometer = `
`; - let cells = Math.ceil(window.thermomterState.countUntil / 5.0) * 5; + let cells = (Math.ceil(window.thermomterState.countUntil / 5.0) * 5) + 5; for (let i = 0; i < cells + 2; i++) { const cellValue = cells - i + 1; let liquidClass = ''; @@ -423,10 +428,10 @@

 

liquidClass = 'liquid' } thermometer += ` - + - - ${i <= cells && i % 5 === 0 ? '' : (i <= cells && (i - 1) % 5 === 0 ? '' : '')} + + ${i <= cells && i % 5 === 0 ? `' : (i <= cells && (i - 1) % 5 === 0 ? '' : ``)} `; } thermometer += `
  ' + (cells - i) + '  ` + (cells - i) + ' 
@@ -473,16 +478,16 @@

 

`; - document.querySelectorAll('#thermometer.interactive tr > td:first-child').forEach((el) => { + document.querySelectorAll('#thermometer.interactive tr').forEach((el) => { el.addEventListener('click', (e) => { e.preventDefault(); const elementId = e.target ? e.target.id : e.srcElement.id; const el = document.getElementById(elementId); const maxValue = Number(el.getAttribute('value')); - document.querySelectorAll('#thermometer.interactive tr:not(:last-child)>td:first-child').forEach((el) => { + document.querySelectorAll('#thermometer.interactive tr:not(:last-child)').forEach((el) => { const value = Number(el.getAttribute('value')); - el.className = value <= maxValue ? 'liquid' : ''; + el.querySelector('td:first-child').className = value <= maxValue ? 'liquid' : ''; }); }) });