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:
Alexander Heldt
2026-07-13 20:40:01 +00:00
parent 0009e63d23
commit c103082ca5
4 changed files with 29 additions and 43 deletions
+11 -12
View File
@@ -674,28 +674,27 @@
let bigClockSince = 0; let bigClockSince = 0;
function renderBigClock(events) { function renderBigClock(events) {
const card = document.getElementById("big-clock"); const pill = document.getElementById("bar-clock");
const label = document.getElementById("bc-label"); const icon = document.getElementById("bar-clock-icon");
const time = document.getElementById("bc-time"); const time = document.getElementById("bar-clock-time");
const since = document.getElementById("bc-since");
const { state, since: ts } = currentSleepState(events); const { state, since: ts } = currentSleepState(events);
bigClockState = state; bigClockState = state;
bigClockSince = ts; bigClockSince = ts;
if (!state) { if (!state) {
card.hidden = true; pill.hidden = true;
return; return;
} }
card.hidden = false; pill.hidden = false;
card.classList.toggle("asleep", state === "asleep"); pill.classList.toggle("asleep", state === "asleep");
card.classList.toggle("awake", state === "awake"); pill.classList.toggle("awake", state === "awake");
label.textContent = state === "asleep" ? "Asleep for" : "Awake for"; icon.textContent = state === "asleep" ? "😴" : "☀️";
time.textContent = formatCounter(Date.now() - ts); pill.title = `${state === "asleep" ? "Asleep" : "Awake"} since ${formatTime(ts)}`;
since.textContent = `since ${formatTime(ts)}`; time.textContent = formatCounter(Date.now() - ts);
} }
function tickBigClock() { function tickBigClock() {
if (!bigClockState) return; if (!bigClockState) return;
const time = document.getElementById("bc-time"); const time = document.getElementById("bar-clock-time");
if (time) time.textContent = formatCounter(Date.now() - bigClockSince); if (time) time.textContent = formatCounter(Date.now() - bigClockSince);
} }
+1
View File
@@ -1,4 +1,5 @@
[ [
{ "date": "2026-07-13", "text": "The awake/asleep timer lives in the frozen top bar" },
{ "date": "2026-07-13", "text": "The day picker is a bar frozen at the top of the page" }, { "date": "2026-07-13", "text": "The day picker is a bar frozen at the top of the page" },
{ "date": "2026-07-13", "text": "Attach multiple photos to an event — the photo picker now also offers the gallery with multi-select" }, { "date": "2026-07-13", "text": "Attach multiple photos to an event — the photo picker now also offers the gallery with multi-select" },
{ "date": "2026-07-13", "text": "Track food by weight: logging a meal asks for grams (optional), with a daily total in the overview and a weekly chart" }, { "date": "2026-07-13", "text": "Track food by weight: logging a meal asks for grams (optional), with a daily total in the overview and a weekly chart" },
+6 -6
View File
@@ -82,12 +82,12 @@
<input type="date" id="day-picker" /> <input type="date" id="day-picker" />
<button type="button" id="day-today" class="ghost">Today</button> <button type="button" id="day-today" class="ghost">Today</button>
<button type="button" id="day-next" class="ghost" aria-label="Next day"></button> <button type="button" id="day-next" class="ghost" aria-label="Next day"></button>
</section> <!-- Compact asleep/awake counter (the old big clock); hidden until a
sleep event exists. Hover/long-press shows "since" via title. -->
<section id="big-clock" class="big-clock" hidden> <div id="bar-clock" class="bar-clock" hidden>
<div class="bc-label" id="bc-label"></div> <span id="bar-clock-icon" aria-hidden="true"></span>
<div class="bc-time" id="bc-time">0:00</div> <span id="bar-clock-time"></span>
<div class="bc-since" id="bc-since"></div> </div>
</section> </section>
<section class="quick-actions"> <section class="quick-actions">
+11 -25
View File
@@ -159,34 +159,20 @@ body::before {
opacity: 0.4; opacity: 0.4;
cursor: not-allowed; cursor: not-allowed;
} }
.big-clock { .bar-clock {
text-align: center; display: flex;
padding: 24px 16px; align-items: center;
} gap: 6px;
.big-clock .bc-label { padding: 7px 12px;
font-size: 0.8rem; border-radius: 999px;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--muted);
margin-bottom: 6px;
}
.big-clock .bc-time {
font-size: 3.25rem;
font-weight: 700; font-weight: 700;
font-size: 0.9rem;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
line-height: 1.05; flex-shrink: 0;
letter-spacing: -0.01em;
} }
.big-clock .bc-since { .bar-clock[hidden] { display: none; }
margin-top: 6px; .bar-clock.asleep { background: color-mix(in srgb, var(--sleep) 18%, var(--surface)); color: var(--sleep); }
font-size: 0.8rem; .bar-clock.awake { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.big-clock.asleep { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--sleep) 10%, var(--surface))); }
.big-clock.asleep .bc-time { color: var(--sleep); }
.big-clock.awake { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--accent) 10%, var(--surface))); }
.big-clock.awake .bc-time { color: var(--accent); }
.grid { .grid {
display: grid; display: grid;