Make sleep phase bars proportional

This commit is contained in:
2026-05-19 16:43:33 +02:00
parent 3b2c36c849
commit 0fb8adbb14
3 changed files with 57 additions and 4 deletions
+26
View File
@@ -1703,6 +1703,31 @@
});
}
function initSleepPhaseTooltips() {
document.querySelectorAll(".sleep-phase-bar__segment[data-tooltip]").forEach(segment => {
segment.addEventListener("click", event => {
event.preventDefault();
event.stopPropagation();
document.querySelectorAll(".sleep-phase-bar__segment.is-tooltip-visible").forEach(active => {
if (active !== segment) {
active.classList.remove("is-tooltip-visible");
}
});
segment.classList.toggle("is-tooltip-visible");
});
});
document.addEventListener("click", event => {
if (event.target.closest(".sleep-phase-bar__segment[data-tooltip]")) {
return;
}
document.querySelectorAll(".sleep-phase-bar__segment.is-tooltip-visible").forEach(segment => {
segment.classList.remove("is-tooltip-visible");
});
});
}
function csrfToken() {
return document.querySelector('meta[name="csrf-token"]')?.getAttribute("content") || "";
}
@@ -2036,6 +2061,7 @@
initOptionsPanels();
initHealthImportStatus();
initMediaLightbox();
initSleepPhaseTooltips();
initSportTypeManager();
initPwaShell();
initPullToRefresh();