zmiany w ux

This commit is contained in:
Mateusz Gruszczyński
2025-09-24 10:55:04 +02:00
parent 8b6fb41a68
commit 4515a1b391
6 changed files with 294 additions and 130 deletions

View File

@@ -26,15 +26,20 @@
const val = clamp(Number(input.value));
const p = Math.max(0, Math.min(100, pct(val)));
if (previewPct) previewPct.textContent = pct(val).toFixed(1);
if (previewBar) previewBar.style.setProperty('--progress-width', p + '%');
if (previewPct) previewPct.textContent = p.toFixed(1);
if (previewBar) {
previewBar.style.width = p + '%';
previewBar.setAttribute('aria-valuenow', p.toFixed(2));
}
if (previewNote) {
if (cel > 0) {
const diff = cel - val;
if (diff > 0) {
const isZero = Math.abs(diff) < 0.005; // float-safe
if (diff > 0 && !isZero) {
previewNote.textContent = 'Do celu brakuje: ' + diff.toFixed(2) + ' PLN';
} else if (diff === 0) {
} else if (isZero) {
previewNote.textContent = 'Cel osiągnięty.';
} else {
previewNote.textContent = 'Przekroczono cel o: ' + Math.abs(diff).toFixed(2) + ' PLN';
@@ -45,6 +50,7 @@
}
}
// Zmiana ręczna
if (input) {
input.addEventListener('input', updatePreview);