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());
|
||||
document.getElementById("day-next").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");
|
||||
if (title) {
|
||||
title.textContent = isToday
|
||||
@@ -2355,6 +2359,17 @@
|
||||
dayPicker.value = ymd(new Date());
|
||||
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) {
|
||||
const d = selectedDay();
|
||||
d.setDate(d.getDate() + days);
|
||||
|
||||
Reference in New Issue
Block a user