Fix calendar activity heatmap in preview and generation

This commit is contained in:
2026-07-20 19:56:18 +02:00
parent 5726b92c5d
commit 3795db76b0
5 changed files with 71 additions and 20 deletions

View File

@@ -55,17 +55,14 @@
function applyHeatStyle(target, count, maxCount) {
if (!(target instanceof HTMLElement) || !Number.isFinite(count) || count <= 0 || !Number.isFinite(maxCount) || maxCount <= 0) {
target?.style?.setProperty('--blog-calendar-heat-alpha', '0');
target?.style?.setProperty('--blog-calendar-heat-hue', '210');
target?.style?.setProperty('--blog-calendar-heat-strength', '0%');
return;
}
const normalized = Math.min(1, count / maxCount);
const hue = Math.round(210 - (210 * normalized));
const alpha = (0.30 + normalized * 0.65).toFixed(3);
const strength = Math.round(30 + normalized * 60);
target.style.setProperty('--blog-calendar-heat-hue', String(hue));
target.style.setProperty('--blog-calendar-heat-alpha', alpha);
target.style.setProperty('--blog-calendar-heat-strength', String(strength) + '%');
}
function navigateTo(pathname) {
@@ -296,4 +293,4 @@
setPanelOpen(false);
});
}
})();
})();