Show a compact year-less date in the day bar so it fits small iPhones
The native date input can't be told to drop the year, so a button face shows e.g. "Jul 10" and the real input sits hidden behind it, still holding the value and opening the native picker on tap.
This commit is contained in:
+15
@@ -1563,6 +1563,10 @@
|
|||||||
const isToday = ymd(day) === ymd(new Date());
|
const isToday = ymd(day) === ymd(new Date());
|
||||||
document.getElementById("day-next").disabled = isToday;
|
document.getElementById("day-next").disabled = isToday;
|
||||||
document.getElementById("day-today").disabled = isToday;
|
document.getElementById("day-today").disabled = isToday;
|
||||||
|
// Year-less date on the picker's face — the year is implicit and the
|
||||||
|
// saved width keeps the bar on one row on small phones.
|
||||||
|
document.getElementById("day-date-face").textContent =
|
||||||
|
day.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
||||||
const title = document.getElementById("overview-title");
|
const title = document.getElementById("overview-title");
|
||||||
if (title) {
|
if (title) {
|
||||||
title.textContent = isToday
|
title.textContent = isToday
|
||||||
@@ -2355,6 +2359,17 @@
|
|||||||
dayPicker.value = ymd(new Date());
|
dayPicker.value = ymd(new Date());
|
||||||
dayPicker.addEventListener("change", render);
|
dayPicker.addEventListener("change", render);
|
||||||
|
|
||||||
|
// The face opens the hidden input's native picker (iOS 16+ has showPicker;
|
||||||
|
// focus() is the fallback and is what pops the picker on older iOS anyway).
|
||||||
|
document.getElementById("day-date-face").addEventListener("click", () => {
|
||||||
|
try {
|
||||||
|
if (typeof dayPicker.showPicker === "function") dayPicker.showPicker();
|
||||||
|
else dayPicker.focus();
|
||||||
|
} catch {
|
||||||
|
dayPicker.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function shiftSelectedDay(days) {
|
function shiftSelectedDay(days) {
|
||||||
const d = selectedDay();
|
const d = selectedDay();
|
||||||
d.setDate(d.getDate() + days);
|
d.setDate(d.getDate() + days);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[
|
[
|
||||||
|
{ "date": "2026-07-15", "text": "The date in the top bar is shorter (no year), so the whole bar fits on smaller iPhones" },
|
||||||
{ "date": "2026-07-13", "text": "The big timer is back at the top — scroll past it and it hops into the frozen bar instead" },
|
{ "date": "2026-07-13", "text": "The big timer is back at the top — scroll past it and it hops into the frozen bar instead" },
|
||||||
{ "date": "2026-07-13", "text": "The top bar fits on one row: timer, day arrows, date picker and Today" },
|
{ "date": "2026-07-13", "text": "The top bar fits on one row: timer, day arrows, date picker and Today" },
|
||||||
{ "date": "2026-07-13", "text": "Pick how many days the charts cover — 7, 14 or 30 (default 7)" },
|
{ "date": "2026-07-13", "text": "Pick how many days the charts cover — 7, 14 or 30 (default 7)" },
|
||||||
|
|||||||
+7
-1
@@ -86,7 +86,13 @@
|
|||||||
<span id="bar-clock-time"></span>
|
<span id="bar-clock-time"></span>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" id="day-prev" class="ghost" aria-label="Previous day">←</button>
|
<button type="button" id="day-prev" class="ghost" aria-label="Previous day">←</button>
|
||||||
<input type="date" id="day-picker" />
|
<!-- A browser won't let us shorten the text a native date input shows,
|
||||||
|
so the face button carries a compact year-less date and the real
|
||||||
|
input stays (visually hidden) as the value + native picker. -->
|
||||||
|
<span class="day-date">
|
||||||
|
<button type="button" id="day-date-face" class="ghost"></button>
|
||||||
|
<input type="date" id="day-picker" tabindex="-1" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
<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>
|
||||||
<button type="button" id="day-today" class="ghost">Today</button>
|
<button type="button" id="day-today" class="ghost">Today</button>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
+16
-3
@@ -147,10 +147,23 @@ body::before {
|
|||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
}
|
}
|
||||||
.day-bar input[type="date"] {
|
/* The face button shows the short date; the real input sits invisibly behind
|
||||||
flex: 0 1 auto;
|
it so its native picker still anchors here (and .showPicker() has a target). */
|
||||||
min-width: 0;
|
.day-date {
|
||||||
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
.day-date input[type="date"] {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
#day-date-face {
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.day-bar button {
|
.day-bar button {
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user