Replace the big clock with a timer pill in the frozen day bar
The full-width asleep/awake card becomes a compact colored pill next to the day controls: state emoji plus the live counter, with "since" moved to the tooltip. One glance at the pinned bar now gives both the day and the current state.
This commit is contained in:
1 parent
0009e63d23
commit
c103082ca5
4 files changed
+29
-43
No files matched your search
+11
-12
@@ -674,28 +674,27 @@
|
||||
let bigClockSince = 0;
|
||||
|
||||
function renderBigClock(events) {
|
||||
const card = document.getElementById("big-clock");
|
||||
const label = document.getElementById("bc-label");
|
||||
const time = document.getElementById("bc-time");
|
||||
const since = document.getElementById("bc-since");
|
||||
const pill = document.getElementById("bar-clock");
|
||||
const icon = document.getElementById("bar-clock-icon");
|
||||
const time = document.getElementById("bar-clock-time");
|
||||
const { state, since: ts } = currentSleepState(events);
|
||||
bigClockState = state;
|
||||
bigClockSince = ts;
|
||||
if (!state) {
|
||||
card.hidden = true;
|
||||
pill.hidden = true;
|
||||
return;
|
||||
}
|
||||
card.hidden = false;
|
||||
card.classList.toggle("asleep", state === "asleep");
|
||||
card.classList.toggle("awake", state === "awake");
|
||||
label.textContent = state === "asleep" ? "Asleep for" : "Awake for";
|
||||
time.textContent = formatCounter(Date.now() - ts);
|
||||
since.textContent = `since ${formatTime(ts)}`;
|
||||
pill.hidden = false;
|
||||
pill.classList.toggle("asleep", state === "asleep");
|
||||
pill.classList.toggle("awake", state === "awake");
|
||||
icon.textContent = state === "asleep" ? "😴" : "☀️";
|
||||
pill.title = `${state === "asleep" ? "Asleep" : "Awake"} since ${formatTime(ts)}`;
|
||||
time.textContent = formatCounter(Date.now() - ts);
|
||||
}
|
||||
|
||||
function tickBigClock() {
|
||||
if (!bigClockState) return;
|
||||
const time = document.getElementById("bc-time");
|
||||
const time = document.getElementById("bar-clock-time");
|
||||
if (time) time.textContent = formatCounter(Date.now() - bigClockSince);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user