Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Calendar: Day view keeps the day at a glance beside its timeline

Yashwanth Kamireddiaf3c8cbfc411
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 76bd095..707d893 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -578,6 +578,7 @@ export function CalendarView() {
)}
{(view === "week" || view === "day") && (
+ <div className={view === "day" ? "cx-dayview" : "cx-weekview"}>
<TimeGrid
days={view === "week" ? week : [selected]}
today={now}
@@ -598,6 +599,16 @@ export function CalendarView() {
: null
}
/>
+ {view === "day" && (
+ <DayPane
+ day={selected}
+ events={shown}
+ reminders={due}
+ calendars={byGuid}
+ onOpen={(e, at) => openDraft(draftOf(e), at)}
+ />
+ )}
+ </div>
)}
{view === "year" && (
@@ -1590,3 +1601,66 @@ function EventPopover({
</form>
);
}
+
+/**
+ * The day at a glance, beside Day's timeline — as Calendar sets it: the date, then what fills
+ * it, all-day first and the rest in time order. A wide window gave the timeline the whole
+ * width and left most of it empty; this is what Calendar puts there.
+ */
+function DayPane({
+ day,
+ events,
+ reminders,
+ calendars,
+ onOpen,
+}: {
+ day: Date;
+ events: CalendarEvent[];
+ reminders: Reminder[];
+ calendars: Map<string, Calendar>;
+ onOpen: (e: CalendarEvent, at: Anchor) => void;
+}) {
+ const from = seconds(day);
+ const to = seconds(addDays(day, 1));
+ const today = events.filter((e) => e.startsAt < to && e.endsAt > from);
+ const allDay = today.filter((e) => spansDays(e));
+ const timed = today.filter((e) => !spansDays(e)).sort((a, b) => a.startsAt - b.startsAt);
+ const due = reminders
+ .filter((r) => r.dueAt !== null && r.dueAt >= from && r.dueAt < to && !r.completedAt)
+ .sort((a, b) => (a.dueAt ?? 0) - (b.dueAt ?? 0));
+ const row = (e: CalendarEvent, when: string) => (
+ <li key={e.guid}>
+ <button
+ className="cx-pane-event"
+ style={{ "--cal": tint(calendars.get(e.calendarGuid)) } as React.CSSProperties}
+ onClick={(ev) => onOpen(e, pointOf(ev.currentTarget))}
+ >
+ <span className="cx-pane-title">{e.title}</span>
+ <span className="cx-pane-when">{when}</span>
+ {e.location && <span className="cx-pane-where">{e.location}</span>}
+ </button>
+ </li>
+ );
+ const nothing = allDay.length + timed.length + due.length === 0;
+ return (
+ <aside className="cx-pane" aria-label={day.toLocaleDateString(undefined, { dateStyle: "full" })}>
+ <h2 className="cx-pane-day">{day.toLocaleDateString(undefined, { weekday: "long" })}</h2>
+ <p className="cx-pane-date">{day.toLocaleDateString(undefined, { day: "numeric", month: "long", year: "numeric" })}</p>
+ {nothing ? (
+ <p className="cx-pane-empty">Nothing on this day.</p>
+ ) : (
+ <ul className="cx-pane-list">
+ {allDay.map((e) => row(e, "all-day"))}
+ {timed.map((e) => row(e, `${clock(e.startsAt)} – ${clock(e.endsAt)}`))}
+ {due.map((r) => (
+ <li key={r.guid} className="cx-pane-reminder">
+ <span className="cx-ring" aria-hidden="true" />
+ <span className="cx-pane-title">{r.title}</span>
+ <span className="cx-pane-when">{clock(r.dueAt ?? 0)}</span>
+ </li>
+ ))}
+ </ul>
+ )}
+ </aside>
+ );
+}
diff --git a/src/styles/calendar.css b/src/styles/calendar.css
index 1461746..3a43b72 100644
--- a/src/styles/calendar.css
+++ b/src/styles/calendar.css
@@ -667,3 +667,43 @@
/* The bottom edge of an event that can be changed: drag it to change when it ends. */
.cx-block-grip { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
+
+/* Day: the timeline, and beside it the day at a glance, as Calendar lays it out. The date is
+ the toolbar's title already, so the timeline drops its own one-column header. */
+.cx-dayview, .cx-weekview { flex: 1; display: flex; min-height: 0; }
+.cx-dayview > .cal-hours, .cx-weekview > .cal-hours { flex: 1; min-width: 0; }
+.cal-hours.is-day .cx-grid-head { display: none; }
+.cx-pane {
+ flex: none;
+ width: 280px;
+ min-height: 0;
+ overflow-y: auto;
+ padding: 6px 18px 18px;
+ border-left: 1px solid var(--separator);
+}
+.cx-pane-day { margin: 0; font-size: var(--t-22); font-weight: 700; letter-spacing: -0.02em; }
+.cx-pane-date { margin: 2px 0 16px; color: var(--text-2); font-size: var(--t-13); }
+.cx-pane-empty { margin: 0; color: var(--text-3); font-size: var(--t-13); }
+.cx-pane-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
+.cx-pane-event {
+ display: grid;
+ gap: 1px;
+ width: 100%;
+ padding: 7px 10px 7px 12px;
+ border: 0;
+ border-left: 3px solid var(--cal);
+ border-radius: 7px;
+ background: color-mix(in srgb, var(--cal) 16%, transparent);
+ color: var(--text);
+ font: inherit;
+ text-align: left;
+ cursor: default;
+}
+.cx-pane-event:hover { background: color-mix(in srgb, var(--cal) 24%, transparent); }
+.cx-pane-event:focus-visible { outline: 3px solid var(--gold-ring); }
+.cx-pane-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-13); font-weight: 600; }
+.cx-pane-when, .cx-pane-where { color: var(--text-2); font-size: var(--t-11); font-variant-numeric: tabular-nums; }
+.cx-pane-reminder { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 10px; font-size: var(--t-13); }
+.cx-pane-reminder .cx-pane-title { font-weight: 400; }
+/* Without room for both, the timeline keeps the window. */
+@container cx-page (max-width: 900px) { .cx-pane { display: none; } }