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.

Interface: one design system across every app, and the Windows findings fixed

Yashwanth Kamireddiffa7d14ea297
diff --git a/.uiverify/a11y.mjs b/.uiverify/a11y.mjs
index 3d2c2c8..6714e86 100644
--- a/.uiverify/a11y.mjs
+++ b/.uiverify/a11y.mjs
@@ -101,7 +101,7 @@ const screens = [
await p.waitForSelector(".drive-row-hit");
await p.hover(".drive-row.is-folder");
await p.click('.drive-row.is-folder .drive-action[aria-label^="Actions for"]');
- await p.getByRole("menuitem", { name: "Move to Folder…" }).click();
+ await p.getByRole("menuitem", { name: "Move to Folder" }).click();
await p.waitForSelector(".modal-sheet");
} },
];
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjs
index cdcfe2f..650879e 100644
--- a/.uiverify/assert.mjs
+++ b/.uiverify/assert.mjs
@@ -186,7 +186,9 @@ let failures = 0;
const pane = document.querySelector(".rx-main");
const row = document.querySelector(".rx-rows li, .rx-add");
if (!pane || !row) return null;
- return row.getBoundingClientRect().width / pane.getBoundingClientRect().width;
+ // Up to the list's readable measure (reminders.css caps it at 960px on a wide window).
+ const w = row.getBoundingClientRect().width;
+ return w >= 950 ? 1 : w / pane.getBoundingClientRect().width;
});
console.log(
fill === null
@@ -734,10 +736,10 @@ let failures = 0;
const open = (await page.locator(".disclosure").innerText()).toLowerCase();
const says = {
"that it is unofficial": /unofficial|not affiliated/.test(open),
- "that Apple can change it": /without notice|stop working/.test(open),
+ "that Apple can change it": /without notice|stop working|kept in step as icloud evolves/.test(open),
"where the copy is kept": /local\/share|dev\.quince\.client/.test(open),
"that the password stays here": /never leaves this computer/.test(open),
- "what no client can read": /end to end|encrypted end/.test(open),
+ "what no client can read": /end.to.end|encrypted end/.test(open),
};
for (const [what, said] of Object.entries(says)) {
console.log(said ? `PASS it says ${what}` : `FAIL it does not say ${what}`);
@@ -781,9 +783,9 @@ let failures = 0;
for (const [screen, expect] of [
["Reminders", ".rem-nolists"],
- ["Calendar", ".cal-grid, .cal-month, .cal-empty"],
- ["Notes", ".cal-empty, .notes-empty"],
- ["Contacts", ".cal-empty, .contact-empty"],
+ ["Calendar", ".cal-grid, .cal-month, .empty-state"],
+ ["Notes", ".empty-state, .notes-empty"],
+ ["Contacts", ".empty-state, .contact-empty"],
["iCloud Drive", ".drive-rows"],
]) {
await page.getByRole("button", { name: screen, exact: true }).click();
diff --git a/.uiverify/calendar-audit.mjs b/.uiverify/calendar-audit.mjs
new file mode 100644
index 0000000..18bc99a
--- /dev/null
+++ b/.uiverify/calendar-audit.mjs
@@ -0,0 +1,159 @@
+// What the Calendar audit fixed, each checked in the engine: dragging upward to make an event,
+// an event carried only to days on screen, a drag drawn per quarter hour rather than per pixel,
+// a popover dismissed by a click elsewhere keeping what was typed, the bare arrows paging,
+// Day's bars running on past the day, back-to-back short events side by side, the title set
+// as a title, Saturday's hairline, and today moving on at midnight even after a sleep.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const open = async (opts = {}) => {
+ const ctx = await b.newContext({ viewport: { width: 1300, height: 850 }, locale: "en-US" });
+ await ctx.addInitScript(() => {
+ window.__commits = 0;
+ window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { supportsFiber: true, renderers: new Map(), inject() { return 1; },
+ onCommitFiberRoot() { window.__commits++; }, onCommitFiberUnmount() {}, onPostCommitFiberRoot() {}, checkDCE() {}, onScheduleFiberRoot() {} };
+ });
+ if (opts.extra) await ctx.addInitScript(opts.extra);
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });
+ const page = await ctx.newPage();
+ if (opts.clock) await page.clock.install({ time: opts.clock });
+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+ await openScreen(page, "Calendar");
+ return { ctx, page };
+};
+
+{
+ const { ctx, page } = await open({ extra: () => {
+ // Two quarter-hour calls back to back, tomorrow at 15:00 and 15:15.
+ const d = new Date(); d.setDate(d.getDate() + 1); d.setHours(15, 0, 0, 0);
+ window.__extraEvents = [0, 1].map((i) => ({ guid: `q${i}`, calendarGuid: "work", title: `Quick call ${i}`, location: null,
+ startsAt: d.getTime() / 1000 + i * 900, endsAt: d.getTime() / 1000 + (i + 1) * 900, allDay: false, timezone: null, url: null, notes: null, etag: null }));
+ } });
+ await page.evaluate(() => { const t = window.__TAURI_INTERNALS__; const inner = t.invoke;
+ t.invoke = async (c, a) => { const r = await inner(c, a); return c === "calendar_events" && Array.isArray(r) ? [...r, ...(window.__extraEvents ?? [])] : r; }; });
+ await page.getByRole("button", { name: "Week", exact: true }).click();
+ await page.getByRole("button", { name: "Month", exact: true }).click();
+ await page.getByRole("button", { name: "Week", exact: true }).click();
+ await page.waitForTimeout(500);
+
+ // Back-to-back quarter hours: each drawn 20px tall, so laid side by side, never overlapping.
+ const q = await page.evaluate(() => ["q0", "q1"].map((g) => document.querySelector(`[data-event="${g}"]`)?.getBoundingClientRect()).map((r) => r && { top: r.top, bottom: r.bottom, left: r.left, right: r.right }));
+ const overlap = q[0] && q[1] && q[0].bottom > q[1].top && q[0].right > q[1].left && q[1].right > q[0].left;
+ ok(q[0] && q[1] && !overlap, `two back-to-back 15-minute events are not drawn over each other ${JSON.stringify(q)}`);
+
+ // Drag upward from 4 PM to 2 PM in an empty day: an event from 2 to 4.15.
+ await page.locator(".cx-scroll").evaluate((el) => { el.scrollTop = 11 * 48; });
+ const col = await page.locator(".cx-columns").boundingBox();
+ const colW = col.width / 7;
+ const yOf = async (h) => (await page.locator(".cx-columns").boundingBox()).y + h * 48;
+ const x = col.x + colW * 1 + colW / 2;
+ await page.mouse.move(x, await yOf(16) + 2);
+ await page.mouse.down();
+ const c0 = await page.evaluate(() => window.__commits);
+ for (let i = 1; i <= 96; i++) await page.mouse.move(x, (await yOf(16)) + 2 - i);
+ const commits = (await page.evaluate(() => window.__commits)) - c0;
+ await page.mouse.up();
+ await page.waitForTimeout(250);
+ ok(commits <= 12, `a 96px drag redraws once per quarter hour, not per pixel [${commits} commits]`);
+ const starts = await page.getByLabel("Starts time").inputValue().catch(() => "");
+ const ends = await page.getByLabel("Ends time").inputValue().catch(() => "");
+ ok(/^2:00/.test(starts) && /^4:15/.test(ends), `dragging upward makes the event above the press [${starts} – ${ends}]`);
+
+ // A title typed, then a click elsewhere: the event is made with it.
+ await page.getByLabel("Title").fill("Typed then clicked away");
+ await page.evaluate(() => { window.__eventSaves = []; });
+ await page.mouse.click(col.x + 20, col.y + 10 * 48);
+ await page.waitForTimeout(300);
+ const saved = await page.evaluate(() => window.__eventSaves.map((d) => d.title));
+ ok(saved.includes("Typed then clicked away"), `a click outside keeps what was typed ${JSON.stringify(saved)}`);
+ // Escape still leaves an event as it was.
+ await page.locator(".cx-block", { hasText: "Design review" }).first().click();
+ await page.waitForTimeout(200);
+ await page.getByLabel("Title").fill("Not this");
+ await page.keyboard.press("Escape");
+ await page.waitForTimeout(200);
+ ok(!(await page.evaluate(() => window.__eventSaves.some((d) => d.title === "Not this"))), "Escape still discards an edit");
+ // Nor is an untouched new event made by clicking away.
+ await page.mouse.dblclick(col.x + colW * 2 + 10, (await yOf(13)) + 5);
+ await page.waitForTimeout(200);
+ const before = await page.evaluate(() => window.__eventSaves.length);
+ await page.mouse.click(col.x + 10, (await yOf(18)) + 5);
+ await page.waitForTimeout(200);
+ const after = [await page.evaluate(() => window.__eventSaves.length) - before, await page.locator(".cx-popover").count()];
+ ok(after[0] === 0 && after[1] === 0,
+ `an untouched new event is let go by a click elsewhere [${after}]`);
+
+ // An event carried past the last day shown stays on the week: Saturday at most.
+ const block = page.locator(".cx-block", { hasText: "Design review" }).first();
+ const bb = await block.boundingBox();
+ await page.evaluate(() => { window.__eventSaves = []; });
+ await page.mouse.move(bb.x + 10, bb.y + 5);
+ await page.mouse.down();
+ await page.mouse.move(bb.x + 10 + colW * 12, bb.y + 5, { steps: 10 });
+ await page.mouse.up();
+ await page.waitForTimeout(300);
+ const moved = await page.evaluate(() => window.__eventSaves[0]);
+ const sat = await page.evaluate(() => { const d = new Date(); d.setDate(d.getDate() + (6 - d.getDay())); d.setHours(10, 0, 0, 0); return d.getTime() / 1000; });
+ ok(moved && moved.startsAt === sat, `an event dragged off the week lands on its last day [${moved && new Date(moved.startsAt * 1000).toString().slice(0, 21)}]`);
+
+ // The bare arrows page, as ⌘-arrows do; T comes back.
+ await page.mouse.click(5, 5);
+ const title0 = await page.locator(".cx-title").getAttribute("aria-label");
+ const firstHead0 = await page.locator(".cal-col-head").first().getAttribute("aria-label");
+ await page.keyboard.press("ArrowRight");
+ await page.waitForTimeout(150);
+ const firstHead1 = await page.locator(".cal-col-head").first().getAttribute("aria-label");
+ ok(firstHead1 !== firstHead0, `→ steps to the next week [${firstHead0} → ${firstHead1}]`);
+ await page.keyboard.press("ArrowLeft");
+ await page.keyboard.press("ArrowLeft");
+ await page.keyboard.press("t");
+ await page.waitForTimeout(150);
+ ok((await page.locator(".cal-col-head").first().getAttribute("aria-label")) === firstHead0, "← steps back and T returns to this week");
+
+ // Month: Saturday ends the grid without a hairline in every week, bars or not.
+ await page.getByRole("button", { name: "Month", exact: true }).click();
+ await page.waitForTimeout(250);
+ const borders = await page.evaluate(() => [...document.querySelectorAll(".cx-week")].map((w) => getComputedStyle(w.children[6]).borderRightWidth));
+ ok(borders.every((x) => x === "0px"), `no week keeps a hairline on Saturday's right ${JSON.stringify(borders)}`);
+
+ // The popover's title is a title: 17px bold, not the body's text.
+ await page.getByRole("button", { name: "Week", exact: true }).click();
+ await page.locator(".cx-block", { hasText: "Design review" }).first().click();
+ await page.waitForTimeout(200);
+ const font = await page.getByLabel("Title").evaluate((el) => [getComputedStyle(el).fontSize, getComputedStyle(el).fontWeight]);
+ ok(font[0] === "17px" && Number(font[1]) >= 700, `the popover's title is set as a title ${JSON.stringify(font)}`);
+ await page.keyboard.press("Escape");
+
+ // Day: a trip running on past the day is drawn running on, square at its right end.
+ await page.getByRole("button", { name: "Day", exact: true }).click();
+ await page.evaluate(() => { const d = new Date(); d.setDate(d.getDate() + 3); window.__day = d; });
+ for (let i = 0; i < 3; i++) await page.keyboard.press("ArrowRight");
+ await page.waitForTimeout(250);
+ const bar = await page.locator(".cx-allday .cx-bar-event", { hasText: "Flight" }).first().getAttribute("class").catch(() => "");
+ ok(/to-after/.test(bar ?? ""), `Day draws a bar that runs on past the day as running on [${bar}]`);
+ await ctx.close();
+}
+
+{
+ // A minute before midnight; then the machine sleeps past it, and the window is come back to.
+ const late = new Date(); late.setHours(23, 59, 0, 0);
+ const { ctx, page } = await open({ clock: late });
+ await page.getByRole("button", { name: "Week", exact: true }).click();
+ await page.waitForTimeout(300);
+ const today = () => page.evaluate(() => document.querySelector(".cal-col-head.is-today")?.getAttribute("aria-label"));
+ const t0 = await today();
+ await page.clock.fastForward("01:30");
+ const t1 = await today();
+ ok(t0 && t1 && t0 !== t1, `today moves on at midnight [${t0} → ${t1}]`);
+ // Asleep: the clock jumps a day without a timer firing; coming back reads it again.
+ await page.clock.setSystemTime(new Date(late.getTime() + 2 * 86400e3 + 3600e3));
+ await page.evaluate(() => window.dispatchEvent(new Event("focus")));
+ await page.waitForTimeout(100);
+ const t2 = await today();
+ ok(t2 !== t1, `coming back to the window after a sleep moves today on [${t1} → ${t2}]`);
+ await ctx.close();
+}
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/calendar-collections.mjs b/.uiverify/calendar-collections.mjs
index 69ba68f..9867a02 100644
--- a/.uiverify/calendar-collections.mjs
+++ b/.uiverify/calendar-collections.mjs
@@ -2,12 +2,12 @@
// one; a name in use is refused with Apple's words; right-click renames, recolours, deletes;
// the default calendar offers no Delete.
import { engine } from "./engine.mjs";
-import { SERVICES, installStub, openScreen } from "./stub.mjs";
+import { SERVICES, autoConfirm, installStub, openScreen } from "./stub.mjs";
const b = await engine.launch();
const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });
const page = await ctx.newPage();
-page.on("dialog", (d) => void d.accept());
+await ctx.addInitScript(autoConfirm);
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Calendar");
await page.waitForTimeout(400);
@@ -51,6 +51,6 @@ await page.keyboard.press("Escape");
await page.locator(".cx-cal", { hasText: "Trips" }).click({ button: "right" });
await page.getByRole("menuitem", { name: /Delete Calendar/ }).click();
await page.waitForTimeout(400);
-ok(!(await names()).includes("Trips"), "Delete Calendar…, once confirmed, removes it");
+ok(!(await names()).includes("Trips"), "Delete Calendar, once confirmed, removes it");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/calendar-locale.mjs b/.uiverify/calendar-locale.mjs
new file mode 100644
index 0000000..9faaf01
--- /dev/null
+++ b/.uiverify/calendar-locale.mjs
@@ -0,0 +1,47 @@
+// The week as this computer's region keeps it: Monday first and a 24-hour clock in Britain,
+// Sunday first and AM/PM in the US — in Month, Week, the mini month and Year alike.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+for (const [locale, first, initial, weekendCols, twelve] of [["en-GB", "Mon", "M", [5, 6], false], ["en-US", "Sun", "S", [0, 6], true]]) {
+ const ctx = await b.newContext({ viewport: { width: 1300, height: 850 }, locale });
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });
+ const page = await ctx.newPage();
+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+ await openScreen(page, "Calendar");
+ await page.getByRole("button", { name: "Month", exact: true }).click();
+ await page.waitForTimeout(300);
+ const month = await page.evaluate(() => ({
+ head: document.querySelector(".cx-weekdays span")?.textContent,
+ firstCell: document.querySelector(".cx-day-hit")?.getAttribute("aria-label"),
+ weekend: [...document.querySelectorAll(".cx-week:first-child .cx-day")].map((d, i) => (d.classList.contains("is-weekend") ? i : -1)).filter((i) => i >= 0),
+ mini: document.querySelector(".cx-side .cx-minimonth-wd")?.textContent,
+ }));
+ ok(month.head === first, `${locale}: Month's first column is ${first} [${month.head}]`);
+ ok(month.firstCell?.startsWith(first === "Mon" ? "Monday" : "Sunday"), `${locale}: Month's first day is a ${first} [${month.firstCell}]`);
+ ok(JSON.stringify(month.weekend) === JSON.stringify(weekendCols), `${locale}: the weekend is shaded where it falls [${month.weekend}]`);
+ ok(month.mini === initial, `${locale}: the mini month starts on ${initial} [${month.mini}]`);
+ await page.getByRole("button", { name: "Week", exact: true }).click();
+ await page.waitForTimeout(300);
+ const week = await page.evaluate(() => ({
+ head: document.querySelector(".cal-col-head")?.getAttribute("aria-label"),
+ weekend: [...document.querySelectorAll(".cx-column")].map((d, i) => (d.classList.contains("is-weekend") ? i : -1)).filter((i) => i >= 0),
+ hours: [...document.querySelectorAll(".cx-hour-labels span:not(.cx-now-label)")].map((s) => s.textContent),
+ }));
+ ok(week.head?.startsWith(first === "Mon" ? "Monday" : "Sunday"), `${locale}: Week starts on ${first} [${week.head}]`);
+ ok(JSON.stringify(week.weekend) === JSON.stringify(weekendCols), `${locale}: Week shades its weekend [${week.weekend}]`);
+ const one = week.hours.find((h) => /13|1\s?PM/i.test(h));
+ ok(twelve ? week.hours.includes("Noon") && /PM/i.test(one ?? "") : !week.hours.includes("Noon") && /^13:00$/.test(one ?? ""),
+ `${locale}: hours on a ${twelve ? "12" : "24"}-hour clock [${week.hours.slice(10, 14).join(" | ")}]`);
+ const times = await page.locator(".cx-block-time").allTextContents();
+ ok(twelve ? times.some((t) => /AM|PM/i.test(t)) : times.every((t) => /^\d{2}:\d{2}$/.test(t)), `${locale}: event times read the same clock [${times.slice(0, 3).join(" | ")}]`);
+ await page.getByRole("button", { name: "Year", exact: true }).click();
+ await page.waitForTimeout(300);
+ const year = await page.evaluate(() => document.querySelector(".cal-mini .cx-minimonth-wd")?.textContent);
+ ok(year === initial, `${locale}: Year's months start on ${initial} [${year}]`);
+ await ctx.close();
+}
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/calendar-model.test.mjs b/.uiverify/calendar-model.test.mjs
index 9bd452d..0670245 100644
--- a/.uiverify/calendar-model.test.mjs
+++ b/.uiverify/calendar-model.test.mjs
@@ -1,14 +1,14 @@
// The arithmetic Calendar's views are drawn from, checked directly.
import { test } from "node:test";
import assert from "node:assert/strict";
-import { placeDay, placeDayWith, weekSpans, monthDays, daysOf, snap, clock } from "../src/screens/calendar/model.ts";
+import { placeDay, placeDayWith, weekSpans, monthDays, daysOf, snap, clock, startOfWeek, weekInfoOf, hourLabel } from "../src/screens/calendar/model.ts";
const at = (y, m, d, h = 0, min = 0) => Math.floor(new Date(y, m, d, h, min).getTime() / 1000);
const ev = (guid, startsAt, endsAt, allDay = false) =>
({ guid, calendarGuid: "c", title: guid, location: null, startsAt, endsAt, allDay, timezone: null, url: null, notes: null, etag: null });
test("a month is six weeks from the Sunday on or before the 1st", () => {
- const days = monthDays(new Date(2026, 8, 15));
+ const days = monthDays(new Date(2026, 8, 15), 0);
assert.equal(days.length, 42);
assert.equal(days[0].getDay(), 0);
assert.deepEqual([days[0].getMonth(), days[0].getDate()], [7, 30]);
@@ -92,8 +92,8 @@ test("dragging snaps to the quarter hour", () => {
});
test("a time on the hour leaves off the minutes", () => {
- assert.doesNotMatch(clock(at(2026, 8, 29, 15)), /:00/);
- assert.match(clock(at(2026, 8, 29, 15, 30)), /30/);
+ assert.doesNotMatch(clock(at(2026, 8, 29, 15), true), /:00/);
+ assert.match(clock(at(2026, 8, 29, 15, 30), true), /30/);
});
import { wallIn, instantIn, sameClockIn, zoneName } from "../src/screens/calendar/model.ts";
@@ -125,3 +125,19 @@ test("a day on is a calendar day, across a clock change too", () => {
assert.equal(addDaysIn("Asia/Kolkata", Z(2026, 10, 21, 3, 30), 1), Z(2026, 10, 22, 3, 30));
assert.equal(addDaysIn("America/New_York", Z(2026, 10, 31, 4, 0), 1), Z(2026, 11, 1, 4, 0));
});
+
+test("a week starts where the region starts it, and a 24-hour clock keeps its :00", () => {
+ // Monday first: September 2026 opens on Monday 31 August.
+ const mon = monthDays(new Date(2026, 8, 15), 1);
+ assert.equal(mon[0].getDay(), 1);
+ assert.deepEqual([mon[0].getMonth(), mon[0].getDate()], [7, 31]);
+ // A Sunday belongs to the week before it when weeks start on Monday.
+ assert.equal(startOfWeek(new Date(2026, 9, 25), 1).getDate(), 19);
+ assert.equal(startOfWeek(new Date(2026, 9, 25), 0).getDate(), 25);
+ assert.equal(weekInfoOf("en-GB").firstDay, 1);
+ assert.equal(weekInfoOf("en-US").firstDay, 0);
+ assert.deepEqual(weekInfoOf("de-DE").weekend.sort(), [0, 6]);
+ assert.match(clock(at(2026, 8, 29, 15), false), /:00/);
+ assert.notEqual(hourLabel(12, false), "Noon");
+ assert.equal(hourLabel(12, true), "Noon");
+});
diff --git a/.uiverify/contacts-keys.mjs b/.uiverify/contacts-keys.mjs
new file mode 100644
index 0000000..1d50d94
--- /dev/null
+++ b/.uiverify/contacts-keys.mjs
@@ -0,0 +1,123 @@
+// Contacts on the Mac by keyboard and by eye: ⌘N (Ctrl here) a new card and Escape out of it,
+// the arrows walk the list, Return edits, Delete deletes, ⌘F the search and Return there the
+// first match; a label click copies its value; a link is a link; and a long list gets the
+// letter index down its edge and stays quick to walk.
+import { engine, engineName } from "./engine.mjs";
+import { SERVICES, autoConfirm, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });
+const page = await ctx.newPage();
+await ctx.addInitScript(autoConfirm);
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(page, "Contacts");
+await page.waitForTimeout(400);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const current = () => page.locator('.contact-row[aria-current="true"] .contact-row-name').allInnerTexts();
+
+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).click();
+await page.keyboard.press("ArrowDown");
+ok(JSON.stringify(await current()) === JSON.stringify(["Amma"]), `Down selects the next person ${JSON.stringify(await current())}`);
+ok((await page.locator(".contact-detail h2").innerText()) === "Amma", "and the card follows");
+await page.keyboard.press("ArrowUp");
+ok(JSON.stringify(await current()) === JSON.stringify(["Zoya Ahuja"]), "Up goes back");
+await page.keyboard.press("Shift+ArrowDown");
+await page.keyboard.press("Shift+ArrowDown");
+ok((await page.locator(".contact-many h2").innerText().catch(() => "")) === "3 Contacts Selected", "Shift and the arrows widen the selection");
+await page.keyboard.press("ArrowDown");
+ok((await current()).length === 1, "a plain arrow narrows it to one again");
+
+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).click();
+await page.keyboard.press("Enter");
+ok(await page.locator(".contact-form h2", { hasText: "Edit contact" }).isVisible(), "Return edits the card");
+await page.keyboard.press("Escape");
+ok(!(await page.locator(".contact-form").count()), "Escape leaves it unsaved");
+
+await page.keyboard.press("Control+n");
+ok(await page.locator(".contact-form h2", { hasText: "New contact" }).isVisible(), "Ctrl-N starts a new card");
+ok(await page.evaluate(() => document.activeElement?.closest(".contact-names") !== null), "with the first name ready to type");
+await page.keyboard.press("Escape");
+ok(!(await page.locator(".contact-form").count()), "and Escape puts it away");
+
+await page.locator(".contact-row", { hasText: "Amma" }).click();
+await page.keyboard.press("Delete");
+await page.waitForTimeout(200);
+const asked = await page.evaluate(() => window.__asked ?? []);
+ok(asked.some((m) => m.startsWith("Delete Amma")), `Delete asks first ${JSON.stringify(asked)}`);
+ok((await page.evaluate(() => window.__contactDeletes ?? [])).some((a) => a.guid === "c2"), "then deletes that card");
+
+await page.keyboard.press("Control+f");
+ok(await page.evaluate(() => document.activeElement?.closest(".contacts-search") !== null), "Ctrl-F goes to the search");
+await page.keyboard.type("a");
+await page.waitForTimeout(250);
+await page.keyboard.press("Enter");
+await page.waitForTimeout(100);
+// (The stub answers every search with everyone; the first row shown is the first match.)
+const first = await page.locator(".contact-row-name").first().innerText();
+ok((await page.locator(".contact-detail h2").innerText()) === first, `Return in the search opens the first match ${first}`);
+ok(await page.evaluate(() => document.activeElement?.classList.contains("contact-row")), "and the list has the keys from there");
+await page.locator(".contacts-search").fill("");
+await page.locator(".contact-row", { hasText: "Northfield" }).click();
+const link = await page.locator(".contact-methods a", { hasText: "northfield.example" }).getAttribute("href").catch(() => null);
+ok(link === "https://northfield.example", `a link without its scheme opens on the web ${link}`);
+const tel = await page.locator(".contact-methods a", { hasText: "+91 891" }).getAttribute("href");
+ok(tel === "tel:+15555550100", `a number dials without its spaces ${tel}`);
+
+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).click();
+await ctx.grantPermissions(["clipboard-read", "clipboard-write"]).catch(() => {});
+await page.getByRole("button", { name: "Copy mobile" }).click();
+await page.waitForTimeout(120);
+ok(await page.locator(".contact-copy span:not(.is-hidden)", { hasText: "copied" }).isVisible(), "a click on a label says it copied");
+if (engineName === "chromium") {
+ const clip = await page.evaluate(() => navigator.clipboard.readText()).catch(() => null);
+ ok(clip === "+91 90000 00001", `and the value is on the clipboard ${clip}`);
+}
+await page.waitForTimeout(1400);
+ok(!(await page.locator(".contact-copy span:not(.is-hidden)", { hasText: "copied" }).count()), "then the label comes back");
+ok(!(await page.locator(".contact-index").count()), "a short list has no index");
+await ctx.close();
+
+// A long address book: the index, and the arrows still quick.
+const big = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await big.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });
+await big.addInitScript(() => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__many) return;
+ const inner = t.invoke;
+ const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ const people = Array.from({ length: 3000 }, (_, i) => ({
+ guid: `m${i}`, firstName: `Person${i}`, lastName: `${letters[i % 26]}name${i}`, company: null, isCompany: false,
+ birthday: null, notes: null, etag: null, methods: [],
+ }));
+ t.invoke = async (cmd, args) => {
+ const out = await inner(cmd, args);
+ if (cmd === "contacts_list" && Array.isArray(out) && !args?.query) return [...out, ...people];
+ return out;
+ };
+ t.__many = true;
+ };
+ wrap(); document.addEventListener("DOMContentLoaded", wrap);
+});
+const p2 = await big.newPage();
+await p2.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(p2, "Contacts");
+await p2.waitForTimeout(800);
+ok((await p2.locator(".contact-index button").count()) >= 26, "a long list has the letters down its edge");
+await p2.locator(".contact-index button", { hasText: "M" }).click();
+await p2.waitForTimeout(100);
+const top = await p2.evaluate(() => {
+ const list = document.querySelector(".contact-rows");
+ const head = document.querySelector('.contact-letter[data-letter="M"]');
+ return Math.abs(head.offsetTop - list.scrollTop);
+});
+ok(top < 2, `a letter goes straight to its names ${top}`);
+await p2.locator(".contact-row").first().click();
+const t0 = await p2.evaluate(() => performance.now());
+for (let i = 0; i < 10; i++) await p2.keyboard.press("ArrowDown");
+await p2.waitForFunction(() => document.querySelectorAll('.contact-row[aria-current="true"]').length === 1);
+const per = ((await p2.evaluate(() => performance.now())) - t0) / 10;
+ok(per < 100, `walking 3000 people stays quick ${per.toFixed(1)} ms a step`);
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/contacts-labels.mjs b/.uiverify/contacts-labels.mjs
index 303b78b..ab4853e 100644
--- a/.uiverify/contacts-labels.mjs
+++ b/.uiverify/contacts-labels.mjs
@@ -23,14 +23,14 @@ ok(/mobile/.test(await first.innerText()) && (await page.getByLabel("Custom labe
"an existing \"mobile\" shows as Apple's own, not as a custom label");
await first.click();
const offered = await page.getByRole("option").allInnerTexts();
-ok(["mobile", "iPhone", "Apple Watch", "work", "custom…"].every((x) => offered.some((o) => o.replace("✓", "").trim() === x)), `Apple's phone labels are offered ${JSON.stringify(offered)}`);
+ok(["mobile", "iPhone", "Apple Watch", "work", "Custom"].every((x) => offered.some((o) => o.replace("✓", "").trim() === x)), `Apple's phone labels are offered ${JSON.stringify(offered)}`);
await page.getByRole("option", { name: "work", exact: true }).click();
const second = page.getByLabel("Label for detail 2");
await second.click();
-await page.getByRole("option", { name: "custom…" }).click();
+await page.getByRole("option", { name: "Custom" }).click();
const typed = page.getByLabel("Custom label for detail 2");
-ok((await typed.count()) === 1, "custom… opens a field to type a label in");
+ok((await typed.count()) === 1, "Custom opens a field to type a label in");
await typed.fill("gym");
await page.getByRole("button", { name: "Save" }).click();
diff --git a/.uiverify/contacts-lists.mjs b/.uiverify/contacts-lists.mjs
index a884cfb..444f618 100644
--- a/.uiverify/contacts-lists.mjs
+++ b/.uiverify/contacts-lists.mjs
@@ -3,12 +3,12 @@
// menu or by dragging, someone taken out, a list deleted — shows the moment it is made,
// though Apple takes most of a second to answer. A change Apple refuses goes back.
import { engine } from "./engine.mjs";
-import { SERVICES, installStub, openScreen } from "./stub.mjs";
+import { SERVICES, autoConfirm, installStub, openScreen } from "./stub.mjs";
const b = await engine.launch();
const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });
const page = await ctx.newPage();
-page.on("dialog", (d) => d.accept());
+await ctx.addInitScript(autoConfirm);
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Contacts");
await page.waitForTimeout(400);
@@ -85,13 +85,13 @@ await page.waitForTimeout(quick);
const drawn = await count("Office");
await page.waitForTimeout(1100);
check(drawn === 1 && (await count("Office")) === 0, "a refused add shows, then goes back");
-check(await page.locator(".notice").first().isVisible().catch(() => false), "and says why");
+check(await page.locator(".toast.is-error").first().isVisible().catch(() => false), "and says why");
await page.evaluate(() => { window.__listFail = false; });
// Deleted.
await row("Office").hover();
await row("Office").getByRole("button", { name: "Actions for Office" }).click();
-await page.getByRole("menuitem", { name: "Delete List…" }).click();
+await page.getByRole("menuitem", { name: "Delete List" }).click();
await page.waitForTimeout(quick);
check((await row("Office").count()) === 0, "a deleted list leaves the column at once");
await page.waitForTimeout(900);
diff --git a/.uiverify/contacts-select.mjs b/.uiverify/contacts-select.mjs
index 94b5805..d07140e 100644
--- a/.uiverify/contacts-select.mjs
+++ b/.uiverify/contacts-select.mjs
@@ -1,12 +1,12 @@
// Several contacts at once, as Contacts on the Mac: Ctrl-click adds one, Shift-click a run,
// Ctrl-A everyone; the card shows how many, and what is done is done to them all.
import { engine } from "./engine.mjs";
-import { SERVICES, installStub, openScreen } from "./stub.mjs";
+import { SERVICES, autoConfirm, installStub, openScreen } from "./stub.mjs";
const b = await engine.launch();
const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });
const page = await ctx.newPage();
-page.on("dialog", (d) => d.accept());
+await ctx.addInitScript(autoConfirm);
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Contacts");
await page.waitForTimeout(400);
diff --git a/.uiverify/contacts-vcard.mjs b/.uiverify/contacts-vcard.mjs
index afe5f1d..29f3afb 100644
--- a/.uiverify/contacts-vcard.mjs
+++ b/.uiverify/contacts-vcard.mjs
@@ -21,14 +21,14 @@ await page.waitForTimeout(150);
ok(JSON.stringify(await meRow()) === JSON.stringify(["Amma"]), "Make This My Card moves it at once");
await page.locator(".contact-row", { hasText: "Amma" }).click({ button: "right" });
-await page.getByRole("menuitem", { name: "Export vCard…" }).click();
+await page.getByRole("menuitem", { name: "Export vCard" }).click();
await page.waitForTimeout(200);
let sent = await page.evaluate(() => window.__exports?.at(-1));
ok(sent?.fileName === "Amma.vcf" && sent.guids.join() === "c2", `one card goes out under its name ${JSON.stringify(sent)}`);
-ok(/Saved to .*Amma\.vcf/.test(await page.locator(".drive-saved").innerText()), "and says where it went");
+ok(/Saved to Downloads/.test(await page.locator(".toast").last().innerText()) && (await page.locator(".toast").last().getByRole("button", { name: "Show in Folder" }).count()) === 1, "and says where it went, with a way to see it");
await page.getByRole("button", { name: "More" }).click();
-await page.getByRole("menuitem", { name: "Export All Contacts…" }).click();
+await page.getByRole("menuitem", { name: "Export All Contacts" }).click();
await page.waitForTimeout(200);
sent = await page.evaluate(() => window.__exports?.at(-1));
ok(sent?.fileName === "iCloud vCards.vcf" && sent.guids.length === 4, `everyone goes out as iCloud vCards ${JSON.stringify(sent?.fileName)}`);
@@ -36,17 +36,17 @@ ok(sent?.fileName === "iCloud vCards.vcf" && sent.guids.length === 4, `everyone
// Mass import: several files at once, a Google Contacts CSV among them.
await page.evaluate(() => { window.__pick = ["/home/test/people.vcf", "/home/test/google.csv"]; });
await page.getByRole("button", { name: "More" }).click();
-await page.getByRole("menuitem", { name: "Import Contacts…" }).click();
+await page.getByRole("menuitem", { name: "Import Contacts" }).click();
await page.waitForTimeout(300);
const paths = await page.evaluate(() => window.__imports?.at(-1)?.paths);
ok(JSON.stringify(paths) === JSON.stringify(["/home/test/people.vcf", "/home/test/google.csv"]), `every chosen file, vCard and CSV, is imported at once ${JSON.stringify(paths)}`);
-ok(/2 contacts imported/.test(await page.locator(".drive-saved").innerText()), "and the count is said");
+ok(/2 contacts imported/.test(await page.locator(".toast").last().innerText()), "and the count is said");
// Importing an export of the same book: everyone already there is left out, and said so.
await page.evaluate(() => { window.__importAnswer = [0, 0, 123]; });
await page.getByRole("button", { name: "More" }).click();
-await page.getByRole("menuitem", { name: "Import Contacts…" }).click();
+await page.getByRole("menuitem", { name: "Import Contacts" }).click();
await page.waitForTimeout(300);
-const said = await page.locator(".drive-saved").innerText();
+const said = await page.locator(".toast").last().innerText();
ok(/0 contacts imported, 123 contacts already in Contacts were left out/.test(said), `people already in Contacts are left out, and that is said "${said}"`);
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/crash.mjs b/.uiverify/crash.mjs
index c657ed7..ad1dd88 100644
--- a/.uiverify/crash.mjs
+++ b/.uiverify/crash.mjs
@@ -4,6 +4,8 @@ import { engine as chromium } from "./engine.mjs";
const b = await chromium.launch();
const ctx = await b.newContext({ viewport: { width: 1100, height: 800 } });
await ctx.addInitScript(() => {
+ // What the real event plugin provides beside the bridge: unlistening needs it.
+ window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
window.__TAURI_INTERNALS__ = {
transformCallback: (c) => c,
invoke: async (cmd) => {
diff --git a/.uiverify/drive-gone.mjs b/.uiverify/drive-gone.mjs
index 213016b..0f4265d 100644
--- a/.uiverify/drive-gone.mjs
+++ b/.uiverify/drive-gone.mjs
@@ -17,7 +17,7 @@ await page.evaluate(() => { window.__driveGone = "FOLDER::a"; });
await page.locator(".drive-row-hit", { hasText: "Downloads" }).dblclick();
await page.waitForTimeout(600);
ok(!(await crumbs()).some((t) => t.includes("Downloads")), `stepped back out of the gone folder ${JSON.stringify(await crumbs())}`);
-ok((await page.locator(".notice", { hasText: "deleted or moved on another device" }).count()) === 1, "and says why");
+ok((await page.locator(".toast.is-error", { hasText: "deleted or moved on another device" }).count()) === 1, "and says why");
ok((await page.locator(".drive-row-hit", { hasText: "Semester Plan" }).count()) === 1, "showing the folder above");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/drive-info.mjs b/.uiverify/drive-info.mjs
index 6cd771a..c9f59ea 100644
--- a/.uiverify/drive-info.mjs
+++ b/.uiverify/drive-info.mjs
@@ -23,13 +23,13 @@ ok((await page.locator(".info-sheet").count()) === 0, "Escape closes it");
await page.locator(".drive-row", { hasText: "Downloads" }).click({ button: "right" });
await page.waitForTimeout(150);
const offered = await page.getByRole("menuitem").allInnerTexts();
-ok(JSON.stringify(offered) === JSON.stringify(["Open", "Get Info", "Rename", "Move to Folder…", "Delete"]),
+ok(JSON.stringify(offered) === JSON.stringify(["Open", "Get Info", "Rename", "Move to Folder", "Delete"]),
`a right-click on a folder offers its menu ${JSON.stringify(offered)}`);
await page.keyboard.press("Escape");
await page.locator(".drive-row", { hasText: "Semester Plan" }).click({ button: "right" });
await page.waitForTimeout(150);
const forFile = await page.getByRole("menuitem").allInnerTexts();
-ok(JSON.stringify(forFile) === JSON.stringify(["Download a Copy", "Get Info", "Duplicate", "Rename", "Move to Folder…", "Delete"]),
+ok(JSON.stringify(forFile) === JSON.stringify(["Download a Copy", "Get Info", "Duplicate", "Rename", "Move to Folder", "Delete"]),
`a file's menu adds Duplicate ${JSON.stringify(forFile)}`);
await page.getByRole("menuitem", { name: "Duplicate" }).click();
await page.waitForTimeout(200);
diff --git a/.uiverify/drive-names.mjs b/.uiverify/drive-names.mjs
index 3f12345..49c45d1 100644
--- a/.uiverify/drive-names.mjs
+++ b/.uiverify/drive-names.mjs
@@ -12,7 +12,7 @@ await page.locator(".nav-item", { hasText: "Drive" }).click();
await page.waitForTimeout(500);
let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
-const notice = () => page.locator(".notice").allInnerTexts();
+const notice = () => page.locator(".toast.is-error").allInnerTexts();
const sent = () => page.evaluate(() => (window.__driveNames ?? []).length);
await page.getByRole("button", { name: "New Folder" }).click();
diff --git a/.uiverify/drive-recents.mjs b/.uiverify/drive-recents.mjs
index c11e528..e71e899 100644
--- a/.uiverify/drive-recents.mjs
+++ b/.uiverify/drive-recents.mjs
@@ -32,7 +32,7 @@ await page.locator("button.drive-row-hit", { hasText: "Invoice" }).dblclick();
await page.waitForTimeout(200);
const sent = await page.evaluate(() => window.__downloads?.at(-1));
ok(sent?.drivewsid === "FILE::r1" && sent?.item?.name === "Invoice-0001", "a double-click saves it, with the file's details sent along");
-ok(/Saved to/.test(await page.locator(".drive-saved").innerText()), "and says where");
+ok(/Saved to Downloads/.test(await page.locator(".toast").innerText()) && (await page.locator(".toast").getByRole("button", { name: "Show in Folder" }).count()) === 1, "and says where, with a way to see it");
await page.locator(".crumb", { hasText: "iCloud Drive" }).click();
ok((await page.locator(".drive-group").count()) === 0, "the breadcrumb goes back to iCloud Drive");
await b.close();
diff --git a/.uiverify/drive-select.mjs b/.uiverify/drive-select.mjs
new file mode 100644
index 0000000..aee1a17
--- /dev/null
+++ b/.uiverify/drive-select.mjs
@@ -0,0 +1,135 @@
+// Finder's selection and keys in Drive: Ctrl-click adds one, Shift-click a run, Ctrl-A all,
+// a click on nothing selects nothing; the menu and Delete act on all of the selection; F2
+// renames with the name (not its extension) selected; Space shows Quick Look; a heading
+// clicked twice turns the order round.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });
+await ctx.addInitScript(() => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__sel) return;
+ const inner = t.invoke;
+ t.invoke = async (cmd, args) => {
+ if (cmd === "drive_delete") (window.__driveDeletes ??= []).push(args.drivewsid);
+ return inner(cmd, args);
+ };
+ t.__sel = true;
+ };
+ wrap(); document.addEventListener("DOMContentLoaded", wrap);
+});
+const page = await ctx.newPage();
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(page, "iCloud Drive");
+await page.waitForTimeout(400);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const chosen = () => page.locator('.drive-row-hit[aria-pressed="true"] .drive-name').allInnerTexts();
+const row = (name) => page.locator(".drive-row-hit", { hasText: name });
+
+await row("Downloads").click();
+await row("Semester Plan").click({ modifiers: ["Control"] });
+ok(JSON.stringify(await chosen()) === JSON.stringify(["Downloads", "Semester Plan.pdf"]), `Ctrl-click adds one ${JSON.stringify(await chosen())}`);
+await row("Downloads").click({ modifiers: ["Control"] });
+ok(JSON.stringify(await chosen()) === JSON.stringify(["Semester Plan.pdf"]), "and takes one away");
+await row("Keynote").click();
+await row("Semester Plan").click({ modifiers: ["Shift"] });
+ok((await chosen()).length === 3, `Shift-click takes the run ${JSON.stringify(await chosen())}`);
+await page.keyboard.press("Control+a");
+ok((await chosen()).length === 4, "Ctrl-A takes everything");
+await page.mouse.click(700, 700);
+ok((await chosen()).length === 0, "a click on nothing selects nothing");
+
+// The menu on a selection is for all of it.
+await row("Downloads").click();
+await row("Semester Plan").click({ modifiers: ["Control"] });
+await row("Semester Plan").click({ button: "right" });
+const offered = await page.getByRole("menuitem").allInnerTexts();
+ok(offered.some((t) => t.includes("Delete 2 Items")) && offered.some((t) => t.includes("Move to Folder")), `the menu names how many ${JSON.stringify(offered)}`);
+await page.keyboard.press("Escape");
+await page.waitForTimeout(100);
+await row("Downloads").click();
+await row("Semester Plan").click({ modifiers: ["Control"] });
+await page.keyboard.press("Delete");
+await page.waitForTimeout(300);
+const deleted = await page.evaluate(() => window.__driveDeletes ?? []);
+ok(deleted.length === 2 && deleted.includes("FOLDER::a") && deleted.includes("FILE::d"), `Delete sends all of the selection ${JSON.stringify(deleted)}`);
+await page.reload({ waitUntil: "networkidle" });
+await openScreen(page, "iCloud Drive");
+await page.waitForTimeout(400);
+
+// F2: rename in place, the name without its extension selected.
+await row("Semester Plan").click();
+await page.keyboard.press("F2");
+const field = page.locator(".drive-rename-input");
+ok(await field.isVisible(), "F2 renames in place");
+const range = await field.evaluate((f) => [f.selectionStart, f.selectionEnd, f.value]);
+ok(range[0] === 0 && range[1] === "Semester Plan".length, `with the name, not ".pdf", selected ${JSON.stringify(range)}`);
+await page.keyboard.press("Escape");
+ok(!(await field.count()), "Escape leaves the name as it was");
+
+// Space: Quick Look.
+await row("Semester Plan").click();
+await page.keyboard.press(" ");
+const peek = page.getByRole("dialog", { name: /Quick Look/ });
+ok(await peek.isVisible(), "Space shows Quick Look");
+ok((await peek.locator(".drive-peek-name").innerText()) === "Semester Plan.pdf", "of the selected file");
+ok(await peek.locator("img").count() === 1, "with Apple's picture of it");
+await page.keyboard.press("ArrowUp");
+await page.waitForTimeout(100);
+ok((await peek.locator(".drive-peek-name").innerText().catch(() => "")) === "Shortcuts", "the arrows walk on and the look follows");
+await page.keyboard.press(" ");
+ok(!(await peek.count()), "Space again closes it");
+await row("Semester Plan").click();
+await page.keyboard.press(" ");
+await page.keyboard.press("Escape");
+ok(!(await peek.count()), "so does Escape");
+
+// A heading clicked twice turns the order round.
+const names = async () => { await page.waitForTimeout(150); return page.locator(".drive-rows .drive-name").allTextContents(); };
+const before = await names();
+await page.locator(".drive-head").getByRole("button", { name: /^Name/ }).click();
+const after = await names();
+ok(JSON.stringify(after) === JSON.stringify(["Shortcuts", "Keynote", "Downloads", "Semester Plan.pdf"]), `Name clicked again: Z to A, folders still on top ${JSON.stringify(after)}`);
+ok((await page.locator(".drive-head .drive-col.is-on").innerText()).includes("⌃"), "and the heading says so");
+await page.locator(".drive-head").getByRole("button", { name: /^Name/ }).click();
+ok(JSON.stringify(await names()) === JSON.stringify(before), "a third click puts it back");
+await page.reload({ waitUntil: "networkidle" });
+await openScreen(page, "iCloud Drive");
+await page.waitForTimeout(300);
+ok(JSON.stringify(await names()) === JSON.stringify(before), "remembered the right way round");
+await ctx.close();
+
+// A folder of thousands: the arrows stay quick.
+const big = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await big.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });
+await big.addInitScript(() => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__many) return;
+ const inner = t.invoke;
+ const files = Array.from({ length: 4000 }, (_, i) => ({ drivewsid: `FILE::n${i}`, parentId: null, name: `Scan ${i}`,
+ extension: "pdf", kind: "FILE", size: 1000 + i, childCount: null, createdAt: 1700000000 + i, modifiedAt: 1700000000 + i, etag: null }));
+ t.invoke = async (cmd, args) => {
+ const out = await inner(cmd, args);
+ if (cmd === "drive_children" && Array.isArray(out)) return [...out, ...files];
+ return out;
+ };
+ t.__many = true;
+ };
+ wrap(); document.addEventListener("DOMContentLoaded", wrap);
+});
+const p2 = await big.newPage();
+await p2.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(p2, "iCloud Drive");
+await p2.waitForTimeout(800);
+await p2.locator("button.drive-row-hit").first().click();
+const t0 = await p2.evaluate(() => performance.now());
+for (let i = 0; i < 10; i++) await p2.keyboard.press("ArrowDown");
+const per = ((await p2.evaluate(() => performance.now())) - t0) / 10;
+ok((await p2.locator('.drive-row-hit[aria-pressed="true"]').count()) === 1, "the selection walked");
+ok(per < 100, `walking 4000 files stays quick ${per.toFixed(1)} ms a step`);
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/drive-trash.mjs b/.uiverify/drive-trash.mjs
index ae6093c..44eee6d 100644
--- a/.uiverify/drive-trash.mjs
+++ b/.uiverify/drive-trash.mjs
@@ -25,12 +25,12 @@ await page.locator("li", { hasText: "Old notes" }).getByRole("button", { name: "
await page.waitForTimeout(100);
ok(!(await names()).includes("Old notes.pdf"), "Recover takes it off the list at once");
-page.once("dialog", (d) => d.dismiss());
await page.locator("li", { hasText: "Wallpaper" }).getByRole("button", { name: "Delete Now" }).click();
+await page.locator(".confirm").getByRole("button", { name: "Cancel" }).click();
await page.waitForTimeout(200);
ok((await names()).includes("Wallpaper.jpg"), "declining Delete Now keeps it");
-page.once("dialog", (d) => d.accept());
await page.locator("li", { hasText: "Wallpaper" }).getByRole("button", { name: "Delete Now" }).click();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(200);
const calls = await page.evaluate(() => window.__trashCalls);
ok(JSON.stringify(calls) === JSON.stringify([["drive_put_back", "FILE::t1"], ["drive_delete_forever", "FILE::t2"]]),
diff --git a/.uiverify/drive-upload-cancel.mjs b/.uiverify/drive-upload-cancel.mjs
index 1f79d69..65881a8 100644
--- a/.uiverify/drive-upload-cancel.mjs
+++ b/.uiverify/drive-upload-cancel.mjs
@@ -73,7 +73,7 @@ let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
await page.getByRole("button", { name: "Upload", exact: true }).click();
-await page.getByRole("menuitem", { name: "Folder…" }).click();
+await page.getByRole("menuitem", { name: "Folder" }).click();
await page.waitForTimeout(700);
const early = await page.evaluate(() => window.__early);
ok(/Holiday/.test(early) && /Preparing/.test(early), `a folder upload says what it is doing from the start [${early.replace(/\s+/g, " ")}]`);
diff --git a/.uiverify/drive-upload.mjs b/.uiverify/drive-upload.mjs
index 32c09b1..f74fc19 100644
--- a/.uiverify/drive-upload.mjs
+++ b/.uiverify/drive-upload.mjs
@@ -66,11 +66,11 @@ const ok = (pass, yes, no) => {
await page.getByRole("button", { name: "Upload", exact: true }).click();
const items = await page.getByRole("menuitem").allInnerTexts();
ok(
- JSON.stringify(items) === JSON.stringify(["Files…", "Folder…"]),
+ JSON.stringify(items) === JSON.stringify(["Files", "Folder"]),
"Upload offers files or a whole folder",
`Upload offered ${JSON.stringify(items)}`
);
-await page.getByRole("menuitem", { name: "Files…" }).click();
+await page.getByRole("menuitem", { name: "Files" }).click();
await page.waitForTimeout(1200);
const midway = await page.evaluate(() => window.__midway);
@@ -96,7 +96,7 @@ const usable = await page.getByRole("button", { name: "Upload", exact: true }).i
ok(usable, "the window stays usable, and another upload can start", "Upload was left disabled");
await page.getByRole("button", { name: "Upload", exact: true }).click();
-await page.getByRole("menuitem", { name: "Folder…" }).click();
+await page.getByRole("menuitem", { name: "Folder" }).click();
await page.waitForTimeout(1000);
const calls = await page.evaluate(() => window.__uploadCalls.map((c) => c.paths));
ok(JSON.stringify(calls[1]) === JSON.stringify(["/home/me/Holiday"]),
diff --git a/.uiverify/drive-widths.mjs b/.uiverify/drive-widths.mjs
index 2904080..aca87fa 100644
--- a/.uiverify/drive-widths.mjs
+++ b/.uiverify/drive-widths.mjs
@@ -18,7 +18,7 @@ for (const [w, h] of [[1920, 1040], [960, 1040], [700, 900], [480, 800]]) {
await openScreen(page, "iCloud Drive").catch(() => openScreen(page, "Drive"));
await page.waitForTimeout(150);
const box = () => page.evaluate(() => {
- const bar = document.querySelector(".drive > .cal-bar"), up = [...bar.querySelectorAll("button")].find((x) => /Upload/.test(x.textContent));
+ const bar = document.querySelector(".drive > .drive-bar"), up = [...bar.querySelectorAll("button")].find((x) => /Upload/.test(x.textContent));
const r = bar.getBoundingClientRect(), u = up.getBoundingClientRect();
return { h: Math.round(r.height), upTop: Math.round(u.top), upRight: Math.round(u.right), right: Math.round(r.right),
scroll: document.querySelector("main.content").scrollWidth - document.querySelector("main.content").clientWidth,
@@ -32,7 +32,7 @@ for (const [w, h] of [[1920, 1040], [960, 1040], [700, 900], [480, 800]]) {
`${w}px: the bar does not move when the count arrives (${before.h}→${after.h}px high, Upload at ${before.upTop}→${after.upTop}; "${after.count}")`);
ok(after.upRight <= after.right + 1 && after.scroll <= 0, `${w}px: nothing runs off the edge`);
if (w === 960) {
- const recents = page.locator(".drive > .cal-bar button[title='Recents']");
+ const recents = page.locator(".drive > .drive-bar button[title='Recents']");
ok((await recents.evaluate((e) => getComputedStyle(e).fontSize)) === "0px" && (await recents.getAttribute("title")) === "Recents",
"960px: the controls are icons, each still named");
}
diff --git a/.uiverify/engine.mjs b/.uiverify/engine.mjs
index f316a00..a8c993d 100644
--- a/.uiverify/engine.mjs
+++ b/.uiverify/engine.mjs
@@ -4,12 +4,14 @@
// ENGINE=webkit node .uiverify/calendar.mjs WebKit's WPE port, off-screen
// ENGINE=gtk node .uiverify/calendar.mjs WebKit's GTK port — Quince's own — in a real
// window on this display
+// ENGINE=msedge node .uiverify/calendar.mjs Microsoft Edge — the engine WebView2 is, with
+// Windows' own fonts — on a Windows machine
//
// Playwright's WebKit build wants a few libraries this machine's distribution names
// differently; .uiverify/webkit-libs.sh fetches them into a private folder, no root needed.
import { chromium, webkit } from "playwright";
-export const engineName = ["webkit", "gtk"].includes(process.env.ENGINE) ? process.env.ENGINE : "chromium";
+export const engineName = ["webkit", "gtk", "msedge"].includes(process.env.ENGINE) ? process.env.ENGINE : "chromium";
const base = engineName === "chromium" ? chromium : webkit;
/**
* In the GTK port the window is a real one on this desktop, and a tiling window manager sizes
@@ -19,7 +21,11 @@ const base = engineName === "chromium" ? chromium : webkit;
*/
export const engine = {
launch: async (options = {}) => {
- const browser = await base.launch({ ...options, ...(engineName === "gtk" ? { headless: false } : {}) });
+ const browser = await base.launch({
+ ...options,
+ ...(engineName === "gtk" ? { headless: false } : {}),
+ ...(engineName === "msedge" ? { channel: "msedge" } : {}),
+ });
if (engineName !== "gtk") return browser;
const newContext = browser.newContext.bind(browser);
browser.newContext = async (opts = {}) => {
diff --git a/.uiverify/footer-refresh.mjs b/.uiverify/footer-refresh.mjs
new file mode 100644
index 0000000..95ec3d7
--- /dev/null
+++ b/.uiverify/footer-refresh.mjs
@@ -0,0 +1,84 @@
+// The footer speaks for the app in front: its own freshness, and a small control that updates
+// that app alone — spinning while it works. Ctrl+R and F5 do the same and never reload the
+// window. The window's title follows the screen. In Settings the footer is the whole account.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1180, height: 820 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });
+// sync_some answers after a beat, so "working" can be seen; set_title is recorded.
+await ctx.addInitScript(() => {
+ const inner = window.__TAURI_INTERNALS__.invoke;
+ window.__some = [];
+ window.__titles = [];
+ // As Tauri describes the window a page is in, so getCurrentWindow() resolves.
+ window.__TAURI_INTERNALS__.metadata = { currentWindow: { label: "app-notes" }, currentWebview: { windowLabel: "app-notes", label: "app-notes" } };
+ window.__TAURI_INTERNALS__.invoke = async (cmd, args) => {
+ if (cmd === "plugin:window|set_title") { window.__titles.push(args.value); return null; }
+ if (cmd === "sync_some") {
+ window.__some.push(args.services);
+ await new Promise((r) => setTimeout(r, window.__someDelay ?? 600));
+ if (window.__someFail) throw window.__someFail;
+ const now = Math.floor(Date.now() / 1000);
+ return { services: args.services.map((s) => ({ service: s, label: s, outcome: "ok", detail: null, lastSyncedAt: now })), asOf: now, tookMs: 5 };
+ }
+ return inner(cmd, args);
+ };
+});
+const page = await ctx.newPage();
+let reloaded = 0;
+page.on("framenavigated", (f) => { if (f === page.mainFrame()) reloaded++; });
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await page.waitForTimeout(500);
+reloaded = 0;
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+
+await page.locator(".nav-item", { hasText: "Reminders" }).click();
+await page.waitForTimeout(150);
+// The freshness line is itself the control (no separate glyph): its tooltip says the whole
+// sentence, and "Click to update now" while it is not already updating.
+const status = page.locator(".sidebar-sync");
+const said = async () => ((await status.getAttribute("title")) ?? "").replace(/\. Click to update now$/, "");
+ok(/^Reminders updated/.test(await said()) && /^Updated/.test(await status.locator(".sidebar-sync-text").innerText()), `the footer speaks for Reminders [${await said()}]`);
+const fits = await status.locator(".sidebar-sync-text").evaluate((el) => el.scrollWidth <= el.clientWidth);
+ok(fits, "and its words fit, not cut off");
+ok((await page.evaluate(() => window.__titles.at(-1))) === "Reminders", "the window is titled Reminders");
+
+const btn = status;
+ok(await btn.isVisible() && /Update now$/.test((await btn.getAttribute("aria-label")) ?? ""), "the line itself is the control to update Reminders");
+await btn.click();
+await page.waitForTimeout(100);
+ok((await said()) === "Updating Reminders…", "pressing it says Reminders is updating");
+const anim = await page.evaluate(() => getComputedStyle(document.querySelector(".sidebar-sync.is-working .sync-dot")).animationName);
+ok(anim === "sync-spin", `and its dot turns in place [${anim}]`);
+ok(JSON.stringify(await page.evaluate(() => window.__some)) === '[["reminders"]]', "only Reminders is asked for");
+await page.waitForTimeout(700);
+ok((await said()) === "Reminders updated just now", `and settles [${await said()}]`);
+
+await page.locator(".nav-item", { hasText: "iCloud Drive" }).click();
+await page.waitForTimeout(150);
+ok((await page.evaluate(() => window.__titles.at(-1))) === "iCloud Drive", "the title follows to iCloud Drive");
+await page.keyboard.press("Control+r");
+await page.waitForTimeout(100);
+ok(JSON.stringify(await page.evaluate(() => window.__some.at(-1))) === '["drive"]', "Ctrl+R updates Drive's own service (drive, not drivews)");
+await page.waitForTimeout(700);
+await page.keyboard.press("F5");
+await page.waitForTimeout(100);
+ok((await page.evaluate(() => window.__some.length)) === 3, "F5 does the same");
+await page.waitForTimeout(700);
+ok(reloaded === 0, "neither key reloads the window");
+
+await page.evaluate(() => { window.__someFail = "Apple didn’t answer."; });
+await status.click();
+await page.waitForTimeout(800);
+ok((await said()) === "iCloud Drive didn’t update: Apple didn’t answer." && (await status.getAttribute("class")).includes("is-trouble"), `a failure says why [${await said()}]`);
+
+await page.locator(".sidebar-account").click();
+await page.waitForSelector(".settings");
+ok((await page.evaluate(() => window.__titles.at(-1))) === "Settings", "in Settings the window is titled Settings");
+ok(/^(Updated|Syncing|Some)/.test(await status.locator(".sidebar-sync-text").innerText()) && !/iCloud Drive|Reminders/.test(await said()), `and the footer is the whole account [${await said()}]`);
+
+await b.close();
+console.log(failures ? `${failures} FAILED` : "all passed");
+process.exit(failures ? 1 : 0);
diff --git a/.uiverify/intake.mjs b/.uiverify/intake.mjs
new file mode 100644
index 0000000..22c5e96
--- /dev/null
+++ b/.uiverify/intake.mjs
@@ -0,0 +1,220 @@
+// A calendar or contacts file opened with Pomander shows what it holds and adds it only on
+// confirm, through the same commands the apps use (event_save, contacts_import). The quick
+// capture window is one field: Enter makes the reminder or note and the window closes.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+
+// Against `npx vite preview --port 4173 --strictPort`; BASE points elsewhere when that port is taken.
+const BASE = process.env.BASE ?? "http://localhost:4173";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+
+// What intake.rs hands a window, shaped as it serializes it.
+const DAY = 86400;
+const base = Math.floor(Date.UTC(2026, 10, 5, 9, 0, 0) / 1000);
+const ARRIVALS = {
+ events: {
+ kind: "events", file: "family.ics",
+ events: [
+ { title: "Design review", location: "Studio", startsAt: base, endsAt: base + 5400, allDay: false,
+ timezone: "Europe/Berlin", notes: null, url: null, alerts: [15], repeat: null, duplicate: false },
+ { title: "Gym", location: null, startsAt: base + DAY, endsAt: base + DAY + 3600, allDay: false,
+ timezone: "Asia/Kolkata", notes: null, url: null, alerts: null,
+ repeat: { freq: "weekly", interval: 1, count: 10 }, duplicate: false },
+ { title: "Holiday in Goa", location: null, startsAt: base + 40 * DAY, endsAt: base + 43 * DAY, allDay: true,
+ timezone: "Asia/Kolkata", notes: null, url: null, alerts: null, repeat: null, duplicate: false },
+ { title: "Dentist", location: null, startsAt: base + 2 * DAY, endsAt: base + 2 * DAY + 1800, allDay: false,
+ timezone: "Asia/Kolkata", notes: null, url: null, alerts: null, repeat: null, duplicate: true },
+ ],
+ refused: [{ title: "Classes", reason: "It repeats on several days of the week, which Pomander can’t set up yet." }],
+ },
+ contacts: {
+ kind: "contacts", file: "people.vcf", path: "/home/test/Downloads/people.vcf",
+ contacts: [{ name: "Ravi Kumar", detail: "+91 98765 43210", known: false },
+ { name: "Zoya Ahuja", detail: "+91 90000 00001", known: true }],
+ },
+};
+
+// The intake commands, layered over the shared stub.
+const intakeStub = ({ arrivals }) => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__intake) return;
+ const inner = t.invoke;
+ window.__pending = arrivals.slice();
+ t.invoke = async (c, a) => {
+ (window.__calls ??= []).push([c, a]);
+ switch (c) {
+ case "intake_pending": { const out = window.__pending; window.__pending = []; return out; }
+ case "intake_capture_close": window.__closed = (window.__closed ?? 0) + 1; return null;
+ case "intake_open_main": return null;
+ case "window_ready": return null;
+ case "sync_some": return { services: [], asOf: null, tookMs: 1 };
+ case "reminder_create": (window.__creates ??= []).push(a); return null;
+ case "note_create": (window.__notes ??= []).push(a); return "NOTE-1";
+ case "event_save": (window.__eventSaves ??= []).push(a.draft); return "E-new";
+ }
+ return inner(c, a);
+ };
+ t.__intake = true;
+ };
+ wrap();
+ document.addEventListener("DOMContentLoaded", wrap);
+};
+
+async function page(url, arrivals, stub = {}) {
+ const ctx = await b.newContext({ viewport: { width: 1040, height: 700 } });
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, ...stub });
+ await ctx.addInitScript(intakeStub, { arrivals });
+ const p = await ctx.newPage();
+ p.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
+ await p.goto(url, { waitUntil: "networkidle" });
+ await p.waitForTimeout(500);
+ return { ctx, p };
+}
+
+// ── An .ics file: the events, the calendar picker, the refusals; Add writes each one. ──
+{
+ const { ctx, p } = await page(`${BASE}/?app=calendar`, [ARRIVALS.events], { calendarFixture: true });
+ const sheet = p.getByRole("dialog", { name: "Import “family.ics”" });
+ ok(await sheet.isVisible(), "an opened .ics shows the import sheet");
+ ok(await sheet.getByRole("heading", { name: "Add 3 events to" }).isVisible(), "headed with how many will be added (the duplicate left out)");
+ const picker = sheet.getByRole("button", { name: /Calendar/ });
+ const pickerText = await picker.innerText().catch(() => "");
+ ok(pickerText.length > 0, `with a calendar picker on the account's default (${pickerText.trim()})`);
+ const rows = sheet.locator(".ix-list li");
+ ok((await rows.count()) === 5, "every event is listed, refused ones too");
+ ok(await sheet.getByText("Every week, 10 times").isVisible(), "a repeat is spelled out");
+ ok(await sheet.getByText("Already in your calendar").isVisible(), "a duplicate is marked");
+ ok(await sheet.getByText(/Can’t be added\. It repeats on several days/).isVisible(), "a refusal says why");
+ ok(await sheet.getByText(/\(Europe\/Berlin\)/).isVisible(), "an event in another zone says its zone");
+ await p.screenshot({ path: ".uiverify/intake-events.png" });
+
+ // Choose another calendar, then add.
+ await picker.click();
+ const offered = (await p.getByRole("option").allInnerTexts()).map((t) => t.replace("✓", "").trim());
+ ok(!offered.some((t) => /Holidays|Birthdays/.test(t)) && offered.length > 1, `only calendars that take events are offered ${JSON.stringify(offered)}`);
+ const option = p.getByRole("option", { selected: false }).first();
+ const chosen = (await option.innerText()).replace("✓", "").trim();
+ await option.click();
+ await sheet.getByRole("button", { name: "Add 3 Events" }).click();
+ await p.waitForTimeout(400);
+ const saves = await p.evaluate(() => window.__eventSaves ?? []);
+ const cals = await p.evaluate(() => window.__cals ?? []);
+ const target = cals.find((c) => c.title === chosen)?.guid;
+ ok(saves.length === 3 && saves.every((s) => s.guid === null && s.calendarGuid === target),
+ `three new events saved through event_save into "${chosen}" ${JSON.stringify(saves.map((s) => s.calendarGuid))}`);
+ ok(saves[0].alerts?.[0] === 15 && saves[0].timezone === "Europe/Berlin" && !("repeat" in saves[0]), "alerts and zone carried, no repeat where none");
+ ok(saves[1].repeatChanged === true && saves[1].repeat?.count === 10, "the repeat is passed through");
+ ok(saves[2].allDay === true, "all-day stays all-day");
+ ok(!saves.some((s) => s.title === "Dentist"), "the duplicate is not added again");
+ ok(!(await sheet.isVisible()), "the sheet closes once added");
+ ok((await p.evaluate(() => (window.__calls ?? []).some(([c]) => c === "sync_some"))), "and the calendar is refreshed");
+ await ctx.close();
+}
+
+// ── Cancel sends nothing. ──
+{
+ const { ctx, p } = await page(`${BASE}/?app=calendar`, [ARRIVALS.events], { calendarFixture: true });
+ await p.getByRole("button", { name: "Cancel" }).click();
+ await p.waitForTimeout(200);
+ ok((await p.evaluate(() => (window.__eventSaves ?? []).length)) === 0 && !(await p.locator(".ix-sheet").count()), "Cancel closes the sheet and adds nothing");
+ await ctx.close();
+}
+
+// ── A .vcf file, arriving while the window is already open. ──
+{
+ const { ctx, p } = await page(`${BASE}/?app=contacts`, [], { contactsFixture: true });
+ ok((await p.locator(".ix-sheet").count()) === 0, "no sheet until a file arrives");
+ await p.evaluate((a) => { window.__pending = [a]; window.__emit("quince://intake", null); }, ARRIVALS.contacts);
+ await p.waitForTimeout(300);
+ const sheet = p.getByRole("dialog", { name: "Import “people.vcf”" });
+ ok(await sheet.getByRole("heading", { name: "Add contact Ravi Kumar" }).isVisible(), "a file forwarded to the open window: \"Add contact Ravi Kumar\"");
+ ok(await sheet.getByText("Already in Contacts").isVisible(), "someone already there is marked");
+ await p.screenshot({ path: ".uiverify/intake-contacts.png" });
+ await sheet.getByRole("button", { name: "Add Contact" }).click();
+ await p.waitForTimeout(300);
+ const imports = await p.evaluate(() => window.__imports ?? []);
+ ok(imports.length === 1 && imports[0].paths[0] === "/home/test/Downloads/people.vcf", "added through contacts_import with the file");
+ ok(!(await sheet.isVisible()), "and the sheet closes");
+ await ctx.close();
+}
+
+// ── A file that can't be read. ──
+{
+ const { ctx, p } = await page(`${BASE}/?app=calendar`,
+ [{ kind: "unreadable", file: "broken.ics", reason: "This isn’t a calendar file." }], { calendarFixture: true });
+ ok(await p.getByText("This isn’t a calendar file.").isVisible(), "an unreadable file says why");
+ await p.getByRole("button", { name: "OK" }).click();
+ ok((await p.locator(".ix-sheet").count()) === 0, "and OK puts it away");
+ await ctx.close();
+}
+
+// ── Quick capture: a reminder into the list last added to. ──
+{
+ const ctx = await b.newContext({ viewport: { width: 460, height: 132 } });
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true, notesFixture: true });
+ await ctx.addInitScript(intakeStub, { arrivals: [] });
+ await ctx.addInitScript(() => { try { localStorage.setItem("quince.reminders.defaultList", "l2"); } catch {} });
+ const p = await ctx.newPage();
+ p.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
+ await p.goto(`${BASE}/?capture=reminder`, { waitUntil: "networkidle" });
+ await p.waitForTimeout(300);
+ const field = p.getByRole("textbox", { name: "New Reminder" });
+ ok(await field.isVisible() && await field.evaluate((el) => el === document.activeElement), "the capture window opens on its one field, focused");
+ ok((await p.locator("nav.sidebar").count()) === 0, "and nothing of the library");
+ ok((await p.getByRole("button", { name: /List/ }).innerText()).includes("GYM"), "into the list last added to");
+ ok(await p.evaluate(() => (window.__calls ?? []).some(([c]) => c === "window_ready")), "shown once drawn (window_ready)");
+ await field.fill("Call the bank");
+ await p.screenshot({ path: ".uiverify/intake-capture.png" });
+ await field.press("Enter");
+ await p.waitForTimeout(300);
+ const made = await p.evaluate(() => window.__creates ?? []);
+ ok(made.length === 1 && made[0].listGuid === "l2" && made[0].title === "Call the bank", `saved with reminder_create ${JSON.stringify(made)}`);
+ ok((await p.evaluate(() => window.__closed)) === 1, "and the window closes");
+
+ // Asked for again as a note: the same window turns into a note.
+ await p.evaluate(() => window.__emit("quince://capture", "note"));
+ await p.waitForTimeout(300);
+ const note = p.getByRole("textbox", { name: "New Note" });
+ ok(await note.isVisible(), "asked for a note, the window becomes a note capture");
+ ok((await p.getByRole("button", { name: /Folder/ }).innerText()).includes("Notes"), "into Notes");
+ await note.fill("Ideas for the trip");
+ await note.press("Enter");
+ await p.waitForTimeout(300);
+ const notes = await p.evaluate(() => window.__notes ?? []);
+ ok(notes.length === 1 && notes[0].folderGuid === null && notes[0].body === "Ideas for the trip", `saved with note_create into the default folder ${JSON.stringify(notes)}`);
+ // Escape leaves without making anything. (Closed for real, the window is gone; here it is
+ // asked for again, which also gives a fresh field.)
+ await p.evaluate(() => window.__emit("quince://capture", "note"));
+ await p.waitForTimeout(200);
+ ok(await note.inputValue() === "" && await note.isEnabled(), "asked for again, the field is fresh");
+ await note.fill("never mind");
+ await note.press("Escape");
+ await p.waitForTimeout(150);
+ ok((await p.evaluate(() => window.__closed)) === 3 && (await p.evaluate(() => window.__notes.length)) === 1, "Escape closes without saving");
+ await ctx.close();
+}
+
+// ── Quick capture before Pomander is signed in. ──
+{
+ const ctx = await b.newContext({ viewport: { width: 460, height: 132 } });
+ await ctx.addInitScript(installStub, { screen: "signin", services: SERVICES, twoFactor: null, remindersFixture: true });
+ await ctx.addInitScript(intakeStub, { arrivals: [] });
+ const p = await ctx.newPage();
+ await p.goto(`${BASE}/?capture=reminder`, { waitUntil: "networkidle" });
+ await p.waitForTimeout(300);
+ const field = p.getByRole("textbox", { name: "New Reminder" });
+ await field.fill("Pay rent");
+ await field.press("Enter");
+ await p.waitForTimeout(300);
+ ok(await p.getByText("Sign in to Pomander first.").isVisible() && (await p.evaluate(() => (window.__creates ?? []).length)) === 0,
+ "signed out, it says so and writes nothing");
+ await p.getByRole("button", { name: "Open Pomander" }).click();
+ ok(await p.evaluate(() => (window.__calls ?? []).some(([c]) => c === "intake_open_main")), "and Open Pomander brings up the sign-in");
+ await ctx.close();
+}
+
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjs
index eef1ede..f0e4c7b 100644
--- a/.uiverify/keyboard.mjs
+++ b/.uiverify/keyboard.mjs
@@ -295,7 +295,7 @@ const focused = (page) =>
await page.waitForSelector(".drive-row-hit");
await page.hover(".drive-row.is-folder");
await page.click('.drive-row.is-folder .drive-action[aria-label^="Actions for"]');
- await page.getByRole("menuitem", { name: "Move to Folder…" }).click();
+ await page.getByRole("menuitem", { name: "Move to Folder" }).click();
await page.waitForSelector(".modal-sheet");
// The focus move is deliberately a tick after mount (it has to win a race against the
diff --git a/.uiverify/login-item.mjs b/.uiverify/login-item.mjs
index c769590..93094d9 100644
--- a/.uiverify/login-item.mjs
+++ b/.uiverify/login-item.mjs
@@ -12,7 +12,7 @@ for (const scheme of ["light", "dark"]) {
const page = await ctx.newPage();
page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
- await page.locator(".account-card, [aria-label*='Settings'], .sidebar-foot button").first().click();
+ await page.locator(".sidebar-account").click();
await page.waitForTimeout(400);
const sw = page.getByRole("switch", { name: "Open at Login" });
const row = page.locator(".settings-row", { has: sw });
@@ -37,7 +37,7 @@ for (const scheme of ["light", "dark"]) {
await page.evaluate(() => { window.__loginRefuse = "There is no configuration folder to keep it in."; });
await sw.click();
await page.waitForTimeout(200);
- ok((await sw.getAttribute("aria-checked")) === "true" && /no configuration folder/.test(await page.locator(".settings-error").innerText()), `${scheme}: refused, back as it was with the reason`);
+ ok((await sw.getAttribute("aria-checked")) === "true" && /no configuration folder/.test(await page.locator(".toast.is-error").innerText()), `${scheme}: refused, back as it was with the reason`);
await ctx.close();
}
await b.close();
diff --git a/.uiverify/look-all.mjs b/.uiverify/look-all.mjs
index 8e51910..9e71e5c 100644
--- a/.uiverify/look-all.mjs
+++ b/.uiverify/look-all.mjs
@@ -7,10 +7,11 @@ const ctx = await b.newContext({ viewport: { width: +w, height: +h }, colorSchem
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,
calendarFixture: true, notesFixture: true, contactsFixture: true, driveFixture: true, remindersFixture: true });
const p = await ctx.newPage();
-await p.goto("http://localhost:4173", { waitUntil: "networkidle" });
-for (const s of ["Reminders", "Notes", "iCloud Drive", "Calendar", "Contacts"]) {
- await openScreen(p, s);
+await p.goto(process.env.BASE ?? "http://localhost:4173", { waitUntil: "networkidle" });
+for (const s of ["Reminders", "Notes", "iCloud Drive", "Calendar", "Contacts", "Photos", "Settings"]) {
+ if (s === "Settings") await p.locator(".sidebar-account").click();
+ else await openScreen(p, s);
await p.waitForTimeout(500);
- await p.screenshot({ path: `${out}/all-${s.replace(/\W/g, "")}.png` });
+ await p.screenshot({ path: `${out}/all-${s.replace(/\W/g, "")}-${scheme}.png` });
}
await b.close();
diff --git a/.uiverify/menu-keys.mjs b/.uiverify/menu-keys.mjs
new file mode 100644
index 0000000..e65a1cb
--- /dev/null
+++ b/.uiverify/menu-keys.mjs
@@ -0,0 +1,85 @@
+// Menus take the keys a Mac menu takes: arrows, Home and End, type-select (letters go to the
+// line that begins with them; the same letter again steps on), Return chooses, Escape leaves.
+// The pointer leaving a menu takes its highlight with it. A pop-up's menu type-selects too.
+import { engine, engineName } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+const all = { notesFixture: true, calendarFixture: true, contactsFixture: true, driveFixture: true, remindersFixture: true };
+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, ...all });
+const page = await ctx.newPage();
+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName} ${m}`); if (!p) failures++; };
+const lit = () => page.locator(".row-menu .row-menu-item.is-active .row-menu-label").first().innerText().catch(() => null);
+
+await openScreen(page, "Contacts");
+await page.waitForTimeout(300);
+const row = page.locator(".contact-row").first();
+await row.click({ button: "right" });
+await page.waitForTimeout(80);
+const labels = await page.locator(".row-menu .row-menu-label").allInnerTexts();
+ok(labels.length >= 4, `the menu opens (${labels.join(" | ")})`);
+ok((await lit()) === null, "with nothing lit, as a Mac menu opens");
+
+await page.keyboard.press("e");
+const firstE = labels.find((l) => l.toLowerCase().startsWith("e"));
+ok((await lit()) === firstE, `a letter lights the first line beginning with it (${await lit()})`);
+await page.keyboard.press("e");
+const es = labels.filter((l) => l.toLowerCase().startsWith("e"));
+ok((await lit()) === (es[1] ?? es[0]), `the same letter again steps to the next (${await lit()})`);
+await page.waitForTimeout(1100);
+await page.keyboard.type("del");
+ok((await lit()) === labels.find((l) => l.toLowerCase().startsWith("del")), `typed in a run, letters spell a prefix (${await lit()})`);
+await page.keyboard.press("Home");
+ok((await lit()) === labels[0], "Home goes to the first line");
+await page.keyboard.press("End");
+ok((await lit()) === labels[labels.length - 1], "End to the last");
+await page.keyboard.press("ArrowDown");
+ok((await lit()) === labels[0], "Down from the last wraps to the first");
+await page.keyboard.press("q");
+ok((await page.locator(".row-menu").count()) === 1 && (await lit()) === labels[0], "a letter nothing begins with changes nothing");
+
+// The pointer: over a line lights it; off the menu, nothing is lit.
+const edit = page.getByRole("menuitem", { name: "Edit Contact" });
+await edit.hover();
+ok((await lit()) === "Edit Contact", "the pointer lights the line under it");
+const box = await page.locator(".row-menu").boundingBox();
+await page.mouse.move(box.x + box.width + 120, box.y + box.height / 2);
+ok((await lit()) === null, "leaving the menu takes the highlight with it");
+await page.keyboard.press("Escape");
+ok((await page.locator(".row-menu").count()) === 0, "Escape closes it");
+
+// Return chooses the lit line: Edit Contact opens the editor.
+await row.click({ button: "right" });
+await page.waitForTimeout(80);
+await page.keyboard.type("ed");
+await page.keyboard.press("Enter");
+await page.waitForTimeout(150);
+ok((await page.locator(".row-menu").count()) === 0, "Return chooses, and the menu goes");
+
+// A pop-up's menu: typing lights the option that begins with it, Return takes it.
+// In a narrow window, where Contacts shows its lists as a pop-up.
+await page.keyboard.press("Escape");
+await page.setViewportSize({ width: 760, height: 600 });
+await page.waitForTimeout(200);
+const pop = page.locator(".contacts .picker-button:visible").first();
+if ((await pop.count()) === 0) ok(false, "a pop-up button on Contacts to try");
+else {
+ await pop.click();
+ await page.waitForSelector(".picker-menu");
+ const opts = await page.locator(".picker-menu .picker-label").allInnerTexts();
+ const target = opts.find((o, i) => i > 0 && !opts.slice(0, i).some((p) => p[0].toLowerCase() === o[0].toLowerCase()));
+ if (!target) ok(true, `pop-up type-select skipped: no option with its own first letter (${opts.join(" | ")})`);
+ else {
+ await page.keyboard.press(target[0].toLowerCase());
+ const now = await page.locator(".picker-menu li.is-active .picker-label").innerText().catch(() => null);
+ ok(now === target, `a pop-up's menu type-selects (${now} for ${target})`);
+ await page.keyboard.press("Enter");
+ await page.waitForTimeout(100);
+ ok((await page.locator(".picker-menu").count()) === 0 && (await pop.innerText()).includes(target), "and Return takes it");
+ }
+}
+await b.close();
+process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/.uiverify/menus.mjs b/.uiverify/menus.mjs
index 697ab75..545f5b1 100644
--- a/.uiverify/menus.mjs
+++ b/.uiverify/menus.mjs
@@ -134,7 +134,7 @@ for (const size of [{ width: 1280, height: 800 }, { width: 760, height: 520 }])
const gone = await page.evaluate(() => { window.__stopAim = true; return window.__subGone; });
ok(!gone && (await page.locator(".row-menu").count()) === 2, `${label} a submenu stays open while the pointer crosses a line on its way in`);
// Resting on another line does still switch to it, a moment later.
- await page.getByRole("menuitem", { name: "Export vCard…" }).hover();
+ await page.getByRole("menuitem", { name: "Export vCard" }).hover();
await page.waitForTimeout(450);
ok((await page.locator(".row-menu").count()) === 1, `${label} resting on another line closes the submenu`);
await page.keyboard.press("Escape");
diff --git a/.uiverify/notes-compose.mjs b/.uiverify/notes-compose.mjs
index fd84522..a88f52d 100644
--- a/.uiverify/notes-compose.mjs
+++ b/.uiverify/notes-compose.mjs
@@ -64,7 +64,7 @@ await page.evaluate(() => {
window.__blank = 0;
window.__lostFocus = 0;
new MutationObserver(() => {
- if (document.querySelector(".note-body .cal-empty")?.textContent?.includes("Select a note")) {
+ if (document.querySelector(".note-body .note-pick")?.textContent?.includes("Select a note")) {
window.__blank++;
}
}).observe(document.body, { subtree: true, childList: true, characterData: true });
diff --git a/.uiverify/notes-folders.mjs b/.uiverify/notes-folders.mjs
index 246cd71..673f50a 100644
--- a/.uiverify/notes-folders.mjs
+++ b/.uiverify/notes-folders.mjs
@@ -26,9 +26,9 @@ await page.locator(".notes-folder-row", { hasText: "Recipes" }).click({ button:
await page.waitForTimeout(150);
const offered = await page.getByRole("menuitem").allInnerTexts();
ok(JSON.stringify(offered) === JSON.stringify(["Rename Folder", "New Folder", "Delete Folder"]), `a folder's menu ${JSON.stringify(offered)}`);
-let question = "";
-page.once("dialog", (d) => { question = d.message(); d.accept(); });
await page.getByRole("menuitem", { name: "Delete Folder" }).click();
+const question = await page.locator(".confirm").innerText();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(250);
ok(question.includes("All notes and any subfolders will be deleted."), "Delete Folder asks Apple's question");
ok(!(await names()).includes("Recipes"), "and the folder is gone");
diff --git a/.uiverify/notes-trash.mjs b/.uiverify/notes-trash.mjs
index d3f8e43..b36161f 100644
--- a/.uiverify/notes-trash.mjs
+++ b/.uiverify/notes-trash.mjs
@@ -40,14 +40,14 @@ const offered = await page.locator(".note-bar-actions button").allInnerTexts();
ok(offered.includes("Recover") && offered.includes("Delete Now"),
"a deleted note offers Recover and Delete Now", `it offered ${JSON.stringify(offered)}`);
-page.once("dialog", (d) => d.dismiss());
await page.getByRole("button", { name: "Delete Now" }).click();
+await page.locator(".confirm").getByRole("button", { name: "Cancel" }).click();
await page.waitForTimeout(300);
ok(await page.evaluate(() => window.__deletes === 0),
"Delete Now does nothing until it is confirmed", "Delete Now deleted without asking");
-page.once("dialog", (d) => d.accept());
await page.getByRole("button", { name: "Delete Now" }).click();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(300);
ok(await page.evaluate(() => window.__deletes === 1), "confirmed, it deletes", "confirmed, nothing happened");
diff --git a/.uiverify/outbox-pending.mjs b/.uiverify/outbox-pending.mjs
new file mode 100644
index 0000000..5538dfc
--- /dev/null
+++ b/.uiverify/outbox-pending.mjs
@@ -0,0 +1,36 @@
+// Edits kept on this computer and not yet at Apple say so ("Waiting to sync"), and one Apple
+// turned down is shown with what it held — copied out, sent again or let go, never dropped.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, notesFixture: true });
+await ctx.addInitScript(() => {
+ window.__outbox = {
+ waiting: [{ service: "notes", record: "n1", kind: "save" }],
+ refused: [{ id: 3, service: "notes", record: "n1", kind: "save", madeAt: 0,
+ reason: "This note was changed on another device while you were writing, in the same place.",
+ content: "Curtains\nmy offline line" }],
+ };
+});
+const page = await ctx.newPage();
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(page, "Notes");
+await page.locator(".note-row", { hasText: "Curtains" }).click();
+await page.waitForTimeout(400);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+ok((await page.locator(".note-when").innerText()).includes("Waiting to sync"), "a note kept here and not yet at Apple says so");
+const notice = page.locator(".unsent");
+ok(/changed on another device/.test(await notice.innerText()), "a refused edit says why");
+ok((await notice.innerText()).includes("my offline line"), "and shows what it held");
+await notice.getByRole("button", { name: "Try Again" }).click();
+await page.waitForTimeout(300);
+ok(JSON.stringify(await page.evaluate(() => window.__outboxCalls)) === JSON.stringify([["outbox_resend", 3]]), "Try Again sends it again");
+ok((await page.locator(".unsent").count()) === 0, "and it leaves the notice");
+// Sent: the backend says the queue moved, and the hint goes.
+await page.evaluate(() => { window.__outbox = { waiting: [], refused: [] }; window.__emit("quince://outbox-changed", null); });
+await page.waitForTimeout(300);
+ok(!(await page.locator(".note-when").innerText()).includes("Waiting to sync"), "once Apple has it, the hint goes");
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/photos-albums.mjs b/.uiverify/photos-albums.mjs
index 909f854..6a18e14 100644
--- a/.uiverify/photos-albums.mjs
+++ b/.uiverify/photos-albums.mjs
@@ -11,7 +11,7 @@ const page = await ctx.newPage();
page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
// Every question agreed to, as soon as it is asked.
await page.addInitScript(() => addEventListener("DOMContentLoaded", () =>
- new MutationObserver(() => document.querySelector(".px-ask .is-act")?.click()).observe(document.body, { childList: true, subtree: true })));
+ new MutationObserver(() => document.querySelector(".confirm .confirm-answer")?.click()).observe(document.body, { childList: true, subtree: true })));
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Photos");
await page.waitForTimeout(400);
@@ -102,7 +102,7 @@ await page.locator(".row-menu").getByText("New Album", { exact: true }).click();
await page.getByLabel("Album name").fill("Nope");
await page.keyboard.press("Enter");
await page.waitForTimeout(300);
-ok(!(await albumNames()).includes("Nope") && (await page.locator(".notice").count()) === 1, "an album iCloud refuses goes away again, and says why");
+ok(!(await albumNames()).includes("Nope") && (await page.locator(".toast.is-error").count()) === 1, "an album iCloud refuses goes away again, and says why");
// Folders, as icloud.com has them: New Folder, named in place; an album made in it sits in it;
// the folder's page shows what it holds; deleting it takes what it holds with it.
diff --git a/.uiverify/photos-download.mjs b/.uiverify/photos-download.mjs
index 665617b..494b557 100644
--- a/.uiverify/photos-download.mjs
+++ b/.uiverify/photos-download.mjs
@@ -17,7 +17,7 @@ const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failu
const last = () => page.evaluate(() => window.__downloads?.at(-1));
await page.locator(".px-tile").nth(1).click({ button: "right" });
-await page.locator(".row-menu").getByText("More Download Options…").click();
+await page.locator(".row-menu").getByText("More Download Options").click();
const sheet = page.getByRole("dialog", { name: "Download Options" });
ok((await sheet.count()) === 1 && /1 Item/.test(await sheet.innerText()) && /Unmodified Originals[\s\S]*Including Edits[\s\S]*Highest Resolution[\s\S]*Most Compatible/.test(await sheet.innerText()),
"the sheet offers what icloud.com's does");
@@ -37,8 +37,8 @@ await page.keyboard.press("Escape");
await page.locator(".px-tile").nth(2).dblclick();
await page.waitForTimeout(600);
await page.locator(".px-stage").click({ button: "right", position: { x: 300, y: 300 } });
-ok((await page.locator(".row-menu").getByText("More Download Options…").count()) === 1, "right-clicking the open photo gives its menu");
-await page.locator(".row-menu").getByText("More Download Options…").click();
+ok((await page.locator(".row-menu").getByText("More Download Options").count()) === 1, "right-clicking the open photo gives its menu");
+await page.locator(".row-menu").getByText("More Download Options").click();
await page.keyboard.press("Escape");
await page.waitForTimeout(200);
ok((await sheet.count()) === 0 && (await page.locator(".px-viewer").count()) === 1, "Escape closes the sheet, and the photo stays open");
diff --git a/.uiverify/photos-keys.mjs b/.uiverify/photos-keys.mjs
index aec9cf4..ea562f7 100644
--- a/.uiverify/photos-keys.mjs
+++ b/.uiverify/photos-keys.mjs
@@ -9,7 +9,7 @@ const page = await ctx.newPage();
page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
// Every question agreed to, as soon as it is asked.
await page.addInitScript(() => addEventListener("DOMContentLoaded", () =>
- new MutationObserver(() => document.querySelector(".px-ask .is-act")?.click()).observe(document.body, { childList: true, subtree: true })));
+ new MutationObserver(() => document.querySelector(".confirm .confirm-answer")?.click()).observe(document.body, { childList: true, subtree: true })));
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Photos");
await page.waitForTimeout(400);
diff --git a/.uiverify/photos-shared.mjs b/.uiverify/photos-shared.mjs
index 2f4c921..a6681e9 100644
--- a/.uiverify/photos-shared.mjs
+++ b/.uiverify/photos-shared.mjs
@@ -34,8 +34,8 @@ ok(await page.evaluate(() => window.__shared.some((a) => a.name === "Beach Trip"
// Deleted from its menu, after asking.
await page.locator(".px-albums-page .px-card", { hasText: "Beach Trip" }).click({ button: "right" });
await page.locator(".row-menu").getByText("Delete Shared Album").click();
-ok(/everyone it is shared with/.test(await page.locator(".px-ask").innerText()), "deleting asks first, saying it goes for everyone");
-await page.locator(".px-ask .is-act").click();
+ok(/everyone it is shared with/.test(await page.locator(".confirm").innerText()), "deleting asks first, saying it goes for everyone");
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(250);
ok(!(await cards()).join().includes("Beach Trip") && !(await page.evaluate(() => window.__shared.some((a) => a.name === "Beach Trip"))), "and it is gone, here and at Apple");
// One shared with this account cannot be deleted from here.
@@ -49,7 +49,7 @@ await page.getByRole("button", { name: "New Shared Album" }).first().click();
await page.getByLabel("Album Name").fill("Nope");
await page.keyboard.press("Enter");
await page.waitForTimeout(300);
-ok(!(await cards()).join().includes("Nope") && /refused/.test(await page.locator(".notice").innerText().catch(() => "")), "a refusal takes it back and says why");
+ok(!(await cards()).join().includes("Nope") && /refused/.test(await page.locator(".toast.is-error").innerText().catch(() => "")), "a refusal takes it back and says why");
await page.evaluate(() => { window.__sharedFail = false; });
// Back to the library.
diff --git a/.uiverify/photos.mjs b/.uiverify/photos.mjs
index 5f60c11..cbb0491 100644
--- a/.uiverify/photos.mjs
+++ b/.uiverify/photos.mjs
@@ -54,7 +54,7 @@ ok((await page.getByRole("button", { name: "Favorite", exact: true }).count()) =
const flags = await page.evaluate(() => window.__flags.map((f) => `${f.id}:${f.flag}:${f.on}`));
ok(JSON.stringify(flags) === JSON.stringify(["p2:favorite:true", "p2:favorite:false"]), `and each goes to iCloud ${JSON.stringify(flags)}`);
await page.getByRole("button", { name: "Delete", exact: true }).click();
-await page.locator(".px-ask .is-act").click();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(300);
const next = await page.locator(".px-stage .px-shown").first().evaluate((i) => i.getAttribute("data-picture") ?? i.getAttribute("src"));
ok(/p3|p4/.test(next ?? "") && (await page.locator(".px-tile").count()) === 4, "Delete, once agreed, takes it out and shows the next");
@@ -79,14 +79,14 @@ await page.evaluate(() => { window.__flagFail = true; });
await page.locator(".px-tile").nth(1).dblclick();
await page.getByRole("button", { name: "Favorite", exact: true }).click();
await page.waitForTimeout(300);
-ok((await page.getByRole("button", { name: "Favorite", exact: true }).count()) === 1 && (await page.locator(".notice").count()) === 1,
+ok((await page.getByRole("button", { name: "Favorite", exact: true }).count()) === 1 && (await page.locator(".toast.is-error").count()) === 1,
"a change iCloud refuses goes back, and says why");
-ok(await page.locator(".notice").evaluate((n) => {
+ok(await page.locator(".toast.is-error").evaluate((n) => {
const r = n.getBoundingClientRect();
return n.contains(document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2));
}), "and says it in front of the open photo, not hidden behind it");
await page.evaluate(() => { window.__flagFail = false; });
-await page.getByRole("button", { name: "Dismiss" }).click();
+await page.locator(".toast.is-error").getByRole("button", { name: "Dismiss" }).click();
await page.keyboard.press("Escape");
// It goes back into its tile first, then is gone.
await page.waitForTimeout(650);
@@ -168,7 +168,7 @@ ok((await page.locator('.px-tile[aria-selected="true"]').count()) === 0, "a clic
// Hide, as Photos hides: asked, out of the library, into Hidden (under Utilities), and back.
await page.locator(".px-tile").nth(1).click({ button: "right" });
await page.locator(".row-menu").getByText("Hide Photo").click();
-await page.locator(".px-ask .is-act").click();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(300);
ok((await page.locator(".px-tile").count()) === 4, "Hide Photo takes it out of the library at once");
await page.locator(".px-source", { hasText: "Hidden" }).click();
@@ -237,13 +237,13 @@ ok((await page.getByRole("button", { name: "Delete All" }).count()) === 1, "with
await page.locator(".px-tile").first().click();
ok((await page.locator(".px-word").allInnerTexts()).join() === "Recover,Delete", "with one selected, Recover and Delete");
await page.locator(".px-word", { hasText: /^Delete$/ }).click();
-const asked = await page.locator(".px-ask").innerText();
-ok((await page.locator(".px-ask .px-ask-symbol").count()) === 1 && (await page.locator(".px-ask button").first().evaluate((b) => b === document.activeElement)),
+const asked = await page.locator(".confirm").innerText();
+ok((await page.locator(".confirm .confirm-symbol").count()) === 1 && (await page.locator(".confirm button").first().evaluate((b) => b === document.activeElement)),
"asked in a sheet, as icloud.com asks: the trash symbol, Cancel holding the focus");
await page.keyboard.press("Escape");
-ok((await page.locator(".px-ask").count()) === 0 && (await page.locator(".px-tile").count()) === 1, "Escape cancels: nothing deleted");
+ok((await page.locator(".confirm").count()) === 0 && (await page.locator(".px-tile").count()) === 1, "Escape cancels: nothing deleted");
await page.locator(".px-word", { hasText: /^Delete$/ }).click();
-await page.locator(".px-ask .is-act").click();
+await page.locator(".confirm .confirm-answer").click();
await page.waitForTimeout(300);
ok(/permanently/.test(asked) && /cannot be undone/.test(asked), `Delete asks first, in Photos' words "${asked.split("\n")[0]}"`);
ok((await page.locator(".px-tile").count()) === 0 && (await page.evaluate(() => window.__flags.at(-1).flag)) === "expunged",
@@ -292,9 +292,7 @@ ok((await page.locator(".px-up-title").innerText()) === "2 of 3 Items Not Upload
ok(/can’t add this kind/.test(await panel.innerText()), "and why");
await panel.getByRole("button", { name: "Done" }).click();
await page.waitForTimeout(60);
-ok(/is-leaving/.test((await panel.getAttribute("class")) ?? ""), "Done slides it away");
-await page.waitForTimeout(400);
-ok((await page.locator(".px-up").count()) === 0, "and it is gone");
+ok((await page.locator(".px-up").count()) === 0, "Done puts it away at once");
// Stop Upload, for a batch still going.
await page.evaluate(() => { window.__pick = ["/home/test/Pictures/ferry.jpg"]; });
await page.getByRole("button", { name: "Add Photos" }).click();
diff --git a/.uiverify/reminders-tick.mjs b/.uiverify/reminders-tick.mjs
index 677ceca..3b9e753 100644
--- a/.uiverify/reminders-tick.mjs
+++ b/.uiverify/reminders-tick.mjs
@@ -50,8 +50,12 @@ ok(JSON.stringify(sent) === JSON.stringify([true, false]), `and Apple gets both
// Apple refuses a change that was queued behind the window: the reason is said, and the list
// is read again (Apple's version back over the tick).
const readsBefore = await page.evaluate(() => (window.__reads ??= 0));
-await page.evaluate(() => window.__emit("quince://outbox-refused", { service: "reminders", record: "r2", message: "This reminder was changed on another device first." }));
+await page.evaluate(() => {
+ // Kept, not dropped: the backend holds it as refused, with what it was.
+ window.__outbox = { waiting: [], refused: [{ id: 7, service: "reminders", record: "r2", kind: "done", reason: "This reminder was changed on another device first.", madeAt: 0, content: "Plan tomorrow" }] };
+ window.__emit("quince://outbox-refused", { service: "reminders", record: "r2", message: "This reminder was changed on another device first." });
+});
await page.waitForTimeout(300);
-ok(/changed on another device/.test(await page.locator(".notice").innerText().catch(() => "")), "a change Apple refuses is put back, and the window says why");
+ok(/changed on another device/.test(await page.locator(".toast.is-error, .unsent").first().innerText().catch(() => "")), "a change Apple refuses is put back, and the window says why");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/settings-drive-folder.mjs b/.uiverify/settings-drive-folder.mjs
index fbada30..d29dc04 100644
--- a/.uiverify/settings-drive-folder.mjs
+++ b/.uiverify/settings-drive-folder.mjs
@@ -11,7 +11,7 @@ page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); proc
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
-await page.locator(".account-card, [aria-label*='Settings'], .sidebar-foot button").first().click();
+await page.locator(".sidebar-account").click();
await page.waitForTimeout(400);
const sw = page.getByRole("switch", { name: "iCloud Drive folder" });
ok((await sw.getAttribute("aria-checked")) === "false", "off until turned on");
diff --git a/.uiverify/settings-scroll.mjs b/.uiverify/settings-scroll.mjs
index 2c00724..8f8c2ba 100644
--- a/.uiverify/settings-scroll.mjs
+++ b/.uiverify/settings-scroll.mjs
@@ -11,7 +11,7 @@ page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); proc
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
-const settings = () => page.locator(".account-card, [aria-label*='Settings'], .sidebar-foot button").first().click();
+const settings = () => page.locator(".sidebar-account").click();
// Scrolled by the wheel, as a person scrolls: the page moves.
const scrolls = async () => {
const box = await page.locator(".settings").boundingBox();
diff --git a/.uiverify/settings-storage.mjs b/.uiverify/settings-storage.mjs
new file mode 100644
index 0000000..e2524ff
--- /dev/null
+++ b/.uiverify/settings-storage.mjs
@@ -0,0 +1,64 @@
+// Settings' storage on this computer: what each part takes, read from the backend; Clear lets go
+// of the cached pictures only and the figures are read again; a desktop with no notification
+// service says so under the alert switches; a folder that cannot be opened says why on its row.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const open = async (init) => {
+ const ctx = await b.newContext({ viewport: { width: 1180, height: 820 } });
+ if (init) await ctx.addInitScript(init);
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });
+ const page = await ctx.newPage();
+ page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));
+ await page.goto(process.env.URL ?? "http://localhost:4173", { waitUntil: "networkidle" });
+ await page.locator(".sidebar-account").click();
+ await page.waitForSelector(".settings");
+ await page.waitForTimeout(300);
+ return { ctx, page };
+};
+
+{
+ const { ctx, page } = await open();
+ const text = await page.locator(".settings").innerText();
+ ok(/Storage on This Computer\s*4\.9 GB/.test(text), "the local copy's whole size is on its heading");
+ ok(/Photos\s*4\.5 GB/.test(text) && /Notes\s*435 MB/.test(text) && /Library\s*13 MB/.test(text), "and each part's size is on its row");
+ ok(/Cached pictures[\s\S]*4\.2 GB/.test(text), "what can be cleared is said before clearing");
+ const clear = page.getByRole("button", { name: "Clear", exact: true });
+ await clear.click();
+ await page.waitForTimeout(200);
+ const after = await page.locator(".settings").innerText();
+ ok((await page.evaluate(() => window.__cleared)) === 1, "Clear asks the backend once");
+ ok(/4\.2 GB cleared/.test(after) && /Storage on This Computer\s*772 MB/.test(after), "and the figures are the backend's answer after");
+ ok(await clear.isDisabled(), "nothing left to clear, Clear rests");
+ ok(!(await page.getByText("no notification service").isVisible()), "a desktop that shows alerts is not warned");
+ await ctx.close();
+}
+{
+ const { ctx, page } = await open(() => {
+ window.__alertsShown = false;
+ window.__driveFolder = { on: true, path: "/home/test/iCloud Drive", problem: null };
+ window.__clearFail = "The data folder could not be read.";
+ window.__driveOpenFail = "That folder is off.";
+ });
+ await page.getByRole("button", { name: "Open", exact: true }).click();
+ await page.waitForTimeout(150);
+ const row = page.locator(".settings-row", { hasText: "iCloud Drive folder" });
+ ok((await row.innerText()).includes("That folder is off.") && !(await page.locator(".toast.is-error").isVisible()), "a folder that cannot be opened says why on its own row");
+ ok(await page.getByText("Alerts can't appear: this desktop has no notification service running.").isVisible(), "a desktop with no notification service is said under the switches");
+ await page.getByRole("button", { name: "Clear", exact: true }).click();
+ await page.waitForTimeout(200);
+ const banner = page.locator(".toast.is-error");
+ ok((await banner.innerText()).includes("could not be read"), "a failed clear says why");
+ await page.locator(".content").evaluate((el) => { el.scrollTop = el.scrollHeight; });
+ await page.waitForTimeout(100);
+ const box = await banner.boundingBox();
+ ok(box && box.y >= 0 && box.y + box.height <= (page.viewportSize()?.height ?? 900), `the reason stays in sight as the page scrolls [y=${box?.y}]`);
+ await banner.getByRole("button", { name: "Dismiss" }).click();
+ await page.waitForTimeout(250);
+ ok(!(await banner.isVisible()), "and is dismissed");
+ await ctx.close();
+}
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/settings.mjs b/.uiverify/settings.mjs
index b397694..671cf72 100644
--- a/.uiverify/settings.mjs
+++ b/.uiverify/settings.mjs
@@ -28,7 +28,7 @@ ok((await page.evaluate(() => window.__settings?.eventAlerts)) === false, "and t
await page.evaluate(() => { window.__settingsFail = true; });
await sw.click();
await page.waitForTimeout(100);
-ok((await sw.getAttribute("aria-checked")) === "false" && (await page.locator(".settings-error").isVisible()), "a setting that could not be kept goes back, and says why");
+ok((await sw.getAttribute("aria-checked")) === "false" && (await page.locator(".toast.is-error").isVisible()), "a setting that could not be kept goes back, and says why");
await page.evaluate(() => { window.__settingsFail = false; });
await page.getByRole("button", { name: "Dark", exact: true }).click();
@@ -70,7 +70,7 @@ await page.locator(".sidebar-account").click();
await page.waitForSelector(".settings");
await page.getByRole("button", { name: "Save Diagnostic Report" }).click();
await page.waitForTimeout(150);
-ok((await page.evaluate(() => window.__diagnostics)) === 1 && /Saved to Downloads\/Pomander diagnostics/.test(await page.locator(".settings").innerText()), "a diagnostic report is saved, and the screen says where");
+ok((await page.evaluate(() => window.__diagnostics)) === 1 && /Saved to Downloads/.test(await page.locator(".toast").last().innerText()), "a diagnostic report is saved, and the screen says where");
// The account's picture is the photo on the person's own card, where it has one.
// (A plain browser cannot load quince:// — the picture falls back to initials, as it should —
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index d308dbe..12a4a8d 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -1,152 +1,22 @@
-// Screenshot every auth screen against the real built bundle.
-// Tauri IPC doesn't exist in a plain browser, so we stub __TAURI_INTERNALS__ with the exact
-// shapes the Rust commands return — no invented UI state.
-import { engine as chromium } from "./engine.mjs";
-import { fileURLToPath } from "node:url";
-import path from "node:path";
-import { SERVICES, installStub } from "./stub.mjs";
-
-const dir = path.dirname(fileURLToPath(import.meta.url));
-const BASE = process.env.BASE ?? "http://localhost:4173";
-
-
-
-const PUSHED = { trustedDeviceCount: 2, phones: [{ id: 1, maskedNumber: "+91 ••••• ••318" }], tooManyCodesSent: false };
-const NOTHING = { trustedDeviceCount: 0, phones: [{ id: 1, maskedNumber: "+91 ••••• ••318" }], tooManyCodesSent: false };
-// No device to prompt and no number to text. Rare, and real — an account whose trusted number
-// was removed. Without a screen of its own it offers a code that can never arrive.
-const NOWHERE = { trustedDeviceCount: 0, phones: [], tooManyCodesSent: false };
-
-const shots = [
- { name: "01-signin", screen: "signin", theme: "light" },
- { name: "02-signin-dark", screen: "signin", theme: "dark" },
- { name: "03-code", screen: "code", theme: "light",
- act: async (p) => {
- await p.fill('input[aria-label="Apple ID"]', "[email protected]");
- await p.fill('input[aria-label="Password"]', "••••••••••••");
- await p.click('button[type="submit"]');
- await p.waitForSelector(".code", { timeout: 5000 });
- await p.fill('input[aria-label="Digit 1"]', "4");
- await p.fill('input[aria-label="Digit 2"]', "8");
- await p.fill('input[aria-label="Digit 3"]', "1");
- } },
- { name: "19-code-nowhere", screen: "code", theme: "light", twoFactor: NOWHERE,
- act: async (p) => {
- await p.fill('input[aria-label="Apple ID"]', "[email protected]");
- await p.fill('input[aria-label="Password"]', "••••••••••••");
- await p.click('button[type="submit"]');
- await p.waitForSelector(".help", { timeout: 5000 });
- } },
- { name: "06-code-no-device", screen: "code", theme: "light", twoFactor: NOTHING,
- act: async (p) => {
- await p.fill('input[aria-label="Apple ID"]', "[email protected]");
- await p.fill('input[aria-label="Password"]', "••••••••••••");
- await p.click('button[type="submit"]');
- await p.waitForSelector(".help", { timeout: 5000 });
- } },
- { name: "07-calendar", screen: "library", theme: "light", calendarFixture: true,
- act: async (p) => { await p.locator(".nav-item", { hasText: "Calendar" }).click(); await p.waitForSelector(".cal-grid"); } },
- { name: "08-calendar-dark", screen: "library", theme: "dark", calendarFixture: true,
- act: async (p) => { await p.locator(".nav-item", { hasText: "Calendar" }).click(); await p.waitForSelector(".cal-grid"); } },
- // The window is often half a screen, where four columns do not fit.
- { name: "09-notes-narrow", screen: "library", theme: "dark", notesFixture: true,
- viewport: { width: 958, height: 1038 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Notes")');
- await p.waitForSelector(".note-rows .note-row");
- await p.click('.note-row:has-text("These sources")');
- } },
- { name: "10-notes-wide", screen: "library", theme: "dark", notesFixture: true,
- viewport: { width: 1600, height: 1000 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Notes")');
- await p.waitForSelector(".note-rows .note-row");
- await p.click('.note-row:has-text("These sources")');
- } },
- { name: "11-contacts", screen: "library", theme: "dark", contactsFixture: true,
- viewport: { width: 1100, height: 820 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Contacts")');
- await p.waitForSelector(".contact-rows .contact-row");
- await p.click('.contact-row:has-text("Zoya")');
- } },
- { name: "12-drive", screen: "library", theme: "dark", driveFixture: true,
- viewport: { width: 1100, height: 760 },
- act: async (p) => {
- await p.click('.nav-item:has-text("iCloud Drive")');
- await p.waitForSelector(".drive-rows .drive-row");
- } },
- { name: "13-reminders", screen: "library", theme: "dark", remindersFixture: true,
- viewport: { width: 1100, height: 760 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Reminders")');
- await p.waitForSelector(".rx-rows li");
- await p.click('.rx-list:has-text("Daily")');
- await p.waitForTimeout(200);
- await p.click('.rx-trailing .rx-icon-button[aria-expanded] >> nth=0');
- } },
- // A full-screen window on a large display is where content stranded in a narrow column
- // becomes obvious, and every shot above is too small to show it.
- { name: "14-reminders-wide", screen: "library", theme: "dark", remindersFixture: true,
- viewport: { width: 1920, height: 1080 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Reminders")');
- await p.waitForSelector(".rx-rows li");
- } },
- { name: "15-notes-full", screen: "library", theme: "dark", notesFixture: true,
- viewport: { width: 1920, height: 1080 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Notes")');
- await p.waitForSelector(".note-rows .note-row");
- await p.click('.note-row:has-text("These sources")');
- } },
- { name: "16-contacts-wide", screen: "library", theme: "dark", contactsFixture: true,
- viewport: { width: 1920, height: 1080 },
- act: async (p) => {
- await p.click('.nav-item:has-text("Contacts")');
- await p.waitForSelector(".contact-rows .contact-row");
- await p.click('.contact-row:has-text("Zoya")');
- } },
- { name: "17-calendar-wide", screen: "library", theme: "dark", calendarFixture: true,
- viewport: { width: 1920, height: 1080 },
- act: async (p) => { await p.locator(".nav-item", { hasText: "Calendar" }).click(); await p.waitForSelector(".cal-grid"); } },
- { name: "18-drive-move", screen: "library", theme: "dark", driveFixture: true,
- act: async (p) => {
- await p.click('.nav-item:has-text("iCloud Drive")');
- await p.waitForSelector(".drive-row-hit");
- await p.hover(".drive-row.is-folder");
- await p.click('.drive-row.is-folder .drive-action[aria-label^="Actions for"]');
- await p.getByRole("menuitem", { name: "Move to Folder…" }).click();
- await p.waitForSelector(".modal-sheet");
- } },
- { name: "04-library", screen: "library", theme: "light" },
- { name: "05-library-dark", screen: "library", theme: "dark" },
-];
-
-const browser = await chromium.launch();
-for (const { name, screen, theme, act, twoFactor = PUSHED, calendarFixture = false, notesFixture = false, contactsFixture = false, driveFixture = false, remindersFixture = false, viewport } of shots) {
- const ctx = await browser.newContext({
- viewport: viewport ?? { width: 1040, height: 720 },
- deviceScaleFactor: 2,
- colorScheme: theme,
- });
- await ctx.addInitScript(installStub, { screen, services: SERVICES, twoFactor, calendarFixture, notesFixture, contactsFixture, driveFixture, remindersFixture });
- const page = await ctx.newPage();
- const errors = [];
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
- page.on("pageerror", (e) => errors.push(String(e)));
-
- await page.goto(BASE, { waitUntil: "networkidle" });
- await page.waitForTimeout(300);
- if (act) await act(page);
- await page.waitForTimeout(700); // let entrance animations settle
- await page.screenshot({ path: path.join(dir, `${name}.png`) });
- if (errors.length) {
- console.error(`${name.padEnd(18)} CONSOLE ERRORS: ${errors.join(" | ")}`);
- process.exitCode = 1;
- } else {
- console.log(`${name.padEnd(18)} clean`);
- }
- await ctx.close();
+import { engine, engineName } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const S = "/tmp/claude-1000/-home-yash-Projects/2540edda-3efd-42b2-8acc-a7662fcef7d7/scratchpad";
+const tag = process.argv[2] || "before";
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1300, height: 850 }, colorScheme: process.argv[3] || "light" });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });
+const page = await ctx.newPage();
+page.on("pageerror", (e) => console.log("pageerror", e.message));
+await page.goto("http://localhost:4181", { waitUntil: "networkidle" });
+await openScreen(page, "Calendar");
+for (const v of ["Month", "Week", "Day", "Year"]) {
+ await page.getByRole("button", { name: v, exact: true }).click();
+ await page.waitForTimeout(400);
+ await page.screenshot({ path: `${S}/${tag}-${engineName}-${v}.png` });
}
-await browser.close();
+await page.getByRole("button", { name: "Week", exact: true }).click();
+await page.waitForTimeout(300);
+await page.locator(".cx-block", { hasText: "Design review" }).first().click();
+await page.waitForTimeout(300);
+await page.screenshot({ path: `${S}/${tag}-${engineName}-pop.png` });
+await b.close();
diff --git a/.uiverify/signout.mjs b/.uiverify/signout.mjs
index 0d1ea12..66cab62 100644
--- a/.uiverify/signout.mjs
+++ b/.uiverify/signout.mjs
@@ -11,7 +11,7 @@ page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); proc
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
-const settings = () => page.locator(".account-card, [aria-label*='Settings'], .sidebar-foot button").first().click();
+const settings = () => page.locator(".sidebar-account").click();
await settings();
await page.waitForTimeout(400);
const signOut = page.getByRole("button", { name: "Sign Out" });
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index db93eb7..6091974 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -550,7 +550,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "drive_folder_set":
if (window.__driveFolderRefuse) return { ...window.__driveFolder, on: false, problem: window.__driveFolderRefuse };
return (window.__driveFolder = { on: args.on, path: "/home/test/iCloud Drive", problem: null, waiting: args.on ? { files: 0, sending: 0, failure: null } : null });
- case "drive_folder_open": (window.__opened ??= []).push("drive"); return null;
+ case "drive_folder_open": if (window.__driveOpenFail) throw window.__driveOpenFail; (window.__opened ??= []).push("drive"); return null;
case "photos_folder_status": return window.__photosFolder ??= { on: false, path: "/home/test/iCloud Photos", problem: null };
case "photos_folder_set": return (window.__photosFolder = { on: args.on, path: "/home/test/iCloud Photos", problem: null });
case "photos_folder_open": (window.__opened ??= []).push("photos"); return null;
@@ -583,6 +583,15 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "drive_thumbnails": return driveFixture ? { "FILE::d": "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='60'><rect width='80' height='60' fill='%23eee'/></svg>" } : {};
case "drive_duplicate": (window.__dups ??= []).push(args.drivewsid); return null;
case "storage_info": return { usedBytes: 182196857, totalBytes: 5368709120 };
+ // The local copy's room, as settings.rs measures it; clearing takes away only the cached pictures.
+ case "local_storage": return (window.__local ??= { library: 13_800_000, photos: 4_812_000_000, notes: 456_000_000, drive: 24_000, other: 7_400_000, total: 5_289_224_000, clearable: 4_480_000_000 });
+ case "local_storage_clear": {
+ if (window.__clearFail) throw window.__clearFail;
+ const l = (window.__local ??= { library: 13_800_000, photos: 4_812_000_000, notes: 456_000_000, drive: 24_000, other: 7_400_000, total: 5_289_224_000, clearable: 4_480_000_000 });
+ window.__cleared = (window.__cleared ?? 0) + 1;
+ return (window.__local = { ...l, photos: l.photos - (l.clearable - l.notes - 3_000), notes: 0, drive: l.drive - 3_000, total: l.total - l.clearable, clearable: 0 });
+ }
+ case "alerts_shown": return window.__alertsShown ?? true;
case "diagnostics_save": (window.__diagnostics = (window.__diagnostics ?? 0) + 1); return "/home/user/Downloads/Pomander diagnostics 2026-10-18 20.00.txt";
case "account_info": return { name: "Asha Rao", email: "[email protected]", photoContact: window.__mePhoto ?? null, webAccessAllowed: window.__webAccess ?? true, dataProtection: false };
case "settings_get": return { reminderAlerts: true, eventAlerts: true, ...(window.__settings ?? {}) };
@@ -626,6 +635,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
if (args.folderId === window.__driveGone) throw "This folder was deleted or moved on another device.";
return driveItems.length;
case "drive_download": return "/home/user/Downloads/file.pdf";
+ case "download_reveal": (window.__revealed ??= []).push(args.path); return null;
case "drive_move": (window.__moves ??= []).push(args); await new Promise((r) => setTimeout(r, 600)); return null;
case "drive_create_folder": case "drive_rename": (window.__driveNames ??= []).push(args); return null;
case "drive_delete": return null;
@@ -657,6 +667,13 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
if (window.__loginRefuse) throw window.__loginRefuse;
return (window.__login = { ...(window.__login ?? {}), on: args.on, command: "\"/usr/bin/quince-app\" --background", honoured: window.__login?.honoured ?? true });
case "account_unsent": return window.__unsent ?? { changes: 0, files: 0, photos: 0 };
+ // Changes waiting for Apple, and ones it refused: a test sets `window.__outbox`.
+ case "outbox_status": return window.__outbox ?? { waiting: [], refused: [] };
+ case "outbox_resend": case "outbox_discard": {
+ (window.__outboxCalls ??= []).push([cmd, args.id]);
+ if (window.__outbox) window.__outbox = { ...window.__outbox, refused: window.__outbox.refused.filter((r) => r.id !== args.id) };
+ return null;
+ }
// One refresh covers every service, so there is one command to stub rather than
// a pair per screen.
case "sync_all":
@@ -703,3 +720,18 @@ export async function openScreen(page, name) {
const root = { Calendar: ".cx", Notes: ".notes", Reminders: ".rx", Contacts: ".contacts", "iCloud Drive": ".drive" }[name];
if (root) await page.locator(root).first().waitFor({ state: "attached", timeout: 10000 });
}
+
+/* Answer every yes-or-no confirmation sheet (components/Confirm) by going ahead — a question
+ with several answers is left to the suite — keeping each question's
+ title in window.__asked — what page.on("dialog") did for the browser's own confirm(). */
+export function autoConfirm() {
+ const watch = () => new MutationObserver(() => {
+ const sheet = document.querySelector(".confirm:not([data-answered]):not(:has(.is-stacked))");
+ if (!sheet) return;
+ sheet.setAttribute("data-answered", "");
+ (window.__asked ??= []).push(sheet.querySelector("h2")?.textContent ?? "");
+ sheet.querySelector(".confirm-answer")?.click();
+ }).observe(document.documentElement, { childList: true, subtree: true });
+ if (document.documentElement) watch();
+ else document.addEventListener("DOMContentLoaded", watch);
+}
diff --git a/.uiverify/switch-frames.mjs b/.uiverify/switch-frames.mjs
new file mode 100644
index 0000000..f29cae9
--- /dev/null
+++ b/.uiverify/switch-frames.mjs
@@ -0,0 +1,61 @@
+// Switching apps never shows an empty frame: from the click on, every frame the page draws has
+// one screen in front, with something in it, and the sidebar already marking the app chosen —
+// for a screen opened for the first time as much as for one coming back.
+import { engine, engineName } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+const b = await engine.launch();
+const all = { notesFixture: true, calendarFixture: true, contactsFixture: true, driveFixture: true, remindersFixture: true };
+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, ...all });
+const page = await ctx.newPage();
+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await page.locator(".nav-item").first().waitFor();
+// Every app's code is in (fetched 300ms after the window opens) — what a person meets after
+// the first moment. Before it is, opening an app waits on its code, which is a different matter.
+await page.waitForFunction(() => ["NotesView", "CalendarView", "ContactsView", "DriveView", "RemindersView", "PhotosView"]
+ .every((n) => performance.getEntriesByType("resource").some((r) => r.name.includes(`/${n}-`))), null, { timeout: 20000 });
+await page.waitForLoadState("networkidle");
+await page.waitForTimeout(300);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+
+/** Each frame from the click on, for a few frames: what is in front and what the sidebar marks. */
+const switchTo = (name) => page.evaluate(async (name) => {
+ const frames = [];
+ const look = () => {
+ const shown = [...document.querySelectorAll(".content > .screen-slot:not([hidden])")];
+ const slot = shown[0];
+ // The slot is `display: contents`: what it holds is what is drawn.
+ let drawn = 0;
+ for (const el of slot?.children ?? []) drawn += el.getBoundingClientRect().height;
+ frames.push({
+ slots: shown.length,
+ drawn: Math.round(drawn),
+ kids: [...(slot?.children ?? [])].map((c) => c.className.split(" ")[0]).join("+"),
+ opacity: slot?.firstElementChild ? Number(getComputedStyle(slot.firstElementChild).opacity) : null,
+ marked: document.querySelector('.nav-item[aria-current="true"]')?.textContent ?? null,
+ });
+ };
+ const btn = [...document.querySelectorAll(".nav-item")].find((b) => b.textContent.includes(name));
+ btn.click();
+ look(); // straight after the click, before anything is drawn
+ for (let i = 0; i < 12; i++) {
+ await new Promise((r) => requestAnimationFrame(() => r()));
+ look();
+ }
+ return frames;
+}, name);
+
+for (const name of ["Notes", "Calendar", "Contacts", "iCloud Drive", "Notes", "Reminders", "Calendar"]) {
+ const frames = await switchTo(name);
+ // Frame 0 is the state in the click's own task, never painted; frames 1.. are each a paint.
+ const painted = frames.slice(1);
+ const blank = painted.findIndex((f) => f.slots !== 1 || f.drawn === 0);
+ ok(blank === -1, `${engineName} → ${name}: every painted frame has a screen in front, drawn ${blank === -1 ? "" : JSON.stringify(painted[blank])}`);
+ if (blank !== -1) console.log(" ", painted.map((f) => `${f.kids || "-"}:${f.drawn}`).join(" "));
+ ok(painted.every((f) => f.marked?.includes(name)), `${engineName} → ${name}: the sidebar marks it from the first frame`);
+ await page.waitForTimeout(250);
+}
+await b.close();
+process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index d7e3ce0..7434031 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -4405,21 +4405,12 @@ fn show_window(app: &tauri::AppHandle) {
/// closed, and can be opened again or quit from there.
fn build_tray(app: &tauri::App) -> tauri::Result<()> {
use tauri::menu::PredefinedMenuItem;
- use tauri::menu::{Menu, MenuItem, Submenu};
+ use tauri::menu::{Menu, MenuItem};
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
- // Five lines, as a menu-bar extra keeps it: the window, the apps folded under one, the two
- // quick notes a person reaches for, and Quit. Syncing needs no button (it runs by itself)
- // and Settings lives in the window; a longer menu was a list nobody could scan.
+ // Four plain lines, nothing nested: the window, the two quick notes a person reaches for
+ // from anywhere, and Quit. A submenu was slow to draw in the panel and one more step;
+ // each app has its own launcher and is a click away in the window.
let open = MenuItem::with_id(app, "open", "Open Pomander", true, None::<&str>)?;
- let each: Vec<MenuItem<tauri::Wry>> = apps::APPS
- .iter()
- .map(|(key, name)| MenuItem::with_id(app, format!("app:{key}"), *name, true, None::<&str>))
- .collect::<tauri::Result<_>>()?;
- let each_ref: Vec<&dyn tauri::menu::IsMenuItem<tauri::Wry>> = each
- .iter()
- .map(|i| i as &dyn tauri::menu::IsMenuItem<tauri::Wry>)
- .collect();
- let apps_menu = Submenu::with_items(app, "Open App", true, &each_ref)?;
let new_reminder = MenuItem::with_id(app, "new:reminder", "New Reminder", true, None::<&str>)?;
let new_note = MenuItem::with_id(app, "new:note", "New Note", true, None::<&str>)?;
let line = PredefinedMenuItem::separator(app)?;
@@ -4427,15 +4418,7 @@ fn build_tray(app: &tauri::App) -> tauri::Result<()> {
let quit = MenuItem::with_id(app, "quit", "Quit Pomander", true, None::<&str>)?;
let menu = Menu::with_items(
app,
- &[
- &open,
- &apps_menu,
- &line,
- &new_reminder,
- &new_note,
- &line2,
- &quit,
- ],
+ &[&open, &line, &new_reminder, &new_note, &line2, &quit],
)?;
let mut tray = TrayIconBuilder::with_id("quince")
.tooltip("Pomander")
@@ -4448,11 +4431,7 @@ fn build_tray(app: &tauri::App) -> tauri::Result<()> {
"quit" => shutdown(app, 0),
"new:reminder" => intake::capture(app, "reminder"),
"new:note" => intake::capture(app, "note"),
- other => {
- if let Some(key) = other.strip_prefix("app:") {
- apps::open(app, key);
- }
- }
+ _ => {}
})
.on_tray_icon_event(|tray, event| {
if let TrayIconEvent::Click {
diff --git a/src/App.tsx b/src/App.tsx
index 5eb475a..e8cf327 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -2,8 +2,11 @@ import { useEffect, useState } from "react";
import { SignIn } from "./screens/SignIn";
import { CodeEntry } from "./screens/CodeEntry";
import { Library } from "./screens/Library";
+import { ImportSheet } from "./components/ImportSheet";
+import { StatusLine } from "./components/StatusLine";
+import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
-import { api, NEEDS_CODE } from "./lib/ipc";
+import { api, NEEDS_CODE, NEEDS_SIGNIN } from "./lib/ipc";
type Phase = "checking" | "signin" | "code" | "library";
@@ -17,9 +20,8 @@ export default function App() {
setShown(true);
requestAnimationFrame(() =>
requestAnimationFrame(() => {
- import("@tauri-apps/api/core")
- // Started at login, the window stays in the tray unless the person is needed here.
- .then(({ invoke }) => invoke("window_ready", { needsYou: phase !== "library" }))
+ // Started at login, the window stays in the tray unless the person is needed here.
+ invoke("window_ready", { needsYou: phase !== "library" })
.catch(() => {});
}),
);
@@ -58,6 +60,16 @@ export default function App() {
};
}, []);
+ // Apple signed the session out: the library stays — still readable — with one line over it
+ // saying so, and the sign-in a click away rather than forced in its place.
+ const [lapsed, setLapsed] = useState(false);
+ useEffect(() => {
+ const stop = listen(NEEDS_SIGNIN, () => setLapsed(true));
+ return () => {
+ void stop.then((unlisten) => unlisten()).catch(() => {});
+ };
+ }, []);
+
// Signed out, the window starts over: nothing of the account is left in its memory either —
// no picture, no list, no cached answer — for whoever signs in next.
async function signOut(keep: boolean) {
@@ -72,17 +84,33 @@ export default function App() {
return (
<>
<div className="app-ground" aria-hidden="true" />
+ {lapsed && (
+ <div className="toast lapsed" role="alert">
+ <p>Apple signed you out. Your copy on this computer is still here.</p>
+ <button className="primary" onClick={() => setPhase("signin")}>
+ Sign In
+ </button>
+ <button className="quiet" onClick={() => setLapsed(false)}>
+ Not Now
+ </button>
+ </div>
+ )}
<Library onSignOut={signOut} />
+ <ImportSheet />
</>
);
return (
<div className="shell">
<div className="app-ground" aria-hidden="true" />
- {phase === "checking" && <span className="badge">Checking your session…</span>}
+ {phase === "checking" && <StatusLine tone="pending">Checking your session…</StatusLine>}
{phase === "signin" && (
<SignIn
- onResult={(r) => setPhase(r === "complete" ? "library" : "code")}
+ onCancel={lapsed ? () => setPhase("library") : undefined}
+ onResult={(r) => {
+ setLapsed(false);
+ setPhase(r === "complete" ? "library" : "code");
+ }}
/>
)}
{phase === "code" && (
diff --git a/src/components/Account.tsx b/src/components/Account.tsx
index 20f7cca..aeb087b 100644
--- a/src/components/Account.tsx
+++ b/src/components/Account.tsx
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { Face } from "./Face";
import { api, contactPhotoSrc, type AccountInfo } from "../lib/ipc";
-import { freshness, useSync } from "../lib/sync";
+import { freshness, useServiceState, useSync } from "../lib/sync";
/** "Asha Rao" → "AR"; an address → its first letter. */
export function initialsOf(name: string): string {
@@ -24,31 +24,81 @@ export function AccountAvatar({ account, large }: { account: AccountInfo | null;
);
}
+/** The app in front, as the account's footer speaks for it: its sync service and its name. */
+export type FooterApp = { service: string; name: string };
+
/**
* The account at the foot of the sidebar — who is signed in and how fresh their iCloud is —
* and the way into Settings, as System Settings puts the account at the head of its list.
+ *
+ * With an app in front it speaks for that app, as Mail's footer does for its mailboxes: how
+ * fresh that app is, and a quiet control to update it alone. In Settings it speaks for the
+ * whole account.
*/
-export function AccountCard({ current, onOpen }: { current: boolean; onOpen: () => void }) {
+export function AccountCard({ current, onOpen, app }: { current: boolean; onOpen: () => void; app?: FooterApp | null }) {
const [account, setAccount] = useState<AccountInfo | null>(null);
- const { report, syncing, error } = useSync();
+ const { report, syncing, error, refreshService, refresh: refreshAll } = useSync();
+ const own = useServiceState(app?.service ?? "");
+ // "Updated just now" has to become "2 min ago" without anything else happening.
+ const [, tick] = useState(0);
useEffect(() => {
api.accountInfo().then(setAccount, () => {});
+ const t = window.setInterval(() => tick((n) => n + 1), 30_000);
+ return () => window.clearInterval(t);
}, []);
- const failed = error || report?.services.some((s) => s.outcome === "failed");
- const status = syncing ? "Syncing…" : failed ? "Some things didn't update" : freshness(report?.asOf ?? null);
+ let failed: boolean;
+ let working: boolean;
+ let status: string;
+ // The whole sentence, naming the app: the sidebar has room for its short form only, as
+ // Mail's footer says "Updated Just Now" under the mailbox it is plainly about.
+ let full: string | undefined;
+ if (app) {
+ failed = own.failure !== null && !own.working;
+ working = own.working;
+ status = working
+ ? "Updating…"
+ : failed
+ ? own.failure!
+ : own.unavailable
+ ? "Not available"
+ : freshness(own.lastSyncedAt);
+ full = working
+ ? `Updating ${app.name}…`
+ : failed
+ ? `${app.name} didn’t update: ${own.failure}`
+ : own.unavailable
+ ? `${app.name} isn’t available`
+ : `${app.name} ${status.replace(/^\w/, (c) => c.toLowerCase())}`;
+ } else {
+ failed = !!(error || report?.services.some((s) => s.outcome === "failed"));
+ working = syncing;
+ status = syncing ? "Syncing…" : failed ? "Some things didn't update" : freshness(report?.asOf ?? null);
+ }
// The first name, as the menu bar greets someone: a full name did not fit the sidebar and
// ended in "…". Settings shows it whole.
const name = account?.name?.split(/\s+/)[0] ?? account?.email ?? "Settings";
+ // Two quiet lines, each one thing, as Mail's sidebar ends: how fresh this app is — the line
+ // itself the control that updates it, its dot turning while it does — and below it who is
+ // signed in, the way into Settings.
+ const refresh = () => void (app ? refreshService(app.service) : refreshAll());
return (
- <button className="sidebar-account" aria-current={current} onClick={onOpen} title="Settings">
- <AccountAvatar account={account} />
- <span className="sidebar-account-text">
+ <div className="sidebar-foot-stack">
+ <button
+ className={`sidebar-sync${failed ? " is-trouble" : ""}${working ? " is-working" : ""}`}
+ onClick={refresh}
+ disabled={working}
+ aria-busy={working}
+ title={working ? full ?? status : `${full ?? status}. Click to update now`}
+ aria-label={working ? full ?? status : `${full ?? status}. Update now`}
+ >
+ <span className={`sync-dot ${failed ? "trouble" : working ? "working" : "clean"}`} aria-hidden="true" />
+ <span className="sidebar-sync-text" aria-hidden="true">{status}</span>
+ <span className="sidebar-sync-now" aria-hidden="true">Update Now</span>
+ </button>
+ <button className="sidebar-account" aria-current={current} onClick={onOpen} title="Settings">
+ <AccountAvatar account={account} />
<span className="sidebar-account-name">{name}</span>
- <span className={`sidebar-account-status${failed ? " is-trouble" : ""}`}>
- <span className={`sync-dot ${failed ? "trouble" : syncing ? "working" : "clean"}`} aria-hidden="true" />
- {status}
- </span>
- </span>
- </button>
+ </button>
+ </div>
);
}
diff --git a/src/components/CodeInput.tsx b/src/components/CodeInput.tsx
index 83d61a7..d7deca9 100644
--- a/src/components/CodeInput.tsx
+++ b/src/components/CodeInput.tsx
@@ -11,21 +11,28 @@ export function CodeInput({
onChange,
onComplete,
disabled,
+ invalid,
}: {
value: string;
onChange: (next: string) => void;
onComplete: (code: string) => void;
disabled?: boolean;
+ invalid?: boolean;
}) {
const boxes = useRef<(HTMLInputElement | null)[]>([]);
- useEffect(() => {
- boxes.current[0]?.focus();
- }, []);
-
const digits = value.padEnd(6, " ").slice(0, 6).split("");
+ const firstEmpty = digits.findIndex((d) => !d.trim());
// The box Tab should land on: the first empty one, or the last if the code is complete.
- const activeIndex = Math.min(digits.findIndex((d) => !d.trim()) === -1 ? 5 : digits.findIndex((d) => !d.trim()), 5);
+ const activeIndex = firstEmpty === -1 ? 5 : firstEmpty;
+
+ // Into the first empty box whenever the boxes come back: on arrival, and after a code was
+ // checked — they were disabled while it was, and a disabled box drops focus.
+ useEffect(() => {
+ if (!disabled) boxes.current[activeIndex]?.focus();
+ // Only on enabling: following every keystroke would fight the arrows.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [disabled]);
function setAt(index: number, digit: string) {
const next = digits.map((d, i) => (i === index ? digit : d)).join("").trimEnd();
@@ -33,23 +40,36 @@ export function CodeInput({
return next;
}
+ /** Several digits at once — pasted, or filled by the system — written forward from `index`. */
+ function fill(index: number, typed: string) {
+ // A whole code always starts at the first box, wherever the caret was.
+ const start = typed.length >= 6 ? 0 : index;
+ const merged = (value.slice(0, start).replace(/\s/g, "") + typed).slice(0, 6);
+ onChange(merged);
+ boxes.current[Math.min(merged.length, 5)]?.focus();
+ if (merged.length === 6) onComplete(merged);
+ }
+
function handleChange(index: number, raw: string) {
- const typed = raw.replace(/\D/g, "");
+ let typed = raw.replace(/\D/g, "");
if (!typed) return;
- // Typing or pasting several digits at once fills forward from here.
- if (typed.length > 1) {
- const merged = (value.slice(0, index) + typed).replace(/\D/g, "").slice(0, 6);
- onChange(merged);
- const landed = Math.min(merged.length, 5);
- boxes.current[landed]?.focus();
- if (merged.length === 6) onComplete(merged);
- return;
- }
+ // Typing over a box that already holds a digit, without it selected, gives both: keep
+ // the new one.
+ const old = digits[index].trim();
+ if (typed.length === 2 && old && typed.startsWith(old)) typed = typed.slice(1);
+ if (typed.length > 1) return fill(index, typed);
const next = setAt(index, typed);
if (index < 5) boxes.current[index + 1]?.focus();
if (next.replace(/\s/g, "").length === 6) onComplete(next);
}
+ function handlePaste(index: number, e: React.ClipboardEvent<HTMLInputElement>) {
+ // "481 516" or "481-516", as messages and password managers write it.
+ const typed = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, 6);
+ e.preventDefault();
+ if (typed) fill(index, typed);
+ }
+
function handleKeyDown(index: number, e: React.KeyboardEvent<HTMLInputElement>) {
if (e.key === "Backspace") {
e.preventDefault();
@@ -60,14 +80,20 @@ export function CodeInput({
boxes.current[index - 1]?.focus();
}
} else if (e.key === "ArrowLeft" && index > 0) {
+ e.preventDefault();
boxes.current[index - 1]?.focus();
} else if (e.key === "ArrowRight" && index < 5) {
+ e.preventDefault();
boxes.current[index + 1]?.focus();
}
}
return (
- <div className="code" role="group" aria-label="Six-digit verification code">
+ <div
+ className={`code${invalid ? " is-invalid" : ""}`}
+ role="group"
+ aria-label="Six-digit verification code"
+ >
{digits.map((digit, i) => (
<Fragment key={i}>
{i === 3 && <span className="gap" aria-hidden="true" />}
@@ -78,13 +104,16 @@ export function CodeInput({
value={digit.trim()}
onChange={(e) => handleChange(i, e.target.value)}
onKeyDown={(e) => handleKeyDown(i, e)}
+ onPaste={(e) => handlePaste(i, e)}
onFocus={(e) => e.target.select()}
+ onMouseUp={(e) => e.preventDefault()}
tabIndex={i === activeIndex ? 0 : -1}
inputMode="numeric"
autoComplete={i === 0 ? "one-time-code" : "off"}
maxLength={6}
disabled={disabled}
aria-label={`Digit ${i + 1}`}
+ aria-invalid={invalid || undefined}
/>
</Fragment>
))}
diff --git a/src/components/Confirm.tsx b/src/components/Confirm.tsx
new file mode 100644
index 0000000..568a0fe
--- /dev/null
+++ b/src/components/Confirm.tsx
@@ -0,0 +1,136 @@
+/**
+ * A question before a change, asked one way everywhere: a sheet over the dimmed window — a
+ * symbol when it helps, the question in bold, a line on what follows, and the answers. Two
+ * answers sit side by side, Cancel first; more stack, the usual one on top, as macOS stacks
+ * an alert's choices. Escape or a click outside is Cancel, and Cancel has the focus unless
+ * another answer is the safe default, so Return never deletes by accident.
+ *
+ * It replaces the browser's own confirm() — a toolkit dialog in WebKitGTK, unlike anything else
+ * in the window — and the four sheets Photos, Calendar and Settings each drew their own way.
+ */
+import { useCallback, useRef, useState } from "react";
+import { EyeOff, Trash2 } from "lucide-react";
+import { Portal } from "./Portal";
+
+export type Choice<T> = {
+ label: string;
+ value: T;
+ /** The filled button: what Return does. */
+ primary?: boolean;
+ /** Red: it destroys. */
+ danger?: boolean;
+ /** Where the focus starts. */
+ focus?: boolean;
+};
+
+export function ConfirmSheet<T>({
+ title,
+ label,
+ body,
+ symbol,
+ choices,
+ onAnswer,
+ onCancel,
+ children,
+}: {
+ title: string;
+ /** Its name for a screen reader, when the title is not it. */
+ label?: string;
+ body?: React.ReactNode;
+ symbol?: "trash" | "hide";
+ /** The answers besides Cancel, in order. */
+ choices: Choice<T>[];
+ onAnswer: (value: T) => void;
+ onCancel: () => void;
+ children?: React.ReactNode;
+}) {
+ const stacked = choices.length > 1;
+ const focusCancel = !choices.some((c) => c.focus);
+ const cancel = (
+ <button key="cancel" className="quiet" autoFocus={focusCancel} onClick={onCancel}>
+ Cancel
+ </button>
+ );
+ const answers = choices.map((c) => (
+ <button
+ key={c.label}
+ className={`${c.primary ? "primary" : "quiet"}${c.danger ? " danger" : ""} confirm-answer`}
+ autoFocus={c.focus}
+ onClick={() => onAnswer(c.value)}
+ >
+ {c.label}
+ </button>
+ ));
+ return (
+ <Portal>
+ <div className="modal-veil" onClick={onCancel}>
+ <div
+ className="modal-sheet confirm"
+ role="alertdialog"
+ aria-modal="true"
+ aria-label={label ?? title}
+ onClick={(e) => e.stopPropagation()}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") {
+ e.stopPropagation();
+ onCancel();
+ }
+ }}
+ >
+ {symbol && (
+ <span className="confirm-symbol" aria-hidden="true">
+ {symbol === "trash" ? <Trash2 size={28} strokeWidth={1.6} /> : <EyeOff size={28} strokeWidth={1.6} />}
+ </span>
+ )}
+ <h2>{title}</h2>
+ {body && <p>{body}</p>}
+ {children}
+ <div className={`confirm-actions${stacked ? " is-stacked" : ""}`}>
+ {stacked ? [...answers, cancel] : [cancel, ...answers]}
+ </div>
+ </div>
+ </div>
+ </Portal>
+ );
+}
+
+export type Question = {
+ title: string;
+ body?: string;
+ /** The word on the button that goes ahead. */
+ action: string;
+ /** Red, for a change that destroys. */
+ danger?: boolean;
+ symbol?: "trash" | "hide";
+};
+
+/** `const [confirm, sheet] = useConfirm()`: `await confirm({...})` is true to go ahead. */
+export function useConfirm(): [(q: Question) => Promise<boolean>, React.ReactNode] {
+ const [asking, setAsking] = useState<Question | null>(null);
+ const answer = useRef<((yes: boolean) => void) | null>(null);
+ const confirm = useCallback(
+ (q: Question) =>
+ new Promise<boolean>((resolve) => {
+ answer.current?.(false);
+ answer.current = resolve;
+ setAsking(q);
+ }),
+ [],
+ );
+ const done = (yes: boolean) => {
+ answer.current?.(yes);
+ answer.current = null;
+ setAsking(null);
+ };
+ const sheet = asking && (
+ <ConfirmSheet
+ title={asking.title}
+ body={asking.body}
+ symbol={asking.symbol}
+ choices={[{ label: asking.action, value: true, primary: true, danger: asking.danger }]}
+ onAnswer={() => done(true)}
+ onCancel={() => done(false)}
+ />
+ );
+ return [confirm, sheet];
+}
diff --git a/src/components/EmptyState.tsx b/src/components/EmptyState.tsx
new file mode 100644
index 0000000..116bc51
--- /dev/null
+++ b/src/components/EmptyState.tsx
@@ -0,0 +1,53 @@
+import { useArriving } from "../lib/sync";
+import { Spinner } from "./Spinner";
+
+/**
+ * What a pane says when it has nothing to show, said one way in every app: a symbol, one line,
+ * and the one thing to do next when there is one — centred in the pane. While something is on
+ * its way it turns into the same line with a spinner, in the same place, so nothing jumps
+ * when it lands.
+ */
+export function EmptyState({
+ icon,
+ busy,
+ action,
+ className,
+ children,
+}: {
+ icon?: React.ReactNode;
+ /** On its way: a spinner, announced politely. */
+ busy?: boolean;
+ action?: { label: string; run: () => void; disabled?: boolean };
+ /** A screen's own hook for it (tests, layout), never its look. */
+ className?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div
+ className={`empty-state${className ? ` ${className}` : ""}`}
+ role={busy ? "status" : undefined}
+ aria-live={busy ? "polite" : undefined}
+ >
+ {busy ? <Spinner /> : icon && <span className="empty-state-icon" aria-hidden="true">{icon}</span>}
+ <p>{children}</p>
+ {action && (
+ <button className="primary" onClick={action.run} disabled={action.disabled}>
+ {action.label}
+ </button>
+ )}
+ </div>
+ );
+}
+
+/**
+ * A first sync, said where the content will be: what is coming, and that it is moving. Shown in
+ * place of an empty state until the service has landed once, and then never again.
+ */
+export function Arriving({ service, what, className }: { service: string; what: string; className?: string }) {
+ if (!useArriving(service)) return null;
+ return (
+ <EmptyState busy className={`arriving${className ? ` ${className}` : ""}`}>
+ Getting your {what} from iCloud…
+ </EmptyState>
+ );
+}
diff --git a/src/components/GlobalSearch.tsx b/src/components/GlobalSearch.tsx
index 9d26a27..ed30be5 100644
--- a/src/components/GlobalSearch.tsx
+++ b/src/components/GlobalSearch.tsx
@@ -8,8 +8,8 @@
* opens it, Escape puts the results away (and a second Escape clears the field). A section with
* more than it shows has Show All, which shows that one whole, in place.
*/
+import { SearchField } from "./SearchField";
import { useEffect, useMemo, useRef, useState } from "react";
-import { Search, X } from "lucide-react";
import {
api,
contactPhotoSrc,
@@ -219,31 +219,26 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =
}, [showing]);
return (
<div className="gsearch" ref={box}>
- <label className="gsearch-field">
- <Search size={14} strokeWidth={2.2} aria-hidden="true" />
- <input
- ref={field}
- type="search"
- placeholder="Search"
- aria-label="Search everything"
- aria-expanded={showing}
- aria-controls="gsearch-results"
- aria-activedescendant={showing && rows[at] ? `gs-${rows[at].key}` : undefined}
- role="combobox"
- value={query}
- onChange={(e) => {
- setQuery(e.target.value);
- setOpen(true);
- }}
- onFocus={() => query && setOpen(true)}
- onKeyDown={onKey}
- />
- {query && (
- <button className="gsearch-clear" aria-label="Clear search" onClick={() => { setQuery(""); field.current?.focus(); }}>
- <X size={12} strokeWidth={2.4} aria-hidden="true" />
- </button>
- )}
- </label>
+ <SearchField
+ ref={field}
+ placeholder="Search"
+ aria-label="Search everything"
+ aria-expanded={showing}
+ aria-controls="gsearch-results"
+ aria-activedescendant={showing && rows[at] ? `gs-${rows[at].key}` : undefined}
+ role="combobox"
+ value={query}
+ onChange={(v) => {
+ setQuery(v);
+ setOpen(true);
+ }}
+ onClear={() => {
+ setQuery("");
+ field.current?.focus();
+ }}
+ onFocus={() => query && setOpen(true)}
+ onKeyDown={onKey}
+ />
{showing && place && (
<Portal>
<div
diff --git a/src/components/ImportSheet.tsx b/src/components/ImportSheet.tsx
new file mode 100644
index 0000000..b3d482f
--- /dev/null
+++ b/src/components/ImportSheet.tsx
@@ -0,0 +1,287 @@
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { listen } from "@tauri-apps/api/event";
+import { api, intakeApi, INTAKE, type Arrival, type Calendar, type ImportEvent } from "../lib/ipc";
+import { Picker } from "./Picker";
+import "../styles/intake.css";
+
+/**
+ * A calendar or contacts file opened with Pomander (src-tauri/src/intake.rs): what it holds,
+ * read on this computer, and one button that adds it. Nothing reaches iCloud until then, and
+ * what can't be added is listed with why, rather than left out unsaid.
+ *
+ * Mounted once per window; it shows the files that arrived for this window, one at a time.
+ */
+export function ImportSheet() {
+ const [queue, setQueue] = useState<Arrival[]>([]);
+
+ const collect = useCallback(() => {
+ intakeApi
+ .pending()
+ .then((more) => more.length && setQueue((q) => [...q, ...more]))
+ .catch(() => {});
+ }, []);
+
+ useEffect(() => {
+ collect();
+ const stop = listen(INTAKE, collect);
+ return () => {
+ void stop.then((unlisten) => unlisten()).catch(() => {});
+ };
+ }, [collect]);
+
+ const current = queue[0];
+ if (!current) return null;
+ const done = () => setQueue((q) => q.slice(1));
+ return createPortal(
+ <div className="modal-veil ix-veil">
+ {current.kind === "events" ? (
+ <EventsSheet key={current.file + queue.length} arrival={current} onDone={done} />
+ ) : current.kind === "contacts" ? (
+ <ContactsSheet key={current.file + queue.length} arrival={current} onDone={done} />
+ ) : (
+ <Shell label={`Can’t open “${current.file}”`} onCancel={done}>
+ <h2>Can’t open “{current.file}”</h2>
+ <p className="ix-reason">{current.reason}</p>
+ <div className="sheet-actions">
+ <button className="primary" autoFocus onClick={done}>
+ OK
+ </button>
+ </div>
+ </Shell>
+ )}
+ </div>,
+ document.body,
+ );
+}
+
+function Shell({ label, onCancel, children }: { label: string; onCancel: () => void; children: React.ReactNode }) {
+ return (
+ <div
+ className="modal-sheet ix-sheet"
+ role="dialog"
+ aria-modal="true"
+ aria-label={label}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") {
+ e.stopPropagation();
+ onCancel();
+ }
+ }}
+ >
+ {children}
+ </div>
+ );
+}
+
+const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;
+
+/** When an event is, as Calendar says it: the day, and its time in its own zone. */
+function when(e: ImportEvent): string {
+ const day: Intl.DateTimeFormatOptions = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
+ if (e.allDay) {
+ const last = e.endsAt - 86400;
+ const first = new Date(e.startsAt * 1000).toLocaleDateString(undefined, day);
+ return last > e.startsAt ? `${first} – ${new Date(last * 1000).toLocaleDateString(undefined, day)}` : `${first}, all day`;
+ }
+ const zone = e.timezone ?? undefined;
+ const fmt = (t: number, o: Intl.DateTimeFormatOptions) => {
+ try {
+ return new Date(t * 1000).toLocaleString(undefined, { ...o, timeZone: zone });
+ } catch {
+ return new Date(t * 1000).toLocaleString(undefined, o);
+ }
+ };
+ const time: Intl.DateTimeFormatOptions = { hour: "numeric", minute: "2-digit" };
+ const start = fmt(e.startsAt, { ...day, ...time });
+ const end = e.endsAt > e.startsAt ? `–${fmt(e.endsAt, time)}` : "";
+ const here = Intl.DateTimeFormat().resolvedOptions().timeZone;
+ const elsewhere = zone && zone !== here ? ` (${zone.replace(/_/g, " ")})` : "";
+ return `${start}${end}${elsewhere}`;
+}
+
+function repeatPhrase(e: ImportEvent): string | null {
+ const r = e.repeat;
+ if (!r) return null;
+ const unit = { daily: "day", weekly: "week", monthly: "month", yearly: "year" }[r.freq];
+ const every = r.interval === 1 ? `Every ${unit}` : `Every ${r.interval} ${unit}s`;
+ return r.count ? `${every}, ${r.count} times` : every;
+}
+
+function EventsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "events" }>; onDone: () => void }) {
+ const [calendars, setCalendars] = useState<Calendar[] | null>(null);
+ const [target, setTarget] = useState("");
+ const [busy, setBusy] = useState<{ done: number; failed: string[] } | null>(null);
+ const [finished, setFinished] = useState<string | null>(null);
+ const fresh = useMemo(() => arrival.events.filter((e) => !e.duplicate), [arrival]);
+
+ useEffect(() => {
+ api
+ .calendarList()
+ .then((all) => {
+ // Only the account's own calendars take a new event: not a subscribed feed, not the
+ // Birthdays and Holidays calendars Pomander draws itself.
+ const writable = all.filter((c) => c.writable && !c.guid.startsWith("quince:"));
+ setCalendars(writable);
+ setTarget((t) => t || (writable.find((c) => c.isDefault) ?? writable[0])?.guid || "");
+ })
+ .catch(() => setCalendars([]));
+ }, []);
+
+ async function add() {
+ let failed: string[] = [];
+ setBusy({ done: 0, failed });
+ for (const [i, e] of fresh.entries()) {
+ try {
+ await api.eventSave({
+ guid: null,
+ calendarGuid: target,
+ title: e.title,
+ location: e.location,
+ startsAt: e.startsAt,
+ endsAt: e.endsAt,
+ allDay: e.allDay,
+ timezone: e.timezone,
+ notes: e.notes,
+ url: e.url,
+ ...(e.alerts ? { alerts: e.alerts } : {}),
+ ...(e.repeat ? { repeat: e.repeat, repeatChanged: true } : {}),
+ });
+ } catch (err) {
+ failed = [...failed, `${e.title}: ${String(err)}`];
+ }
+ setBusy({ done: i + 1, failed });
+ }
+ // The calendar's screens redraw from the library once the pass lands.
+ api.syncSome(["calendar"]).catch(() => {});
+ if (failed.length === 0) return onDone();
+ setBusy(null);
+ setFinished(
+ `${plural(fresh.length - failed.length, "event was", "events were")} added. ${plural(failed.length, "wasn’t", "weren’t")}:\n${failed.join("\n")}`,
+ );
+ }
+
+ const single = fresh.length === 1;
+ const heading =
+ fresh.length === 0
+ ? arrival.events.length > 0
+ ? "These events are already in your calendar"
+ : "Nothing in this file can be added"
+ : single
+ ? `Add “${fresh[0].title}” to`
+ : `Add ${fresh.length} events to`;
+ const options = (calendars ?? []).map((c) => ({ value: c.guid, label: c.title }));
+
+ return (
+ <Shell label={`Import “${arrival.file}”`} onCancel={onDone}>
+ <div className="ix-head">
+ <h2>{heading}</h2>
+ {fresh.length > 0 && calendars && calendars.length > 0 && (
+ <Picker value={target} options={options} onChange={setTarget} label="Calendar" disabled={!!busy} />
+ )}
+ </div>
+ <p className="ix-file">{arrival.file}</p>
+ <ul className="ix-list" aria-label="Events in this file">
+ {arrival.events.map((e, i) => (
+ <li key={i} className={e.duplicate ? "is-skipped" : undefined}>
+ <span className="ix-title">{e.title}</span>
+ <span className="ix-sub">{when(e)}</span>
+ {(repeatPhrase(e) || e.duplicate) && (
+ <span className="ix-sub">{e.duplicate ? "Already in your calendar" : repeatPhrase(e)}</span>
+ )}
+ </li>
+ ))}
+ {arrival.refused.map((r, i) => (
+ <li key={`r${i}`} className="is-refused">
+ <span className="ix-title">{r.title}</span>
+ <span className="ix-sub">Can’t be added. {r.reason}</span>
+ </li>
+ ))}
+ </ul>
+ {calendars && calendars.length === 0 && fresh.length > 0 && (
+ <p className="ix-reason">This account has no calendar that can take new events.</p>
+ )}
+ {finished && <p className="ix-reason ix-error">{finished}</p>}
+ <div className="sheet-actions">
+ {finished || fresh.length === 0 ? (
+ <button className="primary" autoFocus onClick={onDone}>
+ {finished ? "Done" : "OK"}
+ </button>
+ ) : (
+ <>
+ <button className="quiet" onClick={onDone} disabled={!!busy}>
+ Cancel
+ </button>
+ <button className="primary" autoFocus onClick={add} disabled={!!busy || !target}>
+ {busy ? `Adding ${busy.done + 1 > fresh.length ? fresh.length : busy.done + 1} of ${fresh.length}…` : single ? "Add Event" : `Add ${fresh.length} Events`}
+ </button>
+ </>
+ )}
+ </div>
+ </Shell>
+ );
+}
+
+function ContactsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "contacts" }>; onDone: () => void }) {
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const live = useRef(true);
+ useEffect(() => () => void (live.current = false), []);
+ const fresh = arrival.contacts.filter((c) => !c.known);
+ const single = fresh.length === 1;
+ const heading =
+ fresh.length === 0
+ ? arrival.contacts.length === 1
+ ? `${arrival.contacts[0].name} is already in Contacts`
+ : "Everyone in this file is already in Contacts"
+ : single
+ ? `Add contact ${fresh[0].name}`
+ : `Add ${fresh.length} contacts`;
+
+ async function add() {
+ setBusy(true);
+ setError(null);
+ try {
+ // The same import the Contacts app's own Import uses: someone already there is left out.
+ await api.contactsImport([arrival.path]);
+ if (live.current) onDone();
+ } catch (err) {
+ if (live.current) {
+ setBusy(false);
+ setError(String(err));
+ }
+ }
+ }
+
+ return (
+ <Shell label={`Import “${arrival.file}”`} onCancel={onDone}>
+ <h2>{heading}</h2>
+ <p className="ix-file">{arrival.file}</p>
+ <ul className="ix-list" aria-label="Contacts in this file">
+ {arrival.contacts.map((c, i) => (
+ <li key={i} className={c.known ? "is-skipped" : undefined}>
+ <span className="ix-title">{c.name}</span>
+ {(c.detail || c.known) && <span className="ix-sub">{c.known ? "Already in Contacts" : c.detail}</span>}
+ </li>
+ ))}
+ </ul>
+ {error && <p className="ix-reason ix-error">{error}</p>}
+ <div className="sheet-actions">
+ {fresh.length === 0 ? (
+ <button className="primary" autoFocus onClick={onDone}>
+ OK
+ </button>
+ ) : (
+ <>
+ <button className="quiet" onClick={onDone} disabled={busy}>
+ Cancel
+ </button>
+ <button className="primary" autoFocus onClick={add} disabled={busy}>
+ {busy ? "Adding…" : single ? "Add Contact" : `Add ${fresh.length} Contacts`}
+ </button>
+ </>
+ )}
+ </div>
+ </Shell>
+ );
+}
diff --git a/src/components/Notice.tsx b/src/components/Notice.tsx
deleted file mode 100644
index f44c81d..0000000
--- a/src/components/Notice.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { TriangleAlert, X } from "lucide-react";
-
-/**
- * Something went wrong, said once and plainly, beside a way to put it away.
- *
- * Every screen showed failures as a bare red line — on Reminders, CloudKit's own JSON in
- * full — that stayed until something else replaced it.
- */
-export function Notice({ message, onDismiss }: { message: string; onDismiss: () => void }) {
- return (
- <div className="notice" role="alert">
- <TriangleAlert size={15} strokeWidth={2} aria-hidden="true" />
- <p>{message}</p>
- <button className="notice-close" aria-label="Dismiss" title="Dismiss" onClick={onDismiss}>
- <X size={14} strokeWidth={2.25} aria-hidden="true" />
- </button>
- </div>
- );
-}
diff --git a/src/components/PaneTitle.tsx b/src/components/PaneTitle.tsx
new file mode 100644
index 0000000..edfb2e3
--- /dev/null
+++ b/src/components/PaneTitle.tsx
@@ -0,0 +1,52 @@
+import { useLayoutEffect, useRef } from "react";
+
+/**
+ * A pane's title, with how much is in it on its own small line beneath — as Notes and Mail put
+ * "1 note" under a folder's name. The title has its column's whole width: a long one wraps to
+ * two lines, and if two lines at the full size are still not enough it steps down one size;
+ * only past that is it clamped. A title is never cut off to make room for a count or a button.
+ */
+export function PaneTitle({
+ children,
+ count,
+ countLabel,
+ countClassName,
+ className,
+ before,
+}: {
+ children: React.ReactNode;
+ /** The small line under it: "3 notes". */
+ count?: React.ReactNode;
+ countLabel?: string;
+ /** A screen's own hook for the count line. */
+ countClassName?: string;
+ className?: string;
+ /** Above the title: a path back, for a pane opened inside another. */
+ before?: React.ReactNode;
+}) {
+ const title = useRef<HTMLHeadingElement>(null);
+ useLayoutEffect(() => {
+ const el = title.current;
+ if (!el) return undefined;
+ // Measured, not guessed from its length: the column's width is what decides it.
+ const fit = () => {
+ el.classList.remove("is-small");
+ if (el.scrollHeight > el.clientHeight + 1) el.classList.add("is-small");
+ };
+ fit();
+ const watch = new ResizeObserver(fit);
+ watch.observe(el.parentElement ?? el);
+ return () => watch.disconnect();
+ }, [children]);
+ return (
+ <div className={`pane-title${className ? ` ${className}` : ""}`}>
+ {before}
+ <h1 ref={title}>{children}</h1>
+ {count !== undefined && count !== null && count !== false && (
+ <p className={`pane-count${countClassName ? ` ${countClassName}` : ""}`} aria-label={countLabel}>
+ {count}
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/Picker.tsx b/src/components/Picker.tsx
index 0bb756e..12bcaf4 100644
--- a/src/components/Picker.tsx
+++ b/src/components/Picker.tsx
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { Portal } from "./Portal";
+import { useTypeSelect } from "./RowMenu";
export type PickerOption = { value: string; label: string };
@@ -187,6 +188,7 @@ export function Picker({
};
}, [open]);
+ const typeSelect = useTypeSelect(() => options.map((o) => o.label));
const onListKey = (e: React.KeyboardEvent) => {
// From the highlight as it stands after any key not yet drawn, not as last rendered.
const move = (to: (at: number) => number) => {
@@ -199,6 +201,15 @@ export function Picker({
}
setActive((at) => Math.max(0, Math.min(to(at), options.length - 1)));
};
+ // Typing goes to the choice that begins with it, as a Mac pop-up's menu does.
+ const typedTo = typeSelect(e, litNow.current ? active : -1);
+ if (typedTo !== null) {
+ e.preventDefault();
+ byKeyboard.current = true;
+ setLit(true);
+ setActive(typedTo);
+ return;
+ }
if (e.key === "ArrowDown") move((at) => at + 1);
else if (e.key === "ArrowUp") move((at) => at - 1);
else if (e.key === "Home") move(() => 0);
diff --git a/src/components/QuickCapture.tsx b/src/components/QuickCapture.tsx
new file mode 100644
index 0000000..d7646e9
--- /dev/null
+++ b/src/components/QuickCapture.tsx
@@ -0,0 +1,196 @@
+import { useEffect, useRef, useState } from "react";
+import { invoke } from "@tauri-apps/api/core";
+import { listen } from "@tauri-apps/api/event";
+import { api, intakeApi, CAPTURE } from "../lib/ipc";
+import { Picker, type PickerOption } from "./Picker";
+import "../styles/intake.css";
+
+type Kind = "reminder" | "note";
+
+/** Where a reminder made in Today or All goes in the Reminders app: the list last added to. */
+const DEFAULT_LIST = "quince.reminders.defaultList";
+/** The Notes folder a note made without one goes to, at Apple. */
+const DEFAULT_FOLDER = "DefaultFolder-CloudKit";
+const TRASH_FOLDER = "TrashFolder-CloudKit";
+
+const stored = (key: string) => {
+ try {
+ return window.localStorage.getItem(key);
+ } catch {
+ return null;
+ }
+};
+
+/**
+ * The quick-capture window (`pomander --new reminder`, `--new note`): one field, Enter, and it
+ * is in iCloud — a reminder in the list last added to, a note in Notes — and the window goes.
+ * Escape leaves without making anything.
+ */
+export function QuickCapture({ initial }: { initial: Kind }) {
+ const [kind, setKind] = useState<Kind>(initial);
+ const [text, setText] = useState("");
+ const [where, setWhere] = useState<PickerOption[] | null>(null);
+ const [target, setTarget] = useState("");
+ const [state, setState] = useState<"idle" | "saving" | "signin">("idle");
+ const [error, setError] = useState<string | null>(null);
+ const field = useRef<HTMLInputElement | null>(null);
+
+ useEffect(() => {
+ document.documentElement.dataset.app = kind === "note" ? "notes" : "reminders";
+ document.title = kind === "note" ? "New Note" : "New Reminder";
+ }, [kind]);
+
+ // Asked for again from the launcher, perhaps for the other kind.
+ useEffect(() => {
+ const stop = listen<Kind>(CAPTURE, (e) => {
+ if (e.payload === "note" || e.payload === "reminder") setKind(e.payload);
+ // A fresh field each time, whatever the last one was left at.
+ setText("");
+ setState("idle");
+ requestAnimationFrame(() => field.current?.focus());
+ });
+ return () => {
+ void stop.then((unlisten) => unlisten()).catch(() => {});
+ };
+ }, []);
+
+ useEffect(() => {
+ let live = true;
+ setWhere(null);
+ setError(null);
+ (async () => {
+ try {
+ if (kind === "reminder") {
+ const lists = (await api.reminderLists()).filter((l) => l.enabled);
+ if (!live) return;
+ const kept = stored(DEFAULT_LIST);
+ setWhere(lists.map((l) => ({ value: l.guid, label: l.title })));
+ setTarget(lists.some((l) => l.guid === kept) ? (kept as string) : (lists[0]?.guid ?? ""));
+ } else {
+ const folders = (await api.noteFolders()).filter((f) => f.guid !== TRASH_FOLDER && f.guid !== DEFAULT_FOLDER);
+ if (!live) return;
+ setWhere([{ value: DEFAULT_FOLDER, label: "Notes" }, ...folders.map((f) => ({ value: f.guid, label: f.title }))]);
+ setTarget(DEFAULT_FOLDER);
+ }
+ } catch {
+ if (live) setWhere([]);
+ }
+ })();
+ return () => {
+ live = false;
+ };
+ }, [kind]);
+
+ // Shown once drawn, never as a blank frame (window_ready, main.rs).
+ useEffect(() => {
+ requestAnimationFrame(() =>
+ requestAnimationFrame(() => {
+ invoke("window_ready", { needsYou: true }).catch(() => {});
+ field.current?.focus();
+ }),
+ );
+ }, []);
+
+ const close = () => void intakeApi.captureClose().catch(() => window.close());
+
+ async function save() {
+ const title = text.trim();
+ if (!title || state === "saving") return;
+ if (kind === "reminder" && !target) return;
+ setState("saving");
+ setError(null);
+ try {
+ // Started from the launcher, Pomander may still be signing back in: done here first, so
+ // the write does not race it.
+ const status = await api.status();
+ if (!status.signedIn) {
+ const next = status.hasStoredSession ? await api.resume() : "signin";
+ if (next !== "library") {
+ setState("signin");
+ return;
+ }
+ }
+ if (kind === "reminder") {
+ await api.reminderCreate(target, title);
+ try {
+ window.localStorage.setItem(DEFAULT_LIST, target);
+ } catch {
+ /* forgets the choice; nothing else */
+ }
+ } else {
+ await api.noteCreate(target === DEFAULT_FOLDER ? null : target, title);
+ }
+ close();
+ } catch (err) {
+ setState("idle");
+ setError(String(err));
+ }
+ }
+
+ const noun = kind === "note" ? "Note" : "Reminder";
+ return (
+ <main
+ className="qc"
+ onKeyDown={(e) => {
+ if (e.key === "Escape" && !document.querySelector(".picker-menu")) {
+ e.preventDefault();
+ close();
+ }
+ }}
+ >
+ <form
+ className="qc-row"
+ onSubmit={(e) => {
+ e.preventDefault();
+ void save();
+ }}
+ >
+ <span className="qc-mark" aria-hidden="true" data-kind={kind} />
+ <input
+ ref={field}
+ className="qc-field"
+ aria-label={`New ${noun}`}
+ placeholder={`New ${noun}`}
+ value={text}
+ disabled={state === "saving"}
+ onChange={(e) => setText(e.target.value)}
+ autoFocus
+ spellCheck
+ />
+ </form>
+ <div className="qc-foot">
+ {where && where.length > 0 ? (
+ <Picker
+ value={target}
+ options={where}
+ onChange={setTarget}
+ label={kind === "note" ? "Folder" : "List"}
+ disabled={state === "saving"}
+ />
+ ) : where ? (
+ <span className="qc-note">
+ {kind === "reminder" ? "No lists yet. Make one in Reminders first." : "Notes"}
+ </span>
+ ) : (
+ <span />
+ )}
+ <span className="qc-note" role="status">
+ {state === "saving" ? (
+ "Saving…"
+ ) : state === "signin" ? (
+ <>
+ Sign in to Pomander first.{" "}
+ <button type="button" className="link qc-link" onClick={() => void intakeApi.openMain()}>
+ Open Pomander
+ </button>
+ </>
+ ) : error ? (
+ <span className="qc-error">{error}</span>
+ ) : (
+ "Enter to add"
+ )}
+ </span>
+ </div>
+ </main>
+ );
+}
diff --git a/src/components/RowMenu.tsx b/src/components/RowMenu.tsx
index 24511fb..76a7840 100644
--- a/src/components/RowMenu.tsx
+++ b/src/components/RowMenu.tsx
@@ -20,6 +20,38 @@ export type MenuEntry =
type Anchor = { x: number; y: number; alignRight: boolean };
+/**
+ * Type-select, as every Mac menu and list has it: letters typed in quick succession go to the
+ * line that begins with them; the same letter again steps on through the lines that begin
+ * with it. A pause (a second) starts afresh.
+ *
+ * Returns a function that takes a key and the line now lit, and gives the line to light, or
+ * null when the key is not typing (or nothing matches).
+ */
+export function useTypeSelect(labels: () => string[]) {
+ const typed = useRef({ text: "", at: 0 });
+ return (e: { key: string; ctrlKey: boolean; metaKey: boolean; altKey: boolean }, from: number): number | null => {
+ if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey) return null;
+ const now = performance.now();
+ const fresh = now - typed.current.at > 1000;
+ // A space begins nothing; mid-word it is part of what is typed.
+ if (e.key === " " && fresh) return null;
+ typed.current = { text: (fresh ? "" : typed.current.text) + e.key.toLowerCase(), at: now };
+ const text = typed.current.text;
+ const names = labels().map((l) => l.toLowerCase());
+ const n = names.length;
+ // One letter, again and again: the next line after this one that begins with it.
+ const repeat = [...text].every((c) => c === text[0]);
+ const want = repeat ? text[0] : text;
+ const start = repeat ? from + 1 : Math.max(0, from);
+ for (let k = 0; k < n; k++) {
+ const i = (start + k + n) % n;
+ if (names[i].startsWith(want)) return i;
+ }
+ return null;
+ };
+}
+
/**
* A menu as macOS draws one: under the ⋯ that opened it or at the pointer for a right-click,
* kept on screen; arrows to move, Return to choose, Escape or a click elsewhere to leave.
@@ -113,6 +145,7 @@ function Panel({
// Nothing highlighted until the pointer or a key says so, as a Mac menu opens.
const [active, setActive] = useState(focusFirst ? 0 : -1);
const [sub, setSub] = useState<{ index: number; byKeyboard: boolean } | null>(null);
+ const typeSelect = useTypeSelect(() => items.map((e) => e.label));
/**
* Menu aim, as macOS has it: with a submenu open, a pointer heading into it — inside the
* triangle from where it just was to the submenu's near edge — may cross other lines
@@ -207,6 +240,11 @@ function Panel({
tabIndex={-1}
style={pos ? { left: pos.left, top: pos.top } : { left: 0, top: 0, visibility: "hidden" }}
onMouseEnter={onArrive}
+ // The pointer gone off the menu takes its highlight with it, as on the Mac — unless a
+ // submenu is open from the lit line, which stays lit while it is.
+ onMouseLeave={() => {
+ if (!sub) setActive(-1);
+ }}
onMouseMove={(e) => {
last.current = { x: e.clientX, y: e.clientY };
}}
@@ -217,7 +255,20 @@ function Panel({
e.preventDefault();
setActive((a) => (a < 0 ? (by > 0 ? 0 : items.length - 1) : (a + by + items.length) % items.length));
};
- if (e.key === "Escape" || e.key === "ArrowLeft") {
+ const typedTo = typeSelect(e, active);
+ if (typedTo !== null) {
+ e.preventDefault();
+ setActive(typedTo);
+ } else if (e.key.length === 1 && e.key !== " ") {
+ // A letter nothing begins with: used up here, as a Mac menu takes it.
+ e.preventDefault();
+ } else if (e.key === "Home" || e.key === "PageUp") {
+ e.preventDefault();
+ setActive(0);
+ } else if (e.key === "End" || e.key === "PageDown") {
+ e.preventDefault();
+ setActive(items.length - 1);
+ } else if (e.key === "Escape" || e.key === "ArrowLeft") {
e.preventDefault();
e.stopPropagation();
onBack();
diff --git a/src/components/SearchField.tsx b/src/components/SearchField.tsx
new file mode 100644
index 0000000..92fde9f
--- /dev/null
+++ b/src/components/SearchField.tsx
@@ -0,0 +1,34 @@
+import { forwardRef } from "react";
+import { Search, X } from "lucide-react";
+
+type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "onChange" | "type" | "className"> & {
+ value: string;
+ onChange: (value: string) => void;
+ /** Given, a ✕ clears what is typed. */
+ onClear?: () => void;
+ /** In a toolbar, it takes the toolbar's capsule beside the other controls. */
+ inToolbar?: boolean;
+ className?: string;
+};
+
+/**
+ * The search field, one shape everywhere: a capsule with the magnifier, the words, and a ✕
+ * once something is typed. In a sidebar or a list it is a soft fill; in a toolbar it is one
+ * more capsule of the toolbar.
+ */
+export const SearchField = forwardRef<HTMLInputElement, Props>(function SearchField(
+ { value, onChange, onClear, inToolbar, className, spellCheck = false, ...input },
+ ref,
+) {
+ return (
+ <label className={`search-field${inToolbar ? " toolbar-group" : ""}${className ? ` ${className}` : ""}`}>
+ <Search size={14} strokeWidth={2.2} aria-hidden="true" />
+ <input ref={ref} type="search" value={value} spellCheck={spellCheck} onChange={(e) => onChange(e.target.value)} {...input} />
+ {value && onClear && (
+ <button type="button" className="search-clear" aria-label="Clear Search" onClick={onClear}>
+ <X size={10} strokeWidth={3} aria-hidden="true" />
+ </button>
+ )}
+ </label>
+ );
+});
diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx
new file mode 100644
index 0000000..5c08e29
--- /dev/null
+++ b/src/components/Spinner.tsx
@@ -0,0 +1,37 @@
+/**
+ * Something under way, drawn one way everywhere. A spinner for a wait with no measure — a
+ * folder being read, a first sync; a bar for one that has one — an upload, a download.
+ */
+export function Spinner({ small, label }: { small?: boolean; label?: string }) {
+ return (
+ <span
+ className={`spinner${small ? " is-small" : ""}`}
+ role={label ? "progressbar" : undefined}
+ aria-label={label}
+ aria-hidden={label ? undefined : true}
+ />
+ );
+}
+
+/**
+ * How far along, 0 to 1; `null` while there is no measure yet (still counting what is to go),
+ * which draws a segment gliding instead of a number that would only shrink.
+ */
+export function Progress({ value, label, instant, className }: { value: number | null; label?: string; instant?: boolean; className?: string }) {
+ const known = value !== null && Number.isFinite(value);
+ const share = known ? Math.max(0, Math.min(1, value)) : 0;
+ return (
+ <span
+ className={`progress${known ? "" : " is-waiting"}${instant ? " is-instant" : ""}${className ? ` ${className}` : ""}`}
+ role="progressbar"
+ aria-label={label}
+ aria-valuemin={known ? 0 : undefined}
+ aria-valuemax={known ? 100 : undefined}
+ aria-valuenow={known ? Math.round(share * 100) : undefined}
+ >
+ {/* The fill grows by scale, on the compositor: a width animated here laid out its whole
+ panel on every step, and coming back to the window replayed every step at once. */}
+ <span style={known ? { transform: `scaleX(${share})` } : undefined} />
+ </span>
+ );
+}
diff --git a/src/components/StatusLine.tsx b/src/components/StatusLine.tsx
new file mode 100644
index 0000000..ca686b6
--- /dev/null
+++ b/src/components/StatusLine.tsx
@@ -0,0 +1,16 @@
+import { Spinner } from "./Spinner";
+
+/**
+ * A line of status in place — under a sheet's button, in a sidebar — said the one way: a wait
+ * with the spinner, a reason in red, a note in grey. Where there is a window's content to float
+ * over, the same words go in a toast instead (components/Toast); this is for what has to stay
+ * beside the control it is about.
+ */
+export function StatusLine({ tone, id, children }: { tone: "pending" | "error" | "note"; id?: string; children: React.ReactNode }) {
+ return (
+ <p id={id} className={`status-line is-${tone}`} role={tone === "error" ? "alert" : "status"}>
+ {tone === "pending" && <Spinner small />}
+ {children}
+ </p>
+ );
+}
diff --git a/src/components/Toast.tsx b/src/components/Toast.tsx
new file mode 100644
index 0000000..07dc139
--- /dev/null
+++ b/src/components/Toast.tsx
@@ -0,0 +1,202 @@
+import { useEffect, useLayoutEffect, useRef, useSyncExternalStore } from "react";
+import { CircleCheck, TriangleAlert, X } from "lucide-react";
+import { fadeIn, fadeOut } from "../lib/fade";
+import { useScreenActive } from "../lib/screen";
+import { api, messageOf } from "../lib/ipc";
+
+/**
+ * Everything the window says in passing — a file saved, a change undone, a change Apple turned
+ * down — said one way, in one place: a small card at the foot of the content, centred over it,
+ * above anything that sits at the bottom (Photos' filmstrip). At most two at once, the newest
+ * nearest the edge. Each goes by itself after a moment, an error only when put away, since a
+ * reason must be read; any one can carry a single action — Undo, Show in Folder, Try Again.
+ *
+ * Every screen used to say these its own way, in its own corner: a red bar floating over a
+ * list, a line of blue under a toolbar, a pill at the bottom of the window, a box at the left.
+ */
+export type ToastAction = { label: string; run: () => void };
+export type ToastInput = {
+ message: string;
+ /** "done" carries a check; "error" a warning, and stays until put away. */
+ tone?: "info" | "done" | "error";
+ action?: ToastAction;
+ /** How long it stays, in ms; null for until put away. */
+ duration?: number | null;
+};
+type Toast = ToastInput & { id: number };
+
+const MAX = 2;
+let shown: Toast[] = [];
+let next = 1;
+const listeners = new Set<() => void>();
+const emit = () => listeners.forEach((l) => l());
+const subscribe = (l: () => void) => {
+ listeners.add(l);
+ return () => listeners.delete(l);
+};
+
+/** Say something in passing. Returns its id, to take it back early with `dismissToast`. */
+export function toast(input: string | ToastInput): number {
+ const t: Toast = { tone: "info", ...(typeof input === "string" ? { message: input } : input), id: next++ };
+ // The same words twice are one toast, said again: not a stack of copies.
+ shown = [...shown.filter((s) => s.message !== t.message), t].slice(-MAX);
+ emit();
+ return t.id;
+}
+
+export function dismissToast(id: number) {
+ if (!shown.some((t) => t.id === id)) return;
+ shown = shown.filter((t) => t.id !== id);
+ emit();
+}
+
+/**
+ * Room kept clear at the foot of the content while something is drawn there — Photos'
+ * filmstrip — so a toast never lands on it. The largest asked for wins.
+ */
+const clearances = new Map<symbol, number>();
+const clearance = () => Math.max(0, ...clearances.values());
+export function useToastClearance(px: number) {
+ const key = useRef(Symbol("clearance")).current;
+ useEffect(() => {
+ if (px > 0) clearances.set(key, px);
+ else clearances.delete(key);
+ emit();
+ return () => {
+ clearances.delete(key);
+ emit();
+ };
+ }, [key, px]);
+}
+
+/**
+ * A screen's error, said as a toast while that screen is in front — as its notice was, drawn
+ * in the screen — and cleared from the screen's state once put away. Out of sight, it waits.
+ */
+export function useErrorToast(error: string | null, clear: () => void) {
+ const active = useScreenActive();
+ const clearRef = useRef(clear);
+ clearRef.current = clear;
+ const id = useRef<number | null>(null);
+ useEffect(() => {
+ if (!error || !active) return undefined;
+ const mine = toast({ message: error, tone: "error", duration: null });
+ id.current = mine;
+ // Put away in the toast: the screen forgets it too.
+ const stop = subscribe(() => {
+ if (id.current === mine && !shown.some((t) => t.id === mine)) {
+ id.current = null;
+ clearRef.current();
+ }
+ });
+ return () => {
+ stop();
+ // Gone from the screen's state or out of sight: withdrawn without clearing it.
+ if (id.current === mine) {
+ id.current = null;
+ dismissToast(mine);
+ }
+ };
+ }, [error, active]);
+}
+
+/** Drawn once, in the library, over the foot of the content. */
+export function ToastHost() {
+ const list = useSyncExternalStore(subscribe, () => shown);
+ const lift = useSyncExternalStore(subscribe, clearance);
+ return (
+ <div className="toast-host" style={lift ? ({ "--toast-clear": `${lift}px` } as React.CSSProperties) : undefined}>
+ {list.map((t) => (
+ <ToastCard key={t.id} toast={t} />
+ ))}
+ </div>
+ );
+}
+
+function ToastCard({ toast: t }: { toast: Toast }) {
+ const card = useRef<HTMLDivElement>(null);
+ const leaving = useRef(false);
+ useLayoutEffect(() => fadeIn(card.current, { duration: 140 }), []);
+ const dismiss = () => {
+ if (leaving.current) return;
+ leaving.current = true;
+ // The keys go back to the window, not to a card on its way out.
+ if (card.current?.contains(document.activeElement)) (document.activeElement as HTMLElement).blur();
+ fadeOut(card.current, () => dismissToast(t.id), 120);
+ };
+ // Gone by itself after a moment — longer when there is something to do — but never while
+ // the pointer or the keys are on it.
+ const held = useRef(false);
+ const duration = t.duration === undefined ? (t.tone === "error" ? null : t.action ? 6000 : 4000) : t.duration;
+ useEffect(() => {
+ if (duration === null) return undefined;
+ const timer = window.setInterval(() => {
+ if (!held.current) dismiss();
+ }, duration);
+ return () => window.clearInterval(timer);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [duration]);
+ const hold = (on: boolean) => () => {
+ held.current = on;
+ };
+ return (
+ <div
+ ref={card}
+ className={`toast is-${t.tone ?? "info"}`}
+ role={t.tone === "error" ? "alert" : "status"}
+ aria-live={t.tone === "error" ? "assertive" : "polite"}
+ onPointerEnter={hold(true)}
+ onPointerLeave={hold(false)}
+ onFocus={hold(true)}
+ onBlur={hold(false)}
+ onKeyDown={(e) => {
+ if (e.key === "Escape" && !leaving.current) {
+ e.stopPropagation();
+ dismiss();
+ }
+ }}
+ >
+ {t.tone === "error" ? (
+ <TriangleAlert className="toast-glyph" size={15} strokeWidth={2} aria-hidden="true" />
+ ) : t.tone === "done" ? (
+ <CircleCheck className="toast-glyph" size={15} strokeWidth={2} aria-hidden="true" />
+ ) : null}
+ <p>{t.message}</p>
+ {t.action && (
+ <button
+ className="toast-action"
+ onClick={() => {
+ t.action!.run();
+ dismiss();
+ }}
+ >
+ {t.action.label}
+ </button>
+ )}
+ <button className="icon-button small toast-close" aria-label="Dismiss" title="Dismiss" onClick={dismiss}>
+ <X size={13} strokeWidth={2.25} aria-hidden="true" />
+ </button>
+ </div>
+ );
+}
+
+/** Where a file went, as a person names it: the folder, never the whole path from the root. */
+export function folderOf(path: string): string {
+ const parts = path.split(/[\\/]+/).filter(Boolean);
+ return parts.length > 1 ? parts[parts.length - 2] : "your computer";
+}
+
+/**
+ * A file saved to this computer, said the one way: the folder's name — never the whole path —
+ * and Show in Folder, which opens the file manager on the file itself.
+ */
+export function toastSaved(path: string, count = 1) {
+ return toast({
+ message: count === 1 ? `Saved to ${folderOf(path)}` : `${count} saved to ${folderOf(path)}`,
+ tone: "done",
+ action: {
+ label: "Show in Folder",
+ run: () => void api.downloadReveal(path).catch((e) => toast({ message: messageOf(e), tone: "error" })),
+ },
+ });
+}
diff --git a/src/components/Unsent.tsx b/src/components/Unsent.tsx
new file mode 100644
index 0000000..9cdf66c
--- /dev/null
+++ b/src/components/Unsent.tsx
@@ -0,0 +1,67 @@
+import { TriangleAlert } from "lucide-react";
+import type { RefusedChange } from "../lib/ipc";
+
+/** The small grey words beside something saved here that Apple does not have yet. */
+export const WAITING = "Waiting to sync";
+
+/** Inline, so it sits beside any row or title without a stylesheet of its own. */
+export function Waiting({ shown }: { shown: boolean }) {
+ if (!shown) return null;
+ return (
+ <span className="sync-waiting" role="status">
+ {WAITING}
+ </span>
+ );
+}
+
+/**
+ * A change Apple turned down for good — edited in the same place on another device, deleted
+ * elsewhere — said with what it held, never dropped: the words can be copied out, sent again
+ * or let go. One at a time, oldest first, as the queue holds them.
+ */
+export function Unsent({
+ refused,
+ what,
+ onResend,
+ onDiscard,
+}: {
+ refused: RefusedChange[];
+ /** What a change is, in this app's words: "an edit to a note". */
+ what: string;
+ onResend: (r: RefusedChange) => void;
+ onDiscard: (r: RefusedChange) => void;
+}) {
+ const r = refused[0];
+ if (!r) return null;
+ const more = refused.length - 1;
+ const preview = r.content.length > 120 ? `${r.content.slice(0, 120)}…` : r.content;
+ const copy = () => void navigator.clipboard?.writeText(r.content).catch(() => {});
+ return (
+ // In the flow, not floating like a toast: it stays until decided, and over the list it
+ // would hide the rows under it for as long.
+ <div className="unsent" role="alert">
+ <TriangleAlert className="toast-glyph" size={15} strokeWidth={2} aria-hidden="true" />
+ <div className="unsent-body">
+ {/* Apple's reason already says what was not saved; `what` names it for a reader. */}
+ <p aria-label={`iCloud didn’t take ${what}: ${r.reason}`}>
+ {r.reason}
+ {more > 0 ? ` (and ${more} more)` : ""}
+ </p>
+ {preview && <p className="unsent-content">“{preview}”</p>}
+ <div className="unsent-actions">
+ {r.content && (
+ <button className="quiet" onClick={copy}>
+ Copy Text
+ </button>
+ )}
+ <button className="quiet" onClick={() => onResend(r)}>
+ Try Again
+ </button>
+ <button className="quiet danger" onClick={() => onDiscard(r)}>
+ Discard
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/UploadTray.tsx b/src/components/UploadTray.tsx
index 62e8dd9..b8a5daf 100644
--- a/src/components/UploadTray.tsx
+++ b/src/components/UploadTray.tsx
@@ -1,3 +1,4 @@
+import { Progress } from "./Spinner";
import { useEffect, useRef, useState } from "react";
import { api, type UploadEvent } from "../lib/ipc";
import { FileGlyph } from "./FileGlyph";
@@ -157,20 +158,18 @@ export function UploadTray({
{active ? (
<span className="upload-tray-actions">
{allPlanned && <span className="upload-tray-percent">{percent}%</span>}
- <button className="upload-tray-close" onClick={() => batches.forEach((b) => void cancel([], b))}>
+ <button className="quiet upload-tray-close" onClick={() => batches.forEach((b) => void cancel([], b))}>
Cancel
</button>
</span>
) : (
- <button className="upload-tray-close" onClick={onDismiss} aria-label="Close uploads">
+ <button className="quiet upload-tray-close" onClick={onDismiss} aria-label="Close uploads">
Done
</button>
)}
</header>
{active && (
- <div className={`upload-bar${allPlanned ? "" : " is-waiting"}`} aria-hidden="true">
- <span style={allPlanned ? { transform: `scaleX(${percent / 100})` } : undefined} />
- </div>
+ <Progress value={allPlanned ? percent / 100 : null} instant={instant} className="upload-bar" />
)}
<ul className="upload-rows">
{measured.map(({ item, percent: raw, running, failed, status }) => {
@@ -186,9 +185,7 @@ export function UploadTray({
<span className="upload-text">
<span className="upload-name">{item.name}</span>
{running && (item.folder ? planned.has(item.files[0]?.batch ?? "") : true) && (
- <span className="upload-bar small" aria-hidden="true">
- <span style={{ transform: `scaleX(${p / 100})` }} />
- </span>
+ <Progress value={p / 100} instant={instant} className="upload-bar small" />
)}
{!running && !item.folder && failed[0]?.error && <span className="upload-where">{failed[0].error}</span>}
</span>
@@ -197,7 +194,7 @@ export function UploadTray({
</span>
{item.folder && failed.length > 0 && (
<button
- className="upload-stop"
+ className="icon-button small round upload-stop"
aria-expanded={open === item.key}
aria-label={open === item.key ? "Hide what didn’t upload" : "Show what didn’t upload"}
onClick={() => setOpen(open === item.key ? null : item.key)}
@@ -208,7 +205,7 @@ export function UploadTray({
{/* One upload has one Cancel — the head's. */}
{stoppable.length > 0 && measured.length > 1 && (
<button
- className="upload-stop"
+ className="icon-button small round upload-stop"
aria-label={`Cancel ${item.name}`}
title="Cancel"
onClick={() => void cancel(stoppable.map((u) => u.id))}
diff --git a/src/lib/fade.ts b/src/lib/fade.ts
index ee94a04..6e9309f 100644
--- a/src/lib/fade.ts
+++ b/src/lib/fade.ts
@@ -33,13 +33,43 @@ export function fadeIn(el: HTMLElement | null, { from = 0, duration = 150 }: { f
running.set(el, requestAnimationFrame(step));
}
+/** The same fade the other way, then `done` — for something small leaving, as a toast. */
+export function fadeOut(el: HTMLElement | null, done: () => void, duration = 120) {
+ if (!el || (typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches)) {
+ done();
+ return;
+ }
+ cancelAnimationFrame(running.get(el) ?? 0);
+ // Gone on time even where frames are not drawn (a window out of sight draws none).
+ let finished = false;
+ const finish = () => {
+ if (finished) return;
+ finished = true;
+ running.delete(el);
+ done();
+ };
+ window.setTimeout(finish, duration + 250);
+ const start = performance.now();
+ const step = (now: number) => {
+ const t = Math.min(1, (now - start) / duration);
+ // Ease in: gathering pace as it goes, so the end is not watched.
+ el.style.opacity = String(1 - t * t);
+ if (t >= 1) {
+ finish();
+ return;
+ }
+ running.set(el, requestAnimationFrame(step));
+ };
+ running.set(el, requestAnimationFrame(step));
+}
+
/**
* Every sheet, as it is added anywhere in the app, fades in this way — set before the first frame
* is painted (a mutation observer runs before painting), so none shows whole for a frame first.
* The full-window dims behind them simply appear: a large surface is never animated.
*/
export function fadeSheetsIn() {
- const sheets = ".modal-sheet, .px-sheet";
+ const sheets = ".modal-sheet";
new MutationObserver((changes) => {
for (const change of changes) {
for (const node of change.addedNodes) {
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 2e80ca9..c475ced 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -1,6 +1,21 @@
import { convertFileSrc, invoke } from "@tauri-apps/api/core";
export type Status = { hasStoredSession: boolean; signedIn: boolean };
+
+/** A change made here waiting for Apple. */
+export type WaitingChange = { service: string; record: string; kind: string };
+/** A change Apple turned down for good, kept with what it held. */
+export type RefusedChange = {
+ id: number;
+ service: string;
+ record: string;
+ kind: string;
+ reason: string;
+ madeAt: number;
+ /** What was typed: the note's text, the reminder's title, the person's name. */
+ content: string;
+};
+export type OutboxStatus = { waiting: WaitingChange[]; refused: RefusedChange[] };
export type SignInResult = "complete" | "needs_two_factor";
export type TrustedPhone = { id: number; maskedNumber: string };
@@ -55,12 +70,16 @@ export const SYNCED = "quince://synced";
export const OPEN_REMINDER = "quince://open-reminder";
/** A lapsed session signed itself back in only as far as Apple's code. */
export const NEEDS_CODE = "quince://needs-code";
+/** Apple signed the session out and wants the password again. */
+export const NEEDS_SIGNIN = "quince://needs-signin";
export const api = {
/** One refresh for every service. Never rejects for a single service failing. */
syncAll: () => invoke<Refresh>("sync_all"),
/** What the library already knows about its own freshness, fetching nothing. */
syncStatus: () => invoke<Refresh>("sync_status"),
+ /** A refresh of only the services named — one app's "update now". */
+ syncSome: (services: string[]) => invoke<Refresh>("sync_some", { services }),
status: () => invoke<Status>("auth_status"),
/** Where a returning person goes: their library, the code Apple wants, or sign-in. */
@@ -76,6 +95,12 @@ export const api = {
signOut: (keep: boolean) => invoke<void>("auth_sign_out", { keep }),
/** What of the account has not reached iCloud yet: asked before a sign-out. */
unsent: () => invoke<{ changes: number; files: number; photos: number }>("account_unsent"),
+ /** What waits to reach Apple, and what Apple turned down. */
+ outboxStatus: () => invoke<OutboxStatus>("outbox_status"),
+ /** A refused change, sent again. */
+ outboxResend: (id: number) => invoke<void>("outbox_resend", { id }),
+ /** A refused change let go of: Apple's version stands. */
+ outboxDiscard: (id: number) => invoke<void>("outbox_discard", { id }),
services: () => invoke<string[]>("account_services"),
eventSave: (draft: EventWrite) => invoke<string>("event_save", { draft }),
@@ -199,7 +224,7 @@ export const api = {
listGuid: string,
title: string,
implied: { dueAt?: number; allDay?: boolean; flagged?: boolean } = {},
- ) => invoke<void>("reminder_create", { listGuid, title, ...implied }),
+ ) => invoke<string>("reminder_create", { listGuid, title, ...implied }),
reminderDelete: (guid: string, listGuid: string) =>
invoke<void>("reminder_delete", { guid, listGuid }),
@@ -241,7 +266,10 @@ export const api = {
noteBody: (guid: string) => invoke<string | null>("note_body", { guid }),
noteExportMarkdown: (body: string, runs: unknown[], path: string) =>
invoke<void>("note_export_markdown", { body, runs, path }),
- /** Answers with the text Apple now holds — ours, or ours combined with another device's. */
+ /**
+ * Kept on this computer at once and sent behind (the outbox), merged then with whatever
+ * Apple holds against `base`. Answers with the text as kept.
+ */
noteSave: (
guid: string,
body: string,
@@ -314,6 +342,8 @@ export const api = {
/** Settings' switches, as the backend obeys them. */
/** Write a plain diagnostic report to Downloads; answers where. Nothing is sent anywhere. */
diagnosticsSave: () => invoke<string>("diagnostics_save"),
+ /** Show a file saved to Downloads in the file manager. */
+ downloadReveal: (path: string) => invoke<void>("download_reveal", { path }),
settingsGet: () => invoke<{ reminderAlerts: boolean; eventAlerts: boolean }>("settings_get"),
settingsSet: (key: "reminderAlerts" | "eventAlerts", on: boolean) => invoke<void>("settings_set", { key, on }),
drivePutBack: (item: DriveItem) => invoke<void>("drive_put_back", { item }),
@@ -782,4 +812,66 @@ export type DriveFolder = {
problem: string | null;
/** Files written into the folder and not yet at Apple (the Drive folder only). */
waiting?: { files: number; sending: number; failure: string | null } | null;
+ /** False where this system cannot have the folder yet (Windows): the row is not shown. */
+ available: boolean;
+};
+
+/** How much room the local copy takes on this computer, in bytes on disk (src-tauri/src/settings.rs). */
+export type LocalStorage = {
+ library: number;
+ photos: number;
+ notes: number;
+ drive: number;
+ other: number;
+ total: number;
+ /** What Clear Cached Pictures gives back. */
+ clearable: number;
+};
+
+export const settingsApi = {
+ localStorage: () => invoke<LocalStorage>("local_storage"),
+ /** Removes only pictures Apple still has; answers the room used after. */
+ localStorageClear: () => invoke<LocalStorage>("local_storage_clear"),
+ /** False when this desktop has no notification service; null where unknown or always shown. */
+ alertsShown: () => invoke<boolean | null>("alerts_shown"),
+};
+
+/* ── Intake: files opened with Pomander, and quick capture (src-tauri/src/intake.rs) ── */
+
+/** Told to a window when a file has arrived for it; it collects with `intakeApi.pending`. */
+export const INTAKE = "quince://intake";
+/** Told to the quick-capture window when it is asked for again, with the kind now wanted. */
+export const CAPTURE = "quince://capture";
+
+/** An event read from a calendar file: what `eventSave` takes, less the calendar. */
+export type ImportEvent = {
+ title: string;
+ location: string | null;
+ startsAt: number;
+ endsAt: number;
+ allDay: boolean;
+ timezone: string | null;
+ notes: string | null;
+ url: string | null;
+ alerts: number[] | null;
+ repeat: EventRepeat | null;
+ /** The same title at the same time is already in a calendar here: left out. */
+ duplicate: boolean;
+};
+
+export type ImportContact = { name: string; detail: string | null; known: boolean };
+
+/** What a file opened with Pomander holds, read on this computer before anything is sent. */
+export type Arrival =
+ | { kind: "events"; file: string; events: ImportEvent[]; refused: { title: string; reason: string }[] }
+ | { kind: "contacts"; file: string; path: string; contacts: ImportContact[] }
+ | { kind: "unreadable"; file: string; reason: string };
+
+export const intakeApi = {
+ /** What has arrived for this window, taken from the queue. */
+ pending: () => invoke<Arrival[]>("intake_pending"),
+ /** The quick-capture window, closed. */
+ captureClose: () => invoke<void>("intake_capture_close"),
+ /** The main window, for signing in. */
+ openMain: () => invoke<void>("intake_open_main"),
};
diff --git a/src/lib/outbox.ts b/src/lib/outbox.ts
new file mode 100644
index 0000000..5a354be
--- /dev/null
+++ b/src/lib/outbox.ts
@@ -0,0 +1,55 @@
+import { useCallback, useEffect, useMemo, useState } from "react";
+import { listen } from "@tauri-apps/api/event";
+import { api, type OutboxStatus, type RefusedChange } from "./ipc";
+
+const CHANGED = "quince://outbox-changed";
+const REFUSED = "quince://outbox-refused";
+
+/**
+ * Changes made here that Apple does not have yet, for one service: which records are waiting
+ * (shown as "Waiting to sync"), and the changes Apple turned down — kept, with what was typed,
+ * until the person sends them again or lets them go.
+ *
+ * The backend says when this moves (`quince://outbox-changed`): as it starts sending, as a
+ * change lands, as one is refused. `tick` counts those, for a view to read its rows again.
+ */
+export function useOutbox(service: "notes" | "reminders" | "contacts") {
+ const [status, setStatus] = useState<OutboxStatus>({ waiting: [], refused: [] });
+ const [tick, setTick] = useState(0);
+
+ const read = useCallback(() => {
+ api.outboxStatus().then(
+ (s) => setStatus(s && Array.isArray(s.waiting) ? s : { waiting: [], refused: [] }),
+ () => {},
+ );
+ }, []);
+
+ useEffect(() => {
+ read();
+ const offs = [
+ listen(CHANGED, () => {
+ read();
+ setTick((n) => n + 1);
+ }),
+ listen(REFUSED, () => read()),
+ ];
+ return () => offs.forEach((off) => void off.then((f) => f()).catch(() => {}));
+ }, [read]);
+
+ const waiting = useMemo(
+ () => new Set(status.waiting.filter((w) => w.service === service).map((w) => w.record)),
+ [status, service],
+ );
+ const refused = useMemo(() => status.refused.filter((r) => r.service === service), [status, service]);
+
+ const resend = useCallback(async (r: RefusedChange) => {
+ await api.outboxResend(r.id).catch(() => {});
+ read();
+ }, [read]);
+ const discard = useCallback(async (r: RefusedChange) => {
+ await api.outboxDiscard(r.id).catch(() => {});
+ read();
+ }, [read]);
+
+ return { waiting, refused, resend, discard, refresh: read, tick };
+}
diff --git a/src/lib/platform.ts b/src/lib/platform.ts
new file mode 100644
index 0000000..8e0d7cf
--- /dev/null
+++ b/src/lib/platform.ts
@@ -0,0 +1,3 @@
+// Which system the window runs on, for the few places that differ: WebView2 says "Windows NT"
+// in its user agent, WebKitGTK says "Linux".
+export const onWindows = typeof navigator !== "undefined" && /Windows/.test(navigator.userAgent);
diff --git a/src/lib/sync.tsx b/src/lib/sync.tsx
index 712dd0b..ada2dc2 100644
--- a/src/lib/sync.tsx
+++ b/src/lib/sync.tsx
@@ -30,6 +30,14 @@ type Sync = {
refresh: () => Promise<void>;
/** The last refresh that failed outright, rather than a single service reporting trouble. */
error: string | null;
+ /** Refresh one service alone — one app's "update now". Never starts a second pass of it. */
+ refreshService: (service: string) => Promise<void>;
+ /** The services being refreshed on their own right now. */
+ updating: readonly string[];
+ /** Why a service's own refresh failed outright, by service. */
+ serviceErrors: Readonly<Record<string, string>>;
+ /** When the whole-account pass in flight began (unix seconds), or null. */
+ passStartedAt: number | null;
};
const Context = createContext<Sync | null>(null);
@@ -44,11 +52,16 @@ export function SyncProvider({ children }: { children: ReactNode }) {
const [error, setError] = useState<string | null>(null);
// A second click while a pass is running would mean two walks of the same zones.
const inFlight = useRef(false);
+ const [updating, setUpdating] = useState<string[]>([]);
+ const [serviceErrors, setServiceErrors] = useState<Record<string, string>>({});
+ const [passStartedAt, setPassStartedAt] = useState<number | null>(null);
+ const serviceInFlight = useRef(new Set<string>());
const refresh = useCallback(async () => {
if (inFlight.current) return;
inFlight.current = true;
setSyncing(true);
+ setPassStartedAt(Math.floor(Date.now() / 1000));
setError(null);
try {
setReport(await api.syncAll());
@@ -57,6 +70,37 @@ export function SyncProvider({ children }: { children: ReactNode }) {
} finally {
inFlight.current = false;
setSyncing(false);
+ setPassStartedAt(null);
+ setRevision((n) => n + 1);
+ }
+ }, []);
+
+ const refreshService = useCallback(async (service: string) => {
+ if (serviceInFlight.current.has(service)) return;
+ serviceInFlight.current.add(service);
+ setUpdating([...serviceInFlight.current]);
+ setServiceErrors(({ [service]: _gone, ...rest }) => rest);
+ try {
+ const part = await api.syncSome([service]);
+ // The backend's event brings the whole picture; this keeps the answer on screen even
+ // where no event arrives, by folding this service's own report into the last one.
+ setReport((was) =>
+ was
+ ? {
+ ...was,
+ services: [
+ ...was.services.filter((s) => !part.services.some((p) => p.service === s.service)),
+ ...part.services,
+ ],
+ }
+ : part,
+ );
+ } catch (e) {
+ const reason = messageOf(e);
+ setServiceErrors((was) => ({ ...was, [service]: reason }));
+ } finally {
+ serviceInFlight.current.delete(service);
+ setUpdating([...serviceInFlight.current]);
setRevision((n) => n + 1);
}
}, []);
@@ -113,8 +157,8 @@ export function SyncProvider({ children }: { children: ReactNode }) {
}, [refresh]);
const value = useMemo(
- () => ({ report, syncing, revision, refresh, error }),
- [report, syncing, revision, refresh, error]
+ () => ({ report, syncing, revision, refresh, error, refreshService, updating, serviceErrors, passStartedAt }),
+ [report, syncing, revision, refresh, error, refreshService, updating, serviceErrors, passStartedAt]
);
return <Context.Provider value={value}>{children}</Context.Provider>;
}
@@ -137,3 +181,42 @@ export function freshness(asOf: number | null): string {
const days = Math.floor(hours / 24);
return days === 1 ? "Updated yesterday" : `Updated ${days} days ago`;
}
+
+/**
+ * Whether a service's first copy is still on its way: never synced here, and a pass running
+ * (or not yet reported). An empty screen then means "coming", not "you have none" — saying the
+ * second while the first is true told a person with years of reminders that they had none.
+ */
+export function useArriving(service: string): boolean {
+ const { report, syncing, error } = useSync();
+ if (error) return false;
+ const mine = report?.services.find((s) => s.service === service);
+ if (mine?.outcome === "failed" || mine?.outcome === "unavailable") return false;
+ if (mine?.lastSyncedAt) return false;
+ return syncing || report === null;
+}
+
+/** One service as an app shows it: whether it is being fetched, and how it last went. */
+export type ServiceState = {
+ /** Being fetched now — on its own, or as part of a whole-account pass it has not landed from. */
+ working: boolean;
+ /** Why it did not update, when it did not. */
+ failure: string | null;
+ lastSyncedAt: number | null;
+ unavailable: boolean;
+};
+
+/**
+ * One service's own state, for the app showing it. During a whole-account pass a service
+ * counts as working only until its own part has landed — the passes run side by side, and
+ * Reminders is done long before Photos is.
+ */
+export function useServiceState(service: string): ServiceState {
+ const { report, syncing, passStartedAt, updating, serviceErrors } = useSync();
+ const mine = report?.services.find((s) => s.service === service);
+ const lastSyncedAt = mine?.lastSyncedAt ?? null;
+ const landed = passStartedAt !== null && lastSyncedAt !== null && lastSyncedAt >= passStartedAt;
+ const working = updating.includes(service) || (syncing && !landed && mine?.outcome !== "unavailable");
+ const failure = serviceErrors[service] ?? (mine?.outcome === "failed" ? (mine.detail ?? "It didn’t update") : null);
+ return { working, failure, lastSyncedAt, unavailable: mine?.outcome === "unavailable" };
+}
diff --git a/src/main.tsx b/src/main.tsx
index 3349316..8369966 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,7 +1,9 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
+import { QuickCapture } from "./components/QuickCapture";
import "./styles/tokens.css";
+import "./styles/kit.css";
import "./styles/app.css";
import "./styles/reminders.css";
import "./styles/calendar.css";
@@ -41,9 +43,12 @@ document.addEventListener("contextmenu", (e) => {
if (!editable) e.preventDefault();
});
+// The quick-capture window (`pomander --new reminder`) is one field, not the library.
+const capture = new URLSearchParams(window.location.search).get("capture");
+
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
- <App />
+ {capture === "reminder" || capture === "note" ? <QuickCapture initial={capture} /> : <App />}
</React.StrictMode>
);
diff --git a/src/screens/CodeEntry.tsx b/src/screens/CodeEntry.tsx
index 8d98f01..2c3e9dd 100644
--- a/src/screens/CodeEntry.tsx
+++ b/src/screens/CodeEntry.tsx
@@ -1,6 +1,8 @@
import { useEffect, useState } from "react";
import { Mark } from "../components/Mark";
import { CodeInput } from "../components/CodeInput";
+import { StatusLine } from "../components/StatusLine";
+import { sentence } from "./SignIn";
import { api, messageOf, type TwoFactorOptions } from "../lib/ipc";
export function CodeEntry({
@@ -12,6 +14,7 @@ export function CodeEntry({
}) {
const [code, setCode] = useState("");
const [busy, setBusy] = useState(false);
+ const [verifying, setVerifying] = useState(false);
const [error, setError] = useState<string | null>(null);
const [notice, setNotice] = useState<string | null>(null);
const [options, setOptions] = useState<TwoFactorOptions | null>(null);
@@ -37,8 +40,12 @@ export function CodeEntry({
if (nothingSent) setShowHelp(true);
}, [nothingSent]);
+ const texted = options?.phones.find((p) => p.id === smsPhoneId);
+ const devices = options?.trustedDeviceCount ?? 0;
+
async function verify(value: string) {
setBusy(true);
+ setVerifying(true);
setError(null);
setNotice(null);
try {
@@ -46,9 +53,10 @@ export function CodeEntry({
else await api.submitCode(value);
onVerified();
} catch (err) {
- setError(messageOf(err));
+ setError(sentence(messageOf(err)));
setCode("");
setBusy(false);
+ setVerifying(false);
}
}
@@ -58,35 +66,66 @@ export function CodeEntry({
setNotice(null);
try {
await action();
- setNotice(done);
+ setNotice(done || null);
} catch (err) {
- setError(messageOf(err));
+ setError(sentence(messageOf(err)));
} finally {
setBusy(false);
}
}
return (
- <div className="sheet enter-sheet">
+ <div className="sheet enter-sheet" aria-busy={verifying}>
<Mark className="mark" />
<h1>Enter the code</h1>
<p className="lede">
- {options === null
- ? "Apple sent a six-digit code to your trusted devices."
- : nowhereToSend
- ? "Apple has nowhere to send a code for this account."
- : nothingSent
- ? "None of your devices are reachable, but a code can still be texted to you."
- : `Apple sent a six-digit code to ${options.trustedDeviceCount} of your devices.`}
+ {texted
+ ? `Apple texted a code to ${texted.maskedNumber}.`
+ : options === null
+ ? "Apple sent a code to your devices."
+ : nowhereToSend
+ ? "Apple has nowhere to send a code for this account."
+ : nothingSent
+ ? "No device is reachable, but a code can be texted to you."
+ : `Apple sent a code to ${devices === 1 ? "one of your devices" : `${devices} of your devices`}.`}
</p>
- <CodeInput value={code} onChange={setCode} onComplete={verify} disabled={busy} />
+ <CodeInput
+ value={code}
+ onChange={(next) => {
+ setCode(next);
+ if (error) setError(null);
+ }}
+ onComplete={verify}
+ disabled={busy}
+ invalid={!!error}
+ />
- {error && <p className="error" role="alert">{error}</p>}
- {notice && <p className="notice" role="status">{notice}</p>}
+ {/* One line under the boxes whose height is kept, so checking, a wrong code and a
+ sent text all take the same place and nothing below moves. */}
+ <div className="sheet-status">
+ {verifying ? (
+ <StatusLine tone="pending">Checking</StatusLine>
+ ) : error ? (
+ <StatusLine tone="error">{error}</StatusLine>
+ ) : notice ? (
+ <StatusLine tone="note">{notice}</StatusLine>
+ ) : null}
+ </div>
{!showHelp && (
- <button className="quiet" type="button" onClick={() => setShowHelp(true)}>
+ <button
+ className="link"
+ type="button"
+ // The button goes as the help opens; focus moves to the first way to get a code
+ // rather than falling back to the page.
+ onClick={() => {
+ setShowHelp(true);
+ requestAnimationFrame(() =>
+ document.querySelector<HTMLButtonElement>(".help button:not(:disabled)")?.focus(),
+ );
+ }}
+ >
Didn't get a code?
</button>
)}
@@ -94,70 +133,68 @@ export function CodeEntry({
{showHelp && (
<div className="help">
{options?.tooManyCodesSent && (
- <p className="error">
- Apple is limiting new codes. Wait a few minutes — repeated tries risk a
- temporary lock.
+ <p className="help-warn">
+ Apple is limiting new codes. Wait a few minutes before asking again.
</p>
)}
{nowhereToSend ? (
<p>
- This account has no trusted device and no trusted phone number, so there is
- nothing here that can produce a code. Sign in on a device you still have, or add
- a trusted number at <strong>account.apple.com</strong>, and then come back.
+ This account has no device or number to send to. Use a device you're still
+ signed in on, or add a number at <strong>account.apple.com</strong>.
</p>
- ) : (
+ ) : nothingSent ? null : (
<p>
- The code is only created once you tap <strong>Allow</strong> on your iPhone. If
- no prompt appeared, no code exists yet.
+ The code appears once you tap <strong>Allow</strong> on your iPhone.
</p>
)}
- <div className="help-actions">
- {!nothingSent && (
- <button
- className="quiet"
- type="button"
- disabled={busy}
- onClick={() => run(api.resendCode, "Sent again — check your devices.")}
- >
- Send to my devices again
- </button>
- )}
- {options?.phones.map((phone) => (
- <button
- key={phone.id}
- className="quiet"
- type="button"
- disabled={busy}
- onClick={() =>
- run(async () => {
- await api.sendSms(phone.id);
- setSmsPhoneId(phone.id);
- }, `Texted ${phone.maskedNumber}.`)
- }
- >
- Text {phone.maskedNumber}
- </button>
- ))}
- </div>
+ {!nowhereToSend && (
+ <div className="help-actions">
+ {!nothingSent && (
+ <button
+ className="quiet"
+ type="button"
+ disabled={busy}
+ onClick={() => run(api.resendCode, "Sent again. Check your devices.")}
+ >
+ Send to my devices again
+ </button>
+ )}
+ {options?.phones.map((phone) => (
+ <button
+ key={phone.id}
+ className="quiet"
+ type="button"
+ disabled={busy}
+ onClick={() =>
+ // The heading says where it went; the help folds away again.
+ run(async () => {
+ await api.sendSms(phone.id);
+ setSmsPhoneId(phone.id);
+ setShowHelp(false);
+ }, "")
+ }
+ >
+ Text {phone.maskedNumber}
+ </button>
+ ))}
+ </div>
+ )}
- <p>
- Still nothing? On iPhone, turn on <strong>Airplane Mode</strong>, then open
- Settings → your name → Sign-In &amp; Security. A popup offers a code while the
- phone is offline. (iOS hides that option when the phone is online.)
+ <p className="help-tip">
+ No prompt? On iPhone, turn on <strong>Airplane Mode</strong>, then open Settings →
+ your name → Sign-In &amp; Security. iOS offers a code there only while offline.
</p>
</div>
)}
- <p className="assurance">
- After this, Pomander stays signed in. You won't be asked again unless Apple retires the
- session, which takes about two months.
- </p>
-
- <button className="quiet" type="button" onClick={onCancel} disabled={busy}>
- Use a different Apple ID
- </button>
+ <div className="sheet-foot">
+ <p className="assurance">You'll stay signed in for about two months.</p>
+ <button className="link" type="button" onClick={onCancel} disabled={verifying}>
+ Use a different Apple ID
+ </button>
+ </div>
</div>
);
}
diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsx
index 3982c4b..6f35110 100644
--- a/src/screens/ContactsView.tsx
+++ b/src/screens/ContactsView.tsx
@@ -1,7 +1,13 @@
-import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Face } from "../components/Face";
-import { Notice } from "../components/Notice";
-import { ChevronLeft, Plus, UsersRound, UserRound } from "lucide-react";
+import { Unsent, Waiting } from "../components/Unsent";
+import { useOutbox } from "../lib/outbox";
+import { toast, toastSaved, useErrorToast } from "../components/Toast";
+import { ConfirmSheet, useConfirm } from "../components/Confirm";
+import { EmptyState } from "../components/EmptyState";
+import { SearchField } from "../components/SearchField";
+import { PaneTitle } from "../components/PaneTitle";
+import { ChevronLeft, Plus, UserPlus, UsersRound, UserRound } from "lucide-react";
import {
api,
displayName,
@@ -11,10 +17,11 @@ import {
type ContactList,
type ContactMethod,
} from "../lib/ipc";
-import { useSync } from "../lib/sync";
+import { Arriving } from "../components/EmptyState";
+import { useArriving, useSync } from "../lib/sync";
+import { useActiveRef, useScreenActive } from "../lib/screen";
import { Picker } from "../components/Picker";
import { RowMenu, type MenuEntry } from "../components/RowMenu";
-import { Portal } from "../components/Portal";
import { open as openFileDialog } from "@tauri-apps/plugin-dialog";
import { dateText } from "../lib/when";
import { useReveal } from "../lib/reveal";
@@ -109,7 +116,16 @@ export function ContactsView() {
const [detail, setDetail] = useState(false);
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
+ const [confirm, confirmSheet] = useConfirm();
const { revision } = useSync();
+ // A pass that lands while another screen is in front is read when this one comes back, once,
+ // not at every landing: a screen out of sight stays mounted (lib/screen).
+ const active = useScreenActive();
+ const seen = useRef(revision);
+ if (active) seen.current = revision;
+ const due = seen.current;
+ const arriving = useArriving("contacts");
/** The card being written, or null while simply looking. */
const [draft, setDraft] = useState<Contact | null>(null);
/** Details whose label is being typed rather than picked, by their place on the card. */
@@ -125,6 +141,13 @@ export function ContactsView() {
setCustomAt(new Set());
};
const [busy, setBusy] = useState(false);
+ /** The detail whose label was just clicked to copy it, said for a moment. */
+ const [copied, setCopied] = useState<string | null>(null);
+ useEffect(() => {
+ if (!copied) return undefined;
+ const timer = window.setTimeout(() => setCopied(null), 1200);
+ return () => window.clearTimeout(timer);
+ }, [copied]);
const [lists, setLists] = useState<ContactList[]>([]);
/** The list being looked at, or ALL. */
const [list, setList] = useState<string>(ALL);
@@ -144,8 +167,6 @@ export function ContactsView() {
const [contactMenu, setContactMenu] = useState<(MenuAt & { contact: Contact; lists: boolean }) | null>(null);
/** The card that is this person's own. */
const [me, setMe] = useState<string | null>(null);
- /** A moment's word that something finished — a file saved, cards brought in. */
- const [done, setDone] = useState<string | null>(null);
const [moreMenu, setMoreMenu] = useState<MenuAt | null>(null);
/** A contact being deleted while a list is open: out of the list, or gone everywhere? */
const [deleting, setDeleting] = useState<Contact | null>(null);
@@ -158,6 +179,8 @@ export function ContactsView() {
/** List writes go to Apple one after another, in the order they were made. */
const queue = useRef<Promise<unknown>>(Promise.resolve());
+ /** Cards saved here and not yet at Apple, and any Apple turned down. */
+ const outbox = useOutbox("contacts");
const read = useCallback(async (query: string) => {
const found = await api.contactsList(query.trim() || null);
setContacts(Array.isArray(found) ? found : []);
@@ -178,20 +201,15 @@ export function ContactsView() {
return () => {
cancelled = true;
};
- // Re-reading on every keystroke is the point: the filter runs in SQLite.
- }, [read, search, revision]);
+ // Re-reading on every keystroke is the point: the filter runs in SQLite. `outbox.tick`: a
+ // card sent, or turned down, changes what the library holds.
+ }, [read, search, due, outbox.tick]);
const readLists = useCallback(async () => {
const [found, mine] = await Promise.all([api.contactLists(), api.contactMe()]);
setLists(Array.isArray(found) ? found : []);
setMe(typeof mine === "string" ? mine : null);
}, []);
- // The word is a moment, not something that lingers over the next thing done.
- useEffect(() => {
- if (!done) return undefined;
- const timer = window.setTimeout(() => setDone(null), 4000);
- return () => window.clearTimeout(timer);
- }, [done]);
/** People out as a vCard, named as icloud.com names the file. */
const exportCards = async (people: Contact[], label?: string) => {
@@ -202,7 +220,7 @@ export function ContactsView() {
: label ?? "iCloud vCards";
try {
const path = await api.contactsExport(people.map((c) => c.guid), `${name}.vcf`);
- setDone(`Saved to ${path}`);
+ toastSaved(path);
} catch (e) {
setError(messageOf(e));
}
@@ -221,7 +239,7 @@ export function ContactsView() {
const [added, failed, known] = await api.contactsImport(paths);
await Promise.all([read(search), readLists()]);
const people = (n: number) => `${n} ${n === 1 ? "contact" : "contacts"}`;
- setDone(
+ toast(
[
`${people(added)} imported`,
known ? `${people(known)} already in Contacts ${known === 1 ? "was" : "were"} left out` : "",
@@ -248,7 +266,7 @@ export function ContactsView() {
};
useEffect(() => {
readLists().catch((e) => setError(messageOf(e)));
- }, [readLists, revision]);
+ }, [readLists, due]);
// A list deleted elsewhere is not left open, empty, with nothing to say why.
useEffect(() => {
if (list !== ALL && !lists.some((l) => l.guid === list)) setList(ALL);
@@ -314,9 +332,17 @@ export function ContactsView() {
};
const deleteList = (l: ContactList) => {
// icloud.com's own words for it.
- if (!window.confirm(`Delete \u201c${l.name}\u201d?\n\nThis list will be deleted from every device. The contacts in it stay in Contacts.`)) return;
- if (list === l.guid) setList(ALL);
- void changeList((ls) => ls.filter((x) => x.guid !== l.guid), { guid: l.guid, delete: true });
+ void confirm({
+ title: `Delete \u201c${l.name}\u201d?`,
+ body: "This list will be deleted from every device. The contacts in it stay in Contacts.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ }).then((sure) => {
+ if (!sure) return;
+ if (list === l.guid) setList(ALL);
+ void changeList((ls) => ls.filter((x) => x.guid !== l.guid), { guid: l.guid, delete: true });
+ });
};
const addToList = (l: ContactList, people: string[]) => {
const fresh = people.filter((p) => !l.members.some((m) => m.toUpperCase() === p.toUpperCase()));
@@ -342,7 +368,7 @@ export function ContactsView() {
return [
...into.map((l) => ({ label: l.name, run: () => addToList(l, [c.guid]) })),
...(into.length ? [null] : []),
- { label: "New List\u2026", run: () => void createList("Untitled List", [c.guid]) },
+ { label: "New List", run: () => void createList("Untitled List", [c.guid]) },
];
}
return [
@@ -352,8 +378,8 @@ export function ContactsView() {
null,
{ label: "Edit Contact", run: () => { setOpenGuid(c.guid); edit(c); } },
...(me === c.guid ? [] : [{ label: "Make This My Card", run: () => void makeMine(c) }]),
- { label: "Export vCard\u2026", run: () => void exportCards([c]) },
- { label: "Delete Contact\u2026", danger: true, run: () => {
+ { label: "Export vCard", run: () => void exportCards([c]) },
+ { label: "Delete Contact", danger: true, run: () => {
askDelete(c);
} },
];
@@ -398,7 +424,10 @@ export function ContactsView() {
*/
const askDelete = (c: Contact) => {
if (openList) setDeleting(c);
- else if (window.confirm(`Delete ${displayName(c)}?`)) void removeContact(c.guid);
+ else
+ void confirm({ title: `Delete ${displayName(c)}?`, body: "The card is deleted from Contacts on every device.", action: "Delete", danger: true, symbol: "trash" }).then(
+ (sure) => sure && void removeContact(c.guid),
+ );
};
const removeContact = useCallback(
@@ -424,21 +453,218 @@ export function ContactsView() {
[contacts, openGuid]
);
// Who is still here of those picked — a search or a list change narrows them.
- const pickedPeople = useMemo(() => sortedContacts(shown.filter((c) => picked.includes(c.guid))), [shown, picked]);
+ const pickedPeople = useMemo(() => {
+ const chosen = new Set(picked);
+ return sortedContacts(shown.filter((c) => chosen.has(c.guid)));
+ }, [shown, picked]);
const multi = pickedPeople.length > 1;
+ const pickedSet = useMemo(() => new Set(picked), [picked]);
+ /** How many of each list's people are here, counted once per change rather than per render. */
+ const listCounts = useMemo(() => {
+ const here = new Set(contacts.map((c) => c.guid.toUpperCase()));
+ return new Map(lists.map((l) => [l.guid, l.members.filter((m) => here.has(m.toUpperCase())).length]));
+ }, [contacts, lists]);
const removeMany = async (people: Contact[]) => {
- if (!window.confirm(`Delete ${people.length} contacts?\n\nThey will be deleted from Contacts on every device.`)) return;
+ const sure = await confirm({
+ title: `Delete ${people.length} contacts?`,
+ body: "They will be deleted from Contacts on every device.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ });
+ if (!sure) return;
setPicked([]);
await write(async () => {
for (const c of people) await api.contactDelete(c.guid);
});
};
+ /**
+ * Sorted once per change to who is shown, not on every render: typing in the card's form
+ * re-sorted the whole address book with each key, and redrew every row with it.
+ */
+ const sorted = useMemo(() => sortedContacts(shown), [shown]);
+ /** Each person's letter, worked out once per list rather than twice per row per render. */
+ const lettered = useMemo(() => sorted.map((c, i, all) => {
+ const letter = letterOf(c);
+ return { contact: c, letter, starts: i === 0 || letterOf(all[i - 1]) !== letter };
+ }), [sorted]);
+ const rowsRef = useRef<HTMLUListElement | null>(null);
+ const [listFocused, setListFocused] = useState(false);
+ const searchRef = useRef<HTMLInputElement | null>(null);
+ /** The row for a person brought into view and given focus, as the arrows and the index do. */
+ const showRow = (guid: string, focus: boolean) =>
+ requestAnimationFrame(() => {
+ const row = rowsRef.current?.querySelector<HTMLButtonElement>(`.contact-row[data-guid="${CSS.escape(guid)}"]`);
+ row?.scrollIntoView({ block: "nearest" });
+ if (focus) row?.focus({ preventScroll: true });
+ });
+
+ /**
+ * What a row does, as one object that never changes, so a row is redrawn only when what it
+ * shows changes — with a long address book, a click redrew every row in it. The handlers
+ * read the selection as it is at the moment they run.
+ */
+ const latest = useRef({ picked, openGuid, sorted });
+ latest.current = { picked, openGuid, sorted };
+ const rowActions = useMemo<RowActions>(
+ () => ({
+ click: (contact, e) => {
+ const { picked, openGuid, sorted } = latest.current;
+ if (e.metaKey || e.ctrlKey) {
+ // Command/Ctrl-click adds or takes away one, keeping the rest.
+ const base = picked.length ? picked : openGuid ? [openGuid] : [];
+ const next = base.includes(contact.guid) ? base.filter((g) => g !== contact.guid) : [...base, contact.guid];
+ setPicked(next.length > 1 ? next : []);
+ if (next.length === 1) setOpenGuid(next[0]);
+ return;
+ }
+ if (e.shiftKey && openGuid) {
+ // Shift-click takes everyone between the last picked and this one.
+ const order = sorted.map((c) => c.guid);
+ const [a, z] = [order.indexOf(openGuid), order.indexOf(contact.guid)].sort((x, y) => x - y);
+ if (a >= 0) {
+ const range = order.slice(a, z + 1);
+ setPicked(range.length > 1 ? range : []);
+ return;
+ }
+ }
+ setPicked([]);
+ setOpenGuid(contact.guid);
+ setDetail(true);
+ },
+ dragStart: (contact, e) => {
+ const { picked } = latest.current;
+ e.dataTransfer.effectAllowed = "copy";
+ e.dataTransfer.setData("text/plain", displayName(contact));
+ setDragging(picked.includes(contact.guid) ? picked : [contact.guid]);
+ },
+ dragEnd: () => {
+ setDragging(null);
+ setDropOn(null);
+ },
+ menu: (contact, e) => {
+ e.preventDefault();
+ setOpenGuid(contact.guid);
+ setContactMenu({ x: e.clientX, y: e.clientY, alignRight: false, contact, lists: false });
+ },
+ }),
+ [],
+ );
+
+ /** The letters the shown names begin with, for the index down the list's edge. */
+ const letters = useMemo(() => lettered.filter((r) => r.starts).map((r) => r.letter), [lettered]);
+ /** The index earns its column only when the list is longer than the window shows. */
+ const [overflowing, setOverflowing] = useState(false);
+ useEffect(() => {
+ const list = rowsRef.current;
+ if (!list || typeof ResizeObserver === "undefined") return undefined;
+ const measure = () => setOverflowing(list.scrollHeight > list.clientHeight + 1);
+ measure();
+ const watch = new ResizeObserver(measure);
+ watch.observe(list);
+ return () => watch.disconnect();
+ }, [sorted]);
+ const jumpTo = (letter: string) => {
+ const list = rowsRef.current;
+ const head = list?.querySelector<HTMLElement>(`.contact-letter[data-letter="${CSS.escape(letter)}"]`);
+ if (list && head) list.scrollTop = head.offsetTop;
+ };
+
+ // The keys Contacts on the Mac answers (Ctrl in place of Command here): ⌘N a new card,
+ // ⌘F the search, the arrows walk the list — Shift with them widens the selection — Return
+ // edits the card, Delete deletes it, and Escape leaves a card being written unsaved.
+ const live = useActiveRef();
+ const keys = useRef<(e: KeyboardEvent) => void>(() => {});
+ keys.current = (e: KeyboardEvent) => {
+ if (!live.current || e.defaultPrevented) return;
+ // A menu, a picker's list or a sheet open over the screen has the keys to itself.
+ if (document.querySelector('[role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"]')) return;
+ const target = e.target as HTMLElement | null;
+ const inSearch = target === searchRef.current;
+ const typing = !inSearch && !!target?.closest?.("input, textarea, select, [contenteditable]");
+ const command = (e.metaKey || e.ctrlKey) && !e.altKey;
+ const k = e.key.toLowerCase();
+ if (command && !e.shiftKey && k === "n") {
+ e.preventDefault();
+ if (!busy) {
+ setPicked([]);
+ setDraft(blank());
+ }
+ return;
+ }
+ if (command && !e.shiftKey && k === "f") {
+ e.preventDefault();
+ if (draft) return;
+ setDetail(false);
+ searchRef.current?.focus();
+ searchRef.current?.select();
+ return;
+ }
+ if (draft) {
+ // Escape, from a field or not, leaves the card being written, as Cancel does.
+ if (e.key === "Escape") {
+ e.preventDefault();
+ setDraft(null);
+ }
+ return;
+ }
+ if (typing || e.altKey || command) return;
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
+ if (sorted.length === 0) return;
+ e.preventDefault();
+ const order = sorted.map((c) => c.guid);
+ const at = openGuid ? order.indexOf(openGuid) : -1;
+ const nextAt = Math.min(order.length - 1, Math.max(0, at + (e.key === "ArrowDown" ? 1 : -1)));
+ const next = order[at < 0 ? 0 : nextAt];
+ if (e.shiftKey && openGuid && at >= 0) {
+ // Shift and an arrow: the run from where it began to here, as in Finder.
+ const base = picked.length ? picked : [openGuid];
+ const anchor = base[0];
+ const [a, z] = [order.indexOf(anchor), order.indexOf(next)].sort((x, y) => x - y);
+ const range = order.slice(a, z + 1);
+ setPicked(range.length > 1 ? (anchor === range[0] ? range : [anchor, ...range.filter((g) => g !== anchor)]) : []);
+ setOpenGuid(next);
+ } else {
+ setPicked([]);
+ setOpenGuid(next);
+ }
+ showRow(next, !inSearch);
+ return;
+ }
+ if (inSearch) {
+ // Return in the search field goes to the first match, as Contacts does.
+ if (e.key === "Enter" && sorted.length) {
+ e.preventDefault();
+ setOpenGuid(sorted[0].guid);
+ setDetail(true);
+ showRow(sorted[0].guid, true);
+ }
+ return;
+ }
+ if (e.key === "Enter" && open && !multi && !busy) {
+ // A button with the focus would press itself; Return on the list means "edit".
+ if (target?.closest?.("button") && !target.closest(".contact-row")) return;
+ e.preventDefault();
+ edit(open);
+ } else if ((e.key === "Delete" || e.key === "Backspace") && !busy) {
+ if (target?.closest?.(".contact-detail button")) return;
+ e.preventDefault();
+ if (multi) void removeMany(pickedPeople);
+ else if (open) askDelete(open);
+ }
+ };
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => keys.current(e);
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, []);
+
return (
// A contact being written is always what shows; it has its own Cancel.
<div className={`contacts${detail || draft ? " is-detail" : ""}`}>
<aside className="contacts-lists" aria-label="Contact lists">
- <p className="notes-side-heading">iCloud</p>
+ <p className="side-heading">iCloud</p>
<ListRow
name="All Contacts"
count={contacts.length}
@@ -453,7 +679,7 @@ export function ContactsView() {
<ListRow
key={l.guid}
name={l.name}
- count={l.members.filter((m) => contacts.some((c) => c.guid.toUpperCase() === m.toUpperCase())).length}
+ count={listCounts.get(l.guid) ?? 0}
current={list === l.guid}
menuOpen={listMenu?.list.guid === l.guid}
dropping={dropOn === l.guid}
@@ -479,7 +705,7 @@ export function ContactsView() {
{naming === "new" && (
<NameField initial="Untitled List" label="New list name" onDone={(name) => { setNaming(null); void createList(name); }} onCancel={() => setNaming(null)} />
)}
- <button className="notes-new-folder" onClick={() => setNaming("new")}>
+ <button className="side-add" onClick={() => setNaming("new")}>
<Plus size={15} strokeWidth={2} aria-hidden="true" />
New List
</button>
@@ -490,24 +716,21 @@ export function ContactsView() {
entries={[
{ label: "Rename List", run: () => setNaming(listMenu.list.guid) },
null,
- { label: "Delete List\u2026", danger: true, run: () => deleteList(listMenu.list) },
+ { label: "Delete List", danger: true, run: () => deleteList(listMenu.list) },
]}
/>
)}
</aside>
<section className="contacts-list" aria-label="Contacts">
- <header className="cal-bar">
- <div className="cal-nav">
- {/* The count is the sidebar's, beside the list's name; said twice it was noise. */}
- <h1>{openList?.name ?? "Contacts"}</h1>
- </div>
- <div className="cal-actions">
- <button className="quiet" disabled={busy} onClick={() => setDraft(blank())}>
- New contact
+ <header className="pane-head contacts-head">
+ <PaneTitle count={`${shown.length} ${shown.length === 1 ? "contact" : "contacts"}`}>{openList?.name ?? "Contacts"}</PaneTitle>
+ <div className="contacts-head-actions">
+ <button className="icon-button" aria-label="New contact" title="New Contact" disabled={busy} onClick={() => setDraft(blank())}>
+ <UserPlus size={18} strokeWidth={2} aria-hidden="true" />
</button>
<button
- className="quiet"
+ className="icon-button"
aria-label="More"
aria-haspopup="menu"
title="More"
@@ -522,13 +745,13 @@ export function ContactsView() {
</div>
</header>
- <input
+ <SearchField
+ ref={searchRef}
className="contacts-search"
value={search}
- onChange={(e) => setSearch(e.target.value)}
+ onChange={setSearch}
placeholder="Search"
aria-label="Search contacts"
- type="search"
/>
{/* Shown only when the lists column has folded away. */}
@@ -541,21 +764,28 @@ export function ContactsView() {
/>
</div>
- {error && <Notice message={error} onDismiss={() => setError(null)} />}
- {done && <p className="drive-saved" role="status">{done}</p>}
+ <Unsent refused={outbox.refused} what="a change to a contact" onResend={(r) => void outbox.resend(r)} onDiscard={(r) => void outbox.discard(r)} />
{moreMenu && (
<RowMenu
at={moreMenu}
onClose={() => setMoreMenu(null)}
entries={[
- { label: "Import Contacts\u2026", run: () => void importCards() },
- { label: openList ? `Export \u201c${openList.name}\u201d\u2026` : "Export All Contacts\u2026", run: () => void exportCards(sortedContacts(shown), openList?.name) },
+ { label: "Import Contacts", run: () => void importCards() },
+ { label: openList ? `Export \u201c${openList.name}\u201d` : "Export All Contacts", run: () => void exportCards(sorted, openList?.name) },
]}
/>
)}
+ <div className="contact-rows-wrap">
<ul
- className="contact-rows"
+ className={`contact-rows${listFocused ? " is-focused" : ""}`}
+ ref={rowsRef}
+ // Whether the focus is in the list, for the selection's colour — a class rather than
+ // :focus-within, which made WebKit restyle every row at each arrow press.
+ onFocus={() => setListFocused(true)}
+ onBlur={(e) => {
+ if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setListFocused(false);
+ }}
onKeyDown={(e) => {
// Command/Ctrl-A: everyone shown.
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") {
@@ -567,85 +797,73 @@ export function ContactsView() {
}
}}
>
- {sortedContacts(shown).map((contact, i, all) => (
+ {lettered.map(({ contact, letter, starts }) => (
<Fragment key={contact.guid}>
- {(i === 0 || letterOf(all[i - 1]) !== letterOf(contact)) && (
- <li className="contact-letter" aria-hidden="true">{letterOf(contact)}</li>
+ {starts && (
+ <li className="contact-letter" data-letter={letter} aria-hidden="true">{letter}</li>
)}
- <li
- // Dragged onto a list, a person joins it — as in Contacts on the Mac.
+ <ContactRow
+ contact={contact}
+ current={multi ? pickedSet.has(contact.guid) : openGuid === contact.guid}
+ mine={me === contact.guid}
draggable={lists.length > 0}
- onDragStart={(e) => {
- e.dataTransfer.effectAllowed = "copy";
- e.dataTransfer.setData("text/plain", displayName(contact));
- setDragging(picked.includes(contact.guid) ? picked : [contact.guid]);
- }}
- onDragEnd={() => { setDragging(null); setDropOn(null); }}
- onContextMenu={(e) => {
- e.preventDefault();
- setOpenGuid(contact.guid);
- setContactMenu({ x: e.clientX, y: e.clientY, alignRight: false, contact, lists: false });
- }}
- >
- <button
- className="contact-row"
- aria-current={multi ? picked.includes(contact.guid) : openGuid === contact.guid}
- onClick={(e) => {
- if (e.metaKey || e.ctrlKey) {
- // Command/Ctrl-click adds or takes away one, keeping the rest.
- const base = picked.length ? picked : openGuid ? [openGuid] : [];
- const next = base.includes(contact.guid) ? base.filter((g) => g !== contact.guid) : [...base, contact.guid];
- setPicked(next.length > 1 ? next : []);
- if (next.length === 1) setOpenGuid(next[0]);
- return;
- }
- if (e.shiftKey && openGuid) {
- // Shift-click takes everyone between the last picked and this one.
- const order = all.map((c) => c.guid);
- const [a, z] = [order.indexOf(openGuid), order.indexOf(contact.guid)].sort((x, y) => x - y);
- if (a >= 0) {
- const range = order.slice(a, z + 1);
- setPicked(range.length > 1 ? range : []);
- return;
- }
- }
- setPicked([]);
- setOpenGuid(contact.guid);
- setDetail(true);
- }}
- >
- <Avatar contact={contact} />
- <span className="contact-row-name">{displayName(contact)}</span>
- {me === contact.guid && <span className="contact-me" title="My Card">me</span>}
- </button>
- </li>
+ waiting={outbox.waiting.has(contact.guid)}
+ actions={rowActions}
+ />
</Fragment>
))}
</ul>
+ {/* The letters down the edge, as icloud.com and the phone index a long list: a press,
+ or a drag along them, goes straight to that letter. */}
+ {letters.length > 1 && overflowing && (
+ <nav
+ className="contact-index"
+ aria-label="Jump to letter"
+ onPointerDown={(e) => {
+ if (e.button !== 0) return;
+ const letter = (e.target as HTMLElement).closest?.<HTMLElement>(".contact-index button")?.dataset.letter;
+ if (letter) jumpTo(letter);
+ e.currentTarget.setPointerCapture?.(e.pointerId);
+ }}
+ onPointerMove={(e) => {
+ if (!e.currentTarget.hasPointerCapture?.(e.pointerId)) return;
+ const under = document.elementFromPoint(e.clientX, e.clientY) as HTMLElement | null;
+ const letter = under?.closest?.<HTMLElement>(".contact-index button")?.dataset.letter;
+ if (letter) jumpTo(letter);
+ }}
+ >
+ {letters.map((l) => (
+ <button key={l} type="button" tabIndex={-1} data-letter={l} aria-label={`Contacts under ${l}`} onClick={() => jumpTo(l)}>
+ {l}
+ </button>
+ ))}
+ </nav>
+ )}
+ </div>
- {loaded && shown.length === 0 && !error && (
- <p className="cal-empty">{search ? "No matches." : openList ? "No one in this list yet." : "No contacts yet."}</p>
+ {shown.length === 0 && !search && <Arriving service="contacts" what="contacts" />}
+ {loaded && shown.length === 0 && !error && !(arriving && !search) && (
+ <EmptyState className="contact-empty">{search ? "No matches." : openList ? "No one in this list yet." : "No contacts yet."}</EmptyState>
)}
{deleting && openList && (
- <Portal>
- <div className="modal-veil" onClick={() => setDeleting(null)}>
- <div className="modal-sheet cx-ask" role="alertdialog" aria-label="Delete contact" onClick={(e) => e.stopPropagation()}
- onKeyDown={(e) => { if (e.key === "Escape") setDeleting(null); }}>
- <h2>Delete {displayName(deleting)}?</h2>
- <p>Remove this contact from &ldquo;{openList.name}&rdquo;, or delete the card from Contacts on every device.</p>
- <div className="cx-ask-actions">
- <button className="primary" autoFocus onClick={() => { const c = deleting; setDeleting(null); removeFromList(openList, [c.guid]); }}>
- Remove from List
- </button>
- <button className="quiet danger" onClick={() => { const c = deleting; setDeleting(null); void removeContact(c.guid); }}>
- Delete Card
- </button>
- <button className="quiet" onClick={() => setDeleting(null)}>Cancel</button>
- </div>
- </div>
- </div>
- </Portal>
+ <ConfirmSheet<"list" | "card">
+ title={`Delete ${displayName(deleting)}?`}
+ label="Delete contact"
+ body={<>Remove this contact from &ldquo;{openList.name}&rdquo;, or delete the card from Contacts on every device.</>}
+ choices={[
+ { label: "Remove from List", value: "list", primary: true, focus: true },
+ { label: "Delete Card", value: "card", danger: true },
+ ]}
+ onAnswer={(how) => {
+ const c = deleting;
+ setDeleting(null);
+ if (how === "list") removeFromList(openList, [c.guid]);
+ else void removeContact(c.guid);
+ }}
+ onCancel={() => setDeleting(null)}
+ />
)}
+ {confirmSheet}
{contactMenu && (
<RowMenu
at={contactMenu}
@@ -738,7 +956,7 @@ export function ContactsView() {
options={[
...(m.label === null && !custom ? [{ value: "", label: "no label" }] : []),
...standard.map((v) => ({ value: v, label: labelText(v) })),
- { value: CUSTOM, label: "custom…" },
+ { value: CUSTOM, label: "Custom" },
]}
/>
{custom && (
@@ -883,7 +1101,7 @@ export function ContactsView() {
entries={[
...lists.filter((l) => !l.guid.startsWith("pending-")).map((l) => ({ label: l.name, run: () => addToList(l, pickedPeople.map((c) => c.guid)) })),
...(lists.length ? [null] : []),
- { label: "New List\u2026", run: () => void createList("Untitled List", pickedPeople.map((c) => c.guid)) },
+ { label: "New List", run: () => void createList("Untitled List", pickedPeople.map((c) => c.guid)) },
]}
/>
)}
@@ -905,14 +1123,31 @@ export function ContactsView() {
</div>
<dl className="contact-methods">
- {open.methods.map((m, i) => (
- <div key={`${m.kind}-${i}`}>
- <dt>{(m.label && labelText(m.label)) || KIND_LABEL[m.kind] || m.kind}</dt>
+ {open.methods.map((m, i) => {
+ const key = `${m.kind}-${i}`;
+ const label = (m.label && labelText(m.label)) || KIND_LABEL[m.kind] || m.kind;
+ return (
+ <div key={key}>
+ {/* The label copies what is beside it, as a click on one does in Contacts. */}
+ <dt>
+ <button
+ type="button"
+ className="contact-copy"
+ title={`Copy ${label}`}
+ aria-label={`Copy ${label}`}
+ onClick={() => void copyText(m.value).then((ok) => ok && setCopied(key))}
+ >
+ <span className={copied === key ? "is-hidden" : undefined}>{label}</span>
+ <span className={copied === key ? undefined : "is-hidden"} aria-hidden={copied !== key}>copied</span>
+ </button>
+ </dt>
<dd>
{m.kind === "email" ? (
<a href={`mailto:${m.value}`}>{m.value}</a>
) : m.kind === "phone" ? (
- <a href={`tel:${m.value}`}>{m.value}</a>
+ <a href={`tel:${m.value.replace(/[^\d+#*,;]/g, "")}`}>{m.value}</a>
+ ) : m.kind === "url" ? (
+ <a href={webHref(m.value)}>{m.value}</a>
) : m.kind === "address" ? (
// A postal address is several lines and stays that way.
<span className="contact-address">{m.value}</span>
@@ -921,7 +1156,8 @@ export function ContactsView() {
)}
</dd>
</div>
- ))}
+ );
+ })}
{open.birthday && (
<div>
<dt>birthday</dt>
@@ -931,7 +1167,7 @@ export function ContactsView() {
</dl>
{open.methods.length === 0 && !open.birthday && (
- <p className="cal-empty">No phone numbers or addresses saved.</p>
+ <p className="contact-none">No phone numbers or addresses saved.</p>
)}
{open.notes && <p className="contact-notes">{open.notes}</p>}
@@ -964,13 +1200,84 @@ export function ContactsView() {
</div>
</>
) : (
- loaded && <p className="cal-empty">Select a contact.</p>
+ loaded && <EmptyState className="contact-pick">Select a contact.</EmptyState>
)}
</article>
</div>
);
}
+type RowActions = {
+ click: (contact: Contact, e: React.MouseEvent) => void;
+ dragStart: (contact: Contact, e: React.DragEvent) => void;
+ dragEnd: () => void;
+ menu: (contact: Contact, e: React.MouseEvent) => void;
+};
+
+/**
+ * One person in the list. Drawn again only when what it shows changes — its name, its picture,
+ * whether it is selected — so a click or a key in a long address book touches two rows, not
+ * every one. The layout of a row off screen is skipped too (content-visibility, in the CSS).
+ */
+const ContactRow = memo(function ContactRow({ contact, current, mine, draggable, waiting, actions }: {
+ contact: Contact;
+ current: boolean;
+ mine: boolean;
+ draggable: boolean;
+ /** Saved here, not yet at Apple. */
+ waiting: boolean;
+ actions: RowActions;
+}) {
+ return (
+ <li
+ // Dragged onto a list, a person joins it — as in Contacts on the Mac.
+ draggable={draggable}
+ onDragStart={(e) => actions.dragStart(contact, e)}
+ onDragEnd={actions.dragEnd}
+ onContextMenu={(e) => actions.menu(contact, e)}
+ >
+ <button
+ className="contact-row"
+ data-guid={contact.guid}
+ aria-current={current}
+ onClick={(e) => actions.click(contact, e)}
+ >
+ <Avatar contact={contact} />
+ <span className="contact-row-name">{displayName(contact)}</span>
+ {mine && <span className="contact-me" title="My Card">me</span>}
+ <Waiting shown={waiting} />
+ </button>
+ </li>
+ );
+});
+
+/** Text onto the clipboard; the older way where the newer one is refused. */
+async function copyText(text: string): Promise<boolean> {
+ try {
+ await navigator.clipboard.writeText(text);
+ return true;
+ } catch {
+ const field = document.createElement("textarea");
+ field.value = text;
+ field.setAttribute("readonly", "");
+ field.style.position = "fixed";
+ field.style.opacity = "0";
+ document.body.appendChild(field);
+ field.select();
+ let copied = false;
+ try {
+ copied = document.execCommand("copy");
+ } catch {
+ copied = false;
+ }
+ field.remove();
+ return copied;
+ }
+}
+
+/** A link a person typed without its scheme still opens: "example.com" is the web. */
+const webHref = (value: string) => (/^[a-z][a-z0-9+.-]*:/i.test(value.trim()) ? value.trim() : `https://${value.trim()}`);
+
/** A row in the lists column: All Contacts, or one list, with its count and ⋯. */
function ListRow({
name,
@@ -1009,14 +1316,14 @@ function ListRow({
onDragLeave={onDragLeave}
onDrop={onDrop}
>
- <button className="notes-folder" aria-current={current} onClick={onOpen}>
+ <button className="source-row notes-folder" aria-current={current} onClick={onOpen}>
<Glyph className="contacts-list-glyph" size={16} strokeWidth={2} aria-hidden="true" />
- <span className="notes-folder-name">{name}</span>
- <span className="notes-folder-count">{count || ""}</span>
+ <span className="source-name notes-folder-name">{name}</span>
+ <span className="count notes-folder-count">{count || ""}</span>
</button>
{onMenu && (
<button
- className="notes-folder-more"
+ className="icon-button small round row-more notes-folder-more"
aria-label={`Actions for ${name}`}
aria-haspopup="menu"
onClick={(e) => {
@@ -1041,7 +1348,7 @@ function NameField({ initial, label, onDone, onCancel }: {
const settled = useRef(false);
return (
<input
- className="notes-folder notes-folder-rename"
+ className="field notes-folder-rename"
defaultValue={initial}
aria-label={label}
autoFocus
diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsx
index 609bb26..712b9a0 100644
--- a/src/screens/DriveView.tsx
+++ b/src/screens/DriveView.tsx
@@ -1,7 +1,11 @@
-import { useCallback, useEffect, useRef, useState } from "react";
+import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useActiveRef, useScreenActive } from "../lib/screen";
import { useSync } from "../lib/sync";
-import { Notice } from "../components/Notice";
+import { toastSaved, useErrorToast } from "../components/Toast";
+import { useConfirm } from "../components/Confirm";
+import { EmptyState } from "../components/EmptyState";
+import { Spinner } from "../components/Spinner";
+import { PaneTitle } from "../components/PaneTitle";
import { Portal } from "../components/Portal";
import { open as openFileDialog } from "@tauri-apps/plugin-dialog";
import { getCurrentWebview } from "@tauri-apps/api/webview";
@@ -36,6 +40,7 @@ const SORTS = [
] as const;
type SortKey = (typeof SORTS)[number]["key"];
const SORT_KEY = "quince.drive.sort";
+const SORT_REVERSED = "quince.drive.sortReversed";
/**
* Names compare as Finder compares them — "File 2" before "File 10", case ignored; dates and
@@ -43,7 +48,7 @@ const SORT_KEY = "quince.drive.sort";
* Kind, which is itself the grouping.
*/
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
-function sortItems(rows: DriveItem[], by: SortKey): DriveItem[] {
+function sortItems(rows: DriveItem[], by: SortKey, reversed = false): DriveItem[] {
const name = (a: DriveItem, b: DriveItem) => collator.compare(a.name, b.name);
const folderFirst = (a: DriveItem, b: DriveItem) => Number(isContainer(b)) - Number(isContainer(a));
const kindOf = (i: DriveItem) => (isContainer(i) ? " " : (i.extension ?? "").toLowerCase());
@@ -53,7 +58,12 @@ function sortItems(rows: DriveItem[], by: SortKey): DriveItem[] {
kind: (a, b) => collator.compare(kindOf(a), kindOf(b)) || name(a, b),
size: (a, b) => folderFirst(a, b) || (b.size ?? 0) - (a.size ?? 0) || name(a, b),
};
- return [...rows].sort(order[by]);
+ // A second click on a heading turns the order round, as in Finder; folders stay on top.
+ const turn = reversed ? -1 : 1;
+ const sorter = by === "kind"
+ ? (a: DriveItem, b: DriveItem) => turn * order.kind(a, b)
+ : (a: DriveItem, b: DriveItem) => folderFirst(a, b) || turn * order[by](a, b);
+ return [...rows].sort(sorter);
}
const KB = 1024;
@@ -71,14 +81,19 @@ function fileSize(bytes: number | null): string {
return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
}
-const modified = (seconds: number | null) =>
- seconds === null
- ? ""
- : dateText(new Date(seconds * 1000), {
- day: "numeric",
- month: "short",
- year: "numeric",
- });
+/** As Finder writes Date Modified: "Today, 10:12", "Yesterday, 18:40", then the date. */
+const modified = (seconds: number | null, now = new Date()) => {
+ if (seconds === null) return "";
+ const d = new Date(seconds * 1000);
+ const days = Math.round(
+ (new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime() -
+ new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()) / 864e5,
+ );
+ if (days === 0 || days === 1) {
+ return `${days === 0 ? "Today" : "Yesterday"}, ${timeText(d, { hour: "numeric", minute: "2-digit" })}`;
+ }
+ return dateText(d, { day: "numeric", month: "short", year: "numeric" });
+};
/**
* Recently Deleted, as icloud.com shows it: what was deleted, when, and two ways out —
@@ -89,6 +104,7 @@ const modified = (seconds: number | null) =>
function DriveTrash({ onClose }: { onClose: () => void }) {
const [rows, setRows] = useState<TrashItem[] | null>(null);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
const read = useCallback(async () => {
try {
setRows(await api.driveTrash());
@@ -124,32 +140,30 @@ function DriveTrash({ onClose }: { onClose: () => void }) {
}
};
const recover = (items: TrashItem[]) => out(items, true);
+ const [confirm, confirmSheet] = useConfirm();
const destroy = (items: TrashItem[]) => {
const what = items.length === 1 ? `\u201c${driveName(items[0])}\u201d` : `these ${items.length} items`;
- if (!window.confirm(`Delete ${what} now? You can\u2019t undo this.`)) return;
- void out(items, false);
+ void confirm({ title: `Delete ${what} now?`, body: "You can\u2019t undo this.", action: "Delete", danger: true, symbol: "trash" }).then(
+ (sure) => sure && void out(items, false),
+ );
};
return (
<div className="drive drive-trash">
- <header className="cal-bar">
- <nav className="crumbs" aria-label="Folder path">
- <button className="crumb" onClick={onClose}>iCloud Drive</button>
- <span className="crumb-sep" aria-hidden="true">›</span>
+ <header className="pane-head drive-bar">
+ <PaneTitle before={<nav className="crumbs" aria-label="Folder path"><button className="crumb" onClick={onClose}>iCloud Drive</button></nav>}>
<button className="crumb" aria-current>Recently Deleted</button>
- </nav>
+ </PaneTitle>
{rows && rows.length > 0 && (
- <div className="cal-actions">
- <button className="quiet" onClick={() => void recover(rows)}>Recover All</button>
- <button className="quiet danger" onClick={() => destroy(rows)}>Delete All</button>
+ <div className="toolbar-group">
+ <button className="tool has-label is-accent" onClick={() => void recover(rows)}>Recover All</button>
+ <button className="tool has-label danger" onClick={() => destroy(rows)}>Delete All</button>
</div>
)}
</header>
- {error && <Notice message={error} onDismiss={() => setError(null)} />}
- {rows === null && <p className="cal-empty">Loading…</p>}
- {rows && rows.length === 0 && !error && (
- <p className="cal-empty">Nothing in Recently Deleted.</p>
- )}
+ {rows === null && <EmptyState busy>Loading…</EmptyState>}
+ {rows && rows.length === 0 && !error && <EmptyState>Nothing in Recently Deleted.</EmptyState>}
+ {confirmSheet}
{rows && rows.length > 0 && (
<ul className="drive-rows">
{rows.map((item) => (
@@ -171,8 +185,8 @@ function DriveTrash({ onClose }: { onClose: () => void }) {
</span>
</span>
<span className="drive-row-actions is-shown">
- <button className="quiet" onClick={() => void recover([item])}>Recover</button>
- <button className="quiet danger" onClick={() => destroy([item])}>Delete Now</button>
+ <button className="link" onClick={() => void recover([item])}>Recover</button>
+ <button className="link danger" onClick={() => destroy([item])}>Delete Now</button>
</span>
</div>
</li>
@@ -191,7 +205,7 @@ function DriveTrash({ onClose }: { onClose: () => void }) {
function DriveRecents({ onClose }: { onClose: () => void }) {
const [rows, setRows] = useState<RecentItem[] | null>(null);
const [error, setError] = useState<string | null>(null);
- const [savedTo, setSavedTo] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
const [busy, setBusy] = useState<string | null>(null);
const [selected, setSelected] = useState<string | null>(null);
const [menu, setMenu] = useState<{ item: RecentItem; x: number; y: number; alignRight: boolean } | null>(null);
@@ -204,16 +218,11 @@ function DriveRecents({ onClose }: { onClose: () => void }) {
},
);
}, []);
- useEffect(() => {
- if (!savedTo) return undefined;
- const timer = window.setTimeout(() => setSavedTo(null), 4000);
- return () => window.clearTimeout(timer);
- }, [savedTo]);
const download = async (item: RecentItem) => {
setBusy(item.drivewsid);
setError(null);
try {
- setSavedTo(await api.driveDownload(item.drivewsid, item));
+ toastSaved(await api.driveDownload(item.drivewsid, item));
} catch (e) {
setError(messageOf(e));
} finally {
@@ -223,19 +232,13 @@ function DriveRecents({ onClose }: { onClose: () => void }) {
const groups = groupRecents(rows ?? []);
return (
<div className="drive drive-recents">
- <header className="cal-bar">
- <nav className="crumbs" aria-label="Folder path">
- <button className="crumb" onClick={onClose}>iCloud Drive</button>
- <span className="crumb-sep" aria-hidden="true">›</span>
+ <header className="pane-head drive-bar">
+ <PaneTitle before={<nav className="crumbs" aria-label="Folder path"><button className="crumb" onClick={onClose}>iCloud Drive</button></nav>}>
<button className="crumb" aria-current>Recents</button>
- </nav>
+ </PaneTitle>
</header>
- {error && <Notice message={error} onDismiss={() => setError(null)} />}
- {savedTo && <p className="drive-saved" role="status">Saved to {savedTo}</p>}
- {rows === null && <p className="cal-empty">Loading…</p>}
- {rows && rows.length === 0 && !error && (
- <p className="cal-empty">Files which you’ve opened recently will appear here.</p>
- )}
+ {rows === null && <EmptyState busy>Loading…</EmptyState>}
+ {rows && rows.length === 0 && !error && <EmptyState>Files you open show here, newest first.</EmptyState>}
{groups.map((g) => (
<section key={g.heading} aria-label={g.heading}>
<h2 className="drive-group">{g.heading}</h2>
@@ -263,7 +266,7 @@ function DriveRecents({ onClose }: { onClose: () => void }) {
}}
>
<span className="drive-badge" aria-hidden="true">
- {busy === item.drivewsid ? <span className="drive-spinner" /> : <FileGlyph kind={item.kind} extension={item.extension} />}
+ {busy === item.drivewsid ? <Spinner small /> : <FileGlyph kind={item.kind} extension={item.extension} />}
</span>
<span className="drive-name">{driveName(item)}</span>
<span className="drive-meta drive-kind">{kindName(item)}</span>
@@ -360,7 +363,7 @@ function InfoSheet({ item, where, thumb, onClose }: { item: DriveItem; where: st
<div className="modal-sheet info-sheet" role="dialog" aria-label="File Info" onClick={(e) => e.stopPropagation()}>
<header className="info-head">
<h2>{isContainer(item) ? "Folder Info" : "File Info"}</h2>
- <button ref={done} className="quiet info-done" onClick={onClose}>Done</button>
+ <button ref={done} className="link info-done" onClick={onClose}>Done</button>
</header>
<div className={`info-mark${thumb ? " has-thumb" : ""}`} aria-hidden="true">
{thumb ? <img src={thumb} alt="" draggable={false} /> : <FileGlyph kind={item.kind} extension={item.extension} />}
@@ -477,10 +480,21 @@ export function DriveView() {
return "name";
}
});
- const chooseSort = (key: SortKey) => {
+ const [reversed, setReversed] = useState(() => {
+ try {
+ return window.localStorage.getItem(SORT_REVERSED) === "1";
+ } catch {
+ return false;
+ }
+ });
+ /** An order, and which way round: a heading clicked again turns it, as in Finder. */
+ const chooseSort = (key: SortKey, turn = false) => {
+ const nextReversed = turn && key === sortBy ? !reversed : false;
setSortBy(key);
+ setReversed(nextReversed);
try {
window.localStorage.setItem(SORT_KEY, key);
+ window.localStorage.setItem(SORT_REVERSED, nextReversed ? "1" : "0");
} catch {
// Sorted for now; forgotten on restart.
}
@@ -488,17 +502,26 @@ export function DriveView() {
const [loading, setLoading] = useState(false);
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
const [busyGuid, setBusyGuid] = useState<string | null>(null);
/** A file just saved to Downloads, and where — shown for a moment, then cleared. */
- const [savedTo, setSavedTo] = useState<string | null>(null);
const [renaming, setRenaming] = useState<string | null>(null);
const [creatingFolder, setCreatingFolder] = useState(false);
const [newFolderName, setNewFolderName] = useState("");
/** The item a Move dialog is open for, if any. */
- const [moving, setMoving] = useState<DriveItem | null>(null);
+ const [moving, setMoving] = useState<DriveItem[] | null>(null);
const [info, setInfo] = useState<DriveItem | null>(null);
- /** The one item selected, as a click in Finder selects it. */
- const [selected, setSelected] = useState<string | null>(null);
+ /**
+ * What is selected, as Finder selects: a click one, Command/Ctrl-click one more or one
+ * fewer, Shift-click the run. The last one picked is the one Return, F2 and Space act on.
+ */
+ const [picked, setPicked] = useState<string[]>([]);
+ const selected = picked.length ? picked[picked.length - 1] : null;
+ const setSelected = (id: string | null) => setPicked(id ? [id] : []);
+ /** Where a Shift-click or Shift-arrow run starts. */
+ const anchor = useRef<string | null>(null);
+ /** Quick Look: the selected file, large, while Space is held to it. */
+ const [peeking, setPeeking] = useState(false);
// A file or folder found by the search across everything: its folder opened, with the whole
// path above it in the trail, and it selected and brought into view — as Finder's "Show in
// Enclosing Folder". The path is walked up from the library, which knows every folder seen.
@@ -530,8 +553,8 @@ export function DriveView() {
}, [items]);
/** The ⋯ menu, or the same menu opened by a right-click, for one item. */
const [menu, setMenu] = useState<{ item: DriveItem; x: number; y: number; alignRight: boolean } | null>(null);
- /** An item of Drive's own being dragged onto a folder, and the folder it is over. */
- const dragItem = useRef<DriveItem | null>(null);
+ /** Items of Drive's own being dragged onto a folder — one, or all selected — and the folder it is over. */
+ const dragItem = useRef<DriveItem[] | null>(null);
const [dropOn, setDropOn] = useState<string | null>(null);
/** True while files are held over the window, so the drop target can say so. */
const [dropping, setDropping] = useState(false);
@@ -663,18 +686,22 @@ export function DriveView() {
};
}, [shown, refresh]);
const { revision } = useSync();
- const firstRevision = useRef(revision);
+ // A pass that lands while another screen is in front is read when this one comes back, once
+ // (a screen out of sight stays mounted): each landing asked Apple for the folder again.
+ const seen = useRef(revision);
+ if (shown) seen.current = revision;
+ const due = seen.current;
+ const firstRevision = useRef(due);
useEffect(() => {
- if (revision === firstRevision.current) return;
+ if (due === firstRevision.current) return;
void refresh();
- }, [revision, refresh]);
+ }, [due, refresh]);
const download = useCallback(async (item: DriveItem) => {
setBusyGuid(item.drivewsid);
setError(null);
try {
- const path = await api.driveDownload(item.drivewsid);
- setSavedTo(path);
+ toastSaved(await api.driveDownload(item.drivewsid));
} catch (e) {
setError(messageOf(e));
} finally {
@@ -682,12 +709,6 @@ export function DriveView() {
}
}, []);
- // The confirmation is a moment, not a state that lingers over the next thing you do.
- useEffect(() => {
- if (!savedTo) return undefined;
- const timer = window.setTimeout(() => setSavedTo(null), 4000);
- return () => window.clearTimeout(timer);
- }, [savedTo]);
const rename = useCallback(
async (item: DriveItem, name: string) => {
@@ -725,33 +746,45 @@ export function DriveView() {
* from there. The row leaves at once and stays gone — Apple's listing can carry it for a
* moment, and it used to flicker back — unless Apple refuses, when it returns and says why.
*/
- const remove = useCallback(
- async (item: DriveItem) => {
+ const removeAll = useCallback(
+ async (list: DriveItem[]) => {
+ if (list.length === 0) return;
setError(null);
- setGone((g) => new Set(g).add(item.drivewsid));
- // A folder still being uploaded into stops taking files first: deleting it while files
- // went on landing was what Apple would not do.
- if (isContainer(item)) {
- const into = [...uploadsRef.current.values()].filter(
- (u) => !["done", "failed", "cancelled"].includes(u.state) &&
- ((u.folder && !u.within && u.name === item.name) || u.within.split("/")[0] === item.name),
- );
- for (const batch of new Set(into.map((u) => u.batch))) await api.driveUploadCancel([], batch).catch(() => {});
+ const ids = list.map((i) => i.drivewsid);
+ setGone((g) => new Set([...g, ...ids]));
+ const refused: string[] = [];
+ let reason = "";
+ // One after another: Apple turns a burst of deletes away as busy.
+ for (const item of list) {
+ // A folder still being uploaded into stops taking files first: deleting it while files
+ // went on landing was what Apple would not do.
+ if (isContainer(item)) {
+ const into = [...uploadsRef.current.values()].filter(
+ (u) => !["done", "failed", "cancelled"].includes(u.state) &&
+ ((u.folder && !u.within && u.name === item.name) || u.within.split("/")[0] === item.name),
+ );
+ for (const batch of new Set(into.map((u) => u.batch))) await api.driveUploadCancel([], batch).catch(() => {});
+ }
+ try {
+ await api.driveDelete(item.drivewsid);
+ } catch (e) {
+ refused.push(item.drivewsid);
+ reason = messageOf(e);
+ }
}
- try {
- await api.driveDelete(item.drivewsid);
- await refresh();
- } catch (e) {
+ if (refused.length) {
setGone((g) => {
const next = new Set(g);
- next.delete(item.drivewsid);
+ for (const id of refused) next.delete(id);
return next;
});
- setError(messageOf(e));
+ setError(list.length === 1 ? reason : `${refused.length} of ${list.length} items could not be deleted: ${reason}`);
}
+ if (refused.length < list.length) await refresh();
},
[refresh]
);
+ const remove = useCallback((item: DriveItem) => removeAll([item]), [removeAll]);
/**
* Duplicate, as Finder: the copy lands beside the original as "Name 2", and shows as being
@@ -775,23 +808,33 @@ export function DriveView() {
[refresh, here.id]
);
- const move = useCallback(
- async (item: DriveItem, destinationId: string) => {
+ const moveAll = useCallback(
+ async (list: DriveItem[], destinationId: string) => {
setMoving(null);
setError(null);
+ const going = list.filter((i) => i.drivewsid !== destinationId);
+ if (going.length === 0) return;
// Out of this folder at once; back, with the reason, if Apple refuses.
- setGone((g) => new Set(g).add(item.drivewsid));
- try {
- await api.driveMove(item.drivewsid, destinationId);
- await refresh();
- } catch (e) {
+ setGone((g) => new Set([...g, ...going.map((i) => i.drivewsid)]));
+ const refused: string[] = [];
+ let reason = "";
+ for (const item of going) {
+ try {
+ await api.driveMove(item.drivewsid, destinationId);
+ } catch (e) {
+ refused.push(item.drivewsid);
+ reason = messageOf(e);
+ }
+ }
+ if (refused.length) {
setGone((g) => {
const next = new Set(g);
- next.delete(item.drivewsid);
+ for (const id of refused) next.delete(id);
return next;
});
- setError(messageOf(e));
+ setError(going.length === 1 ? reason : `${refused.length} of ${going.length} items could not be moved: ${reason}`);
}
+ if (refused.length < going.length) await refresh();
},
[refresh]
);
@@ -835,6 +878,19 @@ export function DriveView() {
setError(messageOf(e));
}
};
+ /**
+ * The folder whose row is under a point the window system gave (physical pixels), if it is
+ * one that takes files.
+ */
+ const folderAt = (x: number, y: number): string | null => {
+ const ratio = window.devicePixelRatio || 1;
+ const under = document.elementFromPoint(x / ratio, y / ratio) as HTMLElement | null;
+ const id = under?.closest?.<HTMLElement>(".drive-rows [data-id]")?.dataset.id;
+ const item = id ? itemsRef.current.find((i) => i.drivewsid === id) : undefined;
+ return item && item.kind === "FOLDER" && acceptsUploads(item.drivewsid) ? item.drivewsid : null;
+ };
+ const itemsRef = useRef(items);
+ itemsRef.current = items;
const settle = (key: string) => setPending((p) => p.filter((x) => !x.key.startsWith(key)));
const writingRef = useRef(false);
writingRef.current = busyGuid !== null || renaming !== null || pending.length > 0;
@@ -896,12 +952,13 @@ export function DriveView() {
const dismissUploads = useCallback(() => setUploads(new Map()), []);
const upload = useCallback(
- async (paths: string[]) => {
+ async (paths: string[], target?: string) => {
if (paths.length === 0) return;
setError(null);
// Never blocks the window: browse, open another folder, start another upload.
const batch = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
- const into = here.id;
+ // The open folder, or a folder in it the files were dropped on.
+ const into = target ?? here.id;
setPending((p) => [
...p,
...paths.map((path, i) => ({
@@ -913,8 +970,9 @@ export function DriveView() {
]);
try {
await api.driveUpload(batch, into, paths);
- // What failed is named in the tray, file by file; the folder is re-read either way.
- if (into === hereRef.current) await refresh();
+ // What failed is named in the tray, file by file; the folder is re-read either way —
+ // a folder in it that took the files shows its new count.
+ if (into === hereRef.current || target) await refresh();
} catch (e) {
setError(messageOf(e));
} finally {
@@ -968,11 +1026,20 @@ export function DriveView() {
.onDragDropEvent((event) => {
// A row of Drive's own being moved is not a file arriving from this machine.
if (dragItem.current) return;
- if (event.payload.type === "over") setDropping(true);
- else if (event.payload.type === "leave") setDropping(false);
- else if (event.payload.type === "drop") {
+ const p = event.payload;
+ // Over a folder's row, the files go into that folder, as Finder drops them; anywhere
+ // else, into the folder that is open.
+ const folder = p.type === "over" || p.type === "drop" ? folderAt(p.position.x, p.position.y) : null;
+ if (p.type === "over" || p.type === "enter") {
+ setDropping(!folder);
+ setDropOn((d) => (d === folder ? d : folder));
+ } else if (p.type === "leave") {
+ setDropping(false);
+ setDropOn(null);
+ } else if (p.type === "drop") {
setDropping(false);
- void upload(event.payload.paths);
+ setDropOn(null);
+ void upload(p.paths, folder ?? undefined);
}
})
.then((unlisten) => {
@@ -1022,67 +1089,271 @@ export function DriveView() {
}
}, [newFolderName, here.id, refresh, items]);
+ /** The rows as shown, sorted once per change to what is here or to the order. */
+ const rows = useMemo(
+ () => sortItems(items.filter((item) => !gone.has(item.drivewsid)), sortBy, reversed),
+ [items, gone, sortBy, reversed],
+ );
+ const pickedItems = useMemo(() => rows.filter((r) => picked.includes(r.drivewsid)), [rows, picked]);
+ const primary = useMemo(() => (selected ? rows.find((r) => r.drivewsid === selected) ?? null : null), [rows, selected]);
+ const listRef = useRef<HTMLUListElement | null>(null);
+ const [listFocused, setListFocused] = useState(false);
+ /** A row brought into view and given the focus, as the arrows leave it. */
+ const showRow = (id: string) =>
+ requestAnimationFrame(() => {
+ const hit = listRef.current?.querySelector<HTMLButtonElement>(`[data-id="${CSS.escape(id)}"] .drive-row-hit`);
+ hit?.scrollIntoView({ block: "nearest" });
+ hit?.focus({ preventScroll: true });
+ });
+ /** Everything from the anchor to `to`, in the order shown, with `to` last — the one acted on. */
+ const run = (to: string) => {
+ const order = rows.map((r) => r.drivewsid);
+ const from = anchor.current && order.includes(anchor.current) ? anchor.current : to;
+ const [a, z] = [order.indexOf(from), order.indexOf(to)].sort((x, y) => x - y);
+ return [...order.slice(a, z + 1).filter((id) => id !== to), to];
+ };
+ const openItem = (item: DriveItem) => (isContainer(item) ? enter(item) : void download(item));
+
+ /**
+ * What a row does, as one object that never changes, so a row is drawn again only when what
+ * it shows changes: in a folder of thousands, a click redrew every row in it. The handlers
+ * read the folder's state as it is when they run.
+ */
+ const latest = useRef({ rows, picked, run, openItem, rename, moveAll });
+ latest.current = { rows, picked, run, openItem, rename, moveAll };
+ const rowActions = useMemo<DriveRowActions>(
+ () => ({
+ click: (item, e) => {
+ const { picked, run } = latest.current;
+ const id = item.drivewsid;
+ if (e.metaKey || e.ctrlKey) {
+ // Command/Ctrl-click: one more, or one fewer, keeping the rest.
+ anchor.current = id;
+ setPicked(picked.includes(id) ? picked.filter((p) => p !== id) : [...picked, id]);
+ } else if (e.shiftKey && anchor.current) {
+ setPicked(run(id));
+ } else {
+ anchor.current = id;
+ setPicked([id]);
+ }
+ },
+ open: (item) => latest.current.openItem(item),
+ menu: (item, at) => {
+ const { picked } = latest.current;
+ // A right-click on something not selected selects it, as in Finder; on the selection,
+ // it is for all of it.
+ if (!picked.includes(item.drivewsid)) {
+ anchor.current = item.drivewsid;
+ setPicked([item.drivewsid]);
+ }
+ setMenu({ item, ...at });
+ },
+ dragStart: (item, e) => {
+ const { rows, picked } = latest.current;
+ // Dragging a selected row takes the whole selection with it.
+ dragItem.current = picked.includes(item.drivewsid) ? rows.filter((r) => picked.includes(r.drivewsid)) : [item];
+ e.dataTransfer.effectAllowed = "move";
+ e.dataTransfer.setData("application/x-quince-drive", item.drivewsid);
+ },
+ dragEnd: () => {
+ dragItem.current = null;
+ setDropOn(null);
+ },
+ dragOver: (item, e) => {
+ const moving = dragItem.current;
+ if (!moving || item.kind !== "FOLDER" || moving.some((m) => m.drivewsid === item.drivewsid)) return;
+ e.preventDefault();
+ e.dataTransfer.dropEffect = "move";
+ setDropOn((d) => (d === item.drivewsid ? d : item.drivewsid));
+ },
+ dragLeave: (item) => setDropOn((d) => (d === item.drivewsid ? null : d)),
+ drop: (item, e) => {
+ e.preventDefault();
+ const moving = dragItem.current;
+ dragItem.current = null;
+ setDropOn(null);
+ if (moving && item.kind === "FOLDER" && !moving.some((m) => m.drivewsid === item.drivewsid)) {
+ void latest.current.moveAll(moving, item.drivewsid);
+ }
+ },
+ rename: (item, name) => void latest.current.rename(item, name),
+ cancelRename: () => setRenaming(null),
+ }),
+ [],
+ );
+
+ // Finder's keys (Ctrl in place of Command): the arrows walk the selection — across and down
+ // in Grid — and Shift with them widens it; Return or Ctrl-Down opens, Ctrl-Up goes up a
+ // folder, F2 renames, Delete moves to Recently Deleted, Ctrl-A selects all, and Space shows
+ // the selected file large, as Quick Look does.
+ const live = useActiveRef();
+ const keys = useRef<(e: KeyboardEvent) => void>(() => {});
+ keys.current = (e: KeyboardEvent) => {
+ if (!live.current || e.defaultPrevented || inTrash || inRecents) return;
+ if (renaming || creatingFolder || moving || info) return;
+ const target = e.target as HTMLElement | null;
+ if (target?.closest?.("input, textarea, select, [contenteditable], .drive-bar, .upload-menu")) return;
+ if (!peeking && document.querySelector('[role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"]')) return;
+ // Return and Space press a focused button of their own; on a row or nowhere, they are Drive's.
+ const onRows = !target || target === document.body || !!target.closest?.(".drive-rows, .drive-peek");
+ const mod = (e.ctrlKey || e.metaKey) && !e.altKey;
+ const k = e.key;
+ if (peeking && (k === "Escape" || k === " ")) {
+ e.preventDefault();
+ setPeeking(false);
+ return;
+ }
+ const step = (by: number) => {
+ if (rows.length === 0) return;
+ const at = selected ? rows.findIndex((r) => r.drivewsid === selected) : -1;
+ const next = rows[at < 0 ? (by > 0 ? 0 : rows.length - 1) : Math.min(rows.length - 1, Math.max(0, at + by))].drivewsid;
+ if (e.shiftKey && selected) setPicked(run(next));
+ else {
+ anchor.current = next;
+ setPicked([next]);
+ }
+ showRow(next);
+ };
+ /** How many tiles a line of the grid holds, from where they are laid out. */
+ const across = () => {
+ const tiles = [...(listRef.current?.querySelectorAll<HTMLElement>(":scope > li[data-id]") ?? [])];
+ const top = tiles[0]?.offsetTop;
+ return Math.max(1, tiles.filter((t) => t.offsetTop === top).length);
+ };
+ if (mod && (k === "ArrowDown" || k === "o")) {
+ if (!primary) return;
+ e.preventDefault();
+ openItem(primary);
+ } else if (mod && k === "ArrowUp") {
+ e.preventDefault();
+ if (trail.length > 1) setTrail((t) => t.slice(0, -1));
+ } else if (mod && k.toLowerCase() === "a") {
+ e.preventDefault();
+ setPicked(rows.map((r) => r.drivewsid));
+ } else if (!mod && (k === "ArrowDown" || k === "ArrowUp")) {
+ e.preventDefault();
+ step((k === "ArrowDown" ? 1 : -1) * (grid ? across() : 1));
+ } else if (!mod && grid && (k === "ArrowRight" || k === "ArrowLeft")) {
+ e.preventDefault();
+ step(k === "ArrowRight" ? 1 : -1);
+ } else if (!mod && (k === "Home" || k === "End") && rows.length) {
+ e.preventDefault();
+ step(k === "Home" ? -rows.length : rows.length);
+ } else if (k === "Enter" && !mod && onRows && primary) {
+ e.preventDefault();
+ setPeeking(false);
+ openItem(primary);
+ } else if (k === "F2" && primary && pickedItems.length === 1 && busyGuid !== primary.drivewsid) {
+ e.preventDefault();
+ setPeeking(false);
+ setRenaming(primary.drivewsid);
+ } else if ((k === "Delete" || (mod && k === "Backspace")) && pickedItems.length) {
+ e.preventDefault();
+ setPeeking(false);
+ void removeAll(pickedItems);
+ } else if (k === " " && !mod && onRows && primary) {
+ e.preventDefault();
+ setPeeking(true);
+ }
+ };
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => keys.current(e);
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, []);
+ // Nothing selected, nothing to look at.
+ useEffect(() => {
+ if (!primary) setPeeking(false);
+ }, [primary]);
+ // A folder opened starts with nothing selected — except what a search came to show.
+ useEffect(() => {
+ if (!revealing.current) setPicked([]);
+ anchor.current = null;
+ setPeeking(false);
+ }, [here.id]);
+
if (inTrash) return <DriveTrash onClose={() => setInTrash(false)} />;
if (inRecents) return <DriveRecents onClose={() => setInRecents(false)} />;
+ /** A step of the path: the folder open is the title; one further up goes back to it, and takes
+ a dragged item, as Finder's path bar does. */
+ const crumbButton = (crumb: (typeof trail)[number], i: number) => (
+ <button
+ className={`crumb${dropOn === crumb.id ? " is-drop" : ""}`}
+ aria-current={i === trail.length - 1}
+ onClick={() => setTrail((t) => t.slice(0, i + 1))}
+ // A folder further up the path takes a dragged item too, as Finder's path bar does.
+ onDragOver={(e) => {
+ if (!dragItem.current || i === trail.length - 1) return;
+ e.preventDefault();
+ e.dataTransfer.dropEffect = "move";
+ if (dropOn !== crumb.id) setDropOn(crumb.id);
+ }}
+ onDragLeave={() => setDropOn((d) => (d === crumb.id ? null : d))}
+ onDrop={(e) => {
+ e.preventDefault();
+ const moving = dragItem.current;
+ dragItem.current = null;
+ setDropOn(null);
+ if (moving && i < trail.length - 1) void moveAll(moving, crumb.id);
+ }}
+ >
+ {crumb.name}
+ </button>
+ );
+
return (
- <div className={`drive${dropping ? " is-dropping" : ""}`}>
- <header className="cal-bar">
+ <div
+ className={`drive${dropping ? " is-dropping" : ""}`}
+ // A click on nothing — between or below the rows — selects nothing, as in Finder.
+ onClick={(e) => {
+ const t = e.target as HTMLElement;
+ if (!t.closest("[data-id], button, input, form, a, [role='menu'], .modal-veil, .drive-peek-veil")) setPicked([]);
+ }}
+ >
+ <header className="pane-head drive-bar">
{/* The folder's name with what is in it under it, as icloud.com writes them: one block
whose size never depends on when the count arrives, so the bar is laid out once. */}
- <div className="drive-title">
- <nav className="crumbs" aria-label="Folder path">
- {trail.map((crumb, i) => (
- <span key={crumb.id}>
- {i > 0 && (
- <span className="crumb-sep" aria-hidden="true">
- ›
- </span>
- )}
- <button
- className={`crumb${dropOn === crumb.id ? " is-drop" : ""}`}
- aria-current={i === trail.length - 1}
- onClick={() => setTrail((t) => t.slice(0, i + 1))}
- // A folder further up the path takes a dragged item too, as Finder's path bar does.
- onDragOver={(e) => {
- if (!dragItem.current || i === trail.length - 1) return;
- e.preventDefault();
- e.dataTransfer.dropEffect = "move";
- if (dropOn !== crumb.id) setDropOn(crumb.id);
- }}
- onDragLeave={() => setDropOn((d) => (d === crumb.id ? null : d))}
- onDrop={(e) => {
- e.preventDefault();
- const moving = dragItem.current;
- dragItem.current = null;
- setDropOn(null);
- if (moving && i < trail.length - 1) void move(moving, crumb.id);
- }}
- >
- {crumb.name}
- </button>
+ <PaneTitle
+ className="drive-title"
+ before={
+ trail.length > 1 && (
+ <nav className="crumbs" aria-label="Folder path">
+ {trail.slice(0, -1).map((crumb, i) => (
+ <span key={crumb.id}>
+ {i > 0 && <span className="crumb-sep" aria-hidden="true">›</span>}
+ {crumbButton(crumb, i)}
+ </span>
+ ))}
+ </nav>
+ )
+ }
+ count={
+ // How much is in it; its line is kept while it loads, so nothing moves when it comes.
+ <span className="drive-count" aria-live="polite">
+ {loaded
+ ? (() => {
+ const n = items.filter((x) => !gone.has(x.drivewsid)).length;
+ return `${n} item${n === 1 ? "" : "s"}${available ? `, ${available} available` : ""}`;
+ })()
+ : "\u00a0"}
</span>
- ))}
- </nav>
- {/* How much is in it; its line is kept while it loads, so nothing moves when it comes. */}
- <p className="drive-count" aria-live="polite">
- {loaded
- ? (() => {
- const n = items.filter((x) => !gone.has(x.drivewsid)).length;
- return `${n} item${n === 1 ? "" : "s"}${available ? `, ${available} available` : ""}`;
- })()
- : "\u00a0"}
- </p>
- </div>
- <div className="cal-actions">
- <button className="quiet with-glyph" title="Recents" onClick={() => setInRecents(true)}>
+ }
+ >
+ {crumbButton(trail[trail.length - 1], trail.length - 1)}
+ </PaneTitle>
+ <div className="drive-tools">
+ <span className="toolbar-group">
+ <button className="tool has-label with-glyph" title="Recents" onClick={() => setInRecents(true)}>
<Clock size={15} strokeWidth={1.6} aria-hidden="true" />
Recents
</button>
- <button className="quiet with-glyph" title="Recently Deleted" onClick={() => setInTrash(true)}>
+ <button className="tool has-label with-glyph" title="Recently Deleted" onClick={() => setInTrash(true)}>
<ActionGlyph name="delete" />
Recently Deleted
</button>
+ </span>
+ <span className="toolbar-group">
<Picker
pullDown
className="drive-view"
@@ -1099,8 +1370,10 @@ export function DriveView() {
onChange={(v) => chooseSort(v as SortKey)}
options={SORTS.map((o) => ({ value: o.key, label: `by ${o.label}` }))}
/>
+ </span>
+ <span className="toolbar-group">
<button
- className="quiet with-glyph"
+ className="tool has-label with-glyph"
title="New Folder"
onClick={() => setCreatingFolder(true)}
disabled={creatingFolder}
@@ -1108,6 +1381,7 @@ export function DriveView() {
<ActionGlyph name="newFolder" />
New Folder
</button>
+ </span>
{/* An app's own library takes files from the app, not from here. */}
<span className="upload-menu-wrap">
<button
@@ -1127,15 +1401,15 @@ export function DriveView() {
</button>
{uploadMenu && (
<span
- className="upload-menu"
+ className="popover upload-menu"
role="menu"
onKeyDown={(e) => e.key === "Escape" && setUploadMenu(false)}
>
<button role="menuitem" autoFocus onClick={() => void chooseAndUpload(false)}>
- Files…
+ Files
</button>
<button role="menuitem" onClick={() => void chooseAndUpload(true)}>
- Folder…
+ Folder
</button>
</span>
)}
@@ -1143,14 +1417,6 @@ export function DriveView() {
</div>
</header>
- {error && (
- <Notice message={error} onDismiss={() => setError(null)} />
- )}
- {savedTo && (
- <p className="drive-saved" role="status">
- Saved to {savedTo}
- </p>
- )}
{!grid && (
// Finder's and icloud.com's column headings: what each column is, and a click to
@@ -1163,24 +1429,35 @@ export function DriveView() {
key={key}
className={`drive-col${sortBy === key ? " is-on" : ""}${key === "name" ? " is-name" : ""}`}
aria-pressed={sortBy === key}
- onClick={() => chooseSort(key)}
+ title={sortBy === key ? "Click to reverse the order" : `Sort by ${SORTS.find((o) => o.key === key)?.label}`}
+ onClick={() => chooseSort(key, true)}
>
{SORTS.find((o) => o.key === key)?.label}
- {sortBy === key && <span aria-hidden="true"> ⌄</span>}
+ {sortBy === key && <span className="drive-col-turn" aria-hidden="true">{reversed ? " ⌃" : " ⌄"}</span>}
</button>
))}
</span>
<span className="drive-row-actions" aria-hidden="true" />
</div>
)}
- <ul className={`drive-rows${grid ? " is-grid" : ""}`}>
+ <ul
+ ref={listRef}
+ className={`drive-rows${grid ? " is-grid" : ""}${listFocused ? " is-focused" : ""}`}
+ // Whether the focus is in the list, for the selection's colour (see the CSS on why
+ // this is a class and not :focus-within).
+ onFocus={() => setListFocused(true)}
+ onBlur={(e) => {
+ if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setListFocused(false);
+ }}
+ aria-label={here.name}
+ >
{pending
.filter((p) => p.folder === here.id && !items.some((i) => driveName(i) === p.name))
.map((p) => (
<li key={p.key} className="drive-row is-busy" aria-busy="true">
<span className="drive-row-hit">
<span className="drive-badge" aria-hidden="true">
- <span className="drive-spinner" />
+ <Spinner small />
</span>
<span className="drive-name">{p.name}</span>
<span className="drive-meta drive-kind" />
@@ -1220,177 +1497,88 @@ export function DriveView() {
</li>
)}
- {sortItems(items.filter((item) => !gone.has(item.drivewsid)), sortBy).map((item) => {
- const container = isContainer(item);
- const busy = busyGuid === item.drivewsid;
- return (
- <li key={item.drivewsid} data-id={item.drivewsid}>
- {renaming === item.drivewsid ? (
- <div className="drive-row">
- <span className="drive-badge" aria-hidden="true">
- <FileGlyph kind={item.kind} extension={item.extension} />
- </span>
- <input
- className="drive-rename-input"
- autoFocus
- defaultValue={driveName(item)}
- aria-label={`Rename ${driveName(item)}`}
- onBlur={(e) => void rename(item, e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") e.currentTarget.blur();
- if (e.key === "Escape") {
- e.currentTarget.value = driveName(item);
- setRenaming(null);
- }
- }}
- />
- </div>
- ) : (
- <div
- className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menu?.item.drivewsid === item.drivewsid ? " is-menu" : ""}${selected === item.drivewsid ? " is-selected" : ""}${dropOn === item.drivewsid ? " is-drop" : ""}`}
- // Dragged onto a folder, an item moves into it — as in Finder and icloud.com.
- draggable={!busy && item.kind !== "APP_LIBRARY"}
- onDragStart={(e) => {
- dragItem.current = item;
- e.dataTransfer.effectAllowed = "move";
- e.dataTransfer.setData("application/x-quince-drive", item.drivewsid);
- }}
- onDragEnd={() => { dragItem.current = null; setDropOn(null); }}
- onDragOver={(e) => {
- const moving = dragItem.current;
- if (!moving || item.kind !== "FOLDER" || moving.drivewsid === item.drivewsid) return;
- e.preventDefault();
- e.dataTransfer.dropEffect = "move";
- if (dropOn !== item.drivewsid) setDropOn(item.drivewsid);
- }}
- onDragLeave={() => setDropOn((d) => (d === item.drivewsid ? null : d))}
- onDrop={(e) => {
- e.preventDefault();
- const moving = dragItem.current;
- dragItem.current = null;
- setDropOn(null);
- if (moving && item.kind === "FOLDER" && moving.drivewsid !== item.drivewsid) void move(moving, item.drivewsid);
- }}
- onContextMenu={(e) => {
- e.preventDefault();
- if (!busy) setMenu({ item, x: e.clientX, y: e.clientY, alignRight: false });
- }}
- >
- <button
- className="drive-row-hit"
- // As Finder and icloud.com: a click selects, a double-click opens — a folder
- // goes in, a file is saved to Downloads and shown there. Return opens the
- // selected item too; a single click that opened made every misclick a
- // download.
- aria-pressed={selected === item.drivewsid}
- onClick={() => setSelected(item.drivewsid)}
- onDoubleClick={() => (container ? enter(item) : void download(item))}
- onKeyDown={(e) => {
- const mod = e.ctrlKey || e.metaKey;
- if (e.key === "Enter" || (mod && e.key === "ArrowDown")) {
- e.preventDefault();
- if (container) enter(item);
- else void download(item);
- } else if (mod && e.key === "ArrowUp") {
- // Finder's Command-Up: the folder this one is in.
- e.preventDefault();
- if (trail.length > 1) setTrail((t) => t.slice(0, -1));
- } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
- // The arrows walk the selection, as in Finder and icloud.com.
- e.preventDefault();
- const rows = [...(e.currentTarget.closest("ul")?.querySelectorAll<HTMLButtonElement>(".drive-row-hit") ?? [])];
- const next = rows[rows.indexOf(e.currentTarget) + (e.key === "ArrowDown" ? 1 : -1)];
- next?.focus();
- next?.click();
- } else if (e.key === "Delete" || (e.key === "Backspace" && (e.metaKey || e.ctrlKey))) {
- e.preventDefault();
- void remove(item);
- }
- }}
- disabled={busy}
- >
- <span className="drive-badge" aria-hidden="true">
- {busy ? (
- <span className="drive-spinner" />
- ) : (
- thumbs[item.drivewsid] ? <img className="drive-thumb" src={thumbs[item.drivewsid]} alt="" draggable={false} /> : <FileGlyph kind={item.kind} extension={item.extension} />
- )}
- </span>
- <span className="drive-name">{driveName(item)}</span>
- <span className="drive-meta drive-kind">{kindName(item)}</span>
- <span className="drive-meta">
- {container
- ? item.childCount === null
- ? ""
- : `${item.childCount} item${item.childCount === 1 ? "" : "s"}`
- : fileSize(item.size)}
- </span>
- <span className="drive-meta">{modified(item.modifiedAt ?? item.createdAt)}</span>
- </button>
- <span className="drive-row-actions">
- <button
- className="drive-action"
- aria-label={`Actions for ${driveName(item)}`}
- aria-haspopup="menu"
- title="More"
- disabled={busy}
- onClick={(e) => {
- const r = e.currentTarget.getBoundingClientRect();
- setMenu({ item, x: r.right, y: r.bottom + 4, alignRight: true });
- }}
- >
- <span aria-hidden="true" className="drive-more">•••</span>
- </button>
- </span>
- </div>
- )}
- </li>
- );
- })}
+ {rows.map((item) => (
+ <DriveRow
+ key={item.drivewsid}
+ item={item}
+ busy={busyGuid === item.drivewsid}
+ selected={picked.includes(item.drivewsid)}
+ menuOpen={menu?.item.drivewsid === item.drivewsid}
+ dropTarget={dropOn === item.drivewsid}
+ thumb={thumbs[item.drivewsid]}
+ renaming={renaming === item.drivewsid}
+ actions={rowActions}
+ />
+ ))}
</ul>
{items.length === 0 && !creatingFolder && !error && (loading || !loaded) && (
- <p className="cal-empty" aria-live="polite">Opening {here.name}…</p>
+ <EmptyState busy>Opening {here.name}…</EmptyState>
)}
{loaded && !loading && items.length === 0 && !creatingFolder && !error && (
- <p className="cal-empty">This folder is empty.</p>
+ <EmptyState>This folder is empty.</EmptyState>
)}
{moving && (
<MoveDialog
- item={moving}
+ items={moving}
startingIn={here.id}
onCancel={() => setMoving(null)}
- onMove={(destinationId) => void move(moving, destinationId)}
+ onMove={(destinationId) => void moveAll(moving, destinationId)}
/>
)}
- {menu && (
- <RowMenu
- at={menu}
- onClose={() => setMenu(null)}
- entries={[
- // Keep on This Computer, as Finder's Keep Downloaded: only where the iCloud Drive
- // folder is up, which is where a kept file lives.
- ...(kept
- ? [
- {
- label: "Keep on This Computer",
- checked: kept.has(menu.item.drivewsid),
- run: () => void keep(menu.item, !kept.has(menu.item.drivewsid)),
- },
- null,
- ]
- : []),
- { label: isContainer(menu.item) ? "Open" : "Download a Copy", run: () => (isContainer(menu.item) ? enter(menu.item) : void download(menu.item)) },
- { label: "Get Info", run: () => setInfo(menu.item) },
- null,
- ...(isContainer(menu.item) ? [] : [{ label: "Duplicate", run: () => void duplicate(menu.item) }]),
- { label: "Rename", run: () => setRenaming(menu.item.drivewsid) },
- { label: "Move to Folder…", run: () => setMoving(menu.item) },
- null,
- { label: "Delete", danger: true, run: () => void remove(menu.item) },
- ]}
+ {menu && (() => {
+ // A right-click on the selection is for all of it, as Finder's menu is.
+ const many = pickedItems.length > 1 && picked.includes(menu.item.drivewsid) ? pickedItems : null;
+ const files = many?.filter((i) => !isContainer(i)) ?? [];
+ return (
+ <RowMenu
+ at={menu}
+ onClose={() => setMenu(null)}
+ entries={many ? [
+ ...(files.length
+ ? [{
+ label: files.length === 1 ? "Download a Copy" : `Download ${files.length} Copies`,
+ run: () => void (async () => { for (const f of files) await download(f); })(),
+ }]
+ : []),
+ { label: "Move to Folder", run: () => setMoving(many) },
+ null,
+ { label: `Delete ${many.length} Items`, danger: true, run: () => void removeAll(many) },
+ ] : [
+ // Keep on This Computer, as Finder's Keep Downloaded: only where the iCloud Drive
+ // folder is up, which is where a kept file lives.
+ ...(kept
+ ? [
+ {
+ label: "Keep on This Computer",
+ checked: kept.has(menu.item.drivewsid),
+ run: () => void keep(menu.item, !kept.has(menu.item.drivewsid)),
+ },
+ null,
+ ]
+ : []),
+ { label: isContainer(menu.item) ? "Open" : "Download a Copy", run: () => openItem(menu.item) },
+ { label: "Get Info", run: () => setInfo(menu.item) },
+ null,
+ ...(isContainer(menu.item) ? [] : [{ label: "Duplicate", run: () => void duplicate(menu.item) }]),
+ { label: "Rename", run: () => setRenaming(menu.item.drivewsid) },
+ { label: "Move to Folder", run: () => setMoving([menu.item]) },
+ null,
+ { label: "Delete", danger: true, run: () => void remove(menu.item) },
+ ]}
+ />
+ );
+ })()}
+
+ {peeking && primary && (
+ <QuickLook
+ item={primary}
+ thumb={thumbs[primary.drivewsid]}
+ busy={busyGuid === primary.drivewsid}
+ onOpen={() => { setPeeking(false); openItem(primary); }}
+ onClose={() => setPeeking(false)}
/>
)}
@@ -1403,6 +1591,174 @@ export function DriveView() {
);
}
+type MenuAt = { x: number; y: number; alignRight: boolean };
+type DriveRowActions = {
+ click: (item: DriveItem, e: React.MouseEvent) => void;
+ open: (item: DriveItem) => void;
+ menu: (item: DriveItem, at: MenuAt) => void;
+ dragStart: (item: DriveItem, e: React.DragEvent) => void;
+ dragEnd: () => void;
+ dragOver: (item: DriveItem, e: React.DragEvent) => void;
+ dragLeave: (item: DriveItem) => void;
+ drop: (item: DriveItem, e: React.DragEvent) => void;
+ rename: (item: DriveItem, name: string) => void;
+ cancelRename: () => void;
+};
+
+/** What a folder holds, or a file weighs, in the Size column. */
+const sizeText = (item: DriveItem) =>
+ isContainer(item)
+ ? item.childCount === null ? "" : `${item.childCount} item${item.childCount === 1 ? "" : "s"}`
+ : fileSize(item.size);
+
+/**
+ * One file or folder. Memoised on what it shows, so in a folder of thousands a click, a key or
+ * a menu opening redraws the rows it changes and no others.
+ */
+const DriveRow = memo(function DriveRow({
+ item, busy, selected, menuOpen, dropTarget, thumb, renaming, actions,
+}: {
+ item: DriveItem;
+ busy: boolean;
+ selected: boolean;
+ menuOpen: boolean;
+ dropTarget: boolean;
+ thumb?: string;
+ renaming: boolean;
+ actions: DriveRowActions;
+}) {
+ const container = isContainer(item);
+ if (renaming) {
+ return (
+ <li data-id={item.drivewsid}>
+ <div className="drive-row">
+ <span className="drive-badge" aria-hidden="true">
+ <FileGlyph kind={item.kind} extension={item.extension} />
+ </span>
+ <input
+ className="drive-rename-input"
+ autoFocus
+ defaultValue={driveName(item)}
+ aria-label={`Rename ${driveName(item)}`}
+ // The name without its extension is what is selected, as Finder selects it, so
+ // typing keeps ".pdf".
+ onFocus={(e) => {
+ const field = e.currentTarget;
+ const end = item.extension && field.value.endsWith(`.${item.extension}`)
+ ? field.value.length - item.extension.length - 1
+ : field.value.length;
+ field.setSelectionRange(0, end);
+ }}
+ onBlur={(e) => actions.rename(item, e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") e.currentTarget.blur();
+ if (e.key === "Escape") {
+ e.currentTarget.value = driveName(item);
+ actions.cancelRename();
+ }
+ }}
+ />
+ </div>
+ </li>
+ );
+ }
+ return (
+ <li data-id={item.drivewsid}>
+ <div
+ className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menuOpen ? " is-menu" : ""}${selected ? " is-selected" : ""}${dropTarget ? " is-drop" : ""}`}
+ // Dragged onto a folder, an item moves into it — as in Finder and icloud.com.
+ draggable={!busy && item.kind !== "APP_LIBRARY"}
+ onDragStart={(e) => actions.dragStart(item, e)}
+ onDragEnd={actions.dragEnd}
+ onDragOver={(e) => actions.dragOver(item, e)}
+ onDragLeave={() => actions.dragLeave(item)}
+ onDrop={(e) => actions.drop(item, e)}
+ onContextMenu={(e) => {
+ e.preventDefault();
+ if (!busy) actions.menu(item, { x: e.clientX, y: e.clientY, alignRight: false });
+ }}
+ >
+ <button
+ className="drive-row-hit"
+ // As Finder and icloud.com: a click selects, a double-click opens — a folder goes
+ // in, a file is saved to Downloads and shown there. Return opens the selected item
+ // too; a single click that opened made every misclick a download.
+ aria-pressed={selected}
+ onClick={(e) => actions.click(item, e)}
+ onDoubleClick={() => actions.open(item)}
+ disabled={busy}
+ >
+ <span className="drive-badge" aria-hidden="true">
+ {busy ? (
+ <Spinner small />
+ ) : thumb ? (
+ <img className="drive-thumb" src={thumb} alt="" draggable={false} />
+ ) : (
+ <FileGlyph kind={item.kind} extension={item.extension} />
+ )}
+ </span>
+ <span className="drive-name">{driveName(item)}</span>
+ <span className="drive-meta drive-kind">{kindName(item)}</span>
+ <span className="drive-meta">{sizeText(item)}</span>
+ <span className="drive-meta">{modified(item.modifiedAt ?? item.createdAt)}</span>
+ </button>
+ <span className="drive-row-actions">
+ <button
+ className="icon-button small drive-action"
+ aria-label={`Actions for ${driveName(item)}`}
+ aria-haspopup="menu"
+ title="More"
+ disabled={busy}
+ onClick={(e) => {
+ const r = e.currentTarget.getBoundingClientRect();
+ actions.menu(item, { x: r.right, y: r.bottom + 4, alignRight: true });
+ }}
+ >
+ <span aria-hidden="true" className="drive-more">•••</span>
+ </button>
+ </span>
+ </div>
+ </li>
+ );
+});
+
+/**
+ * Quick Look, as near as iCloud lets it be without fetching the file: Apple's own picture of
+ * it, large, with its name, kind, size and date. Space or Escape closes it; the arrows go on
+ * walking the folder behind it and the look follows. Opening it fully is one press away.
+ */
+function QuickLook({ item, thumb, busy, onOpen, onClose }: {
+ item: DriveItem;
+ thumb?: string;
+ busy: boolean;
+ onOpen: () => void;
+ onClose: () => void;
+}) {
+ const container = isContainer(item);
+ const facts = [kindName(item), sizeText(item)].filter(Boolean).join(", ");
+ const when = modified(item.modifiedAt ?? item.createdAt);
+ return (
+ <Portal>
+ <div className="modal-veil drive-peek-veil" onClick={onClose}>
+ <div className="modal-sheet drive-peek" role="dialog" aria-label={`Quick Look: ${driveName(item)}`} onClick={(e) => e.stopPropagation()}>
+ <div className={`drive-peek-face${thumb ? " has-thumb" : ""}`} aria-hidden="true">
+ {thumb ? <img src={thumb} alt="" draggable={false} /> : <FileGlyph kind={item.kind} extension={item.extension} />}
+ </div>
+ <p className="drive-peek-name">{driveName(item)}</p>
+ <p className="drive-peek-facts">{facts}</p>
+ {when && <p className="drive-peek-facts">Modified {when}</p>}
+ <div className="drive-peek-actions">
+ <button className="primary" disabled={busy} onClick={onOpen}>
+ {container ? "Open" : busy ? "Downloading…" : "Download a Copy"}
+ </button>
+ <button className="quiet" onClick={onClose}>Close</button>
+ </div>
+ </div>
+ </div>
+ </Portal>
+ );
+}
+
/**
* Where to move something — a small folder browser of its own, in the same shape Files'
* own Move sheet takes: breadcrumbs, folders only, a Move button that names where it will
@@ -1410,12 +1766,12 @@ export function DriveView() {
* way to move something inside itself.
*/
function MoveDialog({
- item,
+ items,
startingIn,
onCancel,
onMove,
}: {
- item: DriveItem;
+ items: DriveItem[];
startingIn: string;
onCancel: () => void;
onMove: (destinationId: string) => void;
@@ -1425,6 +1781,9 @@ function MoveDialog({
const [loading, setLoading] = useState(false);
const here = trail[trail.length - 1];
+ /** What is being moved: none of it can be gone into, which is what stops a folder going inside itself. */
+ const moving = useMemo(() => new Set(items.map((i) => i.drivewsid)), [items]);
+ const what = items.length === 1 ? `\u201c${driveName(items[0])}\u201d` : `${items.length} Items`;
useEffect(() => {
let cancelled = false;
@@ -1436,7 +1795,7 @@ function MoveDialog({
if (!cancelled) {
setFolders(
(Array.isArray(fresh) ? fresh : []).filter(
- (i) => isContainer(i) && i.drivewsid !== item.drivewsid
+ (i) => isContainer(i) && !moving.has(i.drivewsid)
)
);
}
@@ -1449,7 +1808,7 @@ function MoveDialog({
return () => {
cancelled = true;
};
- }, [here.id, item.drivewsid]);
+ }, [here.id, moving]);
const alreadyHere = here.id === startingIn;
@@ -1482,10 +1841,10 @@ function MoveDialog({
<div
className="modal-sheet move-sheet"
role="dialog"
- aria-label={`Move ${driveName(item)}`}
+ aria-label={items.length === 1 ? `Move ${driveName(items[0])}` : `Move ${items.length} Items`}
onClick={(e) => e.stopPropagation()}
>
- <h2>Move “{driveName(item)}”</h2>
+ <h2>Move {what}</h2>
<nav className="crumbs" aria-label="Destination folder">
{trail.map((crumb, i) => (
@@ -1507,9 +1866,9 @@ function MoveDialog({
</nav>
<ul className="move-sheet-list">
- {loading && <li className="cal-empty">Loading…</li>}
+ {loading && <li className="move-sheet-none">Loading…</li>}
{!loading && folders.length === 0 && (
- <li className="cal-empty">No folders here.</li>
+ <li className="move-sheet-none">No folders here.</li>
)}
{!loading &&
folders.map((folder) => (
diff --git a/src/screens/Library.tsx b/src/screens/Library.tsx
index 8d2f7f1..05a4bc2 100644
--- a/src/screens/Library.tsx
+++ b/src/screens/Library.tsx
@@ -1,8 +1,12 @@
+import { ToastHost } from "../components/Toast";
+import { EmptyState } from "../components/EmptyState";
+import { StatusLine } from "../components/StatusLine";
import { lazy, Suspense, useEffect, useLayoutEffect, useRef, useState } from "react";
import { listen } from "@tauri-apps/api/event";
+import { getCurrentWindow } from "@tauri-apps/api/window";
import { PanelLeft } from "lucide-react";
import { api, messageOf, OPEN_REMINDER } from "../lib/ipc";
-import { SyncProvider } from "../lib/sync";
+import { SyncProvider, useSync } from "../lib/sync";
import { AccountCard } from "../components/Account";
/*
@@ -10,22 +14,39 @@ import { AccountCard } from "../components/Account";
* five — Notes' editor alone is a few hundred kilobytes. The rest are fetched as soon as the
* window is up, before anyone could reach them, so switching never waits on a load.
*/
-const loaders = {
- calendar: () => import("./calendar/CalendarView").then((m) => ({ default: m.CalendarView })),
- reminders: () => import("./RemindersView").then((m) => ({ default: m.RemindersView })),
- notes: () => import("./NotesView").then((m) => ({ default: m.NotesView })),
- contacts: () => import("./ContactsView").then((m) => ({ default: m.ContactsView })),
- drivews: () => import("./DriveView").then((m) => ({ default: m.DriveView })),
- photos: () => import("./PhotosView").then((m) => ({ default: m.PhotosView })),
- settings: () => import("./SettingsView").then((m) => ({ default: m.SettingsView })),
+/**
+ * An app's code, fetched once. Once it is here, the screen is drawn in the same frame as the
+ * click that opens it: `lazy` alone suspends on first use even when the code arrived long ago
+ * (a promise answers a tick later), and that tick was a frame with nothing in the content —
+ * the old screen gone, the new one not yet drawn. Handed back at once, it never suspends.
+ */
+function screen<P extends object>(load: () => Promise<React.ComponentType<P>>) {
+ let mod: { default: React.ComponentType<P> } | null = null;
+ const fetch = () => load().then((c) => (mod = { default: c }));
+ const Screen = lazy(() =>
+ mod
+ ? // A thenable that answers straight away: `lazy` takes it as already resolved.
+ ({ then: (done: (m: { default: React.ComponentType<P> }) => void) => done(mod!) } as unknown as Promise<{ default: React.ComponentType<P> }>)
+ : fetch(),
+ );
+ return { Screen, fetch };
+}
+const apps = {
+ calendar: screen(() => import("./calendar/CalendarView").then((m) => m.CalendarView)),
+ reminders: screen(() => import("./RemindersView").then((m) => m.RemindersView)),
+ notes: screen(() => import("./NotesView").then((m) => m.NotesView)),
+ contacts: screen(() => import("./ContactsView").then((m) => m.ContactsView)),
+ drivews: screen(() => import("./DriveView").then((m) => m.DriveView)),
+ photos: screen(() => import("./PhotosView").then((m) => m.PhotosView)),
+ settings: screen(() => import("./SettingsView").then((m) => m.SettingsView)),
};
-const CalendarView = lazy(loaders.calendar);
-const RemindersView = lazy(loaders.reminders);
-const NotesView = lazy(loaders.notes);
-const ContactsView = lazy(loaders.contacts);
-const DriveView = lazy(loaders.drivews);
-const PhotosView = lazy(loaders.photos);
-const SettingsView = lazy(loaders.settings);
+const CalendarView = apps.calendar.Screen;
+const RemindersView = apps.reminders.Screen;
+const NotesView = apps.notes.Screen;
+const ContactsView = apps.contacts.Screen;
+const DriveView = apps.drivews.Screen;
+const PhotosView = apps.photos.Screen;
+const SettingsView = apps.settings.Screen;
import { ScreenBoundary } from "../components/ScreenBoundary";
import { ScreenActive } from "../lib/screen";
import { AppIcon } from "../components/AppIcon";
@@ -48,6 +69,32 @@ const SCREENS: { key: string; name: string }[] = [
{ key: "contacts", name: "Contacts" },
];
+/** The sync service behind a screen, where its key differs: Drive's screen is Apple's `drivews`. */
+const SERVICE_OF: Record<string, string> = { drivews: "drive" };
+const serviceOf = (screen: string) => SERVICE_OF[screen] ?? screen;
+
+/**
+ * Ctrl+R and F5 update the app in front, as they reload a page in a browser — and never
+ * reload the window itself, which would throw away every open screen. In Settings they
+ * update the whole account.
+ */
+function UpdateKeys({ screen }: { screen: string | null }) {
+ const { refresh, refreshService } = useSync();
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ const reload = e.key === "F5" || ((e.ctrlKey || e.metaKey) && !e.altKey && e.key.toLowerCase() === "r");
+ if (!reload) return;
+ e.preventDefault();
+ if (e.repeat) return;
+ if (screen && SCREENS.some((s) => s.key === screen)) void refreshService(serviceOf(screen));
+ else void refresh();
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [screen, refresh, refreshService]);
+ return null;
+}
+
/** The screen open last time, so the app reopens where it was left. */
const LAST_KEY = "quince.library.screen";
const RAIL_KEY = "quince.library.rail";
@@ -149,11 +196,25 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
};
}, [selected]);
+ // The window is named for what it shows: an app's own window that has moved on to Photos
+ // is not "Notes" any more. Outside Tauri, or where not permitted, the title simply stays.
+ useEffect(() => {
+ if (!selected) return;
+ const title = selected === "settings" ? "Settings" : SCREENS.find((s) => s.key === selected)?.name;
+ if (!title) return;
+ document.title = title;
+ try {
+ void getCurrentWindow().setTitle(title).catch(() => {});
+ } catch {
+ // Not in a Tauri window.
+ }
+ }, [selected]);
+
// The other apps' code, fetched while nothing else is happening.
useEffect(() => {
if (!ready) return undefined;
const t = window.setTimeout(() => {
- for (const load of Object.values(loaders)) void load().catch(() => {});
+ for (const app of Object.values(apps)) void app.fetch().catch(() => {});
}, 300);
return () => window.clearTimeout(t);
}, [ready]);
@@ -248,6 +309,7 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
return (
<SyncProvider>
+ <UpdateKeys screen={selected} />
<div className={`library enter-library${sidebarOpen ? " is-sidebar-open" : ""}${rail ? " is-rail" : ""}`}>
{/* Only in a narrow window, where the sidebar gives its room to the content. */}
<button
@@ -264,7 +326,7 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
<div className="sidebar-head">
<h2>iCloud</h2>
<button
- className="sidebar-fold"
+ className="icon-button sidebar-fold"
aria-label={rail ? "Show Sidebar Names" : "Fold Sidebar to Icons"}
aria-pressed={rail}
title={rail ? "Show Sidebar Names" : "Fold Sidebar to Icons"}
@@ -275,15 +337,18 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
</div>
{!rail && <GlobalSearch available={services} onOpen={(screen) => choose(screen)} />}
{services.map(item)}
- {!ready && !error && <p className="badge">Loading…</p>}
- {error && (
- <p className="error" role="alert">
- {error}
- </p>
- )}
+ {!ready && !error && <StatusLine tone="pending">Loading…</StatusLine>}
+ {error && <StatusLine tone="error">{error}</StatusLine>}
<div className="sidebar-foot">
- <AccountCard current={selected === "settings"} onOpen={() => choose("settings")} />
+ <AccountCard
+ current={selected === "settings"}
+ onOpen={() => choose("settings")}
+ app={(() => {
+ const app = SCREENS.find((s) => s.key === selected);
+ return app && webAccess !== false ? { service: serviceOf(app.key), name: app.name } : null;
+ })()}
+ />
</div>
</nav>
@@ -335,12 +400,13 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
</>
)}
{ready && services.length === 0 && (
- <p className="cal-empty">
+ <EmptyState>
Apple hasn’t offered Reminders, Notes, iCloud Drive, Calendar or Contacts to
this account yet.
- </p>
+ </EmptyState>
)}
</main>
+ <ToastHost />
</div>
</SyncProvider>
);
diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsx
index ee465b7..9baf14f 100644
--- a/src/screens/NotesView.tsx
+++ b/src/screens/NotesView.tsx
@@ -1,6 +1,12 @@
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { usePending } from "../lib/pending";
-import { Notice } from "../components/Notice";
+import { useErrorToast } from "../components/Toast";
+import { useConfirm } from "../components/Confirm";
+import { EmptyState } from "../components/EmptyState";
+import { SearchField } from "../components/SearchField";
+import { PaneTitle } from "../components/PaneTitle";
+import { Unsent, Waiting } from "../components/Unsent";
+import { useOutbox } from "../lib/outbox";
import { ChevronLeft, Folder, FolderOpen, FolderPlus, ListChecks, Pin, PinOff, Share, SquarePen, Trash2 } from "lucide-react";
import { save as saveFileDialog } from "@tauri-apps/plugin-dialog";
import { editorDate, groupNotes, listDate, mergeEdits, splitTitle } from "./notes/model";
@@ -13,7 +19,8 @@ import { FormatPanel } from "./notes/FormatPanel";
import { NotePicture } from "./notes/NotePicture";
import { OPEN_NOTE_EVENT } from "./notes/links";
import { useReveal } from "../lib/reveal";
-import { useSync } from "../lib/sync";
+import { Arriving } from "../components/EmptyState";
+import { useArriving, useSync } from "../lib/sync";
import { Picker } from "../components/Picker";
const ALL = "__all__";
@@ -105,7 +112,10 @@ export function NotesView() {
const [detail, setDetail] = useState(false);
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
+ const [confirm, confirmSheet] = useConfirm();
const { revision } = useSync();
+ const arriving = useArriving("notes");
// Tables on screen keep up with a phone's edits, as the note's text does.
useEffect(() => {
if (revision) refreshTables();
@@ -131,6 +141,8 @@ export function NotesView() {
});
const { hold, over } = usePending<Note>();
+ /** Edits kept here and not yet at Apple, and any Apple turned down. */
+ const outbox = useOutbox("notes");
const read = useCallback(async () => {
api
.noteCounts()
@@ -162,7 +174,8 @@ export function NotesView() {
return () => {
cancelled = true;
};
- }, [read, revision]);
+ // `outbox.tick`: an edit sent, or turned down, changes what the library holds.
+ }, [read, revision, outbox.tick]);
/**
* Every write goes to Apple first and the library is re-read after, so nothing on screen
@@ -287,9 +300,12 @@ export function NotesView() {
.then((text) => {
if (cancelled || text === null) return;
// Never over what is being typed. A refresh follows every save, and adopting its
- // answer under someone's cursor is how a half-saved note replaced a whole one.
+ // answer under someone's cursor is how a half-saved note replaced a whole one. Typing
+ // already kept, with nothing new since, is not being typed: what Apple made of it —
+ // merged with another device's edit, once sent — is taken in.
setDraft((typing) => {
- if (typing === null) setLoadedBody({ guid: openGuid, text });
+ const settled = typing !== null && !pending.current && base.current?.guid === openGuid && typing === base.current.text;
+ if (typing === null || settled) setLoadedBody({ guid: openGuid, text });
return typing;
});
})
@@ -299,7 +315,7 @@ export function NotesView() {
return () => {
cancelled = true;
};
- }, [openGuid, revision]);
+ }, [openGuid, revision, outbox.tick]);
/** How the open note is set, from Apple's attribute runs, read with its body. */
const [loadedRuns, setLoadedRuns] = useState<{ guid: string; runs: Run[] } | null>(null);
@@ -317,7 +333,7 @@ export function NotesView() {
() => {},
);
return () => { cancelled = true; };
- }, [openGuid, revision]);
+ }, [openGuid, revision, outbox.tick]);
/** What the open note says, or null while that is still unknown. */
const body = open && loadedBody?.guid === open.guid ? loadedBody.text : null;
@@ -366,7 +382,12 @@ export function NotesView() {
const ok = await write(async () => {
saved = await api.noteSave(next.guid, next.body, from, next.runs, next.runs ? fromRuns : null);
});
- if (!ok || saved === null) return;
+ if (!ok || saved === null) {
+ // Not sent: the edit goes back in line (unless newer typing already replaced it), to
+ // go with the next pause, the next sync or leaving the note — never dropped.
+ if (!pending.current) pending.current = next;
+ return;
+ }
const kept: string = saved;
const keptRunsForBase = next.runs ? (kept === next.body ? next.runs : carryRuns(next.body, next.runs, kept)) : null;
base.current = { guid: next.guid, text: kept, runs: keptRunsForBase };
@@ -400,6 +421,12 @@ export function NotesView() {
return run;
}, [write]);
+ // An edit that could not be sent goes again when a sync has just succeeded — Apple is
+ // reachable — rather than waiting for more typing.
+ useEffect(() => {
+ if (pending.current) void flush();
+ }, [revision, flush]);
+
const type = useCallback(
(typed: string, typedRuns: Run[]) => {
// Nothing may be typed into a note whose text has not arrived.
@@ -429,10 +456,17 @@ export function NotesView() {
// Leaving the note takes whatever is outstanding with it, before the draft is cleared; the
// next note's edit begins from what that note reads, never from this one's.
- useEffect(() => () => {
- void flush().then(() => {
- if (base.current && base.current.guid !== openGuid) base.current = null;
- });
+ // Only the note being left loses its base. Compared with the note now open instead, this
+ // closure's `openGuid` is the old one: a new note made from a draft (null → its guid) had
+ // its base wiped the moment it became real, and the next save merged from a lagging copy —
+ // which wrote the whole text again on every save.
+ useEffect(() => {
+ const leaving = openGuid;
+ return () => {
+ void flush().then(() => {
+ if (leaving && base.current?.guid === leaving) base.current = null;
+ });
+ };
}, [openGuid, flush]);
useEffect(() => {
if (base.current && base.current.guid !== openGuid) base.current = null;
@@ -590,7 +624,14 @@ export function NotesView() {
};
const deleteFolder = async (f: NoteFolder) => {
// Apple's own words for it.
- if (!window.confirm(`Are you sure you want to delete \u201c${f.title}\u201d?\n\nAll notes and any subfolders will be deleted.`)) return;
+ const sure = await confirm({
+ title: `Delete \u201c${f.title}\u201d?`,
+ body: "All notes and any subfolders will be deleted.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ });
+ if (!sure) return;
setFolders((fs) => fs.filter((x) => x.guid !== f.guid && x.parentGuid !== f.guid));
if (folder === f.guid) setFolder(ALL);
try {
@@ -606,7 +647,13 @@ export function NotesView() {
if (!open) return;
if (
open.folderGuid === TRASH_FOLDER &&
- !window.confirm("This note will be deleted immediately. You can’t undo this action.")
+ !(await confirm({
+ title: "Delete this note now?",
+ body: "It will be deleted immediately. You can’t undo this action.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ }))
) {
return;
}
@@ -618,7 +665,7 @@ export function NotesView() {
const next = order[at + 1] ?? order[at - 1] ?? null;
setOpenGuid(next);
await write(() => api.noteDelete(gone), (rows) => rows.filter((n) => n.guid !== gone));
- }, [open, write, notes]);
+ }, [open, write, notes, confirm]);
/** Out of Recently Deleted and back into Notes — Apple's "Notes" folder where there is one. */
const recover = useCallback(async () => {
@@ -770,11 +817,11 @@ export function NotesView() {
}}
/>
<aside className="notes-folders" aria-label="Note folders" ref={foldersRef}>
- <p className="notes-side-heading">iCloud</p>
- <button className="notes-folder" aria-current={folder === ALL} onClick={() => setFolder(ALL)}>
+ <p className="side-heading">iCloud</p>
+ <button className="source-row notes-folder" aria-current={folder === ALL} onClick={() => setFolder(ALL)}>
<FolderOpen className="notes-folder-glyph" size={16} strokeWidth={2} aria-hidden="true" />
- <span className="notes-folder-name">All iCloud</span>
- <span className="notes-folder-count">{counts.all || ""}</span>
+ <span className="source-name notes-folder-name">All iCloud</span>
+ <span className="count notes-folder-count">{counts.all || ""}</span>
</button>
{nestFolders(folders)
.filter(({ folder: f }) => f.guid !== TRASH_FOLDER)
@@ -784,7 +831,7 @@ export function NotesView() {
return (
<input
key={f.guid}
- className="notes-folder notes-folder-rename"
+ className="field notes-folder-rename"
defaultValue={f.title}
aria-label={`Rename ${f.title}`}
autoFocus
@@ -811,18 +858,18 @@ export function NotesView() {
}}
>
<button
- className="notes-folder"
+ className="source-row notes-folder"
aria-current={folder === f.guid}
onClick={() => setFolder(f.guid)}
style={depth > 0 ? { paddingLeft: `${8 + depth * 16}px` } : undefined}
>
<Folder className="notes-folder-glyph" size={16} strokeWidth={2} aria-hidden="true" />
- <span className="notes-folder-name" title={f.title}>{f.title}</span>
- <span className="notes-folder-count">{counts.per.get(f.guid) || ""}</span>
+ <span className="source-name notes-folder-name" title={f.title}>{f.title}</span>
+ <span className="count notes-folder-count">{counts.per.get(f.guid) || ""}</span>
</button>
{own && (
<button
- className="notes-folder-more"
+ className="icon-button small round row-more notes-folder-more"
aria-label={`Actions for ${f.title}`}
aria-haspopup="menu"
onClick={(e) => {
@@ -838,16 +885,16 @@ export function NotesView() {
})}
{folders.some((f) => f.guid === TRASH_FOLDER) && (
<button
- className="notes-folder"
+ className="source-row notes-folder"
aria-current={folder === TRASH_FOLDER}
onClick={() => setFolder(TRASH_FOLDER)}
>
<Trash2 className="notes-folder-glyph" size={16} strokeWidth={2} aria-hidden="true" />
- <span className="notes-folder-name">Recently Deleted</span>
- <span className="notes-folder-count">{counts.per.get(TRASH_FOLDER) || ""}</span>
+ <span className="source-name notes-folder-name">Recently Deleted</span>
+ <span className="count notes-folder-count">{counts.per.get(TRASH_FOLDER) || ""}</span>
</button>
)}
- <button className="notes-new-folder" onClick={() => void newFolder(null)}>
+ <button className="side-add" onClick={() => void newFolder(null)}>
<FolderPlus size={15} strokeWidth={2} aria-hidden="true" />
New Folder
</button>
@@ -866,15 +913,10 @@ export function NotesView() {
</aside>
<section className="notes-list" aria-label="Notes">
- <header className="notes-list-head">
- <div className="notes-list-title">
- <h1>{heading}</h1>
- <span className="notes-list-count">
- {notes.length} {notes.length === 1 ? "note" : "notes"}
- </span>
- </div>
+ <header className="pane-head notes-list-head">
+ <PaneTitle count={`${notes.length} ${notes.length === 1 ? "note" : "notes"}`}>{heading}</PaneTitle>
<button
- className="notes-icon"
+ className="icon-button"
aria-label="New note"
title="New Note"
onClick={() => void create()}
@@ -883,13 +925,12 @@ export function NotesView() {
<SquarePen size={18} strokeWidth={2} aria-hidden="true" />
</button>
</header>
- <input
+ <SearchField
className="notes-search"
- type="search"
placeholder="Search"
aria-label="Search notes"
value={query}
- onChange={(e) => setQuery(e.target.value)}
+ onChange={setQuery}
onKeyDown={(e) => {
if (e.key === "Escape") setQuery("");
}}
@@ -908,7 +949,7 @@ export function NotesView() {
/>
</div>
- {error && <Notice message={error} onDismiss={() => setError(null)} />}
+ <Unsent refused={outbox.refused} what="an edit to a note" onResend={(r) => void outbox.resend(r)} onDiscard={(r) => void outbox.discard(r)} />
<div className="note-rows" role="list">
{sections.map((section) => (
@@ -935,8 +976,11 @@ export function NotesView() {
))}
</div>
- {loaded && notes.length === 0 && !error && (
- <p className="cal-empty notes-empty">{searching ? "No results." : "No notes here."}</p>
+ {loaded && notes.length === 0 && !error && !(arriving && !searching) && (
+ <EmptyState className="notes-empty">{searching ? "No results." : "No notes here."}</EmptyState>
+ )}
+ {notes.length === 0 && !searching && (
+ <Arriving service="notes" what="notes" className="notes-empty" />
)}
</section>
@@ -957,16 +1001,18 @@ export function NotesView() {
<p className="note-when">
{busy || (!saveFailed && (dirty || composing?.body.trim()))
? "Saving…"
- : saved
+ : open && outbox.waiting.has(open.guid)
+ ? <Waiting shown />
+ : saved
? "Saved"
: editorDate(composing ? Math.floor(Date.now() / 1000) : (open?.modifiedAt ?? null))}
</p>
{!composing && open && !open.locked && (
- <div className="note-bar-actions">
+ <div className="toolbar-group note-bar-actions">
{!inTrash && open.editable && (
<>
<button
- className={`notes-icon notes-aa${formatAt ? " is-on" : ""}`}
+ className={`tool notes-aa${formatAt ? " is-on" : ""}`}
aria-label="Format"
aria-haspopup="dialog"
aria-expanded={Boolean(formatAt)}
@@ -982,7 +1028,7 @@ export function NotesView() {
Aa
</button>
<button
- className={`notes-icon${status?.checklist ? " is-on" : ""}`}
+ className="tool"
aria-label="Make a checklist"
aria-pressed={Boolean(status?.checklist)}
title="Make a checklist"
@@ -1026,7 +1072,7 @@ export function NotesView() {
/>}
{!inTrash && !open.locked && (
<button
- className="notes-icon"
+ className="tool"
aria-label="Export as Markdown"
title="Export as Markdown"
onClick={() => void exportNote()}
@@ -1037,7 +1083,7 @@ export function NotesView() {
)}
{!inTrash && (
<button
- className="notes-icon"
+ className="tool"
aria-label={open.pinned ? "Unpin Note" : "Pin Note"}
aria-pressed={open.pinned}
title={open.pinned ? "Unpin Note" : "Pin Note"}
@@ -1052,17 +1098,17 @@ export function NotesView() {
</button>
)}
{inTrash && (
- <button className="quiet" onClick={() => void recover()} disabled={busy}>
+ <button className="tool has-label is-accent" onClick={() => void recover()} disabled={busy}>
Recover
</button>
)}
{inTrash ? (
- <button className="quiet danger" onClick={() => void remove()}>
+ <button className="tool has-label danger" onClick={() => void remove()}>
Delete Now
</button>
) : (
<button
- className="notes-icon danger"
+ className="tool"
aria-label="Delete"
title="Delete"
onClick={() => void remove()}
@@ -1107,16 +1153,14 @@ export function NotesView() {
/>
</div>
) : open?.locked ? (
- <p className="cal-empty">
+ <EmptyState>
This note is locked. Apple keeps it encrypted, so there is nothing here to show —
open it on a device where you can enter its password.
- </p>
+ </EmptyState>
) : open && body === null ? (
/* Nothing to type into until the note's own text has arrived: an empty box over a
note whose body had not loaded would write that emptiness back. */
- <p className="note-loading" aria-live="polite">
- Opening…
- </p>
+ <EmptyState busy className="note-loading">Opening…</EmptyState>
) : open ? (
<div className="note-editor is-readonly">
<h1 className="note-title">{splitTitle(body ?? "").title}</h1>
@@ -1135,9 +1179,10 @@ export function NotesView() {
</p>
</div>
) : (
- loaded && <p className="cal-empty">Select a note.</p>
+ loaded && <EmptyState className="note-pick">Select a note.</EmptyState>
)}
</article>
+ {confirmSheet}
</div>
);
}
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index 7aa806c..f4fcc94 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -3,12 +3,12 @@
* for how many across; a photo opens on a dark stage with the arrows to go through them. Everything draws from the local library at once; thumbnails come
* from the disk cache and are fetched once.
*/
-import { useActiveRef } from "../lib/screen";
+import { useActiveRef, useScreenActive } from "../lib/screen";
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { getCurrentWebview } from "@tauri-apps/api/webview";
import { open as openFileDialog } from "@tauri-apps/plugin-dialog";
-import { ChevronLeft, ChevronRight, Ellipsis, GalleryThumbnails, CopyMinus, CopyPlus, Download, Clock, Heart, ImagePlus, Images, Info, Minus, Play, Plus, RotateCcw, Scan, Trash2, EyeOff, ArrowDownUp, MonitorPlay, Square, RectangleHorizontal, Star, Layers, Search as SearchIcon, Folder as FolderIcon, Aperture, Video, X, CalendarDays, Maximize2, Minimize2, Users, type LucideIcon } from "lucide-react";
+import { ChevronLeft, ChevronRight, Ellipsis, GalleryThumbnails, CopyMinus, CopyPlus, Download, Clock, Heart, ImagePlus, Images, Info, Minus, Play, Plus, RotateCcw, Scan, Trash2, EyeOff, ArrowDownUp, MonitorPlay, Square, RectangleHorizontal, Star, Layers, Folder as FolderIcon, Aperture, Video, X, CalendarDays, Maximize2, Minimize2, Users, type LucideIcon } from "lucide-react";
import {
api,
messageOf,
@@ -22,13 +22,16 @@ import {
turnStyle,
type Turn,
} from "../lib/ipc";
-import { useSync } from "../lib/sync";
-import { Notice } from "../components/Notice";
+import { Arriving, EmptyState } from "../components/EmptyState";
+import { SearchField } from "../components/SearchField";
+import { PaneTitle } from "../components/PaneTitle";
+import { useArriving, useSync } from "../lib/sync";
+import { toast, toastSaved, useErrorToast, useToastClearance } from "../components/Toast";
import { UploadPanel } from "./photos/UploadPanel";
import { RowMenu, type MenuEntry } from "../components/RowMenu";
import { Portal } from "../components/Portal";
import { Slideshow } from "./photos/Slideshow";
-import { useAsk } from "./photos/Ask";
+import { useConfirm } from "../components/Confirm";
import { VideoPlayer } from "./photos/VideoPlayer";
import { JumpTo, type MonthCover } from "./photos/JumpTo";
import { SharedAlbums } from "./photos/SharedAlbums";
@@ -121,6 +124,40 @@ const clock = (s: number | null) => {
return `${m}:${String(Math.round(s % 60)).padStart(2, "0")}`;
};
+/** Whether two reads of one photo are the same in every field. */
+function samePhoto(a: Photo, b: Photo): boolean {
+ for (const k in b) {
+ const x = (a as Record<string, unknown>)[k];
+ const y = (b as Record<string, unknown>)[k];
+ if (x === y) continue;
+ if (Array.isArray(x) && Array.isArray(y) && x.length === y.length && x.every((v, i) => v === y[i])) continue;
+ return false;
+ }
+ return true;
+}
+
+/**
+ * A fresh read laid over the last one: each photo unchanged keeps the object it had, and a list
+ * unchanged throughout is the last list itself. Every pass, and each service landing in one,
+ * reads the library again; a read that came back new objects for the same photos drew every
+ * month and every tile of the grid again for nothing.
+ */
+function keepSame(before: Photo[] | null, read: Photo[]): Photo[] {
+ if (!before || before.length === 0) return read;
+ const had = new Map(before.map((p) => [p.id, p]));
+ let same = before.length === read.length;
+ const out = read.map((p, i) => {
+ const old = had.get(p.id);
+ if (old && samePhoto(old, p)) {
+ if (before[i] !== old) same = false;
+ return old;
+ }
+ same = false;
+ return p;
+ });
+ return same ? before : out;
+}
+
/** A photo's frame when fitted: its own shape, as large as the square cell lets it be. */
const fitFrame = (p: Photo): React.CSSProperties =>
p.width >= p.height
@@ -272,6 +309,29 @@ const Tile = memo(function Tile({
act: Acts;
}) {
const born = useRef(performance.now());
+ // The thumbnail goes under the tile's picture only when that picture cannot be made, or is
+ // still not here after a long moment (made from Apple, not the disk). Nearly every picture is made ahead (photos_prepare) and lands at once, and
+ // the thumbnail asked for alongside it doubled each tile's requests — every one a trip through
+ // the webview's scheme handler — and its bytes, ~69 KB of thumbnail against ~19 KB of
+ // picture, decoded and then covered. Set on the element itself: no tile draws again for it.
+ const pic = useRef<HTMLSpanElement | null>(null);
+ const landed = useRef(false);
+ const under = useCallback(() => {
+ if (!landed.current && pic.current) pic.current.style.backgroundImage = `url("${pictureSrc(photo.id, "thumb")}")`;
+ }, [photo.id]);
+ const src = tileSrc(photo, cell, fit);
+ const first = useRef(true);
+ useEffect(() => {
+ // A new size asked for (the window resized, zoomed): the thumbnail may be wanted again.
+ if (!first.current) landed.current = false;
+ first.current = false;
+ if (landed.current) return undefined;
+ // Long enough that a grid filling in from the disk never asks for it — a full grid's worth
+ // of pictures through the scheme handler at once takes a while, and thumbnails asked for
+ // then only queued behind them — short enough to cover a picture made from the network.
+ const t = window.setTimeout(under, 1500);
+ return () => window.clearTimeout(t);
+ }, [src, under]);
return (
<button
role="listitem"
@@ -312,15 +372,16 @@ const Tile = memo(function Tile({
{/* The picture's own frame: the whole tile when squares, the photo's own shape when
fitted — what the badges and the selection sit on. */}
<span
+ ref={pic}
className="px-pic"
- // The thumbnail underneath while the picture made for this tile's size comes.
- style={{ ...(fit && photo.width && photo.height ? fitFrame(photo) : {}), backgroundImage: `url("${pictureSrc(photo.id, "thumb")}")` }}
+ // The thumbnail underneath while the picture made for this tile's size comes (see under).
+ style={fit && photo.width && photo.height ? fitFrame(photo) : undefined}
>
{/* Fetched as soon as its month is built, well ahead of the screen — not left to the
engine's own lazy margin, which a fast scroll outran — and made the size it is
drawn at, so the engine never shrinks it. */}
<img
- src={tileSrc(photo, cell, fit)}
+ src={src}
alt=""
decoding="async"
draggable={false}
@@ -328,8 +389,10 @@ const Tile = memo(function Tile({
// its way: it fades in over the thumbnail rather than snapping from soft to sharp.
// Never made: the thumbnail stays.
onLoad={(e) => {
+ landed.current = true;
e.currentTarget.dataset.in = performance.now() - born.current > 80 ? "fade" : "now";
}}
+ onError={under}
/>
{photo.kind === "video" && (
<span className="px-badge px-duration">
@@ -489,6 +552,7 @@ const Month = memo(function Month({
export function PhotosView() {
const { revision } = useSync();
+ const arriving = useArriving("photos");
const [view, setView] = useState<PhotoView>("library");
/** An album open instead of a view. */
const [album, setAlbum] = useState<PhotoAlbum | null>(null);
@@ -525,6 +589,7 @@ export function PhotosView() {
const [inBurst, setInBurst] = useState<{ from: string; count: number } | null>(null);
const [counts, setCounts] = useState<Partial<Record<PhotoView, number>>>({});
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
const [zoom, setZoom] = useState(1);
// Squares that fill each cell, or each photo whole in its own shape — icloud.com's toggle,
// kept on this machine.
@@ -546,7 +611,6 @@ export function PhotosView() {
});
const [open, setOpen] = useState<number | null>(null);
const [info, setInfo] = useState(false);
- const [saved, setSaved] = useState<string | null>(null);
/** A slideshow playing: what it shows, and where it begins. */
const [show, setShow] = useState<{ list: Photo[]; start: number } | null>(null);
/** Photos selected in the grid, as on a Mac: a click selects, a double-click opens. */
@@ -614,16 +678,25 @@ export function PhotosView() {
api.photosAlbums(),
]);
if (mine !== reads.current) return;
- setPhotos(list);
- setDrawn({ view, album, query: searching });
+ setPhotos((before) => keepSame(before, list));
+ // The same view read again is the same view drawn: a new object here built every month
+ // afresh and faded the grid in again at each landing.
+ setDrawn((d) => (d.view === view && d.album === album && d.query === searching ? d : { view, album, query: searching }));
setCounts(Object.fromEntries(c));
setAlbums(a);
// An album deleted elsewhere is not left open, empty.
if (album && !a.some(([x]) => x.id === album.id)) setAlbum(null);
}, [view, album, searching]);
+ // A pass that lands while another screen is in front is read when this one comes back, once,
+ // not at every landing: a screen out of sight is still mounted (lib/screen), and each pass
+ // lands a service at a time.
+ const active = useScreenActive();
+ const seen = useRef(revision);
+ if (active) seen.current = revision;
+ const due = seen.current;
useEffect(() => {
read().catch((e) => setError(messageOf(e)));
- }, [read, revision]);
+ }, [read, due]);
// Grouped by month, as the library reads; an album is one grid in its own order.
const months = useMemo(() => {
@@ -755,6 +828,17 @@ export function PhotosView() {
// as large as fits, never past 1.5× its own pixels, its shape exact. Known before it loads,
// so its thumbnail fills that box at once and the sharper picture lands without anything
// moving; and a window being resized redraws it every frame with no script in the way.
+ // A photo's shape as its picture turned out, where that is not the shape Apple records:
+ // Apple keeps the sensor's width and height, before the turn the camera wrote into the file,
+ // and an engine that honours that turn (WebView2 does) drew an upright photo inside a frame
+ // lying on its side, with the thumbnail painted under it showing at both sides, stretched.
+ const [trueShape, setTrueShape] = useState<ReadonlyMap<string, number>>(() => new Map());
+ const learnShape = (p: Photo, img: HTMLImageElement) => {
+ if (!img.naturalWidth || !img.naturalHeight || !p.width || !p.height) return;
+ const seen = img.naturalWidth / img.naturalHeight;
+ if (Math.abs(seen - p.width / p.height) < 0.02 || trueShape.get(p.id) === seen) return;
+ setTrueShape((was) => new Map(was).set(p.id, seen));
+ };
const fitted = (p: Photo): React.CSSProperties => {
// The grid's thumbnail, already decoded, painted under the picture: never a black stage.
const under = { backgroundImage: `url("${pictureSrc(p.id, "thumb")}")` };
@@ -762,11 +846,14 @@ export function PhotosView() {
// Both sides set, each the smaller of the room across and the room down in the photo's own
// proportion: WebKit sized a replaced image's height from its width alone, ignoring
// aspect-ratio, and drew every photo square.
- const r = (p.width / p.height).toFixed(6);
+ const ratio = trueShape.get(p.id) ?? p.width / p.height;
+ const r = ratio.toFixed(6);
+ const long = Math.max(p.width, p.height) * 1.5;
+ const [w, h] = ratio >= 1 ? [long, long / ratio] : [long * ratio, long];
return {
...under,
- width: `min(100cqw, ${r} * 100cqh, ${Math.round(p.width * 1.5)}px)`,
- height: `min(100cqw / ${r}, 100cqh, ${Math.round(p.height * 1.5)}px)`,
+ width: `min(100cqw, ${r} * 100cqh, ${Math.round(w)}px)`,
+ height: `min(100cqw / ${r}, 100cqh, ${Math.round(h)}px)`,
maxWidth: "none",
maxHeight: "none",
};
@@ -951,6 +1038,8 @@ export function PhotosView() {
}
return !v;
});
+ // A toast says its piece above the filmstrip, never on it.
+ useToastClearance(open !== null && (photos?.length ?? 0) > 1 && (!fullscreen || thumbs) ? (fullscreen ? 52 : 70) : 0);
const [barUp, setBarUp] = useState(true);
const barTimer = useRef<number | undefined>(undefined);
const fullBar = useRef<HTMLElement | null>(null);
@@ -1145,7 +1234,7 @@ export function PhotosView() {
* Favorite, Delete and Recover show at once, as on the phone; Apple's answer only matters if
* it refuses, which puts the photo back as it was and says why.
*/
- const [ask, asking] = useAsk();
+ const [ask, asking] = useConfirm();
const change = (p: Photo, flag: Flag, on: boolean) => changeAll([p], flag, on);
const changeAll = async (list: Photo[], flag: Flag, on: boolean) => {
if (list.length === 0) return;
@@ -1295,7 +1384,7 @@ export function PhotosView() {
setAlbums((list) => list.map((x) => (x[0].id === a.id ? [x[0], x[1] + ids.length] : x)));
try {
await api.photosAlbumAdd(a.id, ids);
- setSaved(ids.length === 1 ? `Added to ${a.name}` : `${ids.length} added to ${a.name}`);
+ toast({ message: ids.length === 1 ? `Added to ${a.name}` : `${ids.length} added to ${a.name}`, tone: "done" });
read().catch(() => {});
} catch (e) {
setAlbums(before);
@@ -1510,7 +1599,7 @@ export function PhotosView() {
const albumEntries = (ids: string[]): MenuEntry[] => [
...albums.filter(([a]) => !a.folder && a.id !== album?.id && !a.id.startsWith("new:")).map(([a]) => ({ label: a.name, run: () => void addTo(a, ids) })),
...(albums.length ? [null] : []),
- { label: "New Album…", run: () => setNaming({ id: null, then: ids, draft: "" }) },
+ { label: "New Album", run: () => setNaming({ id: null, then: ids, draft: "" }) },
];
const photoMenu = (p: Photo, at: { x: number; y: number; alignRight: boolean }) => {
@@ -1537,7 +1626,7 @@ export function PhotosView() {
{ label: anyPlain ? "Favorite" : "Unfavorite", run: () => void changeAll(group, "favorite", anyPlain) },
null,
{ label: `Download ${n} Items`, run: () => void downloadAs(group, "originals") },
- { label: "More Download Options…", run: () => setOptions(group) },
+ { label: "More Download Options", run: () => setOptions(group) },
null,
{ label: "Start Slideshow", run: () => startShow(p) },
{ label: "Add to Album", submenu: albumEntries(group.map((x) => x.id)) },
@@ -1562,7 +1651,7 @@ export function PhotosView() {
: [
{ label: p.favorite ? "Unfavorite" : "Favorite", run: () => void change(p, "favorite", !p.favorite) },
{ label: "Download", run: () => void download(p) },
- { label: "More Download Options…", run: () => setOptions([p]) },
+ { label: "More Download Options", run: () => setOptions([p]) },
{ label: "Start Slideshow", run: () => startShow(p) },
null,
{ label: "Add to Album", submenu: albumEntries([p.id]) },
@@ -1672,7 +1761,7 @@ export function PhotosView() {
const nameField = (
<input
- className="px-source px-naming"
+ className="field px-naming"
aria-label="Album name"
autoFocus
value={naming?.draft ?? ""}
@@ -1766,7 +1855,7 @@ export function PhotosView() {
const download = async (p: Photo) => {
try {
const where = await api.photoDownload(p.id);
- setSaved(`Saved to ${where}`);
+ toastSaved(where);
} catch (e) {
setError(messageOf(e));
}
@@ -1794,7 +1883,7 @@ export function PhotosView() {
let last = "";
try {
for (const p of list) last = await api.photoDownload(p.id, want);
- setSaved(list.length === 1 ? `Saved to ${last}` : `${list.length} saved to Downloads`);
+ toastSaved(last, list.length);
} catch (e) {
setError(messageOf(e));
}
@@ -2121,7 +2210,7 @@ export function PhotosView() {
<ChevronRight className="px-chevron" size={12} strokeWidth={2.4} aria-hidden="true" />
</button>
<button
- className="px-source px-parent"
+ className="source-row px-source px-parent"
aria-current={albumsPage && folderPage === a.id}
onClick={() => openFolder(a.id)}
onDoubleClick={() => setNaming({ id: a.id, then: [], draft: a.name })}
@@ -2142,7 +2231,7 @@ export function PhotosView() {
}}
>
<FolderIcon size={16} strokeWidth={1.8} className="px-glyph" aria-hidden="true" />
- <span className="px-label">{a.name}</span>
+ <span className="source-name px-label">{a.name}</span>
</button>
</div>,
);
@@ -2152,7 +2241,7 @@ export function PhotosView() {
rows.push(
<button
key={a.id}
- className="px-source px-depth"
+ className="source-row px-source px-depth"
style={indent}
aria-current={!albumsPage && album?.id === a.id}
onClick={() => {
@@ -2183,8 +2272,8 @@ export function PhotosView() {
) : (
<AlbumGlyph />
)}
- <span className="px-label">{a.name}</span>
- {n ? <span className="px-count">{n}</span> : null}
+ <span className="source-name px-label">{a.name}</span>
+ {n ? <span className="count px-count">{n}</span> : null}
</button>,
);
}
@@ -2194,7 +2283,7 @@ export function PhotosView() {
const source = (v: (typeof VIEWS)[number]) => (
<button
key={v.key}
- className="px-source"
+ className="source-row px-source"
aria-current={!album && !albumsPage && !sharedPage && view === v.key}
onClick={() => {
setView(v.key);
@@ -2206,26 +2295,26 @@ export function PhotosView() {
}}
>
<v.Icon className="px-glyph" size={16} strokeWidth={1.8} aria-hidden="true" />
- <span className="px-label">{v.label}</span>
- {counts[v.key] ? <span className="px-count">{counts[v.key]}</span> : null}
+ <span className="source-name px-label">{v.label}</span>
+ {counts[v.key] ? <span className="count px-count">{counts[v.key]}</span> : null}
</button>
);
return (
<div className={`px${dropping ? " is-dropping" : ""}`} data-drop-label={album ? `Add to ${album.name}` : "Add to Library"}>
<aside className="px-side" aria-label="Photos">
- <p className="px-side-heading">Photos</p>
+ <p className="side-heading px-side-heading">Photos</p>
{VIEWS.map(source)}
{/* Collections, as icloud.com lists them: Albums and Media Types open to what they
hold, then Rated, Hidden and Recently Deleted. */}
- <p className="px-side-heading px-side-gap">Collections</p>
+ <p className="side-heading px-side-heading px-side-gap">Collections</p>
<div className="px-parent-row">
{/* The chevron opens the list here; the row itself opens the Albums page. */}
<button className="px-twisty" aria-label={branches.albums ? "Hide Albums" : "Show Albums"} aria-expanded={branches.albums} onClick={() => branch("albums")}>
<ChevronRight className="px-chevron" size={12} strokeWidth={2.4} aria-hidden="true" />
</button>
<button
- className="px-source px-parent"
+ className="source-row px-source px-parent"
aria-current={albumsPage && folderPage === null}
onClick={() => {
setAlbumsPage(true);
@@ -2236,9 +2325,9 @@ export function PhotosView() {
}}
>
<AlbumGlyph />
- <span className="px-label">Albums</span>
+ <span className="source-name px-label">Albums</span>
</button>
- <button className="px-side-add" aria-label="New Album" title="New Album or Folder" aria-haspopup="menu" onClick={(e) => {
+ <button className="icon-button small px-side-add" aria-label="New Album" title="New Album or Folder" aria-haspopup="menu" onClick={(e) => {
const b = e.currentTarget.getBoundingClientRect();
newIn(null, { x: b.left, y: b.bottom + 4, alignRight: false });
}}>
@@ -2250,10 +2339,10 @@ export function PhotosView() {
{albumRows(null, 0)}
</div>
)}
- <button className="px-source px-parent" aria-expanded={branches.media} onClick={() => branch("media")}>
+ <button className="source-row px-source px-parent" aria-expanded={branches.media} onClick={() => branch("media")}>
<ChevronRight className="px-chevron" size={12} strokeWidth={2.4} aria-hidden="true" />
<Layers size={16} strokeWidth={1.8} className="px-glyph" aria-hidden="true" />
- <span className="px-label">Media Types</span>
+ <span className="source-name px-label">Media Types</span>
</button>
{branches.media && (
<div className="px-children" role="group" aria-label="Media Types">
@@ -2263,9 +2352,9 @@ export function PhotosView() {
)}
{UTILITIES.map(source)}
{/* Sharing, as icloud.com lists it: the shared albums this account has made or joined. */}
- <p className="px-side-heading px-side-gap">Sharing</p>
+ <p className="side-heading px-side-heading px-side-gap">Sharing</p>
<button
- className="px-source"
+ className="source-row px-source"
aria-current={sharedPage}
onClick={() => {
setSharedPage(true);
@@ -2275,7 +2364,7 @@ export function PhotosView() {
}}
>
<Users className="px-glyph" size={16} strokeWidth={1.8} aria-hidden="true" />
- <span className="px-label">Shared Albums</span>
+ <span className="source-name px-label">Shared Albums</span>
</button>
</aside>
@@ -2292,19 +2381,18 @@ export function PhotosView() {
<>
<header className="px-albums-head">
{folder && (
- <div className="px-capsule">
- <button className="px-cap" aria-label="Back" title="Back" onClick={() => openFolder(folder.parent ?? null)}>
+ <div className="toolbar-group">
+ <button className="tool px-cap" aria-label="Back" title="Back" onClick={() => openFolder(folder.parent ?? null)}>
<ChevronLeft size={17} strokeWidth={2} aria-hidden="true" />
</button>
</div>
)}
- <div className="px-heading">
- <h1>{folder ? folder.name : "Albums"}</h1>
- <p className="px-span">{here.length === 1 ? "1 Item" : `${here.length} Items`}</p>
- </div>
- <div className="px-capsule">
+ <PaneTitle className="px-heading" countClassName="px-span" count={here.length === 1 ? "1 Item" : `${here.length} Items`}>
+ {folder ? folder.name : "Albums"}
+ </PaneTitle>
+ <div className="toolbar-group">
<button
- className="px-cap"
+ className="tool px-cap"
aria-label="New Album or Folder"
title="New Album or Folder"
aria-haspopup="menu"
@@ -2318,9 +2406,9 @@ export function PhotosView() {
</div>
</header>
{here.length === 0 ? (
- <p className="px-empty">
+ <EmptyState className="px-empty">
{folder ? "This folder is empty. Make an album in it with +." : "No albums yet. Make one with +, then add photos to it from their menu or by dragging them onto it."}
- </p>
+ </EmptyState>
) : (
<div className="px-cards" role="list">
{here.map(([a, n, cover]) => (
@@ -2379,42 +2467,43 @@ export function PhotosView() {
{/* As in Photos on macOS 26: the title and the controls float over the library, which
scrolls beneath them and fades out at the top edge. */}
<header className="px-bar" ref={bar}>
- <div className="px-heading">
- <h1>{title}</h1>
- {selected.length > 0 ? (
- <p className="px-span px-picked">{pickedWords(selected)}</p>
- ) : (
- drawn.query ? (
- <p className="px-span">{photos?.length === 1 ? "1 Result" : `${(photos?.length ?? 0).toLocaleString()} Results`}</p>
- ) : (
- (here ?? span) && <p className="px-span">{here ?? span}</p>
- )
- )}
- </div>
+ <PaneTitle
+ className="px-heading"
+ countClassName="px-span"
+ count={
+ selected.length > 0
+ ? pickedWords(selected)
+ : drawn.query
+ ? photos?.length === 1 ? "1 Result" : `${(photos?.length ?? 0).toLocaleString()} Results`
+ : (here ?? span) || undefined
+ }
+ >
+ {title}
+ </PaneTitle>
<div className="px-tools">
{view === "recentlyDeleted" && !album && photos && photos.length > 0 && (
// Recently Deleted's own toolbar, in Photos' words: Recover and Delete for what is
// selected, Delete All when nothing is.
- <div className="px-capsule px-words">
+ <div className="toolbar-group px-words">
{selected.length > 0 ? (
<>
- <button className="px-word" onClick={() => void changeAll(selected, "deleted", false)}>
+ <button className="tool has-label is-accent px-word" onClick={() => void changeAll(selected, "deleted", false)}>
Recover
</button>
- <button className="px-word is-danger" onClick={() => void changeAll(selected, "expunged", true)}>
+ <button className="tool has-label danger px-word" onClick={() => void changeAll(selected, "expunged", true)}>
Delete
</button>
</>
) : (
- <button className="px-word is-danger" onClick={() => void changeAll(photos, "expunged", true)}>
+ <button className="tool has-label danger px-word" onClick={() => void changeAll(photos, "expunged", true)}>
Delete All
</button>
)}
</div>
)}
- <div className="px-capsule">
+ <div className="toolbar-group">
<button
- className="px-cap is-glyph-state"
+ className="tool px-cap is-glyph-state"
aria-label={fit ? "Show Square Photos" : "Show Whole Photos"}
aria-pressed={fit}
title={fit ? "Square photos" : "Whole photos"}
@@ -2424,9 +2513,9 @@ export function PhotosView() {
</button>
</div>
{sort && (
- <div className="px-capsule">
+ <div className="toolbar-group">
<button
- className="px-cap"
+ className="tool px-cap"
aria-label="Sort"
aria-haspopup="menu"
title="Sort"
@@ -2449,9 +2538,9 @@ export function PhotosView() {
</div>
)}
{monthCovers.length > 1 && (
- <div className="px-capsule">
+ <div className="toolbar-group">
<button
- className="px-cap"
+ className="tool px-cap"
aria-label="Go to a Month"
aria-haspopup="dialog"
aria-expanded={jumping !== null}
@@ -2463,56 +2552,47 @@ export function PhotosView() {
</div>
)}
{jumping && <JumpTo months={monthCovers} at={jumping} current={here ?? monthCovers[0]?.label ?? null} onPick={goToMonth} onClose={() => setJumping(null)} />}
- <div className="px-capsule" role="group" aria-label="Zoom">
- <button className="px-cap" aria-label="Zoom Out" title="Zoom Out (Ctrl −)" disabled={zoom === 0} onClick={() => setZoom((z) => Math.max(0, z - 1))}>
+ <div className="toolbar-group" role="group" aria-label="Zoom">
+ <button className="tool px-cap" aria-label="Zoom Out" title="Zoom Out (Ctrl −)" disabled={zoom === 0} onClick={() => setZoom((z) => Math.max(0, z - 1))}>
<Minus size={15} strokeWidth={2.2} aria-hidden="true" />
</button>
- <button className="px-cap" aria-label="Zoom In" title="Zoom In (Ctrl +)" disabled={zoom === ACROSS.length - 1} onClick={() => setZoom((z) => Math.min(ACROSS.length - 1, z + 1))}>
+ <button className="tool px-cap" aria-label="Zoom In" title="Zoom In (Ctrl +)" disabled={zoom === ACROSS.length - 1} onClick={() => setZoom((z) => Math.min(ACROSS.length - 1, z + 1))}>
<Plus size={15} strokeWidth={2.2} aria-hidden="true" />
</button>
</div>
- <div className="px-capsule">
- <button className="px-cap px-add" onClick={() => void choose()} title="Add photos and videos" aria-label="Add Photos">
+ <div className="toolbar-group">
+ <button className="tool px-cap px-add" onClick={() => void choose()} title="Add photos and videos" aria-label="Add Photos">
<ImagePlus size={16} strokeWidth={1.9} aria-hidden="true" />
</button>
</div>
{/* Search, as icloud.com's toolbar has it: names, titles, captions, keywords, years and
months, from the library on this machine — nothing typed leaves it. */}
- <label className="px-capsule px-search">
- <SearchIcon size={15} strokeWidth={2} aria-hidden="true" />
- <input
- type="search"
- aria-label="Search Photos"
- placeholder="Search Photos"
- value={query}
- spellCheck={false}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Escape") {
- e.preventDefault();
- e.stopPropagation();
- endSearch();
- e.currentTarget.blur();
- }
- }}
- />
- {query && (
- <button className="px-search-clear" aria-label="Clear Search" onClick={endSearch}>
- <X size={11} strokeWidth={3} aria-hidden="true" />
- </button>
- )}
- </label>
+ <SearchField
+ inToolbar
+ className="px-search"
+ aria-label="Search Photos"
+ placeholder="Search Photos"
+ value={query}
+ onChange={setQuery}
+ onClear={endSearch}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") {
+ e.preventDefault();
+ e.stopPropagation();
+ endSearch();
+ e.currentTarget.blur();
+ }
+ }}
+ />
</div>
</header>
- {error && (
- <div className="px-notice">
- <Notice message={error} onDismiss={() => setError(null)} />
- </div>
- )}
- {photos && photos.length === 0 && (
- <p className="px-empty">
+ {photos && photos.length === 0 && !drawn.query && (
+ <Arriving service="photos" what="photos" className="px-empty" />
+ )}
+ {photos && photos.length === 0 && !(arriving && !drawn.query) && (
+ <EmptyState className="px-empty">
{drawn.query
? `No photos match “${drawn.query}”. Search finds names, titles, captions, keywords, years and months.`
: album
@@ -2522,7 +2602,7 @@ export function PhotosView() {
: view === "favorites"
? "Mark a photo with the heart and it shows here."
: "No photos here yet."}
- </p>
+ </EmptyState>
)}
<div
@@ -2683,12 +2763,12 @@ export function PhotosView() {
</header>
) : (
<header key="bar" className="px-viewer-bar">
- <div className="px-capsule">
- <button className="px-cap" aria-label="Close" title="Close (Esc)" onClick={close}>
+ <div className="toolbar-group">
+ <button className="tool px-cap" aria-label="Close" title="Close (Esc)" onClick={close}>
<X size={17} strokeWidth={2} />
</button>
<button
- className="px-cap"
+ className="tool px-cap"
aria-label={fullscreen ? "Exit Full Screen" : "Enter Full Screen"}
aria-pressed={fullscreen}
title={fullscreen ? "Exit Full Screen" : "Enter Full Screen"}
@@ -2698,20 +2778,20 @@ export function PhotosView() {
</button>
</div>
{when}
- <div className="px-capsule">
+ <div className="toolbar-group">
{view === "recentlyDeleted" && !album ? (
<>
- <button className="px-cap" aria-label="Recover" title="Recover" onClick={() => void change(shown, "deleted", false)}>
+ <button className="tool px-cap" aria-label="Recover" title="Recover" onClick={() => void change(shown, "deleted", false)}>
<RotateCcw size={17} />
</button>
- <button className="px-cap" aria-label="Delete Permanently" title="Delete permanently (Delete)" onClick={() => void change(shown, "expunged", true)}>
+ <button className="tool px-cap" aria-label="Delete Permanently" title="Delete permanently (Delete)" onClick={() => void change(shown, "expunged", true)}>
<Trash2 size={17} />
</button>
</>
) : (
<>
<button
- className="px-cap"
+ className="tool px-cap"
aria-label={shown.favorite ? "Unfavorite" : "Favorite"}
aria-pressed={shown.favorite}
title={shown.favorite ? "Unfavorite (.)" : "Favorite (.)"}
@@ -2720,7 +2800,7 @@ export function PhotosView() {
<Heart size={17} fill={shown.favorite ? "currentColor" : "none"} />
</button>
<button
- className="px-cap"
+ className="tool px-cap"
aria-label="Add to Album"
aria-haspopup="menu"
title="Add to Album"
@@ -2732,25 +2812,25 @@ export function PhotosView() {
<CopyPlus size={17} />
</button>
{album ? (
- <button className="px-cap" aria-label="Remove from Album" title="Remove from Album (Delete)" onClick={() => void removeFrom([shown])}>
+ <button className="tool px-cap" aria-label="Remove from Album" title="Remove from Album (Delete)" onClick={() => void removeFrom([shown])}>
<CopyMinus size={17} />
</button>
) : (
- <button className="px-cap" aria-label="Delete" title="Delete (Delete)" onClick={() => void change(shown, "deleted", true)}>
+ <button className="tool px-cap" aria-label="Delete" title="Delete (Delete)" onClick={() => void change(shown, "deleted", true)}>
<Trash2 size={17} />
</button>
)}
</>
)}
</div>
- <div className="px-capsule">
- <button className="px-cap" aria-label="Start Slideshow" title="Start Slideshow" onClick={() => startShow(shown)}>
+ <div className="toolbar-group">
+ <button className="tool px-cap" aria-label="Start Slideshow" title="Start Slideshow" onClick={() => startShow(shown)}>
<MonitorPlay size={17} />
</button>
- <button className="px-cap" aria-label="Download" title="Download the original" onClick={() => void download(shown)}>
+ <button className="tool px-cap" aria-label="Download" title="Download the original" onClick={() => void download(shown)}>
<Download size={17} />
</button>
- <button className="px-cap" aria-label="Info" aria-pressed={info} title="Info (I)" onClick={() => setInfo((v) => !v)}>
+ <button className="tool px-cap" aria-label="Info" aria-pressed={info} title="Info (I)" onClick={() => setInfo((v) => !v)}>
<Info size={17} />
</button>
</div>
@@ -2842,6 +2922,7 @@ export function PhotosView() {
onLoad={(e) => {
const img = e.currentTarget;
const url = viewSrc(shown);
+ learnShape(shown, img);
const done = () => {
decoded.add(url);
painted.current = shown;
@@ -3075,11 +3156,6 @@ export function PhotosView() {
</div>
)}
</section>
- {saved && (
- <p className="drive-saved px-saved" role="status" onClick={() => setSaved(null)}>
- {saved}
- </p>
- )}
{menu && <RowMenu at={menu.at} entries={menu.entries} onClose={() => setMenu(null)} />}
{asking}
{/* Drawn at the top of the page: inside the screen, whose content moves by a transform,
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index fd27859..71f7a24 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -3,7 +3,13 @@ import { foldAway } from "../lib/fade";
import { useActiveRef } from "../lib/screen";
import { listen } from "@tauri-apps/api/event";
import { usePending } from "../lib/pending";
-import { Notice } from "../components/Notice";
+import { Unsent, Waiting } from "../components/Unsent";
+import { useOutbox } from "../lib/outbox";
+import { useErrorToast } from "../components/Toast";
+import { useConfirm } from "../components/Confirm";
+import { EmptyState } from "../components/EmptyState";
+import { SearchField } from "../components/SearchField";
+import { PaneTitle } from "../components/PaneTitle";
import { Portal } from "../components/Portal";
import { TimeField } from "../components/TimeField";
import { ChevronLeft } from "lucide-react";
@@ -18,7 +24,8 @@ import {
type ReminderCounts,
type SmartList,
} from "../lib/ipc";
-import { useSync } from "../lib/sync";
+import { Arriving } from "../components/EmptyState";
+import { useArriving, useSync } from "../lib/sync";
import { Picker } from "../components/Picker";
import { RowMenu } from "../components/RowMenu";
import { Glyph, emblemGlyph, type GlyphName } from "../components/Glyph";
@@ -174,6 +181,14 @@ const dayToUtc = (value: string) => {
const [y, m, d] = value.split("-").map(Number);
return Math.floor(Date.UTC(y, m - 1, d) / 1000);
};
+/**
+ * The backend's answer when a reminder acted on is not in the library at all (REMINDER_GONE in
+ * main.rs) — gone from iCloud and synced away. Answered with a quiet re-read, never a notice.
+ */
+const REMINDER_GONE = "reminder-gone";
+/** A row shown for a reminder still being added, before Apple has given it an id. */
+const STAND_IN = "pending:";
+
const asShown = (r: Reminder): Reminder =>
r.allDay && r.dueAt !== null ? { ...r, dueAt: dayToLocal(r.dueAt) } : r;
@@ -245,7 +260,10 @@ export function RemindersView() {
const [renaming, setRenaming] = useState<string | null>(null);
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
+ const [confirm, confirmSheet] = useConfirm();
const { revision } = useSync();
+ const arriving = useArriving("reminders");
/** What each sidebar entry is holding. Apple puts a number on every one. */
const [counts, setCounts] = useState<ReminderCounts | null>(null);
/** The headings inside the list that is open, when a real list is open. */
@@ -283,6 +301,8 @@ export function RemindersView() {
const [detail, setDetail] = useState(false);
const { hold, over } = usePending<Reminder>();
+ /** Changes kept here and not yet at Apple, and any Apple turned down. */
+ const outbox = useOutbox("reminders");
/** Each read is numbered: one overtaken by a later pick is dropped, never drawn late. */
const reads = useRef(0);
const readItems = useCallback(async (): Promise<Reminder[]> => {
@@ -313,9 +333,9 @@ export function RemindersView() {
useEffect(() => {
const offs = [
listen("quince://reminders-synced", () => void readItems().catch(() => {})),
+ // Said by the refused change's own notice (Unsent), which keeps what it held.
listen<{ service: string; message: string }>("quince://outbox-refused", (e) => {
if (e.payload.service !== "reminders") return;
- setError(e.payload.message);
void readItems().catch(() => {});
}),
];
@@ -340,7 +360,8 @@ export function RemindersView() {
useEffect(() => {
readItems().catch((e) => setError(messageOf(e)));
- }, [readItems, revision]);
+ // `outbox.tick`: a change sent, or turned down, changes what the library holds.
+ }, [readItems, revision, outbox.tick]);
useEffect(() => {
if (!moved) return undefined;
@@ -365,6 +386,10 @@ export function RemindersView() {
run: () => Promise<void>,
predict?: (rows: Reminder[]) => Reminder[],
): Promise<Reminder[] | null> => {
+ // A stand-in has no id at Apple yet, so there is nothing to send: a tick or an edit on it
+ // was refused as "no longer in the local library". It is replaced by the real row the
+ // moment the add lands, and that one takes changes.
+ if (reminder.guid.startsWith(STAND_IN)) return null;
setError(null);
if (predict) setItems((rows) => predict(rows));
// Kept over any refresh until Apple has it; let go before the read that confirms it.
@@ -383,7 +408,9 @@ export function RemindersView() {
return await readItems();
} catch (e) {
release();
- setError(messageOf(e));
+ // Not in the library at all — deleted on another device and synced away. Nothing to
+ // say about it: the list is read again and the row goes, as on the phone.
+ if (messageOf(e) !== REMINDER_GONE) setError(messageOf(e));
readItems().catch(() => {});
return null;
} finally {
@@ -456,6 +483,7 @@ export function RemindersView() {
const held = useRef(new Set<string>());
const SETTLE_MS = 1500;
const toggle = (r: Reminder) => {
+ if (r.guid.startsWith(STAND_IN)) return;
const wasOpen = !r.completedAt;
const repeating = repeatLabel(r) !== null;
if (repeating) {
@@ -698,7 +726,7 @@ export function RemindersView() {
? { flagged: true }
: {};
// The row is there the moment Return is pressed, and the field is ready for the next.
- const standIn = `pending:${Date.now()}`;
+ const standIn = `${STAND_IN}${Date.now()}`;
setDraft("");
const shownHere = inList || kind === "today" || kind === "scheduled" || kind === "flagged" || kind === "all";
if (shownHere) setItems((rows) => [
@@ -973,7 +1001,7 @@ export function RemindersView() {
<div className={`rx-list-row${nested ? " nested" : ""}${listMenu?.list.guid === list.guid ? " is-menu" : ""}`} key={list.guid}>
{renaming === list.guid ? (
<input
- className="rx-rename"
+ className="field rx-rename"
defaultValue={list.title}
autoFocus
aria-label={`Rename ${list.title}`}
@@ -995,7 +1023,7 @@ export function RemindersView() {
) : (
<>
<button
- className="rx-list"
+ className="source-row rx-list"
aria-current={picked.type === "list" && picked.guid === list.guid}
onClick={() => {
setQuery("");
@@ -1011,13 +1039,13 @@ export function RemindersView() {
<span className="rx-badge" style={{ background: colourOf(list) }}>
<Glyph name={emblemGlyph(list.emblem)} />
</span>
- <span className="rx-list-name">{list.title}</span>
- <span className="rx-list-count">{countOf(list.guid)}</span>
+ <span className="source-name rx-list-name">{list.title}</span>
+ <span className="count">{countOf(list.guid)}</span>
</button>
{/* One ⋯ over where the count sits, as Notes' and Contacts' rows have: three
buttons there covered the list's own name. Right-click opens the same menu. */}
<button
- className="notes-folder-more rx-list-more"
+ className="icon-button small round row-more rx-list-more"
aria-label={`Actions for ${list.title}`}
aria-haspopup="menu"
onClick={(e) => {
@@ -1095,19 +1123,16 @@ export function RemindersView() {
style={{ "--accent": accent } as React.CSSProperties}
>
<aside className="rx-side" aria-label="Reminder lists">
- <label className="rx-search">
- <Glyph name="search" />
- <input
- type="search"
- placeholder="Search"
- aria-label="Search reminders"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Escape") setQuery("");
- }}
- />
- </label>
+ <SearchField
+ className="rx-search"
+ placeholder="Search"
+ aria-label="Search reminders"
+ value={query}
+ onChange={setQuery}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") setQuery("");
+ }}
+ />
<div className="rx-tiles">
{SMART.map((smart) =>
@@ -1134,7 +1159,7 @@ export function RemindersView() {
)}
</div>
- <p className="rx-side-heading">My Lists</p>
+ <p className="side-heading rx-side-heading">My Lists</p>
<div className="rx-lists">
{topLevel.map((entry) =>
entry.kind === "list" ? (
@@ -1142,14 +1167,14 @@ export function RemindersView() {
) : (
<div className="rx-group" key={entry.group.guid}>
<button
- className="rx-group-row"
+ className="source-row rx-group-row"
aria-expanded={!folded.has(entry.group.guid)}
onClick={() => toggleFolded(entry.group.guid)}
>
<span className="rx-group-glyph">
<Glyph name="folder" />
</span>
- <span className="rx-list-name">{entry.group.title}</span>
+ <span className="source-name rx-list-name">{entry.group.title}</span>
<span className="rx-chevron">
<Glyph name="chevron" />
</span>
@@ -1160,12 +1185,12 @@ export function RemindersView() {
),
)}
</div>
- {loaded && lists.length === 0 && <p className="rx-side-empty">No lists yet</p>}
+ {loaded && lists.length === 0 && !arriving && <p className="side-heading">No lists yet</p>}
{addingList ? (
<form className="rx-new-list" onSubmit={createList}>
<input
- className="rx-rename"
+ className="field rx-rename"
value={newList}
onChange={(e) => setNewList(e.target.value)}
placeholder="List name"
@@ -1175,7 +1200,7 @@ export function RemindersView() {
/>
</form>
) : (
- <button className="rx-add-list" onClick={() => setAddingList(true)}>
+ <button className="side-add" onClick={() => setAddingList(true)}>
<Glyph name="plus" />
Add List
</button>
@@ -1187,33 +1212,28 @@ export function RemindersView() {
<ChevronLeft size={18} strokeWidth={2.25} aria-hidden="true" />
<span>Lists</span>
</button>
- <header className="rx-head">
- <h1>{searching ? `Results for “${query.trim()}”` : heading}</h1>
- <span className="rx-head-count" aria-label={`${outstanding} to do`}>
- {outstanding}
- </span>
- </header>
- {inList && (
- <div className="rx-subhead">
- <button className="rx-link" onClick={() => setShowDone((v) => !v)}>
+ <header className="pane-head rx-head">
+ <PaneTitle count={`${outstanding} ${outstanding === 1 ? "reminder" : "reminders"}`}>
+ {searching ? `Results for “${query.trim()}”` : heading}
+ </PaneTitle>
+ {inList && (
+ <button className="link" onClick={() => setShowDone((v) => !v)}>
{showDone ? "Hide Completed" : "Show Completed"}
</button>
- </div>
- )}
-
- {error && (
- <Notice message={error} onDismiss={() => setError(null)} />
- )}
+ )}
+ </header>
+ <Unsent refused={outbox.refused} what="a change to a reminder" onResend={(r) => void outbox.resend(r)} onDiscard={(r) => void outbox.discard(r)} />
{/* An account with no lists: a reminder cannot exist outside one, so the one thing
that helps is offered instead of an add field with nowhere to go. */}
- {lists.length === 0 && loaded && (
- <div className="rem-nolists">
- <p className="rem-nolists-line">Reminders live in lists, and there aren’t any yet.</p>
- <button className="primary" onClick={() => void makeFirstList()} disabled={syncing}>
- Create a list
- </button>
- </div>
+ <Arriving service="reminders" what="reminders" />
+ {lists.length === 0 && loaded && !arriving && (
+ <EmptyState
+ className="rem-nolists"
+ action={{ label: "Create a List", run: () => void makeFirstList(), disabled: syncing }}
+ >
+ Reminders live in lists. Make your first one to begin.
+ </EmptyState>
)}
{heldBack > 0 && (
@@ -1383,6 +1403,7 @@ export function RemindersView() {
{reminder.notes && !isOpen && (
<span className="rx-notes">{reminder.notes}</span>
)}
+ <Waiting shown={outbox.waiting.has(reminder.guid)} />
{(due || repeat || justMoved || (showListName && home)) && (
<span className="rx-meta">
{justMoved ? (
@@ -1461,6 +1482,7 @@ export function RemindersView() {
<label className="rx-field">
<span>Notes</span>
<textarea
+ className="field"
defaultValue={reminder.notes ?? ""}
rows={2}
onBlur={(e) => void setNotes(reminder, e.target.value)}
@@ -1469,22 +1491,21 @@ export function RemindersView() {
<div className="rx-detail-actions">
{depth > 0 ? (
<button
- className="rx-link"
-
+ className="link"
onClick={() => void outdent(reminder)}
>
Move Out of Subtasks
</button>
) : items.some((x) => x.parentGuid === reminder.guid) ? null : (
<button
- className="rx-link"
+ className="link"
onClick={() => void indent(reminder)}
>
Make Subtask
</button>
)}
<button
- className="rx-link danger"
+ className="link danger"
aria-label={`Delete ${reminder.title}`}
onClick={() => remove(reminder)}
@@ -1498,7 +1519,7 @@ export function RemindersView() {
<span className="rx-trailing">
<button
- className="rx-icon-button"
+ className="icon-button small rx-icon-button"
aria-label={
isOpen ? `Close details for ${reminder.title}` : `Details for ${reminder.title}`
}
@@ -1508,7 +1529,7 @@ export function RemindersView() {
<Glyph name="info" />
</button>
<button
- className={`rx-icon-button rx-flag${reminder.flagged ? " on" : ""}`}
+ className={`icon-button small is-glyph-state rx-icon-button rx-flag${reminder.flagged ? " on" : ""}`}
aria-label={
reminder.flagged ? `Unflag ${reminder.title}` : `Flag ${reminder.title}`
}
@@ -1529,7 +1550,7 @@ export function RemindersView() {
{addRow}
{loaded && items.length === 0 && !error && lists.length > 0 && (
- <p className="rx-empty">
+ <EmptyState className="rx-empty">
{searching
? "No reminders match."
: inList
@@ -1537,7 +1558,7 @@ export function RemindersView() {
? "Nothing in this list."
: "All done here."
: "No Reminders"}
- </p>
+ </EmptyState>
)}
</section>
{rowMenu && (
@@ -1580,19 +1601,26 @@ export function RemindersView() {
{ label: "Rename List", run: () => setRenaming(listMenu.list.guid) },
null,
{
- label: "Delete List…",
+ label: "Delete List",
danger: true,
run: () => {
const list = listMenu.list;
// Deleting a list takes its reminders, so ask before doing it.
- if (window.confirm(`Delete "${list.title}" and everything in it?`)) {
- void listWrite(() => api.reminderListDelete(list.guid));
- }
+ void confirm({
+ title: `Delete \u201c${list.title}\u201d?`,
+ body: "Every reminder in it is deleted too, on all your devices.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ }).then((sure) => {
+ if (sure) void listWrite(() => api.reminderListDelete(list.guid));
+ });
},
},
]}
/>
)}
+ {confirmSheet}
{infoFor && (
<ListInfo
list={infoFor}
@@ -1649,7 +1677,7 @@ function ListInfo({ list, onClose, onDone }: {
<Glyph name="list" />
</span>
<input
- className="rx-info-name"
+ className="field rx-info-name"
value={title}
aria-label="List name"
style={{ color: shown }}
@@ -1670,7 +1698,7 @@ function ListInfo({ list, onClose, onDone }: {
/>
))}
</div>
- <div className="rx-info-actions">
+ <div className="sheet-actions rx-info-actions">
<button className="quiet" onClick={onClose}>Cancel</button>
<button className="primary" onClick={done} disabled={!title.trim()}>Done</button>
</div>
@@ -1695,7 +1723,7 @@ function DueField({ reminder, onChange }: { reminder: Reminder; onChange: (day:
<div className="rx-due">
<input
type="date"
- className="rx-due-day"
+ className="field rx-due-day"
aria-label={`Date for ${reminder.title}`}
defaultValue={day}
key={`d${reminder.dueAt}`}
@@ -1711,11 +1739,12 @@ function DueField({ reminder, onChange }: { reminder: Reminder; onChange: (day:
disabled={!day}
onChange={(e) => onChange(day, e.target.checked ? "09:00" : null)}
/>
- <span className="rx-switch-track" aria-hidden="true" />
+ <span className="switch" aria-hidden="true" />
<span>Time</span>
</label>
{time !== null && at && (
<TimeField
+ className="field"
label={`Time of day for ${reminder.title}`}
hours={at.getHours()}
minutes={at.getMinutes()}
diff --git a/src/screens/SettingsView.tsx b/src/screens/SettingsView.tsx
index 829d83f..394d779 100644
--- a/src/screens/SettingsView.tsx
+++ b/src/screens/SettingsView.tsx
@@ -1,11 +1,20 @@
+import { ConfirmSheet } from "../components/Confirm";
+import { toastSaved, useErrorToast } from "../components/Toast";
import { useEffect, useState } from "react";
import { getVersion } from "@tauri-apps/api/app";
-import { api, type DriveFolder, type LoginItem, messageOf, type AccountInfo } from "../lib/ipc";
+import {
+ api,
+ type AccountInfo,
+ type DriveFolder,
+ type LocalStorage,
+ type LoginItem,
+ messageOf,
+ settingsApi,
+} from "../lib/ipc";
import { freshness, useSync } from "../lib/sync";
import { setTheme, storedTheme, type Theme } from "../lib/theme";
import { AppIcon } from "../components/AppIcon";
import { AccountAvatar } from "../components/Account";
-import { Portal } from "../components/Portal";
/** The app each service's freshness belongs to, for its icon. */
const ICON: Record<string, string> = {
@@ -29,7 +38,30 @@ function folderState(f: DriveFolder): string {
function size(bytes: number): string {
const gb = bytes / 1024 ** 3;
if (gb >= 1) return `${gb >= 10 ? gb.toFixed(0) : gb.toFixed(1)} GB`;
- return `${Math.max(1, Math.round(bytes / 1024 ** 2))} MB`;
+ if (bytes < 1024 ** 2) return bytes < 1024 ? "Zero KB" : `${Math.round(bytes / 1024)} KB`;
+ return `${Math.round(bytes / 1024 ** 2)} MB`;
+}
+
+/** A row's mark where no app's icon fits: a plain tile, the same size as the apps' icons. */
+function Glyph({ kind }: { kind: "library" | "other" }) {
+ return (
+ <span className="settings-glyph" aria-hidden="true">
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.4">
+ {kind === "library" ? (
+ <>
+ <ellipse cx="8" cy="4" rx="5" ry="2" />
+ <path d="M3 4v8c0 1.1 2.2 2 5 2s5-.9 5-2V4M3 8c0 1.1 2.2 2 5 2s5-.9 5-2" />
+ </>
+ ) : (
+ <g fill="currentColor" stroke="none">
+ <circle cx="3.5" cy="8" r="1.4" />
+ <circle cx="8" cy="8" r="1.4" />
+ <circle cx="12.5" cy="8" r="1.4" />
+ </g>
+ )}
+ </svg>
+ </span>
+ );
}
/**
@@ -69,57 +101,102 @@ function SignOutSheet({
const waiting = unsentPhrase(unsent);
const total = unsent.changes + unsent.files + unsent.photos;
return (
- <Portal>
- <div className="modal-veil" onClick={onCancel}>
- <div
- className="modal-sheet px-ask"
- role="alertdialog"
- aria-modal="true"
- aria-label="Keep a copy of your iCloud data on this computer?"
- onClick={(e) => e.stopPropagation()}
- onKeyDown={(e) => {
- if (e.key === "Escape") {
- e.stopPropagation();
- onCancel();
- }
+ <ConfirmSheet<boolean>
+ title="Keep a copy of your iCloud data on this computer?"
+ body="A copy keeps your notes, photos, files and everything else here, ready when you sign back in. Nothing is deleted from iCloud either way."
+ choices={[
+ { label: "Keep a Copy", value: true, primary: true, focus: true },
+ { label: "Remove from This Computer", value: false, danger: true },
+ ]}
+ onAnswer={onChoose}
+ onCancel={onCancel}
+ >
+ {waiting && (
+ <p className="signout-unsent">
+ {waiting} {total === 1 ? "hasn't" : "haven't"} reached iCloud yet. Keep a copy and{" "}
+ {total === 1 ? "it goes" : "they go"} up when you sign back in; remove it and{" "}
+ {total === 1 ? "it's" : "they're"} lost.
+ </p>
+ )}
+ </ConfirmSheet>
+ );
+}
+
+
+/** A folder of iCloud on this computer, as a row: where it is or why it is not, Open, and its switch. */
+function FolderRow({
+ app,
+ label,
+ off,
+ folder,
+ busy,
+ line,
+ onOpen,
+ onSet,
+}: {
+ app: string;
+ label: string;
+ off: string;
+ folder: DriveFolder | null;
+ busy: boolean;
+ line: (f: DriveFolder) => string;
+ onOpen: () => Promise<unknown>;
+ onSet: (on: boolean) => void;
+}) {
+ // Why the folder could not be opened, said on its own row until it is tried again.
+ const [openFailed, setOpenFailed] = useState<string | null>(null);
+ const problem = openFailed ?? folder?.problem;
+ const trouble = Boolean(problem || folder?.waiting?.failure);
+ return (
+ <div className="settings-row">
+ <AppIcon app={app} />
+ <span className="settings-label settings-stack">
+ {label}
+ <span className={`settings-hint${trouble ? " is-trouble" : ""}`} title={folder?.on ? folder.path : undefined}>
+ {problem ?? (folder?.on ? line(folder) : off)}
+ </span>
+ </span>
+ {folder?.on && (
+ <button
+ className="quiet"
+ onClick={() => {
+ setOpenFailed(null);
+ onOpen().catch((e) => setOpenFailed(messageOf(e)));
}}
>
- <h2>Keep a copy of your iCloud data on this computer?</h2>
- <p>
- A copy keeps your notes, photos, files and everything else here, ready when you sign back in. Nothing is
- deleted from iCloud either way.
- </p>
- {waiting && (
- <p className="signout-unsent">
- {waiting} {total === 1 ? "hasn't" : "haven't"} reached iCloud yet. Keep a copy and{" "}
- {total === 1 ? "it goes" : "they go"} up when you sign back in; remove it and{" "}
- {total === 1 ? "it's" : "they're"} lost.
- </p>
- )}
- <div className="px-ask-actions is-stacked">
- <button className="is-act" autoFocus onClick={() => onChoose(true)}>
- Keep a Copy
- </button>
- <button className="is-act danger" onClick={() => onChoose(false)}>
- Remove from This Computer
- </button>
- <button onClick={onCancel}>Cancel</button>
- </div>
- </div>
- </div>
- </Portal>
+ Open
+ </button>
+ )}
+ <button
+ className="switch"
+ role="switch"
+ aria-checked={folder?.on ?? false}
+ aria-label={label}
+ disabled={!folder || busy}
+ onClick={() => {
+ setOpenFailed(null);
+ if (folder) onSet(!folder.on);
+ }}
+ >
+ <span className="switch-knob" />
+ </button>
+ </div>
);
}
export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Promise<void> }) {
const [account, setAccount] = useState<AccountInfo | null>(null);
const [storage, setStorage] = useState<{ usedBytes: number; totalBytes: number } | null>(null);
+ const [local, setLocal] = useState<LocalStorage | null>(null);
+ const [clearing, setClearing] = useState(false);
+ const [freed, setFreed] = useState<number | null>(null);
const [alerts, setAlerts] = useState<{ reminderAlerts: boolean; eventAlerts: boolean } | null>(null);
+ const [alertsShown, setAlertsShown] = useState<boolean | null>(null);
const [theme, chooseTheme] = useState<Theme>(storedTheme);
const [version, setVersion] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
const [signingOut, setSigningOut] = useState<Unsent | null>(null);
- const [savedReport, setSavedReport] = useState<string | null>(null);
const [folder, setFolder] = useState<DriveFolder | null>(null);
const [folderBusy, setFolderBusy] = useState(false);
const [photosFolder, setPhotosFolder] = useState<DriveFolder | null>(null);
@@ -132,6 +209,8 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
api.accountInfo().then(setAccount, () => setAccount({ name: null, email: null }));
api.storageInfo().then(setStorage, () => {});
api.settingsGet().then(setAlerts, (e) => setError(messageOf(e)));
+ settingsApi.alertsShown().then(setAlertsShown, () => {});
+ settingsApi.localStorage().then(setLocal, () => {});
getVersion().then(setVersion, () => {});
api.driveFolderStatus().then(setFolder, () => {});
api.photosFolderStatus().then(setPhotosFolder, () => {});
@@ -160,12 +239,49 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
});
};
+ // A folder's switch moves at once; Apple's answer only matters when it could not come up,
+ // and then the reason is said on the folder's own row, where the eye already is.
+ const setFolderOn = (
+ current: DriveFolder,
+ on: boolean,
+ put: (f: DriveFolder) => void,
+ busy: (b: boolean) => void,
+ ask: (on: boolean) => Promise<DriveFolder>,
+ ) => {
+ put({ ...current, on, problem: null });
+ busy(true);
+ ask(on)
+ .then(put, (e) => put({ ...current, problem: messageOf(e) }))
+ .finally(() => busy(false));
+ };
+
+ const clearPictures = () => {
+ if (!local) return;
+ const before = local.total;
+ setClearing(true);
+ setFreed(null);
+ settingsApi
+ .localStorageClear()
+ .then(
+ (after) => {
+ setLocal(after);
+ setFreed(Math.max(0, before - after.total));
+ },
+ (e) => setError(messageOf(e)),
+ )
+ .finally(() => setClearing(false));
+ };
+
const used = storage && storage.totalBytes > 0 ? Math.min(1, storage.usedBytes / storage.totalBytes) : 0;
+ const services = (report?.services ?? []).filter((s) => s.outcome !== "unavailable");
+ const showDrive = folder?.available !== false;
+ const showPhotos = photosFolder?.available !== false;
+ const MB = 1024 ** 2;
return (
<div className="settings">
<h1 className="settings-title">Settings</h1>
- {error && <p className="settings-error" role="alert">{error}</p>}
+ {/* Held at the top of the window as it scrolls: a reason is never left out of sight. */}
<section className="settings-group settings-account" aria-label="Account">
<AccountAvatar account={account} large />
@@ -193,23 +309,23 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
/>
)}
- {account?.dataProtection != null && (
- <section className="settings-group settings-gap">
- <div className="settings-row">
- <span className="settings-label">Advanced Data Protection</span>
- <span className="settings-value">{account.dataProtection ? "On" : "Off"}</span>
- </div>
- </section>
- )}
-
- <h2 className="settings-heading">iCloud Storage</h2>
+ <h2 className="settings-heading">iCloud</h2>
<section className="settings-group">
<div className="settings-row is-stacked">
<div className="settings-row-line">
<span>{storage ? `${size(storage.usedBytes)} of ${size(storage.totalBytes)} used` : "Reading storage…"}</span>
- {storage && <span className="settings-value">{size(Math.max(0, storage.totalBytes - storage.usedBytes))} available</span>}
+ {storage && (
+ <span className="settings-value">{size(Math.max(0, storage.totalBytes - storage.usedBytes))} available</span>
+ )}
</div>
- <div className="storage-bar" role="meter" aria-label="iCloud storage used" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(used * 100)}>
+ <div
+ className="storage-bar"
+ role="meter"
+ aria-label="iCloud storage used"
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={Math.round(used * 100)}
+ >
<span style={{ width: `${used * 100}%` }} />
</div>
</div>
@@ -217,95 +333,116 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
<h2 className="settings-heading">Sync</h2>
<section className="settings-group">
- {(report?.services ?? []).filter((s) => s.outcome !== "unavailable").map((s) => (
+ {services.map((s) => (
<div className="settings-row" key={s.service}>
<AppIcon app={ICON[s.service] ?? s.service} />
<span className="settings-label">{s.label}</span>
<span className={`settings-value${s.outcome === "failed" ? " is-trouble" : ""}`}>
- {s.outcome === "failed" ? (s.detail ?? "Didn't update") : freshness(s.lastSyncedAt ?? null)}
+ {s.outcome === "failed"
+ ? (s.detail ?? "Didn't update")
+ : syncing && !s.lastSyncedAt
+ ? "Downloading…"
+ : freshness(s.lastSyncedAt ?? null)}
</span>
</div>
))}
<div className="settings-row">
- <span className="settings-label settings-hint">Changes made on your other devices arrive here within seconds.</span>
+ <span className="settings-label settings-hint">Changes from your other devices arrive within seconds.</span>
<button className="quiet" onClick={() => void refresh()} disabled={syncing}>
{syncing ? "Syncing…" : "Sync Now"}
</button>
</div>
</section>
- <h2 className="settings-heading">On This Computer</h2>
- <section className="settings-group">
+ {(showDrive || showPhotos) && (
+ <>
+ <h2 className="settings-heading">Folders</h2>
+ <section className="settings-group">
+ {showDrive && (
+ <FolderRow
+ app="drivews"
+ label="iCloud Drive folder"
+ off="Your iCloud Drive in Files and every other app"
+ folder={folder}
+ busy={folderBusy}
+ line={folderState}
+ onOpen={api.driveFolderOpen}
+ onSet={(on) => folder && setFolderOn(folder, on, setFolder, setFolderBusy, api.driveFolderSet)}
+ />
+ )}
+ {showPhotos && (
+ <FolderRow
+ app="photos"
+ label="iCloud Photos folder"
+ off="Your photos by date and album, for every other app"
+ folder={photosFolder}
+ busy={photosBusy}
+ line={(f) => f.path}
+ onOpen={api.photosFolderOpen}
+ onSet={(on) =>
+ photosFolder && setFolderOn(photosFolder, on, setPhotosFolder, setPhotosBusy, api.photosFolderSet)
+ }
+ />
+ )}
+ </section>
+ </>
+ )}
+
+ <h2 className="settings-heading settings-heading-line">
+ <span>Storage on This Computer</span>
+ {local && <span className="settings-heading-value">{size(local.total)}</span>}
+ </h2>
+ <section className="settings-group" aria-busy={!local}>
+ {(
+ [
+ ["photos", "Photos", local?.photos],
+ ["notes", "Notes", local?.notes],
+ ["drivews", "iCloud Drive", local?.drive],
+ ["library", "Library", local?.library],
+ ["other", "Other", local?.other],
+ ] as const
+ )
+ .filter(([key, , bytes]) => key !== "other" || (bytes ?? 0) >= MB)
+ .map(([key, label, bytes]) => (
+ <div className="settings-row" key={key}>
+ {key === "library" || key === "other" ? <Glyph kind={key} /> : <AppIcon app={key} />}
+ <span className="settings-label">{label}</span>
+ <span className="settings-value">{bytes == null ? "…" : size(bytes)}</span>
+ </div>
+ ))}
<div className="settings-row">
- <AppIcon app="drivews" />
<span className="settings-label settings-stack">
- iCloud Drive folder
- {/* Where it is, and — when it could not come up — why, in a sentence. */}
- <span className={`settings-hint${folder?.problem || folder?.waiting?.failure ? " is-trouble" : ""}`}>
- {folder?.problem ?? (folder?.on ? folderState(folder) : "Your iCloud Drive in Files and every other app")}
+ Cached pictures
+ <span className="settings-hint" aria-live="polite">
+ {freed != null ? `${size(freed)} cleared. They download again when needed.` : "They download again when needed."}
</span>
</span>
- {folder?.on && (
- <button className="quiet" onClick={() => api.driveFolderOpen().catch((e) => setError(messageOf(e)))}>
- Open
- </button>
- )}
- <button
- className="switch"
- role="switch"
- aria-checked={folder?.on ?? false}
- aria-label="iCloud Drive folder"
- disabled={!folder || folderBusy}
- onClick={() => {
- if (!folder) return;
- const on = !folder.on;
- // Moves at once; Apple's answer only matters when the folder could not come up.
- setFolder({ ...folder, on, problem: null });
- setFolderBusy(true);
- api
- .driveFolderSet(on)
- .then(setFolder, (e) => {
- setFolder({ ...folder, problem: messageOf(e) });
- })
- .finally(() => setFolderBusy(false));
- }}
- >
- <span className="switch-knob" />
+ {local && local.clearable >= MB && <span className="settings-value">{size(local.clearable)}</span>}
+ <button className="quiet" onClick={clearPictures} disabled={!local || clearing || local.clearable < MB}>
+ {clearing ? "Clearing…" : "Clear"}
</button>
</div>
+ </section>
+
+ <h2 className="settings-heading">General</h2>
+ <section className="settings-group">
<div className="settings-row">
- <AppIcon app="photos" />
- <span className="settings-label settings-stack">
- iCloud Photos folder
- <span className={`settings-hint${photosFolder?.problem ? " is-trouble" : ""}`}>
- {photosFolder?.problem ??
- (photosFolder?.on ? photosFolder.path : "Your photos by date and album, for every other app")}
- </span>
- </span>
- {photosFolder?.on && (
- <button className="quiet" onClick={() => api.photosFolderOpen().catch((e) => setError(messageOf(e)))}>
- Open
- </button>
- )}
- <button
- className="switch"
- role="switch"
- aria-checked={photosFolder?.on ?? false}
- aria-label="iCloud Photos folder"
- disabled={!photosFolder || photosBusy}
- onClick={() => {
- if (!photosFolder) return;
- const on = !photosFolder.on;
- setPhotosFolder({ ...photosFolder, on, problem: null });
- setPhotosBusy(true);
- api
- .photosFolderSet(on)
- .then(setPhotosFolder, (e) => setPhotosFolder({ ...photosFolder, problem: messageOf(e) }))
- .finally(() => setPhotosBusy(false));
- }}
- >
- <span className="switch-knob" />
- </button>
+ <span className="settings-label">Appearance</span>
+ <div className="segmented" role="group" aria-label="Appearance">
+ {(["auto", "light", "dark"] as const).map((t) => (
+ <button
+ key={t}
+ className="segment"
+ aria-pressed={theme === t}
+ onClick={() => {
+ chooseTheme(t);
+ setTheme(t);
+ }}
+ >
+ {t === "auto" ? "Automatic" : t === "light" ? "Light" : "Dark"}
+ </button>
+ ))}
+ </div>
</div>
<div className="settings-row">
<span className="settings-label settings-stack">
@@ -313,7 +450,7 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
<span className="settings-hint">
{login?.on && !login.honoured
? "This desktop doesn't open apps at login by itself. Add this to its startup:"
- : "Starts in the background, so reminders ring and changes sync without the window"}
+ : "Starts in the background, so alerts ring and changes sync"}
</span>
{login?.on && !login.honoured && <code className="settings-command">{login.command}</code>}
</span>
@@ -342,34 +479,14 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
</div>
</section>
- <h2 className="settings-heading">Appearance</h2>
- <section className="settings-group">
- <div className="settings-row">
- <span className="settings-label">Appearance</span>
- <div className="segmented" role="group" aria-label="Appearance">
- {(["auto", "light", "dark"] as const).map((t) => (
- <button
- key={t}
- className="segment"
- aria-pressed={theme === t}
- onClick={() => {
- chooseTheme(t);
- setTheme(t);
- }}
- >
- {t === "auto" ? "Automatic" : t === "light" ? "Light" : "Dark"}
- </button>
- ))}
- </div>
- </div>
- </section>
-
<h2 className="settings-heading">Notifications</h2>
<section className="settings-group">
- {([
- ["reminderAlerts", "Reminder alerts", "reminders"],
- ["eventAlerts", "Calendar alerts", "calendar"],
- ] as const).map(([key, label, icon]) => (
+ {(
+ [
+ ["reminderAlerts", "Reminder alerts", "reminders"],
+ ["eventAlerts", "Calendar alerts", "calendar"],
+ ] as const
+ ).map(([key, label, icon]) => (
<div className="settings-row" key={key}>
<AppIcon app={icon} />
<span className="settings-label">{label}</span>
@@ -385,6 +502,14 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
</button>
</div>
))}
+ {/* Asked of the desktop itself: without a notification service every alert is dropped. */}
+ {alertsShown === false && (
+ <div className="settings-row">
+ <span className="settings-label settings-hint is-trouble">
+ Alerts can't appear: this desktop has no notification service running.
+ </span>
+ </div>
+ )}
</section>
<h2 className="settings-heading">About</h2>
@@ -394,24 +519,25 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom
<span className="settings-value">{version ?? "—"}</span>
</div>
<div className="settings-row">
- <span className="settings-label settings-hint">
- Your iCloud is kept on this computer and talks only to Apple. Pomander has no servers.
- </span>
- </div>
- <div className="settings-row">
- <span className="settings-label settings-hint">
- {savedReport
- ? `Saved to ${savedReport.split("/").slice(-2).join("/")} — versions and sync states only, no names or contents. Attach it to a bug report.`
- : "A plain report of how Pomander is doing, for a bug report. Nothing is sent anywhere."}
+ <span className="settings-label settings-stack">
+ Diagnostic Report
+ <span className="settings-hint settings-hint-wrap">Versions and sync states only. Nothing is sent.</span>
</span>
<button
className="quiet"
- onClick={() => api.diagnosticsSave().then(setSavedReport, (e) => setError(messageOf(e)))}
+ aria-label="Save Diagnostic Report"
+ onClick={() =>
+ api.diagnosticsSave().then(
+ (path) => void toastSaved(path),
+ (e) => setError(messageOf(e)),
+ )
+ }
>
- Save Diagnostic Report
+ Save
</button>
</div>
</section>
+ <p className="settings-note">Pomander talks only to Apple. It has no servers of its own.</p>
</div>
);
}
diff --git a/src/screens/SignIn.tsx b/src/screens/SignIn.tsx
index da0b370..c2d9813 100644
--- a/src/screens/SignIn.tsx
+++ b/src/screens/SignIn.tsx
@@ -1,14 +1,53 @@
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { Mark } from "../components/Mark";
+import { Spinner } from "../components/Spinner";
+import { StatusLine } from "../components/StatusLine";
import { api, messageOf, type SignInResult } from "../lib/ipc";
+import { onWindows } from "../lib/platform";
-export function SignIn({ onResult }: { onResult: (r: SignInResult) => void }) {
+// Where the copy is kept, as this system names it.
+const STORE = onWindows ? "%APPDATA%\\io.github.yashwanthkamireddi.Pomander" : "~/.local/share/io.github.yashwanthkamireddi.Pomander";
+
+/**
+ * An error as a sentence: some of the engine's messages start in lower case and end without
+ * a stop ("couldn't reach Apple: check your connection"), which reads as a log line.
+ */
+export function sentence(message: string) {
+ const s = message.trim();
+ if (!s) return "Something went wrong. Try again.";
+ const capped = s[0].toUpperCase() + s.slice(1);
+ return /[.!?]$/.test(capped) ? capped : `${capped}.`;
+}
+
+export function SignIn({
+ onResult,
+ onCancel,
+}: {
+ onResult: (r: SignInResult) => void;
+ /** Back to the library: offered when signing in again after Apple signed the session out. */
+ onCancel?: () => void;
+}) {
const [appleId, setAppleId] = useState("");
const [password, setPassword] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
+ const passwordRef = useRef<HTMLInputElement>(null);
+ // A wait Apple's limits ask for, counted down where it is said, and the button held until
+ // it is over — not a number frozen at the moment it was said.
+ const [wait, setWait] = useState(0);
+ useEffect(() => {
+ if (wait <= 0) return;
+ const t = setTimeout(() => setWait((w) => w - 1), 1000);
+ return () => clearTimeout(t);
+ }, [wait]);
+
+ const ready = appleId.trim().length > 0 && password.length > 0 && !busy && wait <= 0;
- const ready = appleId.trim().length > 0 && password.length > 0 && !busy;
+ // Back to the password once a try has come back, so the next one is a type and an Enter.
+ // After the fields are enabled again: a disabled field cannot take focus.
+ useEffect(() => {
+ if (!busy && error) passwordRef.current?.focus();
+ }, [busy, error]);
async function submit(e: React.FormEvent) {
e.preventDefault();
@@ -18,54 +57,94 @@ export function SignIn({ onResult }: { onResult: (r: SignInResult) => void }) {
try {
onResult(await api.signIn(appleId.trim(), password));
} catch (err) {
- setError(messageOf(err));
+ const message = messageOf(err);
+ const seconds = /Try again in (\d+) seconds/.exec(message);
+ if (seconds) {
+ setWait(Number(seconds[1]));
+ setError(null);
+ } else {
+ // Apple's refusal names no field, so neither can this; it can say what to do.
+ setError(
+ /Apple ID or password/.test(message)
+ ? "Apple ID or password is incorrect. Check both and try again."
+ : sentence(message),
+ );
+ }
} finally {
setPassword("");
setBusy(false);
}
}
+ function edit(set: (v: string) => void) {
+ return (e: React.ChangeEvent<HTMLInputElement>) => {
+ set(e.target.value);
+ if (error) setError(null);
+ };
+ }
+
return (
- <form className="sheet enter-sheet" onSubmit={submit}>
+ <form className="sheet enter-sheet" onSubmit={submit} aria-busy={busy} noValidate>
<Mark className="mark" />
<h1>Sign in with your Apple ID</h1>
- <p className="lede">
- Pomander keeps your iCloud on this computer, so it opens instantly and works offline.
- </p>
+ <p className="lede">Your iCloud, kept on this computer.</p>
- <div className="field-group">
+ <div className={`field-group${error ? " is-invalid" : ""}`}>
<input
value={appleId}
- onChange={(e) => setAppleId(e.target.value)}
+ onChange={edit(setAppleId)}
+ // Enter on the Apple ID with no password yet goes on to the password, as a Mac
+ // sheet does; with both filled it signs in.
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !password) {
+ e.preventDefault();
+ if (appleId.trim()) passwordRef.current?.focus();
+ }
+ }}
type="email"
autoComplete="username"
+ autoCapitalize="off"
+ spellCheck={false}
placeholder="Apple ID"
aria-label="Apple ID"
+ aria-invalid={!!error}
autoFocus
disabled={busy}
/>
<input
+ ref={passwordRef}
value={password}
- onChange={(e) => setPassword(e.target.value)}
+ onChange={edit(setPassword)}
type="password"
autoComplete="current-password"
placeholder="Password"
aria-label="Password"
+ aria-invalid={!!error}
+ aria-describedby={error ? "signin-error" : undefined}
disabled={busy}
/>
</div>
- <button className="primary" type="submit" disabled={!ready}>
- {busy ? "Signing in…" : "Sign in"}
+ <button className="primary" type="submit" disabled={!ready} aria-disabled={!ready}>
+ {busy && <Spinner small />}
+ <span>{busy ? "Signing in" : wait > 0 ? `Try again in ${wait}s` : "Sign in"}</span>
</button>
+ {onCancel && (
+ <button type="button" className="quiet" onClick={onCancel}>
+ Not Now
+ </button>
+ )}
- {error && <p className="error" role="alert">{error}</p>}
+ {/* One slot under the button, its height kept: an error takes the assurance's place
+ rather than pushing the screen about. */}
+ <div className="sheet-status">
+ {error ? (
+ <StatusLine tone="error" id="signin-error">{error}</StatusLine>
+ ) : (
+ <p className="assurance">Your password never leaves this computer.</p>
+ )}
+ </div>
- <p className="assurance">
- Your password never leaves this computer. Pomander proves you know it without sending
- it, and keeps it in your system keyring so it can sign itself back in. Signing out
- erases it.
- </p>
{/*
* What somebody is owed before they type an Apple ID into software a stranger wrote.
*
@@ -74,29 +153,26 @@ export function SignIn({ onResult }: { onResult: (r: SignInResult) => void }) {
* the rest a click away for anyone who wants it.
*/}
<details className="disclosure">
- <summary>An independent project. Not affiliated with Apple.</summary>
+ <summary>How Pomander keeps you private</summary>
<div className="disclosure-body">
<p>
- <strong>Unofficial.</strong> Pomander reaches iCloud through interfaces Apple has
- not published. Apple can change them without notice, and when that happens
- something here will stop working until it is put right.
+ <strong>Private by design.</strong> Your password never leaves this computer.
+ Pomander proves you know it without sending it, and keeps your session in your
+ system keyring. No Pomander account, no Pomander servers: it talks only to Apple.
</p>
<p>
- <strong>Your password never leaves this computer.</strong> Pomander proves you know
- it without sending it, and keeps the result in your system keyring. There is no
- Pomander account and no Pomander server — there is nowhere else for any of this to go.
+ <strong>Your iCloud, right here.</strong> Your calendar, reminders, notes, contacts
+ and Drive live on this computer in <code>{STORE}</code>, so everything opens
+ instantly and works offline.
</p>
<p>
- <strong>What it keeps, and where.</strong> A copy of your calendar, reminders,
- notes, contacts and the listing of your Drive, in a database under{" "}
- <code>~/.local/share/dev.quince.client</code>. Signing out removes the session;
- deleting that folder removes the copy.
+ <strong>Sealed by Apple.</strong> Health, Messages, Keychain and your other
+ end-to-end encrypted data stay protected on your Apple devices, just as Apple
+ designed.
</p>
<p>
- <strong>What no client can read.</strong> Health, Messages, Keychain, Home, Safari
- history and Screen Time are encrypted end to end — Apple's own servers hold no key
- to them, so no app can show them. Pomander says they are unavailable rather than
- quietly leaving them out.
+ <strong>Independent.</strong> Made by an independent developer, not affiliated with
+ Apple, and kept in step as iCloud evolves.
</p>
</div>
</details>
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 64eab73..1b0e470 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -1,10 +1,13 @@
-import { Notice } from "../../components/Notice";
+import { toast, dismissToast, useErrorToast } from "../../components/Toast";
+import { ConfirmSheet, useConfirm } from "../../components/Confirm";
+import { EmptyState } from "../../components/EmptyState";
+import { SearchField } from "../../components/SearchField";
import { useActiveRef } from "../../lib/screen";
import { usePending } from "../../lib/pending";
import { inMenu, Portal } from "../../components/Portal";
import { TimeField } from "../../components/TimeField";
-import { Search } from "lucide-react";
-import { createContext, Fragment, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { ChevronLeft, ChevronRight, Plus } from "lucide-react";
+import { createContext, Fragment, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import {
type EventRepeat,
api,
@@ -23,9 +26,11 @@ import {
clock,
dateOf,
dayKey,
+ daysOf,
hourLabel,
instantIn,
midnight,
+ isWeekend,
monthDays,
placeDayWith,
sameClockIn,
@@ -97,6 +102,9 @@ const VIEWS = [
] as const;
type View = (typeof VIEWS)[number]["key"];
+/** A day with nothing in it, the same empty list every time. */
+const NOTHING: never[] = [];
+
/** One hour of the Day and Week grids. */
const HOUR = 48;
/** A bar in the all-day row, and the gap under it. */
@@ -222,14 +230,14 @@ export function CalendarView() {
return "month";
}
});
- const setView = (v: View) => {
+ const setView = useCallback((v: View) => {
setViewState(v);
try {
window.localStorage.setItem(VIEW_KEY, v);
} catch {
// Remembering the view is a convenience.
}
- };
+ }, []);
/** A found event: its day, in Day view, and the search put away. */
const openFound = (e: CalendarEvent) => {
setSelected(midnight(dateOf(e.startsAt)));
@@ -290,6 +298,8 @@ export function CalendarView() {
});
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
+ useErrorToast(error, () => setError(null));
+ const [confirm, confirmSheet] = useConfirm();
const [draft, setDraft] = useState<Draft | null>(null);
const draftRef = useRef<Draft | null>(null);
draftRef.current = draft;
@@ -307,7 +317,21 @@ export function CalendarView() {
timer = window.setTimeout(tick, 60_000 - (Date.now() % 60_000));
};
timer = window.setTimeout(tick, 60_000 - (Date.now() % 60_000));
- return () => window.clearTimeout(timer);
+ // A timer sleeps with the machine: woken after midnight, today stayed yesterday — the red
+ // circle and the line for now in the wrong place — until the minute came round. Coming
+ // back to the window reads the clock again.
+ const wake = () => {
+ if (document.visibilityState === "hidden") return;
+ window.clearTimeout(timer);
+ tick();
+ };
+ document.addEventListener("visibilitychange", wake);
+ window.addEventListener("focus", wake);
+ return () => {
+ window.clearTimeout(timer);
+ document.removeEventListener("visibilitychange", wake);
+ window.removeEventListener("focus", wake);
+ };
}, []);
const week = useMemo(() => {
@@ -462,9 +486,17 @@ export function CalendarView() {
};
const deleteCalendar = (c: Calendar) => {
// icloud.com's own warning: the events go with it, on every device.
- if (!window.confirm(`Delete \u201c${c.title}\u201d?\n\nAll events in this calendar will be deleted from every device.`)) return;
- setCalendars((cs) => cs.filter((x) => x.guid !== c.guid));
- void write(async () => { await api.calendarDelete(c.guid); });
+ void confirm({
+ title: `Delete \u201c${c.title}\u201d?`,
+ body: "All events in this calendar will be deleted from every device.",
+ action: "Delete",
+ danger: true,
+ symbol: "trash",
+ }).then((sure) => {
+ if (!sure) return;
+ setCalendars((cs) => cs.filter((x) => x.guid !== c.guid));
+ void write(async () => { await api.calendarDelete(c.guid); });
+ });
};
/**
@@ -584,17 +616,50 @@ export function CalendarView() {
// Made again as it was, its alerts with it (its guests are not this app's to invite).
if (gone) await save({ ...draftOf(gone), guid: null, alerts: gone.alerts, alertsChanged: gone.alerts.length > 0 });
}, [undo, save]);
+ const moveEvent = useCallback(
+ (e: CalendarEvent, startsAt: number, endsAt: number) => void save({ ...draftOf(e), startsAt, endsAt }),
+ [save]
+ );
+ /**
+ * The popover put away by a click elsewhere keeps what was written in it, as Calendar's
+ * does — a title typed and then a click on the next day had thrown the title away. Escape
+ * and Cancel still leave the event as it was, and a new event nothing was written into is
+ * not made.
+ */
+ const dismiss = useCallback(() => {
+ const d = draftRef.current;
+ const was = openedAs.current;
+ const changed = Boolean(d && was && (
+ d.title !== was.title || d.location !== was.location || d.notes !== was.notes ||
+ (d.url ?? "") !== (was.url ?? "") || d.calendarGuid !== was.calendarGuid ||
+ d.timezone !== was.timezone || d.allDay !== was.allDay ||
+ d.alertsChanged || d.repeatChanged ||
+ // A new event's times are where it was made; only an existing one's are a change.
+ (d.guid !== null && (d.startsAt !== was.startsAt || d.endsAt !== was.endsAt))
+ ));
+ if (d && changed) void save(d, true);
+ else setDraft(null);
+ }, [save]);
+ // Deleted, said in a toast with Undo for as long as Undo can put it back.
useEffect(() => {
if (!undo) return undefined;
+ const id = toast({ message: `Deleted \u201c${undo.title}\u201d`, action: { label: "Undo", run: () => void takeBack() }, duration: 8000 });
const timer = window.setTimeout(() => setUndo(null), 8000);
- return () => window.clearTimeout(timer);
- }, [undo]);
+ return () => {
+ window.clearTimeout(timer);
+ dismissToast(id);
+ };
+ }, [undo, takeBack]);
- const openDraft = (d: Draft, at: Anchor) => {
+ /** The draft as it was opened, to tell whether anything in it has been changed since. */
+ const openedAs = useRef<Draft | null>(null);
+ const openDraft = useCallback((d: Draft, at: Anchor) => {
// The event already open stays as it is: a second click — a double-click — closed it and
// opened it again, and the popover flickered.
if (d.guid && draftRef.current?.guid === d.guid) return;
- setDraft(d.guid ? d : { ...d, alerts: [], repeat: null });
+ const opened = d.guid ? d : { ...d, alerts: [], repeat: null };
+ openedAs.current = opened;
+ setDraft(opened);
setAnchor(at);
const guid = d.guid;
if (guid && !guid.startsWith("quince:")) {
@@ -607,7 +672,7 @@ export function CalendarView() {
() => {},
);
}
- };
+ }, []);
// Opened once it is drawn: its day and calendar may take a render or two to come up. One
// that never shows (gone since it was found) is let go of rather than opened later.
useLayoutEffect(() => {
@@ -625,13 +690,39 @@ export function CalendarView() {
const t = window.setTimeout(() => setFinding(null), 3000);
return () => window.clearTimeout(t);
}, [finding]);
- const newAt = (startsAt: number, endsAt: number, allDay: boolean, at: Anchor) => {
- if (!target) return;
+ const targetGuid = target?.guid ?? null;
+ const newAt = useCallback((startsAt: number, endsAt: number, allDay: boolean, at: Anchor) => {
+ if (!targetGuid) return;
openDraft(
- { guid: null, calendarGuid: target.guid, title: "", location: "", startsAt, endsAt, allDay, notes: "", url: null, timezone: null },
+ { guid: null, calendarGuid: targetGuid, title: "", location: "", startsAt, endsAt, allDay, notes: "", url: null, timezone: null },
at
);
- };
+ }, [targetGuid, openDraft]);
+
+ /*
+ * What the views are handed, kept the same from one draw to the next so a view whose own
+ * inputs have not changed is not drawn again — not the week for every key typed in the
+ * popover, not the year for every minute the clock moves on.
+ */
+ const openEvent = useCallback((e: CalendarEvent, at: Anchor) => openDraft(draftOf(e), at), [openDraft]);
+ const createInMonth = useCallback((day: Date, at: Anchor) => {
+ const start = new Date(day);
+ start.setHours(9, 0, 0, 0);
+ newAt(seconds(start), seconds(start) + 3600, false, at);
+ }, [newAt]);
+ const showDay = useCallback((day: Date) => {
+ setSelected(day);
+ setView("day");
+ }, [setView]);
+ const canWrite = useCallback((guid: string) => byGuid.get(guid)?.writable ?? false, [byGuid]);
+ const gridDays = useMemo(() => (view === "week" ? week : [selected]), [view, week, selected]);
+ const pendingFrom = draft && !draft.guid && !draft.allDay ? draft.startsAt : null;
+ const pendingTo = draft && !draft.guid && !draft.allDay ? draft.endsAt : null;
+ const pendingTitle = draft && !draft.guid && !draft.allDay ? draft.title : "";
+ const pending = useMemo(
+ () => (pendingFrom === null || pendingTo === null ? null : { startsAt: pendingFrom, endsAt: pendingTo, title: pendingTitle }),
+ [pendingFrom, pendingTo, pendingTitle]
+ );
/** "New event": the next whole hour on the selected day, for an hour — Apple's default. */
const newEvent = (e?: React.MouseEvent) => {
@@ -694,8 +785,13 @@ export function CalendarView() {
setGoingTo(true);
return;
}
- if (command && e.key === "ArrowLeft") shift(-1);
- else if (command && e.key === "ArrowRight") shift(1);
+ // ⌘← and ⌘→ page, and so do the bare arrows wherever they have nothing else to do — a
+ // focused day in Month moves its selection with them instead, and has said so already.
+ const bare = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented &&
+ !(e.target as HTMLElement | null)?.closest?.('[role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"]') &&
+ !document.querySelector('[role="menu"]');
+ if ((command || bare) && e.key === "ArrowLeft") shift(-1);
+ else if ((command || bare) && e.key === "ArrowRight") shift(1);
// ⌘T, and the bare T this screen always had.
else if (k === "t" && !e.altKey && !e.shiftKey) setSelected(midnight(new Date()));
// ⌘1–⌘4: Day, Week, Month, Year, in the order the switch shows them.
@@ -743,32 +839,40 @@ export function CalendarView() {
};
}, [view, selected, week]);
- /** A day's reminders and timed events for a month cell, in time order. */
- const dayItems = useCallback(
- (day: Date) => {
- const start = seconds(day);
- const end = seconds(addDays(day, 1));
- const timed = shown
- .filter((e) => !spansDays(e) && e.startsAt < end && e.endsAt > start)
- .map((event) => ({ kind: "event" as const, at: Math.max(event.startsAt, start), event }));
- const reminders = due
- .filter((r) => r.dueAt !== null && r.dueAt >= start && r.dueAt < end)
- .map((reminder) => ({ kind: "reminder" as const, at: reminder.dueAt ?? 0, reminder }));
- return [...timed, ...reminders].sort((a, b) => a.at - b.at);
- },
- [shown, due]
- );
- /** Whether a day has anything at all — all-day events too, which Month draws as bars and
- * `dayItems` therefore leaves out. The dots in the mini month and Year use this; with
- * `dayItems` a birthday, a holiday or a trip left its days looking empty. */
- const busyOn = useCallback(
- (day: Date) => {
- const start = seconds(day);
- const end = seconds(addDays(day, 1));
- return shown.some((e) => e.startsAt < end && e.endsAt > start) || dayItems(day).length > 0;
- },
- [shown, dayItems]
- );
+ /**
+ * Every day's items, worked out once for what is shown: a month cell's reminders and timed
+ * events in time order, and which days have anything at all — all-day events too, which
+ * Month draws as bars and so leaves out of a cell's list. The dots in the mini month and Year
+ * read this; with the cell's list a birthday, a holiday or a trip left its days looking empty.
+ * Asked of the whole list once per day, Year did it 365 times on every draw.
+ */
+ const byDay = useMemo(() => {
+ const items = new Map<string, Item[]>();
+ const busy = new Set<string>();
+ const put = (d: Date, item: Item | null) => {
+ const key = dayKey(d);
+ busy.add(key);
+ if (!item) return;
+ const list = items.get(key);
+ if (list) list.push(item);
+ else items.set(key, [item]);
+ };
+ for (const event of shown) {
+ const [first, last] = daysOf(event);
+ const timed = !spansDays(event);
+ // A year at most: a feed's "forever" event is not walked day by day.
+ for (let d = first, n = 0; d <= last && n < 366; d = addDays(d, 1), n++) {
+ put(d, timed ? { kind: "event", at: Math.max(event.startsAt, seconds(d)), event } : null);
+ }
+ }
+ for (const reminder of due) {
+ if (reminder.dueAt !== null) put(midnight(dateOf(reminder.dueAt)), { kind: "reminder", at: reminder.dueAt, reminder });
+ }
+ for (const list of items.values()) list.sort((a, b) => a.at - b.at);
+ return { items, busy };
+ }, [shown, due]);
+ const dayItems = useCallback((day: Date) => byDay.items.get(dayKey(day)) ?? NOTHING, [byDay]);
+ const busyOn = useCallback((day: Date) => byDay.busy.has(dayKey(day)), [byDay]);
return (
<TickContext.Provider value={tickValue}>
@@ -782,11 +886,11 @@ export function CalendarView() {
.filter((g) => g.list.length > 0)
.map((group) => (
<Fragment key={group.heading}>
- <p className="cx-side-heading">
+ <p className="side-heading cx-side-heading">
{group.heading}
{group.heading === "iCloud" && (
- <button className="cx-side-add" aria-label="New Calendar" title="New Calendar" onClick={() => setNaming("new")}>
- +
+ <button className="icon-button small cx-side-add" aria-label="New Calendar" title="New Calendar" onClick={() => setNaming("new")}>
+ <Plus size={14} strokeWidth={2.2} aria-hidden="true" />
</button>
)}
</p>
@@ -795,7 +899,7 @@ export function CalendarView() {
<CalendarName key={c.guid} initial={c.title} label={`Rename ${c.title}`} onDone={(t) => updateCalendar(c, { title: t })} onCancel={() => setNaming(null)} />
) : (
<label
- className="cx-cal"
+ className="source-row cx-cal"
key={c.guid}
onContextMenu={(e) => {
// A calendar of this account can be renamed, recoloured or removed, as on icloud.com.
@@ -815,7 +919,7 @@ export function CalendarView() {
onChange={() => toggleCalendar(c.guid)}
style={{ "--cal": tint(c) } as React.CSSProperties}
/>
- <span className="cx-cal-name">{c.title}</span>
+ <span className="source-name cx-cal-name">{c.title}</span>
</label>
),
)}
@@ -825,14 +929,14 @@ export function CalendarView() {
</Fragment>
))}
{loaded && calendars.length === 0 && (
- <p className="cal-empty">There are no calendars on this account yet.</p>
+ <EmptyState className="cal-empty">There are no calendars on this account yet.</EmptyState>
)}
</div>
<MiniMonth
selected={selected}
today={now}
busy={busyOn}
- onPick={(d) => setSelected(d)}
+ onPick={setSelected}
/>
</aside>
@@ -846,7 +950,7 @@ export function CalendarView() {
{title.brief}
</strong>
</h1>
- <div className="segmented" role="group" aria-label="View">
+ <div className="segmented toolbar-group" role="group" aria-label="View">
{VIEWS.map((v) => (
<button
key={v.key}
@@ -860,20 +964,22 @@ export function CalendarView() {
</div>
<div className="cx-tools">
{writable.length > 0 && (
- <button className="cx-icon" aria-label="New event" title="New Event" onClick={newEvent}>
- +
- </button>
+ <span className="toolbar-group">
+ <button className="tool cx-icon" aria-label="New event" title="New Event" onClick={newEvent}>
+ <Plus size={17} strokeWidth={2} aria-hidden="true" />
+ </button>
+ </span>
)}
- <span className="cx-step">
- <button className="cx-icon" aria-label="Previous" onClick={() => shift(-1)}>
- ‹
+ <span className="toolbar-group cx-step">
+ <button className="tool cx-icon" aria-label="Previous" onClick={() => shift(-1)}>
+ <ChevronLeft size={17} strokeWidth={2} aria-hidden="true" />
</button>
- <button className="cx-today" title="Today · Shift-Ctrl-T to go to a date" onClick={() => setSelected(midnight(new Date()))}>
+ <button className="tool has-label cx-today" title="Today · Shift-Ctrl-T to go to a date" onClick={() => setSelected(midnight(new Date()))}>
Today
</button>
{goingTo && (
<form
- className="cx-goto"
+ className="popover cx-goto"
role="dialog"
aria-label="Go to Date"
onSubmit={(e) => {
@@ -891,39 +997,38 @@ export function CalendarView() {
}}
>
<input
+ className="field"
name="day"
type="date"
aria-label="Date"
autoFocus
defaultValue={`${selected.getFullYear()}-${String(selected.getMonth() + 1).padStart(2, "0")}-${String(selected.getDate()).padStart(2, "0")}`}
/>
- <button type="submit">Go</button>
+ <button type="submit" className="primary">Go</button>
</form>
)}
- <button className="cx-icon" aria-label="Next" onClick={() => shift(1)}>
- ›
+ <button className="tool cx-icon" aria-label="Next" onClick={() => shift(1)}>
+ <ChevronRight size={17} strokeWidth={2} aria-hidden="true" />
</button>
</span>
- <label className="cx-search">
- <Search size={13} strokeWidth={2.25} aria-hidden="true" />
- <input
- ref={searchField}
- type="search"
- placeholder="Search"
- aria-label="Search events"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Escape") setQuery("");
- if (e.key === "Enter" && found[0]) openFound(found[0]);
- }}
- />
- </label>
+ <SearchField
+ ref={searchField}
+ inToolbar
+ className="cx-search"
+ placeholder="Search"
+ aria-label="Search events"
+ value={query}
+ onChange={setQuery}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") setQuery("");
+ if (e.key === "Enter" && found[0]) openFound(found[0]);
+ }}
+ />
</div>
</header>
{query.trim() && (
- <div className="cx-found" role="listbox" aria-label="Events found">
+ <div className="popover cx-found" role="listbox" aria-label="Events found">
{found.length === 0 ? (
<p className="cx-found-none">No events match “{query.trim()}”.</p>
) : (
@@ -948,9 +1053,6 @@ export function CalendarView() {
</div>
)}
- {error && (
- <Notice message={error} onDismiss={() => setError(null)} />
- )}
{calMenu && (
<RowMenu
at={calMenu.at}
@@ -962,7 +1064,7 @@ export function CalendarView() {
submenu: CALENDAR_COLOURS.map(([hex, name]) => ({ label: name, run: () => updateCalendar(calMenu.cal, { colour: hex }) })),
},
null,
- ...(calMenu.cal.isDefault ? [] : [{ label: "Delete Calendar\u2026", danger: true, run: () => deleteCalendar(calMenu.cal) }]),
+ ...(calMenu.cal.isDefault ? [] : [{ label: "Delete Calendar", danger: true, run: () => deleteCalendar(calMenu.cal) }]),
]}
/>
)}
@@ -976,40 +1078,26 @@ export function CalendarView() {
calendars={byGuid}
items={dayItems}
onSelect={setSelected}
- onOpen={(e, at) => openDraft(draftOf(e), at)}
- onCreate={(day, at) => {
- const start = new Date(day);
- start.setHours(9, 0, 0, 0);
- newAt(seconds(start), seconds(start) + 3600, false, at);
- }}
- onMore={(day) => {
- setSelected(day);
- setView("day");
- }}
+ onOpen={openEvent}
+ onCreate={createInMonth}
+ onMore={showDay}
/>
)}
{(view === "week" || view === "day") && (
<div className={view === "day" ? "cx-dayview" : "cx-weekview"}>
<TimeGrid
- days={view === "week" ? week : [selected]}
+ days={gridDays}
today={now}
events={shown}
reminders={due}
calendars={byGuid}
- canWrite={(guid) => byGuid.get(guid)?.writable ?? false}
- onOpen={(e, at) => openDraft(draftOf(e), at)}
- onCreate={(startsAt, endsAt, allDay, at) => newAt(startsAt, endsAt, allDay, at)}
- onMove={(e, startsAt, endsAt) => void save({ ...draftOf(e), startsAt, endsAt })}
- onPickDay={(d) => {
- setSelected(d);
- setView("day");
- }}
- pending={
- draft && !draft.guid && !draft.allDay
- ? { startsAt: draft.startsAt, endsAt: draft.endsAt, title: draft.title }
- : null
- }
+ canWrite={canWrite}
+ onOpen={openEvent}
+ onCreate={newAt}
+ onMove={moveEvent}
+ onPickDay={showDay}
+ pending={pending}
/>
{view === "day" && (
<DayPane
@@ -1017,14 +1105,14 @@ export function CalendarView() {
events={shown}
reminders={due}
calendars={byGuid}
- onOpen={(e, at) => openDraft(draftOf(e), at)}
+ onOpen={openEvent}
>
{/* As macOS 27's Day view sets it: the month above the day, to step across it. */}
<MiniMonth
selected={selected}
today={now}
busy={busyOn}
- onPick={(d) => setSelected(d)}
+ onPick={setSelected}
/>
</DayPane>
)}
@@ -1036,10 +1124,7 @@ export function CalendarView() {
year={selected.getFullYear()}
today={now}
busy={busyOn}
- onPick={(d) => {
- setSelected(d);
- setView("day");
- }}
+ onPick={showDay}
/>
)}
</section>
@@ -1051,6 +1136,7 @@ export function CalendarView() {
calendars={calendars}
onChange={setDraft}
onClose={() => setDraft(null)}
+ onDismiss={dismiss}
onSave={() => void save(draft, true)}
onDelete={draft.guid ? () => void remove(draft.guid as string) : undefined}
onNudge={draft.guid ? (by) => {
@@ -1066,41 +1152,28 @@ export function CalendarView() {
)}
{asking && (
- <Portal>
- <div className="modal-veil" onClick={() => asking.answer(null)}>
- <div className="modal-sheet cx-ask" role="alertdialog" aria-label="Repeating event" onClick={(e) => e.stopPropagation()}>
- <h2>This is a repeating event.</h2>
- <p>
- {asking.verb === "delete"
- ? "Do you want to delete only this event, this and all future events, or all events in the series?"
- : "Do you want to change only this event, this and all future events, or all events in the series?"}
- </p>
- {/* Stacked, the chosen-by-default first, as macOS stacks an alert's choices. */}
- <div className="cx-ask-actions">
- <button className={asking.verb === "delete" ? "primary danger" : "primary"} autoFocus onClick={() => asking.answer("this")}>
- {asking.verb === "delete" ? "Delete Only This Event" : "Only This Event"}
- </button>
- <button className={asking.verb === "delete" ? "quiet danger" : "quiet"} onClick={() => asking.answer("future")}>
- {asking.verb === "delete" ? "Delete All Future Events" : "All Future Events"}
- </button>
- <button className={asking.verb === "delete" ? "quiet danger" : "quiet"} onClick={() => asking.answer("all")}>
- {asking.verb === "delete" ? "Delete All Events" : "All Events"}
- </button>
- <button className="quiet" onClick={() => asking.answer(null)}>Cancel</button>
- </div>
- </div>
- </div>
- </Portal>
+ <ConfirmSheet<EventScope>
+ title="This is a repeating event."
+ body={asking.verb === "delete"
+ ? "Do you want to delete only this event, this and all future events, or all events in the series?"
+ : "Do you want to change only this event, this and all future events, or all events in the series?"}
+ choices={asking.verb === "delete"
+ ? [
+ { label: "Delete Only This Event", value: "this", primary: true, danger: true, focus: true },
+ { label: "Delete All Future Events", value: "future", danger: true },
+ { label: "Delete All Events", value: "all", danger: true },
+ ]
+ : [
+ { label: "Only This Event", value: "this", primary: true, focus: true },
+ { label: "All Future Events", value: "future" },
+ { label: "All Events", value: "all" },
+ ]}
+ onAnswer={(scope) => asking.answer(scope)}
+ onCancel={() => asking.answer(null)}
+ />
)}
+ {confirmSheet}
- {undo && (
- <div className="cx-toast" role="status">
- Deleted “{undo.title}”
- <button className="cx-toast-undo" onClick={() => void takeBack()}>
- Undo
- </button>
- </div>
- )}
</div>
</TickContext.Provider>
);
@@ -1108,7 +1181,7 @@ export function CalendarView() {
/* ---- the mini month in the sidebar ------------------------------------------------ */
-function MiniMonth({
+const MiniMonth = memo(function MiniMonth({
selected,
today,
busy,
@@ -1130,18 +1203,18 @@ function MiniMonth({
<span>{dateText(shown, { month: "long", year: "numeric" })}</span>
<span>
<button
- className="cx-icon small"
+ className="icon-button small"
aria-label="Previous month"
onClick={() => setShown((m) => new Date(m.getFullYear(), m.getMonth() - 1, 1))}
>
- ‹
+ <ChevronLeft size={14} strokeWidth={2.2} aria-hidden="true" />
</button>
<button
- className="cx-icon small"
+ className="icon-button small"
aria-label="Next month"
onClick={() => setShown((m) => new Date(m.getFullYear(), m.getMonth() + 1, 1))}
>
- ›
+ <ChevronRight size={14} strokeWidth={2.2} aria-hidden="true" />
</button>
</span>
</div>
@@ -1151,9 +1224,9 @@ function MiniMonth({
{weekdayShort(d).slice(0, 1)}
</span>
))}
- {days.map((d) => (
+ {days.map((d, i) => (
<button
- key={dayKey(d)}
+ key={i}
className={`cx-minimonth-day${d.getMonth() !== shown.getMonth() ? " is-out" : ""}${
sameDay(d, today) ? " is-today" : ""
}${sameDay(d, selected) ? " is-selected" : ""}${busy(d) ? " is-busy" : ""}`}
@@ -1166,7 +1239,7 @@ function MiniMonth({
</div>
</div>
);
-}
+});
/* ---- month ------------------------------------------------------------------------ */
@@ -1174,7 +1247,7 @@ type Item =
| { kind: "event"; at: number; event: CalendarEvent }
| { kind: "reminder"; at: number; reminder: Reminder };
-function MonthView({
+const MonthView = memo(function MonthView({
days,
selected,
today,
@@ -1213,10 +1286,10 @@ function MonthView({
onSelect(addDays(day, by));
} else if (e.key === "Home") {
e.preventDefault();
- onSelect(addDays(day, -day.getDay()));
+ onSelect(startOfWeek(day));
} else if (e.key === "End") {
e.preventDefault();
- onSelect(addDays(day, 6 - day.getDay()));
+ onSelect(addDays(startOfWeek(day), 6));
}
};
@@ -1255,10 +1328,10 @@ function MonthView({
))}
</div>
<div className="cal-grid" role="grid" aria-label="Month" ref={grid}>
- {weeks.map((row) => {
+ {weeks.map((row, w) => {
const spans = weekSpans(events, row[0]);
return (
- <div className="cx-week" role="row" key={dayKey(row[0])}>
+ <div className="cx-week" role="row" key={w}>
{row.map((day, i) => {
const list = items(day);
// Only the lanes of the bars that cross this day are kept clear in it: a bar
@@ -1277,11 +1350,11 @@ function MonthView({
return (
<div
className={`cx-day${day.getMonth() !== inMonth ? " is-out" : ""}${
- day.getDay() === 0 || day.getDay() === 6 ? " is-weekend" : ""
+ isWeekend(day) ? " is-weekend" : ""
}${isSelected ? " is-selected" : ""}`}
role="gridcell"
aria-selected={isSelected}
- key={dayKey(day)}
+ key={i}
>
<button
ref={isSelected ? cell : undefined}
@@ -1368,17 +1441,19 @@ function MonthView({
</div>
</div>
);
-}
+});
/* ---- week and day ------------------------------------------------------------------- */
type Drag =
- | { kind: "create"; day: Date; column: number; from: number; to: number }
- | { kind: "move"; event: CalendarEvent; startX: number; startY: number; dx: number; dMinutes: number }
+ /** `anchor` is the quarter hour pressed: the drag runs from it up or down, as in Calendar. */
+ | { kind: "create"; day: Date; column: number; anchor: number; from: number; to: number }
+ /** `column` is the day the event was taken from, so it can be carried only to days shown. */
+ | { kind: "move"; event: CalendarEvent; column: number; startX: number; startY: number; dx: number; dMinutes: number }
/** Dragging an event's bottom edge: its end moves, its start stays. */
| { kind: "resize"; event: CalendarEvent; startY: number; dMinutes: number };
-function TimeGrid({
+const TimeGrid = memo(function TimeGrid({
days,
today,
events,
@@ -1408,7 +1483,16 @@ function TimeGrid({
const scroller = useRef<HTMLDivElement | null>(null);
const columnsEl = useRef<HTMLDivElement | null>(null);
const [drag, setDrag] = useState<Drag | null>(null);
- const spans = weekSpans(events, days[0]).filter((s) => s.from < days.length);
+ const daysKey = days.map((d) => dayKey(d)).join();
+ // A bar that runs past the last day shown carries on to the right — in Day, past the one
+ // day, not only past the week the layout counts from.
+ const spans = useMemo(
+ () => weekSpans(events, days[0])
+ .filter((s) => s.from < days.length)
+ .map((s) => (s.to >= days.length ? { ...s, to: days.length - 1, continuesRight: true } : s)),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [events, daysKey]
+ );
const lanes = Math.max(1, ...spans.map((s) => s.lane + 1));
// Opened, it shows the working day rather than midnight — as Calendar does.
@@ -1421,7 +1505,7 @@ function TimeGrid({
el.scrollTop = Math.max(0, hour * HOUR - 12);
// Only when the days change, never under someone's scrolling.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [days.map((d) => dayKey(d)).join()]);
+ }, [daysKey]);
/** Minutes since midnight under the pointer, in the column it is over. */
const where = (clientX: number, clientY: number) => {
@@ -1454,25 +1538,35 @@ function TimeGrid({
setDrag(d);
};
+ /*
+ * The pointer reports every pixel, the grid moves by quarter hours: only a move that lands
+ * on a new quarter hour (or day) is drawn. Re-rendering the whole week on every pixel was
+ * the stutter of a drag in WebKitGTK.
+ */
const follow = (clientX: number, clientY: number) => {
const current = dragRef.current;
const at = where(clientX, clientY);
if (!current || !at) return;
+ let next: Drag;
if (current.kind === "create") {
- setDragNow({ ...current, to: Math.max(current.from + 15, snap(at.minutes)) });
+ const to = snap(at.minutes);
+ next = { ...current, from: Math.min(current.anchor, to), to: Math.max(current.anchor + 15, to) };
+ if (next.from === current.from && next.to === current.to) return;
} else if (current.kind === "resize") {
// Never shorter than a quarter hour, as Calendar holds it.
const length = (current.event.endsAt - current.event.startsAt) / 60;
- setDragNow({ ...current, dMinutes: Math.max(15 - length, snap(((clientY - current.startY) / HOUR) * 60)) });
+ next = { ...current, dMinutes: Math.max(15 - length, snap(((clientY - current.startY) / HOUR) * 60)) };
+ if (next.dMinutes === current.dMinutes) return;
} else {
const el = columnsEl.current;
const width = el ? el.getBoundingClientRect().width / days.length : 1;
- setDragNow({
- ...current,
- dx: Math.round((clientX - current.startX) / width),
- dMinutes: snap(((clientY - current.startY) / HOUR) * 60),
- });
+ // Carried only as far as the days on screen: past them it went nowhere visible and
+ // landed on a day no one could see.
+ const dx = Math.min(days.length - 1 - current.column, Math.max(-current.column, Math.round((clientX - current.startX) / width)));
+ next = { ...current, dx, dMinutes: snap(((clientY - current.startY) / HOUR) * 60) };
+ if (next.dx === current.dx && next.dMinutes === current.dMinutes) return;
}
+ setDragNow(next);
};
const finish = (clientX: number, clientY: number) => {
@@ -1543,11 +1637,16 @@ function TimeGrid({
// No text selection or native drag while making an event.
e.preventDefault();
const from = snap(at.minutes) - (snap(at.minutes) === 24 * 60 ? 15 : 0);
- setDragNow({ kind: "create", day: days[at.column], column: at.column, from, to: from + 15 });
+ setDragNow({ kind: "create", day: days[at.column], column: at.column, anchor: from, from, to: from + 15 });
};
// Each day's events and timed reminders, laid out together so neither is drawn over the other.
- const layouts = days.map((d) => {
+ // Worked out once for what is shown, not again for every move of a drag or key typed in the
+ // popover; the title of the event being named changes nothing here.
+ const pendingFrom = pending?.startsAt ?? null;
+ const pendingTo = pending?.endsAt ?? null;
+ const layouts = useMemo(() => days.map((d) => {
+ const pending = pendingFrom === null || pendingTo === null ? null : { startsAt: pendingFrom, endsAt: pendingTo };
const due = stackReminders(reminders.filter((r) => r.dueAt !== null && sameDay(dateOf(r.dueAt), d)));
const marks = due.map(({ reminder, top }) => ({
id: reminder.guid,
@@ -1560,17 +1659,18 @@ function TimeGrid({
marks.push({
id: PENDING,
top: from.getHours() * 60 + from.getMinutes(),
- length: Math.max((pending.endsAt - pending.startsAt) / 60, 15),
+ length: Math.max((pending.endsAt - pending.startsAt) / 60, MIN_BLOCK),
});
}
- const laid = placeDayWith(events, d, marks);
+ const laid = placeDayWith(events, d, marks, MIN_BLOCK);
return {
events: laid.events,
marks: laid.marks.filter((m) => m.id !== PENDING),
pending: laid.marks.find((m) => m.id === PENDING) ?? null,
reminders: new Map(due.map((x) => [x.reminder.guid, x.reminder])),
};
- });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }), [daysKey, events, reminders, pendingFrom, pendingTo]);
const nowMinutes = today.getHours() * 60 + today.getMinutes();
const todayColumn = days.findIndex((d) => sameDay(d, today));
@@ -1579,10 +1679,10 @@ function TimeGrid({
<div className={`cal-hours${days.length === 1 ? " is-day" : ""}`}>
<div className="cx-grid-head" style={{ "--cols": days.length } as React.CSSProperties}>
<span className="cx-gutter" aria-hidden="true" />
- {days.map((d) => (
+ {days.map((d, i) => (
<button
className={`cal-col-head${sameDay(d, today) ? " is-today" : ""}`}
- key={dayKey(d)}
+ key={i}
onClick={() => onPickDay(d)}
aria-label={dateText(d, { dateStyle: "full" })}
>
@@ -1656,7 +1756,7 @@ function TimeGrid({
}}
>
{days.map((d, column) => (
- <div className={`cx-column${d.getDay() === 0 || d.getDay() === 6 ? " is-weekend" : ""}`} key={dayKey(d)}>
+ <div className={`cx-column${isWeekend(d) ? " is-weekend" : ""}`} key={column}>
{layouts[column].events.map((p) => {
const moving = drag?.kind === "move" && drag.event.guid === p.event.guid ? drag : null;
const sizing = drag?.kind === "resize" && drag.event.guid === p.event.guid ? drag : null;
@@ -1680,7 +1780,7 @@ function TimeGrid({
e.stopPropagation();
e.preventDefault();
if (canWrite(p.event.calendarGuid)) {
- setDragNow({ kind: "move", event: p.event, startX: e.clientX, startY: e.clientY, dx: 0, dMinutes: 0 });
+ setDragNow({ kind: "move", event: p.event, column, startX: e.clientX, startY: e.clientY, dx: 0, dMinutes: 0 });
} else {
onOpen(p.event, { x: e.clientX, y: e.clientY });
}
@@ -1770,13 +1870,15 @@ function TimeGrid({
</div>
</div>
);
-}
+});
/**
* Where each reminder sits on a day's hour grid. Two due at the same time — a morning routine
* set for eight — stack one under the other instead of being drawn over each other.
*/
const REMINDER_LINE = 18;
+/** The shortest a block is drawn — 20px, room for one line — in minutes, and so laid out. */
+const MIN_BLOCK = ((20 + 2) / HOUR) * 60;
/** The layout's name for the event being named, which has no guid yet. */
const PENDING = "\u0000pending";
export function stackReminders(list: Reminder[]): { reminder: Reminder; top: number }[] {
@@ -1799,7 +1901,7 @@ const pointOf = (el: Element): Anchor => {
/* ---- year --------------------------------------------------------------------------- */
-function YearView({
+const YearView = memo(function YearView({
year,
today,
busy,
@@ -1827,12 +1929,12 @@ function YearView({
{weekdayShort(d).slice(0, 1)}
</span>
))}
- {days.map((d) =>
+ {days.map((d, i) =>
d.getMonth() !== m ? (
- <span key={dayKey(d)} className="cx-minimonth-day is-blank" aria-hidden="true" />
+ <span key={i} className="cx-minimonth-day is-blank" aria-hidden="true" />
) : (
<button
- key={dayKey(d)}
+ key={i}
className={`cx-minimonth-day${sameDay(d, today) ? " is-today" : ""}${busy(d) ? " is-busy" : ""}`}
aria-label={dateText(d, { dateStyle: "full" })}
onClick={() => onPick(d)}
@@ -1847,7 +1949,7 @@ function YearView({
})}
</div>
);
-}
+});
/* ---- the event popover ---------------------------------------------------------------- */
@@ -1994,6 +2096,7 @@ function EventPopover({
calendars,
onChange,
onClose,
+ onDismiss,
onSave,
onDelete,
onNudge,
@@ -2004,6 +2107,8 @@ function EventPopover({
calendars: Calendar[];
onChange: (d: Draft) => void;
onClose: () => void;
+ /** Put away by a click outside it. */
+ onDismiss: () => void;
onSave: () => void;
onDelete?: () => void;
onNudge?: (by: { days: number } | { minutes: number }) => void;
@@ -2059,19 +2164,25 @@ function EventPopover({
onDelete();
}
};
- const onDown = (e: MouseEvent) => {
+ const onDown = (e: PointerEvent) => {
if (!box.current || box.current.contains(e.target as Node) || inMenu(e.target)) return;
+ // Calendar's question about a repeating event is this popover's own, asked on its Save.
+ if ((e.target as HTMLElement).closest?.(".modal-veil")) return;
// A press on the event this is open for is not a press elsewhere: it keeps it open.
if (draft.guid && (e.target as HTMLElement).closest?.(`[data-event="${CSS.escape(draft.guid)}"]`)) return;
- onClose();
+ onDismiss();
};
window.addEventListener("keydown", onKey);
- window.addEventListener("mousedown", onDown);
+ // A press, not a mouse-down: the timeline cancels its presses' default to keep text from
+ // being selected, and a cancelled pointer press sends no mouse-down — a click on empty time
+ // left the popover open. Caught on the way down, before an event block stops it: a press
+ // on another event puts this one away — keeping what was typed — before that one opens.
+ window.addEventListener("pointerdown", onDown, true);
return () => {
window.removeEventListener("keydown", onKey);
- window.removeEventListener("mousedown", onDown);
+ window.removeEventListener("pointerdown", onDown, true);
};
- }, [onClose, onDelete, onNudge, editable, view, draft.allDay, draft.guid]);
+ }, [onClose, onDismiss, onDelete, onNudge, editable, view, draft.allDay, draft.guid]);
const set = (patch: Partial<Draft>) => onChange({ ...draft, ...patch });
@@ -2277,7 +2388,7 @@ function EventPopover({
/>
<div className="cx-pop-actions">
{onDelete && editable ? (
- <button type="button" className="cx-pop-delete" onClick={onDelete}>
+ <button type="button" className="link danger cx-pop-delete" onClick={onDelete}>
Delete
</button>
) : (
@@ -2304,7 +2415,7 @@ function EventPopover({
* 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({
+const DayPane = memo(function DayPane({
day,
events,
reminders,
@@ -2365,7 +2476,7 @@ function DayPane({
)}
</aside>
);
-}
+});
/** Apple's calendar colours, in icloud.com's order (calendar bundle `r2`). */
const CALENDAR_COLOURS: [string, string][] = [
@@ -2388,7 +2499,7 @@ function CalendarName({ initial, label, onDone, onCancel }: {
const settled = useRef(false);
return (
<input
- className="cx-cal-rename"
+ className="field cx-cal-rename"
defaultValue={initial}
aria-label={label}
autoFocus
diff --git a/src/screens/calendar/model.ts b/src/screens/calendar/model.ts
index a3f1942..b2192bb 100644
--- a/src/screens/calendar/model.ts
+++ b/src/screens/calendar/model.ts
@@ -17,15 +17,62 @@ export const sameDay = (a: Date, b: Date) =>
a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
export const dayKey = (d: Date) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
-/** The Sunday on or before `d`, where Apple starts a week. */
-export const startOfWeek = (d: Date) => addDays(midnight(d), -d.getDay());
+/* ---- the week, as this computer's region keeps it ---------------------------------------- */
+
+/** Which day a week starts on and which days are the weekend, 0 for Sunday as `getDay` counts. */
+export type WeekInfo = { firstDay: number; weekend: number[] };
+
+// For an engine without `Intl.Locale#getWeekInfo` (WebKitGTK's, for one), CLDR's own answer
+// for the regions that differ from a Monday start and a Saturday–Sunday weekend.
+const SUNDAY_FIRST = new Set(
+ ("AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX " +
+ "MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW").split(" ")
+);
+const SATURDAY_FIRST = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
+const FRIDAY_SATURDAY = new Set("BH DZ EG IQ IL JO KW LY OM QA SA SD SY YE".split(" "));
+
+/** The week of `locale`'s region: Monday first in Britain, Sunday in the US, Saturday in Egypt. */
+export function weekInfoOf(locale: string): WeekInfo {
+ try {
+ const l = new Intl.Locale(locale) as Intl.Locale & {
+ getWeekInfo?: () => { firstDay: number; weekend: number[] };
+ weekInfo?: { firstDay: number; weekend: number[] };
+ };
+ const info = l.getWeekInfo?.() ?? l.weekInfo;
+ // Intl counts Monday 1 to Sunday 7; `getDay`, Sunday 0 to Saturday 6.
+ if (info) return { firstDay: info.firstDay % 7, weekend: info.weekend.map((d) => d % 7) };
+ const region = l.maximize().region ?? "US";
+ return {
+ firstDay: SUNDAY_FIRST.has(region) ? 0 : SATURDAY_FIRST.has(region) ? 6 : 1,
+ weekend: region === "IN" ? [0] : region === "IR" ? [5] : region === "AF" ? [4, 5] : FRIDAY_SATURDAY.has(region) ? [5, 6] : [6, 0],
+ };
+ } catch {
+ return { firstDay: 0, weekend: [6, 0] };
+ }
+}
+
+/** This computer's week, read once. */
+export const WEEK: WeekInfo = weekInfoOf(
+ (typeof navigator !== "undefined" && navigator.language) || Intl.DateTimeFormat().resolvedOptions().locale
+);
+export const isWeekend = (d: Date) => WEEK.weekend.includes(d.getDay());
+
+/** The day on or before `d` that a week starts on here — Sunday in the US, Monday in Europe. */
+export const startOfWeek = (d: Date, firstDay = WEEK.firstDay) =>
+ addDays(midnight(d), -((d.getDay() - firstDay + 7) % 7));
/** The six weeks a month shows: from the week holding the 1st, forty-two days. */
-export function monthDays(anchor: Date): Date[] {
- const start = startOfWeek(new Date(anchor.getFullYear(), anchor.getMonth(), 1));
+export function monthDays(anchor: Date, firstDay = WEEK.firstDay): Date[] {
+ const start = startOfWeek(new Date(anchor.getFullYear(), anchor.getMonth(), 1), firstDay);
return Array.from({ length: 42 }, (_, i) => addDays(start, i));
}
+/** Whether this computer's clock is a twelve-hour one, read from its locale's hour cycle. */
+export const TWELVE_HOUR = (() => {
+ const o = new Intl.DateTimeFormat(undefined, { hour: "numeric" }).resolvedOptions() as { hourCycle?: string; hour12?: boolean };
+ return o.hourCycle ? o.hourCycle === "h12" || o.hourCycle === "h11" : o.hour12 ?? true;
+})();
+
/** An event's first and last local day, the last being the day holding its final moment. */
export function daysOf(event: CalendarEvent): [Date, Date] {
const first = midnight(dateOf(event.startsAt));
@@ -132,6 +179,9 @@ export function placeDayWith(
events: CalendarEvent[],
day: Date,
marks: Mark[],
+ /** The shortest a block is drawn, in minutes. Laid out shorter than it is drawn, a
+ * quarter-hour call and the one after it were set one above the other and drawn overlapping. */
+ minLength = 15,
): { events: Placed[]; marks: PlacedMark[] } {
const start = seconds(midnight(day));
const end = seconds(addDays(day, 1));
@@ -145,7 +195,7 @@ export function placeDayWith(
.map((event): Item => {
const from = Math.max(event.startsAt, start);
const to = Math.min(Math.max(event.endsAt, event.startsAt), end);
- return { kind: "event", event, top: (from - start) / 60, length: Math.max((to - from) / 60, 15), column: 0, columns: 1 };
+ return { kind: "event", event, top: (from - start) / 60, length: Math.max((to - from) / 60, minLength), column: 0, columns: 1 };
}),
...marks.map((mark): Item => ({ kind: "mark", mark, top: mark.top, length: mark.length, column: 0, columns: 1 })),
].sort((a, b) => a.top - b.top || b.length - a.length);
@@ -182,16 +232,19 @@ export function placeDayWith(
export const snap = (minutes: number, step = 15) => Math.round(minutes / step) * step;
/** "9 AM", "Noon", "3 PM" — the hour labels in the viewer's own clock. */
-export function hourLabel(hour: number): string {
- if (hour === 12) return "Noon";
+export function hourLabel(hour: number, twelve = TWELVE_HOUR): string {
+ // "Noon" is a twelve-hour clock's word; a 24-hour one writes 12:00 like every other hour.
+ if (twelve && hour === 12) return "Noon";
const d = new Date(2024, 0, 1, hour);
- return timeText(d, { hour: "numeric" });
+ return twelve ? timeText(d, { hour: "numeric" }) : timeText(d, { hour: "2-digit", minute: "2-digit" });
}
-/** "9:30 AM", with ":00" left off, as Calendar writes a time. */
-export const clock = (s: number) =>
- timeText(dateOf(s), { hour: "numeric", minute: "2-digit" })
- .replace(/:00(?=\D|$)/, "");
+/** "9:30 AM", with ":00" left off, as Calendar writes a time — on a twelve-hour clock. A
+ * 24-hour one keeps it: "14:00", never a bare "14". */
+export const clock = (s: number, twelve = TWELVE_HOUR) => {
+ const text = timeText(dateOf(s), { hour: "numeric", minute: "2-digit" });
+ return twelve ? text.replace(/:00(?=\D|$)/, "") : text;
+};
/* ---- time zones ------------------------------------------------------------------------ */
diff --git a/src/screens/notes/Formatted.tsx b/src/screens/notes/Formatted.tsx
index ff454da..8333220 100644
--- a/src/screens/notes/Formatted.tsx
+++ b/src/screens/notes/Formatted.tsx
@@ -8,6 +8,8 @@
* lay over the text directly. Runs that do not add up to the text — a note edited here since
* the last sync — are not guessed at: the caller shows the plain text instead.
*/
+import { useEffect, useRef } from "react";
+import { describe, drawMedia } from "./NoteEditor";
import { addressesIn, openLinkAt } from "./links";
export type Run = {
length: number;
@@ -125,8 +127,27 @@ function withAddresses(text: string): React.ReactNode {
return out;
}
+/**
+ * An attachment where it stands in a note shown read-only: drawn as the editor draws it — the
+ * picture, the scan, the file's chip — not an invisible character on an empty line.
+ */
+function Attachment({ id }: { id: string }) {
+ const host = useRef<HTMLSpanElement | null>(null);
+ useEffect(() => {
+ let gone = false;
+ void describe(id).then((info) => {
+ if (!gone && info && host.current) drawMedia(host.current, info);
+ });
+ return () => {
+ gone = true;
+ };
+ }, [id]);
+ return <span ref={host} className="nf-attachment" />;
+}
+
function Inline({ span }: { span: Span }) {
const { run, text } = span;
+ if (run.attachment && text.includes("\ufffc")) return <Attachment id={run.attachment} />;
let node: React.ReactNode = run.link ? text : withAddresses(text);
if (run.bold) node = <strong>{node}</strong>;
if (run.italic) node = <em>{node}</em>;
diff --git a/src/screens/notes/NoteEditor.tsx b/src/screens/notes/NoteEditor.tsx
index 172512c..2514741 100644
--- a/src/screens/notes/NoteEditor.tsx
+++ b/src/screens/notes/NoteEditor.tsx
@@ -55,7 +55,7 @@ let openCellMenu: ((menu: CellMenu) => void) | null = null;
*/
/** What each attachment is, asked once a session: a note re-drawn does not ask again. */
const described = new Map<string, Promise<NoteAttachment | null>>();
-function describe(id: string): Promise<NoteAttachment | null> {
+export function describe(id: string): Promise<NoteAttachment | null> {
let known = described.get(id);
if (!known) {
// A lookup that failed (offline, the session being renewed) is not kept: the next time
@@ -85,7 +85,7 @@ function size(bytes: number | null): string {
export const PICTURE_EVENT = "quince:note-picture";
export type PictureShown = { id: string; name: string; src: string; srcDark?: string; drawing?: boolean };
-function drawMedia(dom: HTMLElement, info: NoteAttachment) {
+export function drawMedia(dom: HTMLElement, info: NoteAttachment) {
const name = info.filename ?? info.title ?? (info.kind === "audio" ? "Recording" : "Attachment");
// Opened in the app this computer uses for it; one that cannot be says why, on the chip
// itself, rather than a click that seems to do nothing.
@@ -125,7 +125,12 @@ function drawMedia(dom: HTMLElement, info: NoteAttachment) {
img.draggable = false;
if (info.width && info.height) img.style.aspectRatio = `${info.width} / ${info.height}`;
img.src = noteMediaSrc(info.id, part);
- img.addEventListener("error", () => dom.replaceChildren(chip()));
+ // The backend says whether the picture can be shown: a 404 (a HEIC with no decoder on
+ // this computer, a fetch that failed) and it is the file's chip, drawn as one.
+ img.addEventListener("error", () => {
+ dom.className = "nf-attachment is-file";
+ dom.replaceChildren(chip());
+ });
return img;
};
dom.title = `Open ${name}`;
@@ -182,7 +187,10 @@ function attachmentView(node: PMNode) {
const dom = document.createElement("span");
dom.className = "nf-attachment";
dom.contentEditable = "false";
- dom.textContent = "Attachment";
+ // Nothing until it is known what it is — then the picture, the table, the file. A word
+ // standing in for it ("Attachment") read as clutter, and stayed where a lookup failed.
+ dom.textContent = "";
+ dom.classList.add("is-pending");
dom.title = "Open it on an Apple device to change it";
const id = node.attrs.id as string | null;
@@ -628,8 +636,15 @@ export const NoteEditor = forwardRef<EditorHandle, Props>(function NoteEditor(
.replace(/<\/tr>/gi, "</p>")
.replace(/<\/?(table|tbody|thead|tfoot|td|th)[^>]*>/gi, "");
},
- transformPasted(slice) {
- return new Slice(withoutAttachments(slice.content), slice.openStart, slice.openEnd);
+ // Lines copied whole keep their style, tick, indent and numbering (rich.ts reads them
+ // back). Into an empty line, the first copied line comes whole too, its setting with it,
+ // rather than taking the empty line's; into a line with text in it, it joins that line.
+ // Plain text has no setting of its own, so it takes the line's.
+ transformPasted(slice, view, plain) {
+ const { $from, empty } = view.state.selection;
+ const blank = empty && $from.parent.type === schema.nodes.paragraph && $from.parent.content.size === 0;
+ const openStart = blank && !plain ? 0 : slice.openStart;
+ return new Slice(withoutAttachments(slice.content), openStart, slice.openEnd);
},
// Lists typed as on the phone: "- " a dashed list, "* " a bulleted one, "1. " a numbered
// one; in a dashed line "[ ] " or "[x] " makes it a checklist item, so "- [ ] " works
@@ -669,6 +684,8 @@ export const NoteEditor = forwardRef<EditorHandle, Props>(function NoteEditor(
mousedown: (vw, event) => {
const line = (event.target as HTMLElement).closest?.('p[data-style="103"]') as HTMLElement | null;
if (!line || !editable) return false;
+ // A line holding a table or picture has no circle to press.
+ if (line.querySelector(":scope > .nf-attachment:is(.is-table, .is-image, .is-doc, .is-drawing, .is-table-unread)")) return false;
const box = line.getBoundingClientRect();
const pad = parseFloat(getComputedStyle(line).paddingInlineStart) || 0;
if (event.clientX - box.left > pad) return false;
diff --git a/src/screens/notes/NotePicture.tsx b/src/screens/notes/NotePicture.tsx
index d9501f4..944e295 100644
--- a/src/screens/notes/NotePicture.tsx
+++ b/src/screens/notes/NotePicture.tsx
@@ -61,7 +61,7 @@ export function NotePicture() {
Open in Default App
</button>
)}
- <button className="nf-picture-close" aria-label="Close" autoFocus onClick={() => setShown(null)}>
+ <button className="icon-button round nf-picture-close" aria-label="Close" autoFocus onClick={() => setShown(null)}>
<X size={16} strokeWidth={2} />
</button>
</figcaption>
diff --git a/src/screens/notes/rich.ts b/src/screens/notes/rich.ts
index 19e9a18..7c6e1fa 100644
--- a/src/screens/notes/rich.ts
+++ b/src/screens/notes/rich.ts
@@ -34,6 +34,23 @@ const ATTACHMENT = "";
export const tableCells = new Map<string, string[][]>();
const LINE_BREAK = "
";
+/** A paragraph's settings from the element its toDOM made; nothing set when it is not one. */
+function paragraphAttrs(p: HTMLElement) {
+ const raw = p.getAttribute("data-style");
+ const n = raw === null || raw === "none" ? NaN : Number(raw);
+ const style = Number.isInteger(n) && Object.values(STYLE).includes(n as never) ? n : null;
+ const css = p.getAttribute("style") ?? "";
+ const indent = Number(/--indent:\s*(\d+)/.exec(css)?.[1] ?? 0);
+ const start = Number(/counter-set:\s*nf-num\s+(\d+)/.exec(css)?.[1] ?? NaN);
+ return {
+ style,
+ indent,
+ checked: style === STYLE.checklist ? p.getAttribute("data-checked") === "true" : null,
+ start: style === STYLE.numbered && start > 1 ? start : null,
+ quote: p.getAttribute("data-quote") === "true",
+ };
+}
+
export const schema = new Schema({
nodes: {
doc: { content: "paragraph+" },
@@ -48,7 +65,10 @@ export const schema = new Schema({
/** A block quote line. */
quote: { default: false },
},
- parseDOM: [{ tag: "p" }],
+ // Read back exactly what toDOM writes, so a copy pasted within Pomander keeps each
+ // line's style, tick, indent and numbering. A `<p>` from anywhere else has none of these
+ // and stays plain body.
+ parseDOM: [{ tag: "p", getAttrs: (d) => paragraphAttrs(d as HTMLElement) }],
toDOM: (node) => [
"p",
{
diff --git a/src/screens/photos/AdjustDate.tsx b/src/screens/photos/AdjustDate.tsx
index 43eee64..063ad06 100644
--- a/src/screens/photos/AdjustDate.tsx
+++ b/src/screens/photos/AdjustDate.tsx
@@ -38,9 +38,9 @@ export function AdjustDate({ photo, onSave, onClose }: { photo: Photo; onSave: (
const changed = next !== null && next !== photo.takenAt && next > -2_208_988_800 && next < 253_402_300_800;
const shown = new Date(photo.takenAt * 1000).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "medium" });
return (
- <div className="px-sheet-scrim" role="presentation" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
+ <div className="modal-veil" role="presentation" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
<form
- className="px-sheet"
+ className="modal-sheet px-sheet"
role="dialog"
aria-modal="true"
aria-label="Adjust Date and Time"
@@ -49,7 +49,7 @@ export function AdjustDate({ photo, onSave, onClose }: { photo: Photo; onSave: (
if (changed && next !== null) onSave(next);
}}
>
- <button type="button" className="px-sheet-x" aria-label="Close" onClick={onClose}>
+ <button type="button" className="icon-button small round sheet-close" aria-label="Close" onClick={onClose}>
<X size={16} strokeWidth={2.2} aria-hidden="true" />
</button>
<h2>Adjust Date and Time</h2>
@@ -63,7 +63,7 @@ export function AdjustDate({ photo, onSave, onClose }: { photo: Photo; onSave: (
<label htmlFor="px-adjusted">Adjusted:</label>
<input
id="px-adjusted"
- className="px-date-field"
+ className="field px-date-field"
type="datetime-local"
step={1}
value={value}
@@ -71,11 +71,11 @@ export function AdjustDate({ photo, onSave, onClose }: { photo: Photo; onSave: (
onChange={(e) => setValue(e.target.value)}
/>
</div>
- <div className="px-sheet-buttons">
- <button type="button" className="px-sheet-button" onClick={onClose}>
+ <div className="sheet-actions">
+ <button type="button" className="quiet" onClick={onClose}>
Cancel
</button>
- <button type="submit" className="px-sheet-button is-primary" disabled={!changed}>
+ <button type="submit" className="primary" disabled={!changed}>
Save
</button>
</div>
diff --git a/src/screens/photos/Ask.tsx b/src/screens/photos/Ask.tsx
deleted file mode 100644
index b431e09..0000000
--- a/src/screens/photos/Ask.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * A question before a change that reaches every device, as icloud.com's Photos asks it: a
- * sheet over the dimmed window — a symbol, the question in bold, a line on what follows, and
- * Cancel beside the action, red when it destroys. Escape or a click outside cancels; Cancel
- * has the focus, so Return never deletes by accident.
- */
-import { useCallback, useRef, useState } from "react";
-import { EyeOff, Trash2 } from "lucide-react";
-import { Portal } from "../../components/Portal";
-
-export type Question = {
- title: string;
- body: string;
- action: string;
- /** Red, and the trash symbol: a delete. */
- danger?: boolean;
- symbol?: "trash" | "hide";
-};
-
-export function useAsk(): [(q: Question) => Promise<boolean>, React.ReactNode] {
- const [asking, setAsking] = useState<Question | null>(null);
- const answer = useRef<((yes: boolean) => void) | null>(null);
- const ask = useCallback(
- (q: Question) =>
- new Promise<boolean>((resolve) => {
- answer.current?.(false);
- answer.current = resolve;
- setAsking(q);
- }),
- [],
- );
- const done = (yes: boolean) => {
- answer.current?.(yes);
- answer.current = null;
- setAsking(null);
- };
- const sheet = asking && (
- <Portal>
- <div className="modal-veil" onClick={() => done(false)}>
- <div
- className="modal-sheet px-ask"
- role="alertdialog"
- aria-modal="true"
- aria-label={asking.title}
- onClick={(e) => e.stopPropagation()}
- onKeyDown={(e) => {
- if (e.key === "Escape") {
- e.stopPropagation();
- done(false);
- }
- }}
- >
- {asking.symbol && (
- <span className={`px-ask-symbol${asking.danger ? " is-danger" : ""}`} aria-hidden="true">
- {asking.symbol === "trash" ? <Trash2 size={30} strokeWidth={1.6} /> : <EyeOff size={30} strokeWidth={1.6} />}
- </span>
- )}
- <h2>{asking.title}</h2>
- <p>{asking.body}</p>
- <div className="px-ask-actions">
- <button autoFocus onClick={() => done(false)}>
- Cancel
- </button>
- <button className={`is-act${asking.danger ? " danger" : ""}`} onClick={() => done(true)}>
- {asking.action}
- </button>
- </div>
- </div>
- </div>
- </Portal>
- );
- return [ask, sheet];
-}
diff --git a/src/screens/photos/DownloadOptions.tsx b/src/screens/photos/DownloadOptions.tsx
index 59905a0..e3cd226 100644
--- a/src/screens/photos/DownloadOptions.tsx
+++ b/src/screens/photos/DownloadOptions.tsx
@@ -30,15 +30,15 @@ export function DownloadOptions({ photos, onPick, onClose }: { photos: Photo[];
<strong>{title}</strong>
<small>{words}</small>
</span>
- <button className="px-dl-go" aria-label={`Download ${title}`} title="Download" onClick={() => onPick(want)}>
+ <button className="icon-button px-dl-go" aria-label={`Download ${title}`} title="Download" onClick={() => onPick(want)}>
<Download size={16} strokeWidth={2} aria-hidden="true" />
</button>
</div>
);
return (
- <div className="px-sheet-scrim" role="presentation" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
- <div className="px-sheet" role="dialog" aria-modal="true" aria-label="Download Options">
- <button className="px-sheet-x" aria-label="Close" onClick={onClose}>
+ <div className="modal-veil" role="presentation" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
+ <div className="modal-sheet px-sheet" role="dialog" aria-modal="true" aria-label="Download Options">
+ <button className="icon-button small round sheet-close" aria-label="Close" onClick={onClose}>
<X size={16} strokeWidth={2.2} aria-hidden="true" />
</button>
<h2>Download Options</h2>
diff --git a/src/screens/photos/SharedAlbums.tsx b/src/screens/photos/SharedAlbums.tsx
index fef1e92..6435254 100644
--- a/src/screens/photos/SharedAlbums.tsx
+++ b/src/screens/photos/SharedAlbums.tsx
@@ -5,12 +5,14 @@
* (or taken back, with Apple's reason); one of this account's is deleted from its menu, asked
* first, for everyone it was shared with.
*/
+import { EmptyState } from "../../components/EmptyState";
+import { PaneTitle } from "../../components/PaneTitle";
import { useEffect, useRef, useState } from "react";
import { Plus, Users } from "lucide-react";
import { api, type SharedAlbum } from "../../lib/ipc";
import { Portal } from "../../components/Portal";
import { RowMenu, type MenuEntry } from "../../components/RowMenu";
-import type { Question } from "./Ask";
+import type { Question } from "../../components/Confirm";
export function SharedAlbums({ ask, onError }: { ask: (q: Question) => Promise<boolean>; onError: (message: string) => void }) {
const [albums, setAlbums] = useState<SharedAlbum[] | null>(null);
@@ -61,23 +63,19 @@ export function SharedAlbums({ ask, onError }: { ask: (q: Question) => Promise<b
return (
<div className="px-albums-page">
<header className="px-albums-head">
- <div className="px-heading">
- <h1>Shared Albums</h1>
- <p className="px-span">{albums === null ? " " : n === 1 ? "1 Item" : `${n} Items`}</p>
- </div>
- <div className="px-capsule">
- <button className="px-cap" aria-label="New Shared Album" title="New Shared Album" onClick={() => setNaming(true)}>
+ <PaneTitle className="px-heading" countClassName="px-span" count={albums === null ? "\u00a0" : n === 1 ? "1 Item" : `${n} Items`}>
+ Shared Albums
+ </PaneTitle>
+ <div className="toolbar-group">
+ <button className="tool px-cap" aria-label="New Shared Album" title="New Shared Album" onClick={() => setNaming(true)}>
<Plus size={16} strokeWidth={2} aria-hidden="true" />
</button>
</div>
</header>
{albums !== null && n === 0 ? (
- <div className="px-empty px-shared-empty">
- <p>No shared albums yet. Make one to share photos with the people you choose.</p>
- <button className="primary" onClick={() => setNaming(true)}>
- New Shared Album
- </button>
- </div>
+ <EmptyState className="px-empty px-shared-empty" action={{ label: "New Shared Album", run: () => setNaming(true) }}>
+ No shared albums yet. Make one to share photos with the people you choose.
+ </EmptyState>
) : (
<div className="px-cards" role="list" aria-busy={albums === null}>
{(albums ?? []).map((a) => (
@@ -122,7 +120,7 @@ function NameSheet({ onCancel, onCreate }: { onCancel: () => void; onCreate: (na
<Portal>
<div className="modal-veil" onClick={onCancel}>
<form
- className="modal-sheet px-ask"
+ className="modal-sheet confirm"
role="dialog"
aria-label="New Shared Album"
onClick={(e) => e.stopPropagation()}
@@ -138,12 +136,12 @@ function NameSheet({ onCancel, onCreate }: { onCancel: () => void; onCreate: (na
}}
>
<h2>New Shared Album</h2>
- <input ref={field} className="px-shared-name" placeholder="Album Name" aria-label="Album Name" value={name} onChange={(e) => setName(e.target.value)} />
- <div className="px-ask-actions">
- <button type="button" onClick={onCancel}>
+ <input ref={field} className="field px-shared-name" placeholder="Album Name" aria-label="Album Name" value={name} onChange={(e) => setName(e.target.value)} />
+ <div className="confirm-actions">
+ <button type="button" className="quiet" onClick={onCancel}>
Cancel
</button>
- <button type="submit" className="is-act" disabled={!name.trim()}>
+ <button type="submit" className="primary confirm-answer" disabled={!name.trim()}>
Create
</button>
</div>
diff --git a/src/screens/photos/Slideshow.tsx b/src/screens/photos/Slideshow.tsx
index 30da232..a09319f 100644
--- a/src/screens/photos/Slideshow.tsx
+++ b/src/screens/photos/Slideshow.tsx
@@ -141,20 +141,20 @@ export function Slideshow({ photos, start, onClose }: { photos: Photo[]; start:
src={screenSrc(photo)}
alt={photo.filename ?? "Photo"}
/>
- <div className="px-show-bar px-capsule" role="toolbar" aria-label="Slideshow controls">
- <button className="px-cap" aria-label="Previous" onClick={() => go(-1)}>
+ <div className="px-show-bar toolbar-group" role="toolbar" aria-label="Slideshow controls">
+ <button className="tool px-cap" aria-label="Previous" onClick={() => go(-1)}>
<ChevronLeft size={18} />
</button>
- <button className="px-cap" aria-label={playing ? "Pause" : "Play"} onClick={() => setPlaying((p) => !p)}>
+ <button className="tool px-cap" aria-label={playing ? "Pause" : "Play"} onClick={() => setPlaying((p) => !p)}>
{playing ? <Pause size={17} fill="currentColor" strokeWidth={0} /> : <Play size={17} fill="currentColor" strokeWidth={0} />}
</button>
- <button className="px-cap" aria-label="Next" onClick={() => go(1)}>
+ <button className="tool px-cap" aria-label="Next" onClick={() => go(1)}>
<ChevronRight size={18} />
</button>
<span className="px-show-count" aria-live="polite">
{at + 1} of {list.length}
</span>
- <button className="px-cap" aria-label="End Slideshow" title="End Slideshow (Esc)" onClick={onClose}>
+ <button className="tool px-cap" aria-label="End Slideshow" title="End Slideshow (Esc)" onClick={onClose}>
<X size={17} />
</button>
</div>
diff --git a/src/screens/photos/UploadPanel.tsx b/src/screens/photos/UploadPanel.tsx
index 371b761..b879f9a 100644
--- a/src/screens/photos/UploadPanel.tsx
+++ b/src/screens/photos/UploadPanel.tsx
@@ -4,7 +4,8 @@
* and, at the end, what did not go and why ("Duplicate item."), until Done slides it away. A
* clean finish goes by itself after a moment.
*/
-import { useCallback, useEffect, useRef, useState } from "react";
+import { Progress, Spinner } from "../../components/Spinner";
+import { useEffect, useRef, useState } from "react";
import { convertFileSrc } from "@tauri-apps/api/core";
import { Check, CloudAlert, CloudUpload, Info, X } from "lucide-react";
import type { UploadEvent } from "../../lib/ipc";
@@ -59,17 +60,9 @@ export function UploadPanel({
const percent = (most.current = Math.max(most.current, total ? sent / total : 0));
const processing = active && files.every((u) => ended(u) || u.state === "verifying");
- // Leaving slides out first, then the panel goes.
- const [leaving, setLeaving] = useState(false);
- const close = useCallback(() => {
- const still = typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
- if (still) return onDismiss();
- setLeaving(true);
- window.setTimeout(() => {
- setLeaving(false);
- onDismiss();
- }, 240);
- }, [onDismiss]);
+ // Gone at once, as it came: a panel the window's height sliding was a large layer moving,
+ // the kind WebKitGTK on Hyprland flickers.
+ const close = onDismiss;
// A clean finish goes by itself; anything that did not go waits to be read.
useEffect(() => {
@@ -94,14 +87,14 @@ export function UploadPanel({
const batches = [...new Set(files.filter((u) => !ended(u)).map((u) => u.batch))];
return (
- <aside className={`px-up${leaving ? " is-leaving" : ""}`} aria-label="Uploads" aria-live="polite">
+ <aside className="px-up" aria-label="Uploads" aria-live="polite">
<header className="px-up-head">
{active ? (
- <button className="px-up-link" onClick={() => batches.forEach((b) => void cancel([], b))}>
+ <button className="link px-up-link" onClick={() => batches.forEach((b) => void cancel([], b))}>
Stop Upload
</button>
) : (
- <button className="px-up-link" onClick={close}>
+ <button className="link px-up-link" onClick={close}>
Done
</button>
)}
@@ -116,9 +109,7 @@ export function UploadPanel({
)}
<h2 className="px-up-title">{title}</h2>
{active && (
- <div className="px-up-bar" role="progressbar" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(percent * 100)}>
- <span style={{ transform: `scaleX(${percent})` }} />
- </div>
+ <Progress value={percent} label="Uploaded so far" className="px-up-bar" />
)}
</div>
<ul className="px-up-rows">
@@ -143,12 +134,12 @@ export function UploadPanel({
{u.state === "waiting" && (
<>
<span className="px-up-pending">Pending</span>
- <button className="px-up-stop" aria-label={`Stop ${u.name}`} title="Stop" onClick={() => void cancel([u.id])}>
+ <button className="icon-button small round px-up-stop" aria-label={`Stop ${u.name}`} title="Stop" onClick={() => void cancel([u.id])}>
<X size={11} strokeWidth={3} aria-hidden="true" />
</button>
</>
)}
- {(u.state === "sending" || u.state === "verifying") && <span className="px-up-spin" aria-label="Uploading" />}
+ {(u.state === "sending" || u.state === "verifying") && <Spinner label="Uploading" />}
{u.state === "done" && <Check className="px-up-ok" size={15} strokeWidth={2.4} aria-label="Uploaded" />}
{u.state === "failed" && <Info className="px-up-why" size={15} strokeWidth={2} aria-label={u.error ?? "Not uploaded"} />}
</span>
diff --git a/src/screens/photos/VideoPlayer.tsx b/src/screens/photos/VideoPlayer.tsx
index ea6ea3a..77d4596 100644
--- a/src/screens/photos/VideoPlayer.tsx
+++ b/src/screens/photos/VideoPlayer.tsx
@@ -147,8 +147,8 @@ export function VideoPlayer({
onVolumeChange={(e) => setMuted(e.currentTarget.muted)}
onError={onError}
/>
- <div className="px-player-bar px-capsule" role="toolbar" aria-label="Video controls" onClick={(e) => e.stopPropagation()}>
- <button className="px-cap" aria-label={playing ? "Pause" : "Play"} onClick={toggle}>
+ <div className="px-player-bar toolbar-group" role="toolbar" aria-label="Video controls" onClick={(e) => e.stopPropagation()}>
+ <button className="tool px-cap" aria-label={playing ? "Pause" : "Play"} onClick={toggle}>
{playing ? <Pause size={17} strokeWidth={0} fill="currentColor" /> : <Play size={17} strokeWidth={0} fill="currentColor" />}
</button>
<span className="px-player-time" ref={said}>
@@ -197,7 +197,7 @@ export function VideoPlayer({
−0:00
</span>
<button
- className="px-cap"
+ className="tool px-cap"
aria-label={muted ? "Unmute" : "Mute"}
onClick={() => {
const v = film.current;
diff --git a/src/styles/app.css b/src/styles/app.css
index 692bffe..2a5e9eb 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -3,6 +3,10 @@
inset: 0;
z-index: 0;
pointer-events: none;
+ /* Painted once, on a layer of its own that never moves: behind a scrolling page, WebKit
+ otherwise painted both gradients again on every frame. (A still layer, never animated.) */
+ transform: translateZ(0);
+ contain: strict;
background:
radial-gradient(110% 80% at 8% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 58%),
radial-gradient(90% 70% at 100% 108%, color-mix(in srgb, var(--text) 5%, transparent), transparent 52%);
@@ -10,57 +14,106 @@
/* ---- shell ------------------------------------------------------------------ */
+/*
+ * Signed out. The sheet hangs from a fixed point a little above the middle rather than being
+ * centred: centred, every line that came or went — an error, the disclosure opening — moved
+ * the whole sheet, the icon included. Anchored, things below a change move and nothing above.
+ */
.shell {
height: 100%;
+ /* Always a scroll box, so a sheet that grows past the window (the disclosure open, in a
+ short window) does not jump sideways as a scrollbar arrives. The track is transparent
+ and there is no thumb until there is something to scroll; the 10px it takes on the
+ right is given back on the left, so the sheet stays centred. (scrollbar-gutter would
+ say this in one line, but WebKit does not support it.) */
+ overflow-y: scroll;
display: grid;
- place-items: center;
- padding: 32px;
+ justify-items: center;
+ align-content: start;
+ padding: clamp(28px, calc(50vh - 260px), 24vh) 24px 32px 34px;
+
+ /* The one filled control takes the app's own accent — the same blue the app it opens into
+ uses, as Apple's own sign-in sheets do. Said outright here: with no app open yet,
+ tokens.css hands :root the brand gold in light (white on it is 2.8:1), and a custom
+ property resolves where it is declared, so the ring is re-derived too. The fill is the
+ deeper blue, which carries white at 5.6:1 where the bright one manages 3.5:1. */
+ --accent: #0088ff;
+ --accent-strong: #0068d6;
+ --accent-ring: color-mix(in srgb, #0088ff 34%, transparent);
+ --go: #0068d6;
+ --go-text: #fff;
+}
+@media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) .shell {
+ --accent: #0091ff;
+ --accent-strong: #0091ff;
+ --accent-ring: color-mix(in srgb, #0091ff 34%, transparent);
+ }
+}
+:root[data-theme="dark"] .shell {
+ --accent: #0091ff;
+ --accent-strong: #0091ff;
+ --accent-ring: color-mix(in srgb, #0091ff 34%, transparent);
+}
+
+/* "Not Now", under the primary when signing in again can wait: the same capsule and height
+ in the quiet fill, so the pair reads as one choice with one default. */
+.sheet > .quiet {
+ width: 100%;
+ height: 40px;
+ margin-top: 8px;
+ font-size: var(--t-15);
}
/* ---- the sign-in sheet ------------------------------------------------------- */
.sheet {
width: 100%;
- max-width: 344px;
+ max-width: 320px;
text-align: center;
}
/* The icon's own grid leaves a margin round the tile, so it is drawn a little larger than
the tile is meant to look. */
.mark {
- width: 92px;
- height: 92px;
- margin: -10px auto 10px;
+ width: 80px;
+ height: 80px;
+ margin: 0 auto 14px;
display: block;
user-select: none;
}
+/* Type scale: 22 title, 15 fields and the button, 13 lede and messages, 12 footnotes,
+ 11 the disclosure. Weights are 600 and 400 only — Segoe UI and the Linux fallbacks
+ all have both, and nothing is synthesised. */
.sheet h1 {
- margin: 0 0 7px;
+ margin: 0;
font-size: var(--t-22);
font-weight: 600;
- letter-spacing: -0.021em;
- line-height: 1.2;
+ letter-spacing: -0.012em;
+ line-height: 1.25;
+ text-wrap: balance;
}
.lede {
- margin: 0 auto 24px;
- max-width: 36ch;
+ margin: 6px auto 24px;
+ max-width: 34ch;
color: var(--text-2);
font-size: var(--t-13);
- line-height: 1.5;
+ line-height: 1.45;
+ text-wrap: balance;
}
/* macOS groups related fields into one bordered block with a hairline between them,
rather than floating separate inputs. */
.field-group {
border: 1px solid var(--field-edge);
- border-radius: var(--r-field);
+ border-radius: 10px;
background: var(--field);
box-shadow: var(--shadow-field);
overflow: hidden;
text-align: left;
- transition: border-color 140ms var(--ease);
+ transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease), opacity 140ms var(--ease);
}
.field-group:hover { border-color: var(--field-edge-hover); }
@@ -70,182 +123,167 @@
box-shadow: var(--shadow-field), 0 0 0 3px var(--accent-ring);
}
+.field-group.is-invalid { border-color: var(--danger); }
+.field-group.is-invalid:focus-within {
+ box-shadow: var(--shadow-field), 0 0 0 3px color-mix(in srgb, var(--danger) 26%, transparent);
+}
+
.field-group input {
+ display: block;
width: 100%;
+ height: 42px;
border: 0;
+ margin: 0;
background: transparent;
color: var(--text);
font: inherit;
font-size: var(--t-15);
- padding: 10px 12px;
+ padding: 0 13px;
outline: none;
}
-.field-group input::placeholder { color: var(--text-3); }
+.field-group input::placeholder { color: var(--text-3); opacity: 1; }
.field-group input + input { border-top: 1px solid var(--separator); }
+/* Held while Apple answers: the fields stay put and simply quieten. */
+.field-group input:disabled { color: var(--text-2); }
+.sheet[aria-busy="true"] .field-group { opacity: 0.6; }
-/* ---- buttons ----------------------------------------------------------------- */
+/* ---- the sign-in sheet's own buttons ------------------------------------------- */
-/*
- * White on the plain quince gold measures 2.8:1 — well under the 4.5:1 white text needs, and
- * it stood that way until an Upload button put a primary control on an audited screen for the
- * first time. The deeper gold measures 6.3:1 and is the same hue, so the accent is unchanged
- * and the label is legible.
- */
-.primary {
- border: 0;
- /* A capsule, as macOS 27's regular-size buttons are. */
- border-radius: var(--r-pill);
- background: var(--accent-deep);
- color: #fff;
- font: inherit;
- font-size: var(--t-13);
- font-weight: 550;
- min-height: 28px;
- padding: 5px 16px;
- cursor: pointer;
+/* The one thing on the screen, so it takes the width. Its height never changes: the busy
+ spinner and the countdown sit inside the same 40px. */
+.sheet .primary {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ width: 100%;
+ height: 40px;
+ margin-top: 16px;
+ padding: 0 16px;
+ background: var(--go);
+ color: var(--go-text);
+ font-size: var(--t-15);
+ font-weight: 600;
+ font-variant-numeric: tabular-nums;
+ transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
-
-/* A Mac button keeps its colour under the pointer; pressing darkens its own colour. */
-.primary:active:not(:disabled) { background: color-mix(in srgb, var(--accent-deep) 84%, #000); }
-.primary:disabled {
- background: color-mix(in srgb, var(--text) 11%, transparent);
+.sheet .primary:active:not(:disabled) { background: color-mix(in srgb, var(--go) 86%, #000); }
+/* Nothing to send yet, or Apple asked for a wait: plainly not pressable. */
+.sheet .primary:disabled {
+ background: color-mix(in srgb, var(--text) 8%, transparent);
color: var(--text-3);
- cursor: default;
-}
-.primary:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
-
-/* A secondary button, as macOS 27 draws one at regular size: a capsule of quiet fill and
- no outline (Button/Radius 1000 from Large up in Apple's kit). It used to be bare
- coloured text that underlined on hover, which reads as a link; then a hairline-bordered
- plateau, which is the pre-Tahoe shape. */
-.quiet {
- border: 0;
- background: color-mix(in srgb, var(--text) 7%, transparent);
- box-shadow: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- font-weight: 510;
- cursor: pointer;
- min-height: 28px;
- padding: 4px 14px;
- border-radius: var(--r-pill);
- white-space: nowrap;
-}
-
-.quiet:hover:not(:disabled) {
- background: color-mix(in srgb, var(--text) 11%, transparent);
}
-.quiet:active:not(:disabled) {
- background: color-mix(in srgb, var(--text) 16%, transparent);
+/* Signing in is not "unavailable": the button keeps its colour and only softens. */
+.sheet[aria-busy="true"] .primary:disabled {
+ background: color-mix(in srgb, var(--go) 72%, transparent);
+ color: var(--go-text);
}
-.quiet:disabled { color: var(--text-3); cursor: default; }
-.quiet:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
-
-/* The sign-in screen's button is the one thing on the screen, so it takes the width and
- the weight. Everywhere else it is one control among several. */
-.shell .primary { margin-top: 18px; width: 100%; font-size: var(--t-15); padding: 10px 16px; }
-
-.quiet.danger { color: var(--danger); }
-.quiet.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
-
-/* The sign-in screen's own buttons sit under a form and need the gap they had. */
-.shell .quiet { margin-top: 14px; }
+/* The secondary ways out of a sheet: the kit's text button, a little roomier. */
+.sheet .link { padding: 4px 8px; }
/* ---- footnotes --------------------------------------------------------------- */
+/* The line under the sheet's main control. Its height is kept whether it is empty, says
+ "Checking", or holds a two-line error, so nothing under it moves when it changes. */
+.sheet-status {
+ min-height: 38px;
+ margin-top: 12px;
+ display: flex;
+ justify-content: center;
+ align-items: flex-start;
+}
+.sheet-status > p { margin: 0; max-width: 34ch; font-size: var(--t-13); line-height: 1.4; }
+
.assurance {
- margin: 22px auto 0;
+ margin: 0 auto;
max-width: 40ch;
color: var(--text-2);
- font-size: var(--t-11);
- line-height: 1.55;
-}
-
-.disclaimer {
- margin: 10px auto 0;
- color: var(--text-3);
- font-size: var(--t-11);
+ font-size: 12px;
+ line-height: 1.5;
}
+.sheet-status > .assurance { max-width: none; font-size: 12px; line-height: 1.6; }
-.notice {
- margin: 16px auto 0;
- max-width: 34ch;
- color: var(--text-2);
- font-size: var(--t-13);
-}
+.sheet-foot { margin-top: 28px; display: grid; justify-items: center; gap: 4px; }
/* Recovery options stay folded away until asked for: the code field is the task. */
.help {
- margin: 18px auto 0;
- max-width: 38ch;
+ margin: -6px auto 0;
text-align: left;
- padding: 14px 15px;
- border-radius: var(--r-field);
+ padding: 14px 16px;
+ border-radius: 12px;
background: color-mix(in srgb, var(--text) 4.5%, transparent);
}
.help p {
- margin: 0 0 10px;
- color: var(--text-2);
- font-size: var(--t-11);
- line-height: 1.55;
+ margin: 0;
+ /* A step darker than secondary text: on the panel's tint, --text-2 falls just short of
+ 4.5:1. */
+ color: color-mix(in srgb, var(--text) 74%, var(--bg));
+ font-size: 12px;
+ line-height: 1.5;
}
-
-.help p:last-child { margin-bottom: 0; }
.help strong { color: var(--text); font-weight: 600; }
+.help .help-warn { color: var(--danger); margin-bottom: 8px; }
+.help > :first-child { margin-top: 0; }
.help-actions {
display: flex;
- flex-direction: column;
- align-items: flex-start;
- gap: 2px;
- margin: 0 0 10px;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin: 12px 0 0;
}
+.help-actions .quiet { font-variant-numeric: tabular-nums; }
-.help-actions .quiet { margin-top: 0; padding: 3px 6px; }
-
-.error {
- margin: 16px auto 0;
- max-width: 32ch;
- color: var(--danger);
- font-size: var(--t-13);
- line-height: 1.45;
+.help .help-tip {
+ margin-top: 12px;
+ padding-top: 12px;
+ border-top: 1px solid var(--separator);
}
/* ---- six-digit code ---------------------------------------------------------- */
.code {
display: flex;
- gap: 7px;
+ gap: 8px;
justify-content: center;
}
-.code .gap { width: 9px; }
+.code .gap { width: 10px; }
.code input {
- width: 40px;
- height: 50px;
+ width: 42px;
+ height: 52px;
+ padding: 0;
text-align: center;
- font-size: var(--t-22);
+ font: inherit;
+ font-size: 24px;
font-weight: 500;
font-variant-numeric: tabular-nums;
color: var(--text);
background: var(--field);
border: 1px solid var(--field-edge);
- border-radius: var(--r-field);
+ border-radius: 10px;
box-shadow: var(--shadow-field);
+ caret-color: var(--accent);
outline: none;
- transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
+ transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease), opacity 140ms var(--ease);
}
+.code input:hover:not(:disabled) { border-color: var(--field-edge-hover); }
+
.code input:focus {
border-color: var(--accent);
box-shadow: var(--shadow-field), 0 0 0 3px var(--accent-ring);
}
+.code.is-invalid input { border-color: var(--danger); }
+.code.is-invalid input:focus {
+ box-shadow: var(--shadow-field), 0 0 0 3px color-mix(in srgb, var(--danger) 26%, transparent);
+}
+.code input:disabled { opacity: 0.55; }
+
/* ---- library ----------------------------------------------------------------- */
.library {
@@ -379,20 +417,6 @@
gap: 4px;
}
-/* A footer link, not a control to press by accident: the one place a bordered button
- would be heavier than what it does. */
-.sidebar-signout {
- align-self: flex-start;
- font-size: var(--t-11);
- border: 0;
- background: none;
- box-shadow: none;
- color: var(--accent-strong);
- padding: 4px 8px;
-}
-
-.sidebar-signout:hover:not(:disabled) { background: none; text-decoration: underline; }
-
.sidebar h2 {
margin: 6px 8px 10px;
font-size: var(--t-11);
@@ -407,7 +431,8 @@
gap: 10px;
min-height: 34px;
white-space: nowrap;
- transition: background 120ms ease;
+ /* No transition here: what the base state is reached by — the current app changing, the
+ pointer leaving — happens at once, so the selection moves crisply, as in a Mac sidebar. */
width: 100%;
border: 0;
background: none;
@@ -465,12 +490,6 @@
.nav-name { overflow: hidden; text-overflow: ellipsis; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 6px; min-height: 28px; }
.sidebar-head h2 { margin: 0 8px; }
-.sidebar-fold {
- display: grid; place-items: center; width: 28px; height: 28px; padding: 0; flex: none;
- border: 0; border-radius: 7px; background: none; box-shadow: none; color: var(--text-2); cursor: pointer;
-}
-.sidebar-fold:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
-.sidebar-fold:focus-visible { outline: 3px solid var(--accent-ring); }
/* Folded: the icons alone, centred, names gone; the foot keeps only its status dot. */
@media (min-width: 901px) {
.is-rail .sidebar { width: 60px; }
@@ -481,54 +500,34 @@
}
@media (max-width: 900px) { .sidebar-fold { display: none; } }
@media (prefers-reduced-motion: reduce) { .content, .sidebar, .nav-item { transition: none; } }
-.nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
+.nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); transition: background-color var(--motion-hover) var(--motion-ease-out); }
+/* Pressed: a shade deeper at once, as a Mac sidebar row darkens under the click. */
+.nav-item:active:not([aria-current="true"]) { background: color-mix(in srgb, var(--text) 12%, transparent); transition: none; }
/* The current app: a neutral highlight, as a Tahoe sidebar draws one, the label unchanged in
colour. Tinting it with the app's accent made three apps — Reminders, Drive, Contacts —
select in the same blue; the icon is what tells them apart. */
-.nav-item[aria-current="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font-weight: 590; }
-.nav-item:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
-
-.nav-toggle {
- margin-top: 6px;
- color: var(--text-2);
-}
+.nav-item[aria-current="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font-weight: 590; transition: none; }
+.nav-item:focus-visible { outline: var(--focus-ring); outline-offset: -1px; }
.badge {
font-size: var(--t-11);
color: var(--text-3);
flex: none;
- opacity: 0.62;
-}
-
-/* The count beside a screen's title, as Reminders shows it: the same size as the heading,
- in a lighter weight and colour, so it reads as part of the title rather than as a stray
- digit that wandered in from somewhere. */
-.cal-nav > .badge {
- font-size: var(--t-22);
- font-weight: 400;
- color: var(--text-3);
- opacity: 1;
- font-variant-numeric: tabular-nums;
- letter-spacing: -0.021em;
+ opacity: 0.85;
}
-.nav-item[aria-current="true"] .nav-toggle {
- margin-top: 6px;
- color: var(--text-2);
-}
-
-.badge { opacity: 0.85; }
-
/* Full-bleed, so it passes under the floating sidebar as it scrolls. */
.content {
height: 100%;
overflow-y: auto;
- padding: 28px 34px 28px var(--side, 236px);
+ padding: 28px 34px 28px var(--side, 220px);
/* No transition: folding the sidebar slides the content on the compositor instead
(Library's slideContent) — a padding animated here re-laid out the whole screen on
every frame. */
}
-.library { --side: 236px; }
+/* The content begins 16px past the sidebar's card (8px in, 196px wide), open or folded alike:
+ a wider gutter here left a band of nothing between the sidebar and every app. */
+.library { --side: 220px; }
.library.is-rail { --side: 84px; }
.sidebar-toggle, .sidebar-scrim, .compact-back { display: none; }
@@ -577,7 +576,7 @@
color: var(--text);
cursor: default;
}
- .sidebar-toggle:focus-visible { outline: 3px solid var(--accent-ring); }
+ .sidebar-toggle:focus-visible { outline: var(--focus-ring); }
.is-sidebar-open .sidebar-scrim {
position: absolute;
z-index: 25;
@@ -623,192 +622,18 @@
*/
.content p:not([class]) { margin: 0 0 18px; color: var(--text-2); font-size: var(--t-15); max-width: 62ch; }
-.toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
-
/* ---- the one orchestrated moment: sign-in dissolving into the library ---------- */
-.enter-sheet { animation: sheet-in 420ms var(--ease) both; }
+/* Opacity only, short, and not held afterwards ("backwards", not "both"): a sheet that moved
+ or scaled in sat in an animated compositor layer, and WebKitGTK on Hyprland flickers those. */
+.enter-sheet { animation: sheet-in 200ms ease-out backwards; }
+@media (prefers-reduced-motion: reduce) { .enter-sheet { animation: none; } }
/* The library simply appears: a whole-window animation, held at its last frame forever by
"both", kept the entire app inside an animated layer of WebKitGTK's — and every animation
handed to the compositor glitched on his screen. */
@keyframes sheet-in {
- from { opacity: 0; transform: translateY(8px) scale(0.985); }
- to { opacity: 1; transform: none; }
-}
-
-
-/* ---- calendar: month grid ------------------------------------------------------
- Apple's Calendar is a month grid, not a list. Weekday header, six rows of seven, the day
- number in the corner, events as coloured chips, today marked with the accent. */
-
-.cal { display: flex; flex-direction: column; height: 100%; min-height: 0; }
-
-.cal-bar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 16px;
- margin-bottom: 14px;
-}
-
-/* Title and its count sit together, as one thing. */
-.cal-nav { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
-
-.cal-nav h1 {
- margin: 0;
- font-size: var(--t-22);
- font-weight: 600;
- letter-spacing: -0.021em;
-}
-
-/* Only the calendar needs a reserved width, and only so the arrows either side of a month
- name stay put as it changes. Everywhere else it left the count stranded beside a short
- title with nothing between them. */
-.cal .cal-nav h1 { min-width: 8.5ch; margin-right: 10px; }
-
-.chev {
- width: 26px;
- height: 24px;
- border: 1px solid var(--field-edge);
- background: var(--field);
- color: var(--text);
- border-radius: var(--r-field);
- font-size: var(--t-15);
- line-height: 1;
- cursor: pointer;
-}
-
-.chev:hover { background: color-mix(in srgb, var(--text) 7%, var(--field)); }
-.chev:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
-
-.today-btn {
- height: 24px;
- padding: 0 11px;
- border: 1px solid var(--field-edge);
- background: var(--field);
- color: var(--text);
- border-radius: var(--r-field);
- font: inherit;
- font-size: var(--t-13);
- cursor: pointer;
-}
-
-.today-btn:hover { background: color-mix(in srgb, var(--text) 7%, var(--field)); }
-.today-btn:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
-
-.cal-actions { display: flex; align-items: center; gap: 12px; }
-
-.daynum {
- align-self: flex-start;
- font-size: var(--t-11);
- font-weight: 550;
- color: var(--text-2);
- min-width: 18px;
- height: 18px;
- line-height: 18px;
- text-align: center;
- border-radius: var(--r-pill);
- font-variant-numeric: tabular-nums;
-}
-
-/* White on the standard gold falls below 4.5:1, so today's badge uses a deeper shade. */
-.daynum.is-today {
- background: var(--accent-deep);
- color: #fff;
- font-weight: 650;
-}
-
-.chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
-
-.chip {
- display: flex;
- align-items: center;
- gap: 4px;
- min-width: 0;
- font-size: var(--t-11);
- line-height: 1.35;
- padding: 1px 4px;
- border-radius: 4px;
- white-space: nowrap;
- overflow: hidden;
-}
-
-.chip:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
-
-.chip-dot { width: 6px; height: 6px; border-radius: var(--r-pill); flex: none; }
-.chip-time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
-.chip-title { overflow: hidden; text-overflow: ellipsis; }
-
-/* An all-day event reads as a filled bar, the way Apple shows it. */
-.chip.all-day { color: #fff; font-weight: 550; }
-.chip.all-day:hover { filter: brightness(1.06); }
-
-.chip.more { color: var(--text-3); }
-
-.cal-empty { margin-top: 14px; color: var(--text-2); max-width: 54ch; }
-
-/* The content pane holds the grid, so it must not scroll independently. */
-.content[data-screen="calendar"] { display: flex; flex-direction: column; overflow: hidden; }
-
-.rem-lists {
- overflow-y: auto;
- padding-right: 4px;
- border-right: 1px solid var(--separator);
-}
-
-.rem-list {
- display: flex;
- align-items: center;
- gap: 8px;
- width: 100%;
- border: 0;
- background: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- text-align: left;
- padding: 6px 8px;
- border-radius: var(--r-field);
- cursor: pointer;
-}
-
-.rem-list:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.rem-list[aria-current="true"] { background: var(--accent-tint); font-weight: 550; }
-.rem-list:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
-.rem-list-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-
-/* A reminder in the calendar reads as a task, not an event: a ring rather than a dot. */
-.chip.reminder .chip-title { color: var(--text); }
-
-.chip-ring {
- width: 7px;
- height: 7px;
- border-radius: var(--r-pill);
- border: 1.5px solid var(--text-3);
- flex: none;
- box-sizing: border-box;
-}
-
-.chip.reminder.is-done .chip-title,
-.chip.reminder.is-done .chip-time {
- color: var(--text-3);
- text-decoration: line-through;
-}
-
-.chip.reminder.is-done .chip-ring {
- background: var(--text-3);
- border-color: var(--text-3);
-}
-
-.pin { color: var(--accent); font-size: 9px; margin-right: 5px; vertical-align: 2px; }
-
-.quiet.danger { color: var(--danger); }
-
-/* Four columns do not fit a half-screen window: at 958px the body was reduced to about
- 200px, wrapping every few words. Below this width the folder column folds away and its
- choice moves into the list, which is what Apple does when space runs out. */
-@media (max-width: 1180px) {
+ from { opacity: 0; }
}
/* ---- contacts -------------------------------------------------------------------
@@ -832,10 +657,10 @@
border-right: 1px solid var(--separator);
}
.contacts-list-glyph { flex: none; color: var(--text-2); }
-.contacts-lists .notes-folder-row.is-drop .notes-folder {
- background: var(--accent-tint);
- box-shadow: inset 0 0 0 2px var(--accent);
-}
+.contacts-head { margin-bottom: 8px; }
+.contacts-head-actions { display: flex; gap: 2px; }
+.contacts-search { margin-bottom: 8px; }
+.contact-none { margin: 14px 0 0; color: var(--text-2); }
.contacts-list-picker { display: none; margin-bottom: 8px; }
.contacts-list-picker .picker { width: 100%; }
/* The lists fold into a picker above the people first. */
@@ -863,26 +688,22 @@
padding: 0 14px 0 0;
}
-.contacts-list .cal-bar { flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 8px; }
-.contacts-list .cal-nav h1 { font-size: var(--t-17); }
-
-.contacts-search {
- width: 100%;
- font: inherit;
- font-size: var(--t-13);
- color: var(--text);
- background: var(--field);
- border: 1px solid var(--field-edge);
- border-radius: var(--r-field);
- padding: 5px 9px;
- margin-bottom: 8px;
- outline: none;
+/* The list and the letter index beside it share what is left of the column's height. */
+.contact-rows-wrap { display: flex; flex: 1 1 auto; min-height: 0; }
+.contact-rows { position: relative; flex: 1 1 auto; min-width: 0; list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
+/* A long address book lays out and paints only the rows in view. */
+.contact-rows > li:not(.contact-letter) { content-visibility: auto; contain-intrinsic-size: auto 38px; }
+.contact-index {
+ display: flex; flex-direction: column; justify-content: center; flex: none;
+ width: 16px; margin-left: 2px; padding: 4px 0;
+ touch-action: none; user-select: none; -webkit-user-select: none;
}
-
-.contacts-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
-.contacts-search::placeholder { color: var(--text-3); }
-
-.contact-rows { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
+.contact-index button {
+ flex: 0 1 18px; min-height: 0; padding: 0; border: 0; background: none;
+ color: var(--accent-strong); font: inherit; font-size: 10px; font-weight: 600; line-height: 1;
+ cursor: pointer;
+}
+.contact-index button:hover { color: var(--text); }
.contact-row {
display: flex;
@@ -903,8 +724,8 @@
.contact-row:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
/* As macOS selects: the accent with white text while the list has focus, grey after. */
.contact-row[aria-current="true"] { background: color-mix(in srgb, var(--text) 11%, transparent); }
-.contact-rows:focus-within .contact-row[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
-.contact-rows:focus-within .contact-row[aria-current="true"] .avatar:not(:has(img)) { background: rgba(255, 255, 255, 0.28); color: #fff; }
+.contact-rows.is-focused .contact-row[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
+.contact-rows.is-focused .contact-row[aria-current="true"] .avatar:not(:has(img)) { background: rgba(255, 255, 255, 0.28); color: #fff; }
.contact-row:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
.contact-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Several picked: their faces fanned, the count, and what can be done to all of them. */
@@ -914,7 +735,7 @@
.contact-many h2 { margin: 0; font-size: var(--t-17); }
/* "me" beside this person's own card, as Contacts marks it. */
.contact-me { margin-left: auto; color: var(--text-3); font-size: var(--t-11); }
-.contact-rows:focus-within .contact-row[aria-current="true"] .contact-me { color: var(--on-accent-2); }
+.contact-rows.is-focused .contact-row[aria-current="true"] .contact-me { color: var(--on-accent-2); }
.avatar {
width: 26px;
@@ -979,7 +800,18 @@
border-top: 1px solid var(--separator);
}
-.contact-methods dt { color: var(--text-2); font-size: var(--t-11); padding-top: 2px; }
+/* Labels right-aligned against their values, grey and small, as Contacts on the Mac sets a card. */
+.contact-methods dt { color: var(--text-2); font-size: var(--t-11); padding-top: 3px; text-align: right; }
+.contact-copy {
+ display: inline-grid; justify-items: end; padding: 0; border: 0; background: none;
+ color: inherit; font: inherit; text-align: right; cursor: copy;
+}
+/* The two words swap at once: a CSS fade is the kind WebKitGTK glitches (lib/fade.ts). */
+.contact-copy > span { grid-area: 1 / 1; }
+.contact-copy > span.is-hidden { opacity: 0; }
+.contact-copy > span:last-child { color: var(--accent-strong); }
+.contact-copy:hover > span:first-child { color: var(--text); }
+.contact-copy:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; border-radius: 3px; }
.contact-methods dd { margin: 0; font-size: var(--t-15); overflow-wrap: anywhere; }
/* A postal address is several lines and reads as several lines. */
@@ -1016,18 +848,38 @@
background: none;
color: var(--text-2);
font: inherit;
- font-size: var(--t-15);
- padding: 2px 5px;
- border-radius: var(--r-field);
+ font-size: var(--t-13);
+ padding: 0 4px;
+ border-radius: 5px;
cursor: pointer;
}
-.crumb:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
-.crumb[aria-current="true"] { color: var(--text); font-weight: 600; }
-.crumb:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
+.crumb:hover { background: var(--fill); color: var(--text); }
+/* The folder open is the pane's title (PaneTitle); the path back sits small above it. */
+.pane-title h1 > .crumb { padding: 0; font: inherit; letter-spacing: inherit; color: var(--text); text-align: start; cursor: default; }
+.pane-title h1 > .crumb:hover { background: none; }
+.crumb:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
.crumb-sep { color: var(--text-3); padding: 0 1px; }
.drive-rows { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; min-height: 0; }
+/* A folder of thousands lays out and paints only the rows in view. */
+.drive-rows:not(.is-grid) > li[data-id] { content-visibility: auto; contain-intrinsic-size: auto 39px; }
+.drive-col-turn { white-space: pre; }
+/* Quick Look: Apple's picture of the file, large, on a sheet that fades in (lib/fade.ts). */
+.drive-peek { width: min(520px, 92vw); max-height: 88vh; align-items: center; text-align: center; gap: 6px; }
+.drive-peek-face {
+ display: grid; place-items: center; width: 160px; height: 160px; margin: 6px auto 10px;
+ border-radius: 22px; background: color-mix(in srgb, var(--text) 6%, transparent);
+}
+.drive-peek-face > svg { transform: scale(4); }
+.drive-peek-face.has-thumb { width: auto; height: auto; max-width: 100%; background: none; }
+.drive-peek-face.has-thumb img {
+ display: block; max-width: min(460px, 84vw); max-height: 52vh; min-width: 160px; object-fit: contain;
+ border-radius: 8px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.2);
+}
+.drive-peek-name { margin: 0; font-size: var(--t-15); font-weight: 600; overflow-wrap: anywhere; }
+.drive-peek-facts { margin: 0; color: var(--text-2); font-size: var(--t-12, 12px); }
+.drive-peek-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
/* Grid, as icloud.com and Finder's icon view lay it out: a large mark, the name under it in
two lines at most, the size and date left to List. Actions stay on hover, over the tile. */
.drive-rows.is-grid {
@@ -1132,13 +984,6 @@
border-bottom: 1px solid var(--separator);
}
-.drive-saved {
- margin: 6px 0 0;
- font-size: var(--t-11);
- color: var(--accent-strong);
- animation: rem-moved-in 240ms var(--ease-spring) both;
-}
-
/* The icon carries its own colour and needs no plate behind it. */
.drive-badge {
display: grid;
@@ -1146,47 +991,6 @@
height: 22px;
}
-.drive-spinner {
- width: 13px;
- height: 13px;
- border-radius: var(--r-pill);
- border: 1.6px solid color-mix(in srgb, var(--text) 22%, transparent);
- border-top-color: var(--text-2);
- animation: drive-spin 640ms linear infinite;
-}
-
-@keyframes drive-spin { to { transform: rotate(360deg); } }
-
-@media (prefers-reduced-motion: reduce) {
- .drive-spinner { animation-duration: 2s; }
-}
-
-/*
- * What can be done to a row.
- *
- * These used to borrow the Reminders row-action style, whose reveal rule keys off a class
- * these rows do not have — so they were left at zero opacity and no amount of hovering
- * brought them back. Downloading, renaming, moving and deleting were all implemented and
- * none of them could be reached.
- */
-.drive-action {
- display: grid;
- place-items: center;
- width: 26px;
- height: 26px;
- border: 0;
- border-radius: var(--r-field);
- background: none;
- color: var(--text-2);
- cursor: pointer;
- transition: background 120ms var(--ease), color 120ms var(--ease);
-}
-
-.drive-action:hover { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
-.drive-action.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
-.drive-action:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
-.drive-action:disabled { opacity: 0.4; cursor: default; }
-
/* A button whose icon sits with its label rather than replacing it. */
.with-glyph {
display: inline-flex;
@@ -1207,9 +1011,8 @@
place-items: center;
border-radius: var(--r-plateau);
border: 2px dashed var(--accent-ring);
- background: color-mix(in srgb, var(--accent-tint) 70%, transparent);
- -webkit-backdrop-filter: blur(2px);
- backdrop-filter: blur(2px);
+ /* A tint, not a blur: a window-sized backdrop blur is WebKitGTK's costliest frame. */
+ background: color-mix(in srgb, var(--accent-tint) 80%, transparent);
color: var(--accent-strong);
font-size: var(--t-13);
font-weight: 600;
@@ -1230,6 +1033,8 @@
*/
@container (max-width: 560px) {
.drive-row { position: relative; }
+ /* Set as Files on iPhone sets a row: name, then size and date; the kind has no place. */
+ .drive-row-hit > .drive-kind { display: none; }
.drive-row-hit {
grid-template-columns: 28px auto minmax(0, 1fr);
grid-template-areas: "badge name name" "badge size date";
@@ -1261,33 +1066,6 @@
.drive-row-actions:focus-within { pointer-events: auto; }
}
-/* ---- reminders: smart lists, inline editing, flags ------------------------------ */
-
-/* Lines up with the list names beneath it, not with their icons — the heading used to sit
- nineteen pixels to their left, which read as a column that had slipped. 8px of row
- padding, a 16px icon, and the 8px gap between them is where the names begin. */
-/*
- * Sits on the same left edge as the icons in the rows beneath it, which is where Apple puts a
- * section heading in a source list. It was inset a further 24px to line up with the row
- * *labels* instead, leaving it adrift of both the cards above and the icons below.
- */
-.rem-lists-heading {
- margin: 14px 0 4px;
- padding-left: 8px;
- font-size: var(--t-11);
- font-weight: 600;
- letter-spacing: 0.02em;
- color: var(--text-3);
-}
-
-@keyframes rem-moved-in {
- from { opacity: 0; transform: translateY(-4px); }
- to { opacity: 1; transform: none; }
-}
-
-.rem-list.add { color: var(--text-3); }
-.rem-list.add:hover { color: var(--text-2); }
-
.cal-form-actions {
grid-column: 1 / -1;
display: flex;
@@ -1355,7 +1133,7 @@
margin: 0;
padding: 5px;
list-style: none;
- border-radius: 12px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--glass-float);
color: var(--text);
@@ -1397,41 +1175,6 @@
.picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
-/* ── Scope control ──────────────────────────────────────────────────────────────────────
- Calendar's Day / Week / Month / Year, as a segmented control: one recessed track with a
- raised cap over the active segment, which is the macOS shape. */
-.segmented {
- display: inline-flex;
- padding: 2px;
- gap: 2px;
- border-radius: var(--r-field);
- background: color-mix(in srgb, var(--text) 7%, transparent);
-}
-
-.segment {
- border: 0;
- background: none;
- font: inherit;
- font-size: var(--t-11);
- font-weight: 510;
- color: var(--text-2);
- padding: 3px 10px;
- border-radius: 5px;
- cursor: pointer;
- transition: background 140ms var(--ease), color 140ms var(--ease);
-}
-
-.segment:hover { color: var(--text); }
-
-.segment[aria-pressed="true"] {
- background: var(--sheet);
- color: var(--text);
- font-weight: 590;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 0 0 0.5px var(--glass-edge);
-}
-
-.segment:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
-
/* ── Editing a contact ──────────────────────────────────────────────────────────────────
The card and the editor are the same surface: the same measure, the same rhythm, so
pressing Edit changes what you can do rather than where you are. */
@@ -1503,52 +1246,6 @@
/* Apple's label picked from a list; a custom one typed under it, in the same column. */
.contact-label-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
-/* ── Modal sheet ────────────────────────────────────────────────────────────────────────
- The Move dialog is the app's first modal, so this is the shape everything after it will
- share: a dimmed veil behind a raised sheet, in the macOS sheet's proportions rather than
- a full-screen dialog. */
-.modal-veil {
- position: fixed;
- inset: 0;
- z-index: 100;
- display: grid;
- place-items: center;
- /* A dim, not a blur: macOS dims the window behind a sheet, and a blur of the whole
- window under glass was glass on glass — and in WebKitGTK the costliest frame there is. */
- background: rgba(0, 0, 0, 0.2);
- /* At once: a full-window dim is never animated (the sheet on it fades in; see fadeSheetsIn). */
-}
-
-
-.modal-sheet {
- width: min(440px, 92vw);
- max-height: min(560px, 84vh);
- display: flex;
- flex-direction: column;
- gap: 12px;
- padding: 20px 22px;
- border-radius: var(--r-window);
- background: var(--glass-thick);
- box-shadow: var(--glass-float);
- /* Simply there, as the menus and popovers are: grown in on a spring, the sheet glitched
- as it came in on WebKitGTK. The window dims behind it. */
-}
-
-@keyframes modal-sheet-in {
- from { opacity: 0; scale: 0.94; }
- 60% { opacity: 1; }
- to { opacity: 1; scale: 1; }
-}
-
-.modal-sheet h2 {
- margin: 0;
- font-size: var(--t-17);
- font-weight: 600;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
.move-sheet-list {
flex: 1;
min-height: 120px;
@@ -1560,6 +1257,7 @@
border-radius: var(--r-plateau);
}
+.move-sheet-none { padding: 10px 12px; color: var(--text-2); }
.move-sheet-row {
grid-template-columns: 28px 1fr;
padding: 7px 9px;
@@ -1606,44 +1304,56 @@
* the screen is not read, and a page nobody reads discloses nothing.
*/
.disclosure {
- margin-top: 12px;
+ margin-top: 6px;
font-size: var(--t-11);
- color: var(--text-3);
+ color: var(--text-2);
text-align: left;
}
.disclosure > summary {
cursor: pointer;
list-style: none;
- text-align: center;
- padding: 4px;
- border-radius: var(--r-field);
+ width: fit-content;
+ margin: 0 auto;
+ padding: 4px 8px;
+ border-radius: 6px;
+ user-select: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
+/* Drawn, not a ⌄ character: Segoe UI has no such glyph and Windows put a comma there. */
.disclosure > summary::after {
- content: " ⌄";
+ content: "";
+ display: inline-block;
+ width: 5px;
+ height: 5px;
+ margin: 0 0 3px 7px;
+ border-right: 1.5px solid currentColor;
+ border-bottom: 1.5px solid currentColor;
+ transform: rotate(45deg);
opacity: 0.7;
}
-.disclosure[open] > summary::after { content: " ⌃"; }
-.disclosure > summary:hover { color: var(--text-2); }
+.disclosure[open] > summary::after { transform: rotate(-135deg); margin-bottom: 0; }
+.disclosure > summary:hover { color: var(--text); }
.disclosure > summary:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--accent-ring);
}
.disclosure-body {
- margin-top: 6px;
- padding: 10px 12px;
- border-radius: var(--r-field);
+ margin-top: 8px;
+ padding: 12px 14px;
+ border-radius: 12px;
+ color: var(--text-2);
+ font-size: 12px;
background: color-mix(in srgb, var(--text) 4%, transparent);
- max-height: 210px;
+ max-height: min(210px, 34vh);
overflow-y: auto;
}
.disclosure-body p { margin: 0 0 8px; line-height: 1.5; }
.disclosure-body p:last-child { margin-bottom: 0; }
-.disclosure-body strong { color: var(--text-2); font-weight: 600; }
+.disclosure-body strong { color: var(--text); font-weight: 600; }
.disclosure-body code {
font-size: 0.95em;
padding: 1px 4px;
@@ -1665,7 +1375,7 @@
flex-direction: column;
min-width: 150px;
padding: 5px;
- border-radius: 12px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--glass-float);
}
@@ -1694,7 +1404,7 @@
display: flex;
flex-direction: column;
border: 1px solid var(--glass-edge);
- border-radius: 12px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--shadow-sheet), var(--glass-specular);
overflow: hidden;
@@ -1708,39 +1418,8 @@
}
.upload-tray-title { font-size: var(--t-13); font-weight: 600; }
.upload-tray-percent { color: var(--text-2); font-size: var(--t-13); font-variant-numeric: tabular-nums; }
-.upload-tray-close {
- padding: 2px 10px;
- border: 0;
- border-radius: var(--r-pill);
- background: color-mix(in srgb, var(--text) 10%, transparent);
- color: var(--text);
- font: inherit;
- font-size: var(--t-11);
- font-weight: 600;
- cursor: default;
-}
-.upload-tray-close:focus-visible { outline: 3px solid var(--accent-ring); }
-.upload-bar {
- height: 4px;
- margin: 0 14px 8px;
- border-radius: var(--r-pill);
- background: color-mix(in srgb, var(--text) 10%, transparent);
- overflow: hidden;
-}
-/* The fill grows by scale, on the compositor: a width animated here laid out the tray on
- every step, and coming back to the window replayed every step at once as a glitch. */
-.upload-bar > span {
- display: block;
- width: 100%;
- height: 100%;
- border-radius: inherit;
- background: var(--accent);
- transform-origin: left center;
- transform: scaleX(0);
- transition: transform 200ms var(--ease);
-}
-.upload-tray.is-instant .upload-bar > span { transition: none; }
+.upload-tray > .upload-bar { margin: 0 14px 8px; }
.upload-bar.small { height: 3px; margin: 4px 0 0; }
.upload-rows { margin: 0; padding: 0 6px 8px; list-style: none; overflow-y: auto; }
@@ -1771,38 +1450,6 @@
.upload-row.is-failed .upload-state,
.upload-row.is-failed .upload-where { color: var(--danger); }
-/* Something went wrong: said once, plainly, beside a way to put it away. Shared by every
- screen. */
-.notice {
- display: flex;
- align-items: flex-start;
- gap: 8px;
- margin: 0 0 10px;
- padding: 8px 8px 8px 12px;
- border-radius: 10px;
- background: color-mix(in srgb, var(--danger) 12%, transparent);
- color: var(--text);
- font-size: var(--t-13);
- line-height: 1.4;
-}
-.notice > svg { flex: none; margin-top: 2px; color: var(--danger); }
-.notice p { flex: 1; min-width: 0; margin: 0; }
-.notice-close {
- display: grid;
- place-items: center;
- flex: none;
- width: 22px;
- height: 22px;
- padding: 0;
- border: 0;
- border-radius: 6px;
- background: none;
- color: var(--text-2);
- cursor: default;
-}
-.notice-close:hover { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
-.notice-close:focus-visible { outline: 3px solid var(--accent-ring); }
-
/* A screen that failed to draw, in place of the screen — the rest of the app carries on. */
.screen-failed { max-width: 46ch; margin: 64px auto 0; text-align: center; color: var(--text-2); }
.screen-failed p { margin: 0 0 12px; font-size: var(--t-13); }
@@ -1816,7 +1463,7 @@
.info-sheet { width: min(400px, calc(100vw - 32px)); padding: 0 0 8px; }
.info-head { display: flex; align-items: center; justify-content: center; position: relative; padding: 14px 16px; border-bottom: 1px solid var(--separator); }
.info-head h2 { margin: 0; font-size: var(--t-15); font-weight: 600; }
-.info-done { position: absolute; right: 10px; font-weight: 600; color: var(--sys-blue); }
+.info-done { position: absolute; right: 10px; font-weight: 600; }
.info-mark { display: grid; place-items: center; margin: 18px auto 10px; width: 96px; height: 96px; border-radius: 16px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.info-mark > * { transform: scale(2.6); }
.info-name { margin: 0 20px 14px; text-align: center; font-weight: 600; word-break: break-word; }
@@ -1832,9 +1479,12 @@
.row-menu {
position: fixed; z-index: 60; min-width: 200px; padding: 5px;
display: flex; flex-direction: column; outline: none;
- border-radius: 12px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--glass-float);
+ /* Opens and closes at once, as a macOS menu does, and as the pop-up's menu and search's
+ results do — one rule for every menu. A 120ms fade-and-drop was tried here and flashed on
+ his WebKitGTK (the compositor layer it needs is built on the first frame). */
}
.row-menu-item {
display: flex; align-items: center; gap: 12px; width: 100%; min-height: 24px; padding: 0 12px;
@@ -1853,18 +1503,20 @@
.drive-more { font-size: 9px; letter-spacing: 1px; }
.drive-row.is-menu { background: color-mix(in srgb, var(--text) 8%, transparent); }
.drive-row.is-menu .drive-row-actions { opacity: 1; }
-.drive-count { margin: 0 auto 0 10px; color: var(--text-3); font-size: var(--t-12, 12px); white-space: nowrap; }
/* Selected, as Finder marks it: the accent behind the row, its text in white. */
.drive-row.is-selected { background: var(--sys-blue, #0a84ff); }
.drive-row.is-selected .drive-name, .drive-row.is-selected .drive-meta { color: #fff; }
.drive-rows.is-grid .drive-row.is-selected { background: color-mix(in srgb, var(--sys-blue, #0a84ff) 28%, transparent); box-shadow: inset 0 0 0 2px var(--sys-blue, #0a84ff); }
.drive-rows.is-grid .drive-row.is-selected .drive-name { color: var(--text); }
/* With focus elsewhere the selection stays, quietly — grey, the text its own colour. */
-.drive-rows:not(.is-grid):not(:focus-within) .drive-row.is-selected { background: color-mix(in srgb, var(--text) 11%, transparent); }
-.drive-rows:not(.is-grid):not(:focus-within) .drive-row.is-selected .drive-name { color: var(--text); }
-.drive-rows:not(.is-grid):not(:focus-within) .drive-row.is-selected .drive-meta { color: var(--text-2); }
-.drive-rows:not(.is-grid):not(:focus-within) .drive-row.is-selected .drive-more { color: var(--text); }
-.drive-rows:not(.is-grid):not(:focus-within) .drive-row.is-selected .drive-badge > svg { filter: none; }
+/* "Focused" is a class the list sets as the focus comes into it and leaves, not :focus-within:
+ WebKit restyled every row under a :focus-within ancestor at each move of the focus between
+ rows — 130 ms an arrow press in a folder of thousands. The same for Contacts' list. */
+.drive-rows:not(.is-grid):not(.is-focused) .drive-row.is-selected { background: color-mix(in srgb, var(--text) 11%, transparent); }
+.drive-rows:not(.is-grid):not(.is-focused) .drive-row.is-selected .drive-name { color: var(--text); }
+.drive-rows:not(.is-grid):not(.is-focused) .drive-row.is-selected .drive-meta { color: var(--text-2); }
+.drive-rows:not(.is-grid):not(.is-focused) .drive-row.is-selected .drive-more { color: var(--text); }
+.drive-rows:not(.is-grid):not(.is-focused) .drive-row.is-selected .drive-badge > svg { filter: none; }
/* Apple's own picture of a file: small in a list, the tile's face in Grid, as icloud.com. */
.drive-thumb { width: 22px; height: 22px; object-fit: contain; border-radius: 3px; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.25); background: #fff; }
.drive-rows.is-grid .drive-badge:has(.drive-thumb) { transform: none; height: 76px; }
@@ -1894,25 +1546,20 @@
.drive-col.is-on { color: var(--text-2); font-weight: 600; }
.drive-col:hover { color: var(--text); }
.drive-kind { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-/* Drive's bar: the path and its count stay one line and give way first; the controls wrap
- beneath only when the window is too narrow for both. At 760px the title broke in two and
- ran into its own count. */
-.drive > .cal-bar { flex-wrap: wrap; row-gap: 10px; }
-.drive > .cal-bar .crumbs { flex-wrap: nowrap; overflow: hidden; }
-.drive > .cal-bar .crumb { white-space: nowrap; }
-.drive > .cal-bar .drive-title { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
-/* The name's first letter in line with its count's. */
-.drive > .cal-bar .drive-title .crumbs { margin-left: -5px; }
-.drive > .cal-bar .drive-count { margin: 0; overflow: hidden; text-overflow: ellipsis; }
-.drive > .cal-bar .cal-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
+/* Drive's bar: the title takes what room there is; the controls wrap beneath only when the
+ window is too narrow for both. */
+.drive-bar { flex-wrap: wrap; row-gap: 10px; margin-bottom: 10px; }
+.drive-bar .crumbs { display: flex; flex-wrap: wrap; margin-left: -4px; }
+.drive-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
+.drive-tools .primary { min-height: var(--h-tool); }
/* Sized by Drive's own width, not the window's: half a screen, a folded sidebar, a wide
one — each lays out the same for the same room. */
.drive { container-type: inline-size; }
@container (max-width: 880px) {
/* Too narrow for the named controls beside the name: icons alone, their names kept for
anyone who cannot see them (title, aria). */
- .drive > .cal-bar .with-glyph:not(.primary) { font-size: 0; gap: 0; padding-inline: 9px; }
- .drive > .cal-bar .with-glyph:not(.primary) svg { font-size: initial; }
+ .drive-bar .with-glyph:not(.primary) { font-size: 0; gap: 0; padding-inline: 7px; }
+ .drive-bar .with-glyph:not(.primary) svg { font-size: initial; }
}
/* Narrower, the kind column goes (above the narrowest, which sets rows as Files on iPhone). */
@container (min-width: 561px) and (max-width: 640px) {
@@ -1921,7 +1568,7 @@
}
@container (max-width: 560px) {
/* Too narrow for both: the controls go under the name, starting at its edge. */
- .drive > .cal-bar .cal-actions { width: 100%; justify-content: flex-start; }
+ .drive-tools { width: 100%; justify-content: flex-start; }
/* Rows set as Files on iPhone sets them have no columns to head; the sort menu stays. */
.drive-head { display: none; }
}
@@ -1936,53 +1583,17 @@
.drive-group { margin: 14px 0 4px; padding: 0 10px; color: var(--text); font-size: var(--t-13); font-weight: 700; }
.drive-recents section:first-of-type .drive-group { margin-top: 4px; }
-/* ── Liquid Glass, shared across the apps ──────────────────────────────────────────────
- macOS 27's search field is a capsule of soft fill (130×24/36, r100 in Apple's kit), in a
- sidebar or a toolbar alike — never a bordered box. */
-:root :is(.notes-search, .rx-search, .contacts-search) {
- border: 0;
- border-radius: var(--r-pill);
- background: color-mix(in srgb, var(--text) 6%, transparent);
- min-height: 28px;
- padding-inline: 12px;
-}
-.contacts-search:focus { box-shadow: 0 0 0 3px var(--accent-ring); }
-
-/* A toolbar's pop-up buttons are capsules beside the capsule buttons they sit with. */
-:root :is(.cal-actions, .note-bar-actions) .picker-button {
- min-height: 28px;
- border-radius: var(--r-pill);
- padding-inline: 12px;
-}
-
-/* A note's tools float together in one glass capsule, as Notes on macOS 27 groups them. */
-.note-bar-actions {
- gap: 2px;
- padding: 2px 4px;
- border-radius: var(--r-pill);
- background: var(--glass);
- -webkit-backdrop-filter: var(--glass-blur);
- backdrop-filter: var(--glass-blur);
- box-shadow: var(--glass-specular), 0 0 0 0.5px var(--glass-edge), 0 1px 5px rgba(0, 0, 0, 0.06);
-}
-.note-bar-actions .notes-icon { border-radius: var(--r-pill); }
-.note-bar-actions .picker-button { background: none; }
-.note-bar-actions .picker-button:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); }
-
-
/* ── The account, at the foot of the sidebar ──────────────────────────────────────────── */
.sidebar-account {
display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px;
padding: 6px 8px; border: 0; border-radius: var(--r-field); background: none;
color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
-.sidebar-account:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.sidebar-account[aria-current="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); }
-.sidebar-account:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
-.sidebar-account-text { display: flex; flex-direction: column; min-width: 0; }
+.sidebar-account:hover { background: color-mix(in srgb, var(--text) 6%, transparent); transition: background-color var(--motion-hover) var(--motion-ease-out); }
+.sidebar-account:active:not([aria-current="true"]) { background: color-mix(in srgb, var(--text) 12%, transparent); transition: none; }
+.sidebar-account[aria-current="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); transition: none; }
+.sidebar-account:focus-visible { outline: var(--focus-ring); outline-offset: -1px; }
.sidebar-account-name { font-size: var(--t-13); font-weight: 590; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.sidebar-account-status { display: flex; align-items: center; gap: 5px; color: var(--text-2); font-size: var(--t-11); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
-.sidebar-account-status.is-trouble { color: var(--danger); }
/* Apple's monogram: initials on a soft grey gradient disc. */
.account-avatar {
flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
@@ -2015,7 +1626,9 @@
.settings-group {
border-radius: 12px;
background: color-mix(in srgb, var(--text) 4%, transparent);
- box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 8%, transparent);
+ /* Edges and hairlines as borders, not inset shadows: WebKit repainted every shadow on each
+ frame of a scroll, and Settings stuttered (25ms frames, 16ms without). */
+ border: 0.5px solid color-mix(in srgb, var(--text) 8%, transparent);
overflow: hidden;
}
.settings-row {
@@ -2023,48 +1636,37 @@
font-size: var(--t-13);
}
/* Separators inset past the icon, as Apple draws them between rows of a group. */
-.settings-row + .settings-row { box-shadow: inset 0 0.5px 0 color-mix(in srgb, var(--text) 10%, transparent); }
+.settings-row + .settings-row { border-top: 1px solid color-mix(in srgb, var(--text) 7%, transparent); }
.settings-row.is-stacked { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
.settings-row-line { display: flex; justify-content: space-between; gap: 10px; }
.settings-label { flex: 1; min-width: 0; }
.settings-hint { color: var(--text-2); font-size: var(--t-11); line-height: 1.4; }
.settings-value { color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.settings-value.is-trouble { color: var(--danger); max-width: 60%; }
-.settings-error { margin: 0 0 12px; color: var(--danger); }
+/* A section whose figure belongs to all of it carries it on its heading's line. */
+.settings-heading-line { display: flex; justify-content: space-between; gap: 10px; margin-right: 14px; }
+.settings-heading-value { font-weight: 400; font-variant-numeric: tabular-nums; }
+/* The mark of a row no app's icon fits: a plain tile the apps' icons' size and shape. */
+.settings-glyph {
+ flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 5px;
+ color: #fff; background: linear-gradient(#a1a1a6, #8e8e93);
+}
+.settings-stack .settings-hint.settings-hint-wrap { white-space: normal; }
+.settings-row > .quiet { flex: none; }
+.settings-value { flex: none; }
.settings-note { margin: 8px 12px 0; color: var(--text-2); font-size: var(--t-11); }
.settings-account { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.settings-account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-account-text strong { font-size: var(--t-17); font-weight: 600; }
.settings-account-text span { color: var(--text-2); font-size: var(--t-13); overflow: hidden; text-overflow: ellipsis; }
-.settings-confirm { display: flex; gap: 6px; }
-.settings .segmented { padding: 2px; border-radius: var(--r-pill); }
-.settings .segment { border-radius: var(--r-pill); padding: 3px 12px; font-size: var(--t-13); }
.storage-bar { height: 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.storage-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
-/* The switch, as macOS 27 draws it (Toggle: track 38×22 at this size, knob inset 2): green
- when on, the knob sliding on the snappy spring. */
-.switch {
- position: relative; flex: none; width: 38px; height: 22px; padding: 0; border: 0;
- border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 16%, transparent);
- cursor: pointer; transition: background-color 180ms ease;
-}
-.switch[aria-checked="true"] { background: #34c759; }
-.switch-knob {
- position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
- background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
- transition: translate var(--spring-snappy-d) var(--spring-snappy);
-}
-.switch[aria-checked="true"] .switch-knob { translate: 16px 0; }
-.switch:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
-.switch:disabled { opacity: 0.5; }
-
/* Advanced Data Protection with web access off: one plain answer, Apple's own switch. */
.web-access-off { max-width: 520px; margin: 12vh auto 0; text-align: center; }
.web-access-off h1 { font-size: var(--t-22); font-weight: 700; margin: 0 0 12px; }
.web-access-off p { color: var(--text-2); font-size: var(--t-15); line-height: 1.5; margin: 0 0 12px; }
.web-access-off b { color: var(--text); font-weight: 600; }
-.settings-gap { margin-top: 12px; }
/* A new folder in the grid, named as Finder names one: the field fits its cell under the
icon, its text centred. At the field's own width it overflowed the 112px cell and was cut
@@ -2074,19 +1676,7 @@
/* Uploads that can still be stopped have a ✕; the tray's Cancel stops every one of them. */
.upload-tray-actions { display: flex; align-items: center; gap: 10px; }
-.upload-stop {
- flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-left: 6px; padding: 0;
- border: 0; border-radius: 50%; background: color-mix(in srgb, var(--text) 10%, transparent);
- color: var(--text-2); font-size: 10px; cursor: pointer;
-}
-.upload-stop:hover { background: color-mix(in srgb, var(--text) 18%, transparent); color: var(--text); }
.upload-row.is-cancelled .upload-name { color: var(--text-3); }
-/* Still finding what is in a folder: no total yet, so no share of one — a segment gliding
- across instead of a number that would only shrink. */
-.upload-bar.is-waiting > span { width: 30%; animation: upload-finding 1.2s var(--ease) infinite alternate; }
-@keyframes upload-finding { from { transform: translateX(-10%); } to { transform: translateX(240%); } }
-.upload-bar.is-waiting > span { transform: none; }
-@media (prefers-reduced-motion: reduce) { .upload-bar.is-waiting > span { animation: none; width: 100%; opacity: 0.4; } }
/* A kept screen's box is the screen's own (it lays out as before, straight in the content);
one out of sight is not drawn at all. */
@@ -2105,20 +1695,6 @@
A field at the head of the sidebar, as Finder's; what it finds over the window under it,
grouped by app as Spotlight groups it. */
.gsearch { margin: 0 0 8px; }
-.gsearch-field {
- display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 8px;
- background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text-2);
-}
-.gsearch-field:focus-within { outline: 2px solid var(--accent-ring, var(--accent)); outline-offset: -1px; }
-.gsearch-field input {
- flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--text); font: inherit;
- font-size: var(--t-13); outline: none;
-}
-.gsearch-field input::-webkit-search-cancel-button { display: none; }
-.gsearch-clear {
- display: grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%;
- background: color-mix(in srgb, var(--text) 30%, transparent); color: var(--bg); cursor: pointer;
-}
.gsearch-results {
position: fixed; z-index: 70; width: min(420px, calc(100vw - 24px)); max-height: min(70vh, 560px);
overflow-y: auto; padding: 6px; border-radius: 12px;
@@ -2136,7 +1712,7 @@
font: inherit; font-weight: 500; color: var(--accent); cursor: default;
}
.gsearch-more:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
-.gsearch-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
+.gsearch-more:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
.gsearch-row {
display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 4px 8px; border: 0;
border-radius: 7px; background: none; color: inherit; font: inherit; text-align: start; cursor: default;
@@ -2148,3 +1724,44 @@
.gsearch-title { font-size: var(--t-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-detail { font-size: var(--t-11); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-none { margin: 0; padding: 10px; font-size: var(--t-13); color: var(--text-2); }
+
+/* ---- a session Apple signed out -------------------------------------------- */
+
+/* One line across the top of the window, over the library — never in place of it: a toast
+ (kit.css) that stays, at the top since it is about the whole window, not one app. */
+.lapsed { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding-right: 5px; }
+.lapsed > button { min-height: 26px; padding-inline: 12px; }
+
+/* ---- the sidebar's foot: freshness, then the account ------------------------- */
+
+.sidebar-foot-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
+/* The freshness line is the update control, as a whole: quiet text that, under the pointer,
+ says what a click does — no extra glyph standing apart in the corner. */
+.sidebar-sync {
+ /* Lined up with the account below: the dot on the avatar's centre (8px in, 30px wide), the
+ words on the name's edge (8 + 30 + 9). */
+ position: relative; display: flex; align-items: center; gap: 21px; min-width: 0;
+ padding: 4px 8px 4px 20px; border: 0; border-radius: var(--r-field); background: none; text-align: left;
+ color: var(--text-2); font: inherit; font-size: var(--t-11); cursor: default;
+}
+.sidebar-sync-text, .sidebar-sync-now { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.sidebar-sync-now { position: absolute; left: 47px; right: 8px; opacity: 0; color: var(--text); }
+.sidebar-sync:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 6%, transparent); }
+.sidebar-sync:hover:not(:disabled) .sidebar-sync-text { opacity: 0; }
+.sidebar-sync:hover:not(:disabled) .sidebar-sync-now { opacity: 1; }
+.sidebar-sync:active:not(:disabled) { background: color-mix(in srgb, var(--text) 10%, transparent); }
+.sidebar-sync:focus-visible { outline: var(--focus-ring); outline-offset: -1px; }
+.sidebar-sync.is-trouble { color: var(--danger); }
+/* Working: the dot becomes a small ring turning in place — the same spot, the same size. */
+.sidebar-sync.is-working .sync-dot {
+ background: none; border: 1.5px solid color-mix(in srgb, var(--text) 22%, transparent);
+ border-top-color: var(--text-2); animation: sync-spin 800ms linear infinite;
+}
+@media (prefers-reduced-motion: reduce) { .sidebar-sync.is-working .sync-dot { animation: none; opacity: 0.6; } }
+.sidebar-foot-stack .sidebar-account { align-items: center; }
+.sidebar-foot-stack .sidebar-account-name { flex: 1; min-width: 0; }
+.is-rail .sidebar-sync { justify-content: center; padding-inline: 0; }
+.is-rail .sidebar-sync-text, .is-rail .sidebar-sync-now { display: none; }
+.is-rail .sidebar-foot-stack .sidebar-account-name { display: none; }
+.sidebar .status-line { padding: 4px 8px; font-size: var(--t-11); }
+.drive-bar .drive-title { flex: 1 1 14ch; }
diff --git a/src/styles/calendar.css b/src/styles/calendar.css
index dc3810c..2698b6f 100644
--- a/src/styles/calendar.css
+++ b/src/styles/calendar.css
@@ -30,26 +30,6 @@
overflow-y: auto;
}
.cx-cals { display: flex; flex-direction: column; gap: 2px; }
-.cx-side-heading {
- margin: 10px 0 4px;
- color: var(--text-3);
- font-size: var(--t-11);
- font-weight: 600;
-}
-.cx-side-heading:first-child { margin-top: 0; }
-
-.cx-cal {
- display: flex;
- align-items: center;
- gap: 8px;
- height: 26px;
- padding: 0 6px;
- border-radius: 6px;
- font-size: var(--t-13);
- cursor: default;
-}
-.cx-cal:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.cx-cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Apple's calendar checkbox: a rounded square in the calendar's own colour. */
.cx-cal input {
@@ -153,22 +133,7 @@
}
.cx-title strong { font-weight: 700; }
.cx-title-brief { display: none; }
-.cx-bar > .segmented { flex: none; }
-/* Search, at the toolbar's end as in Calendar. */
-.cx-search {
- display: flex;
- align-items: center;
- gap: 5px;
- width: 168px;
- height: 26px;
- padding: 0 8px;
- border-radius: var(--r-field);
- background: color-mix(in srgb, var(--text) 7%, transparent);
- color: var(--text-3);
-}
-.cx-search:focus-within { box-shadow: 0 0 0 3px var(--accent-ring); }
-.cx-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: var(--t-13); outline: none; }
-.cx-search input::placeholder { color: var(--text-3); }
+.cx-search { width: 168px; }
@container cx-page (max-width: 860px) { .cx-search { width: 120px; } }
@container cx-page (max-width: 560px) { .cx-search { width: 34px; padding: 0 9px; } .cx-search:focus-within { width: 150px; } }
@@ -180,9 +145,6 @@
margin: 0 18px 10px;
padding: 4px;
overflow-y: auto;
- border-radius: 12px;
- background: var(--glass-thick);
- box-shadow: var(--glass-specular), 0 0 0 0.5px var(--glass-edge), var(--shadow-sheet);
}
.cx-found-row {
display: grid;
@@ -206,39 +168,6 @@
.cx-found-none { margin: 0; padding: 10px; color: var(--text-3); font-size: var(--t-13); }
.cx-tools { flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
-.cx-step { display: inline-flex; align-items: center; gap: 2px; }
-
-.cx-icon {
- display: grid;
- place-items: center;
- min-width: 28px;
- height: 26px;
- padding: 0 6px;
- border: 0;
- border-radius: 6px;
- background: none;
- color: var(--text-2);
- font: inherit;
- font-size: 18px;
- line-height: 1;
- cursor: default;
-}
-.cx-icon.small { min-width: 22px; height: 22px; font-size: 15px; }
-.cx-icon:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
-.cx-today {
- height: 24px;
- padding: 0 10px;
- border: 1px solid var(--field-edge);
- border-radius: 6px;
- background: var(--field);
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- cursor: default;
-}
-.cx-icon:focus-visible, .cx-today:focus-visible { outline: 3px solid color-mix(in srgb, var(--sys-blue) 40%, transparent); }
-
-.cx .notice { margin: 0 18px 10px; }
/* ---- month ---------------------------------------------------------------------- */
@@ -269,7 +198,9 @@
border-right: 1px solid var(--separator);
overflow: hidden;
}
-.cx-day:last-child { border-right: 0; }
+/* The seventh day, not the last child: a week's bars come after its days, and with one in the
+ week Saturday had kept a hairline down the grid's right edge that the other weeks had not. */
+.cx-day:nth-child(7) { border-right: 0; }
.cx-day.is-weekend { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
.cx-day.is-selected { background: color-mix(in srgb, var(--sys-blue) 7%, transparent); }
.cx-day-hit {
@@ -599,7 +530,7 @@
gap: 8px;
width: 300px;
padding: 14px 14px 12px;
- border-radius: 14px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--glass-float);
/* Opacity and a small lift only, on the compositor: scaling from the corner read as a
@@ -624,9 +555,11 @@
font: inherit;
outline: none;
}
-.cx-pop-title { padding: 0; font-size: var(--t-17); font-weight: 700; }
+/* Under `.cx-popover` to outrank its `input { font: inherit }`, which had set the title in the
+ body's 13px regular — a field, not a title. */
+.cx-popover .cx-pop-title { padding: 0; font-size: var(--t-17); font-weight: 700; }
.cx-pop-title::placeholder, .cx-pop-line::placeholder, .cx-pop-notes::placeholder { color: var(--text-3); }
-.cx-pop-line { padding: 0; font-size: var(--t-13); }
+.cx-popover .cx-pop-line { padding: 0; font-size: var(--t-13); }
.cx-pop-rows { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.cx-pop-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; font-size: var(--t-13); }
.cx-pop-row > span:first-child { color: var(--text-2); text-align: right; }
@@ -666,38 +599,11 @@
}
.cx-pop-row input[type="checkbox"]:focus-visible { outline: 3px solid color-mix(in srgb, var(--sys-blue) 45%, transparent); outline-offset: 1px; }
/* Notes grow with what is written, as in Calendar; no grip in the corner. */
-.cx-pop-notes { min-height: 2.6em; max-height: 9em; padding: 0; font-size: var(--t-13); resize: none; field-sizing: content; }
+.cx-popover .cx-pop-notes { min-height: 2.6em; max-height: 9em; padding: 0; font-size: var(--t-13); resize: none; field-sizing: content; }
.cx-pop-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cx-pop-actions > span { display: flex; gap: 6px; }
-.cx-pop-delete { padding: 4px 6px; border: 0; background: none; color: var(--sys-red); font: inherit; font-size: var(--t-13); cursor: default; }
.cx-pop-note { margin: 0; color: var(--text-3); font-size: var(--t-11); }
-.cx-toast {
- position: fixed;
- left: 50%;
- bottom: 24px;
- z-index: 45;
- display: flex;
- align-items: center;
- gap: 14px;
- padding: 9px 10px 9px 16px;
- transform: translateX(-50%);
- border-radius: var(--r-pill);
- background: var(--glass-thick);
- box-shadow: var(--glass-float);
- font-size: var(--t-13);
-}
-.cx-toast-undo {
- padding: 3px 10px;
- border: 0;
- border-radius: 6px;
- background: color-mix(in srgb, var(--sys-blue) 16%, transparent);
- color: var(--sys-blue);
- font: inherit;
- font-weight: 600;
- cursor: default;
-}
-
/* 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; }
@@ -769,31 +675,6 @@
:root[data-theme="dark"] .cx-reminder, :root[data-theme="dark"] .cx-item.is-reminder .cx-item-title, :root[data-theme="dark"] .cx-pane-reminder .cx-pane-title { color: color-mix(in srgb, var(--cal, var(--text)) 50%, #fff); }
.cx-reminder.is-done, .cx-item.is-reminder.is-done .cx-item-title { color: var(--text-3); }
-/* ── The toolbar in Liquid Glass ────────────────────────────────────────────────────────
- As macOS 27's Calendar sets it: each group of controls is a capsule of glass floating
- over the window — the view switcher, New, the ‹ Today › stepper, search — rather than
- flat controls printed on it. Concentric: a segment's cap is the capsule's radius less
- its inset. */
-.cx-bar .segmented,
-.cx-step,
-.cx-search,
-.cx-tools > .cx-icon {
- height: 32px;
- border-radius: var(--r-pill);
- background: var(--glass);
- -webkit-backdrop-filter: var(--glass-blur);
- backdrop-filter: var(--glass-blur);
- box-shadow: var(--glass-specular), 0 0 0 0.5px var(--glass-edge), 0 1px 5px rgba(0, 0, 0, 0.06);
-}
-.cx-bar .segmented { align-items: center; padding: 3px; gap: 0; }
-.cx-bar .segment { height: 26px; padding: 0 12px; border-radius: var(--r-pill); font-size: var(--t-13); }
-.cx-step { padding: 0 3px; gap: 0; }
-.cx-step .cx-icon { height: 26px; min-width: 26px; border-radius: var(--r-pill); }
-.cx-step .cx-today { height: 26px; border: 0; border-radius: var(--r-pill); background: none; padding: 0 8px; }
-.cx-step .cx-today:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
-.cx-tools > .cx-icon { min-width: 32px; padding: 0; color: var(--text); }
-.cx-search { padding: 0 12px; }
-
/* Go to Date… (⇧⌘T): a small date field under Today. Opaque and drawn at once, as the other
popovers are, because a blurred or animated layer flickers in WebKitGTK. */
.cx-step { position: relative; }
@@ -806,27 +687,11 @@
display: flex;
gap: 6px;
padding: 8px;
- border-radius: 12px;
- background: var(--glass-thick);
- box-shadow: var(--glass-specular), var(--glass-lift);
}
-.cx-goto input { font: inherit; }
-.cx-goto button { padding: 0 12px; border-radius: var(--r-pill); }
/* New Calendar: a quiet + at the end of the iCloud heading, as the Mac's sidebar has. */
-.cx-side-heading { display: flex; align-items: center; justify-content: space-between; }
-.cx-side-add {
- width: 20px; height: 20px; padding: 0; border: 0; border-radius: 6px;
- background: none; box-shadow: none; color: var(--text-2);
- font-size: 15px; line-height: 1; cursor: pointer;
-}
-.cx-side-add:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
-.cx-side-add:focus-visible { outline: 3px solid var(--accent-ring); }
-/* A calendar's name being typed, in the row it will take. */
-.cx-cal-rename {
- width: 100%; height: 26px; margin: 0; padding: 0 6px;
- border-radius: 6px; font: inherit; font-size: var(--t-13);
-}
+.cx-side-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-right: 0; }
+.cx-side-heading:first-child { margin-top: 0; }
/* An event's time zone: its city, with the offset quieter beside it; a field that finds one. */
.cx-zone {
diff --git a/src/styles/intake.css b/src/styles/intake.css
new file mode 100644
index 0000000..cdd7fdc
--- /dev/null
+++ b/src/styles/intake.css
@@ -0,0 +1,75 @@
+/* ── Import sheet: a file opened with Pomander (components/ImportSheet.tsx) ─────────────── */
+
+/* Under the menus (z-index 80), so its calendar picker opens over it. */
+.modal-veil.ix-veil { z-index: 70; }
+.ix-sheet { width: min(480px, 92vw); gap: 10px; }
+.ix-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
+.ix-head h2 { flex: 0 1 auto; min-width: 0; }
+.ix-head .picker { flex: none; max-width: 50%; }
+.ix-file { margin: -6px 0 0; font-size: var(--t-11); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+
+.ix-list {
+ flex: 1;
+ min-height: 0;
+ max-height: 300px;
+ overflow-y: auto;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ border: 1px solid var(--separator);
+ border-radius: var(--r-plateau);
+}
+.ix-list li { display: grid; gap: 1px; padding: 8px 12px; }
+.ix-list li + li { border-top: 1px solid var(--separator); }
+.ix-title { font-size: var(--t-13); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ix-sub { font-size: 12px; color: var(--text-2); line-height: 1.35; }
+.ix-list li.is-skipped .ix-title { color: var(--text-3); }
+.ix-list li.is-refused .ix-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
+.ix-list li.is-refused .ix-sub { color: var(--text-2); }
+
+.ix-reason { margin: 0; font-size: var(--t-13); color: var(--text-2); line-height: 1.4; white-space: pre-line; }
+.ix-error { color: var(--danger); }
+
+/* ── Quick capture: its own small window (components/QuickCapture.tsx) ──────────────────── */
+
+html:has(.qc), html:has(.qc) body, html:has(.qc) #root { height: 100%; margin: 0; overflow: hidden; }
+.qc {
+ height: 100%;
+ box-sizing: border-box;
+ display: grid;
+ grid-template-rows: 1fr auto;
+ padding: 14px 16px 12px;
+ background: var(--sheet);
+ color: var(--text);
+}
+.qc-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
+/* The app it goes into, in its own colour: a reminder's empty circle, a note's page corner. */
+.qc-mark { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--accent); }
+.qc-mark[data-kind="note"] { border-radius: 4px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
+.qc-field {
+ flex: 1;
+ min-width: 0;
+ border: 0;
+ outline: 0;
+ background: transparent;
+ color: inherit;
+ font: inherit;
+ font-size: var(--t-22);
+ font-weight: 500;
+ letter-spacing: -0.01em;
+ padding: 4px 0;
+}
+.qc-field::placeholder { color: var(--text-3); }
+.qc-field:disabled { opacity: 0.6; }
+.qc-foot {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ padding-top: 10px;
+ border-top: 1px solid var(--separator);
+ min-width: 0;
+}
+.qc-note { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.qc-error { color: var(--danger); }
+.qc-link { padding: 0; font-size: inherit; }
diff --git a/src/styles/kit.css b/src/styles/kit.css
new file mode 100644
index 0000000..eb1ea6c
--- /dev/null
+++ b/src/styles/kit.css
@@ -0,0 +1,544 @@
+/* The kit: every control and surface the apps share, drawn once.
+ *
+ * Each app keeps its own classes as hooks — for its layout and its tests — but the look of a
+ * button, a search field, a row of a source list, a toast or a question comes from here, so the
+ * same kind of thing looks and behaves the same in Notes, Reminders, Calendar, Contacts,
+ * iCloud Drive, Photos and Settings. Sizes, fills and radii are tokens (styles/tokens.css).
+ *
+ * Motion is the shell's rule: only small things change, by colour or by a frame-by-frame fade
+ * from the page (lib/fade.ts); nothing large moves or scales, since WebKitGTK on Hyprland
+ * flickers what it hands to the compositor. Menus and popovers appear at once. */
+
+/* ---- buttons ------------------------------------------------------------------------------ */
+
+/* A capsule, as macOS 27's regular-size buttons are: the filled one is the single action that
+ matters on its surface; the quiet one is everything else. */
+.primary,
+.quiet {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ min-height: var(--h-control);
+ padding: 4px 14px;
+ border: 0;
+ border-radius: var(--r-pill);
+ box-shadow: none;
+ font: inherit;
+ font-size: var(--t-13);
+ font-weight: 510;
+ white-space: nowrap;
+ cursor: pointer;
+}
+/*
+ * White on the plain quince gold measures 2.8:1 — well under the 4.5:1 white text needs. The
+ * deeper shade of each accent is the same hue at 4.5:1 or better.
+ */
+.primary { background: var(--accent-deep); color: #fff; font-weight: 550; padding-inline: 16px; }
+/* A Mac button keeps its colour under the pointer; pressing darkens its own colour. */
+.primary:active:not(:disabled) { background: color-mix(in srgb, var(--accent-deep) 84%, #000); }
+.primary.danger { background: var(--danger-deep); }
+.primary.danger:active:not(:disabled) { background: color-mix(in srgb, var(--danger-deep) 84%, #000); }
+.primary:disabled { background: var(--fill-selected); color: var(--text-3); cursor: default; }
+
+/* A quiet fill, no outline (Button/Radius 1000 from Large up in Apple's kit). */
+.quiet { background: var(--fill); color: var(--text); }
+.quiet:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 11%, transparent); }
+.quiet:active:not(:disabled) { background: color-mix(in srgb, var(--text) 16%, transparent); }
+.quiet:disabled { color: var(--text-3); cursor: default; }
+.quiet.danger { color: var(--danger); }
+.quiet.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
+
+/* Words that act — a secondary way out, a toggle of what is shown — in the accent. */
+.link {
+ padding: 2px 4px;
+ border: 0;
+ border-radius: 6px;
+ background: none;
+ box-shadow: none;
+ color: var(--accent-strong);
+ font: inherit;
+ font-size: var(--t-13);
+ cursor: pointer;
+}
+.link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
+.link:disabled { color: var(--text-3); cursor: default; }
+.link.danger { color: var(--danger); }
+
+/* A symbol alone: in a row, a list's header, a sheet's corner. Quiet until pointed at. */
+.icon-button {
+ display: inline-grid;
+ place-items: center;
+ flex: none;
+ width: var(--h-control);
+ height: var(--h-control);
+ padding: 0;
+ border: 0;
+ border-radius: var(--r-field);
+ background: none;
+ box-shadow: none;
+ color: var(--text-2);
+ font: inherit;
+ font-size: var(--t-13);
+ line-height: 1;
+ cursor: default;
+}
+.icon-button:hover:not(:disabled) { background: var(--fill); color: var(--text); }
+.icon-button:active:not(:disabled) { background: var(--fill-press); }
+.icon-button:is([aria-pressed="true"], .is-on) { background: var(--fill-selected); color: var(--text); }
+.icon-button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
+.icon-button:disabled { opacity: 0.4; }
+.icon-button.small { width: var(--h-mini); height: var(--h-mini); border-radius: 6px; }
+.icon-button.round { border-radius: 50%; }
+
+:is(.primary, .quiet, .link, .icon-button, .tool):focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
+
+/* ---- toolbars ----------------------------------------------------------------------------- */
+
+/* A group of a toolbar's controls, as macOS 27 floats them: one capsule, its controls round
+ inside it, concentric. Nearly solid rather than a live blur — these sit over scrolling
+ photos and lists, and WebKitGTK blurs what is behind again on every frame of a scroll. */
+.toolbar-group {
+ display: inline-flex;
+ align-items: center;
+ flex: none;
+ gap: 0;
+ height: var(--h-tool);
+ padding: 0 2px;
+ border-radius: var(--r-pill);
+ background: var(--tool-bg);
+ box-shadow: var(--tool-lift);
+}
+.tool {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 5px;
+ min-width: var(--h-control);
+ height: var(--h-control);
+ padding: 0 5px;
+ border: 0;
+ border-radius: var(--r-pill);
+ background: none;
+ box-shadow: none;
+ color: var(--text);
+ font: inherit;
+ font-size: var(--t-13);
+ font-weight: 510;
+ white-space: nowrap;
+ cursor: default;
+}
+.tool.has-label { padding: 0 10px; }
+.tool:hover:not(:disabled) { background: var(--fill); }
+.tool:active:not(:disabled) { background: var(--fill-press); }
+.tool:is([aria-pressed="true"], .is-on) { background: var(--fill-selected); }
+.tool:disabled { color: var(--text-3); }
+.tool.is-accent { color: var(--accent-strong); font-weight: 600; }
+.tool.danger { color: var(--danger); font-weight: 600; }
+/* A symbol that already says how it is set — a flag that is on — takes no pressed fill too. */
+.is-glyph-state[aria-pressed="true"]:not(:hover) { background: none; }
+/* A pop-up button in a toolbar is one more of its controls: no fill of its own. */
+.toolbar-group .picker-button { min-height: var(--h-control); border-radius: var(--r-pill); padding-inline: 10px; background: none; }
+.toolbar-group .picker-button:hover:not(:disabled) { background: var(--fill); }
+/* A segmented control in a toolbar is one more group: its chosen segment the same fill. */
+.toolbar-group.segmented { padding: 0 2px; gap: 0; }
+.toolbar-group .segment { height: var(--h-control); padding: 0 12px; border-radius: var(--r-pill); font-size: var(--t-13); }
+.toolbar-group .segment[aria-pressed="true"] { background: var(--fill-selected); box-shadow: none; }
+
+/* A pane's head (components/PaneTitle): the title with its column's whole width and the count
+ on its own line beneath; the controls beside it keep their size and never squeeze it. A long
+ title wraps to two balanced lines, then steps down a size (.is-small, measured); the clamp
+ is the last resort. */
+.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
+.pane-head > :not(.pane-title) { flex: none; }
+.pane-title { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
+:root .pane-title h1 {
+ margin: 0;
+ font-size: var(--t-22);
+ font-weight: 700;
+ letter-spacing: -0.016em;
+ line-height: 1.2;
+ text-wrap: balance;
+ overflow-wrap: anywhere;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow: hidden;
+}
+:root .pane-title h1.is-small { font-size: var(--t-17); }
+.pane-count { margin: 0; color: var(--text-2); font-size: var(--t-13); font-weight: 400; font-variant-numeric: tabular-nums; }
+
+/* ---- fields ------------------------------------------------------------------------------- */
+
+.search-field {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+ height: var(--h-control);
+ padding: 0 10px;
+ border-radius: var(--r-pill);
+ background: var(--fill);
+ color: var(--text-3);
+ cursor: text;
+}
+.search-field > svg { flex: none; }
+.search-field input {
+ flex: 1;
+ min-width: 0;
+ height: 100%;
+ padding: 0;
+ border: 0;
+ background: none;
+ color: var(--text);
+ font: inherit;
+ font-size: var(--t-13);
+ outline: none;
+}
+.search-field input::placeholder { color: var(--text-3); opacity: 1; }
+.search-field input::-webkit-search-cancel-button { display: none; }
+.search-field:focus-within { box-shadow: var(--ring); }
+.search-field.toolbar-group { height: var(--h-tool); padding: 0 12px; background: var(--tool-bg); }
+.search-field.toolbar-group:focus-within { box-shadow: var(--tool-lift), var(--ring); }
+.search-clear {
+ display: grid;
+ place-items: center;
+ flex: none;
+ width: 16px;
+ height: 16px;
+ padding: 0;
+ border: 0;
+ border-radius: 50%;
+ background: var(--text-3);
+ color: var(--sheet);
+ cursor: default;
+}
+.search-clear:hover { background: var(--text-2); }
+
+/* A text field: the field's own fill on a hairline, the accent ring when typing. */
+.field {
+ min-width: 0;
+ min-height: var(--h-control);
+ padding: 4px 9px;
+ border: 1px solid var(--field-edge);
+ border-radius: var(--r-field);
+ background: var(--field);
+ box-shadow: var(--shadow-field);
+ color: var(--text);
+ font: inherit;
+ font-size: var(--t-13);
+ outline: none;
+}
+.field::placeholder { color: var(--text-3); opacity: 1; }
+.field:hover:not(:disabled):not(:focus) { border-color: var(--field-edge-hover); }
+.field:focus { border-color: var(--accent); box-shadow: var(--shadow-field), var(--ring); }
+textarea.field { padding-block: 5px; resize: vertical; }
+
+/* ---- source lists: an app's own sidebar of folders, lists, albums, calendars -------------- */
+
+.side-heading { margin: 0 0 4px; padding: 0 8px; color: var(--text-3); font-size: var(--t-11); font-weight: 600; }
+.source-row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+ min-width: 0;
+ height: var(--h-row);
+ padding: 0 8px;
+ border: 0;
+ border-radius: var(--r-field);
+ background: none;
+ box-shadow: none;
+ color: var(--text);
+ font: inherit;
+ font-size: var(--t-13);
+ text-align: left;
+ cursor: default;
+}
+/* The highlight is the row's, not its button's alone: the ⋯ over the row took the hover off
+ the button, and the highlight blinked out and back. Held while the row's menu is open. */
+.source-row:hover, :is(:hover, .is-menu) > .source-row:has(~ .row-more) { background: var(--fill-hover); }
+.source-row[aria-current="true"] { background: var(--fill-press); }
+.source-row:focus-visible { outline: var(--focus-ring); outline-offset: -1px; }
+.source-row[data-drop], .is-drop > .source-row { background: var(--accent-tint); outline: 2px solid var(--accent); outline-offset: -2px; }
+.source-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.count { flex: none; min-width: 26px; color: var(--text-3); font-size: var(--t-13); font-variant-numeric: tabular-nums; text-align: right; }
+/* A row's ⋯, over where its count sits, waiting until the row is pointed at — shown and
+ hidden at once, never faded (a fade here is the compositor's, and flickered). Opacity, not
+ visibility: hidden, it could not be reached with Tab. */
+.row-more { position: absolute; right: 6px; opacity: 0; }
+:hover > .row-more, .is-menu > .row-more, .row-more:focus-visible { opacity: 1; }
+:is(:hover, .is-menu) > .source-row:has(~ .row-more) .count { visibility: hidden; }
+/* Adding one more, at the foot of the column, as Notes and Reminders put it. */
+.side-add {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: auto;
+ padding: 10px 8px 0;
+ border: 0;
+ background: none;
+ box-shadow: none;
+ color: var(--text-2);
+ font: inherit;
+ font-size: var(--t-13);
+ cursor: default;
+}
+.side-add:hover { color: var(--text); }
+.side-add:focus-visible { outline: var(--focus-ring); border-radius: var(--r-field); }
+
+/* ---- under way ---------------------------------------------------------------------------- */
+
+.spinner {
+ flex: none;
+ display: inline-block;
+ width: 16px;
+ height: 16px;
+ border-radius: 50%;
+ border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
+ border-top-color: currentColor;
+ animation: spin 800ms linear infinite;
+}
+.spinner.is-small { width: 12px; height: 12px; border-width: 1.6px; }
+@keyframes spin { to { transform: rotate(1turn); } }
+
+.progress {
+ position: relative;
+ display: block;
+ height: 4px;
+ border-radius: var(--r-pill);
+ background: var(--fill-selected);
+ overflow: hidden;
+}
+.progress > span {
+ display: block;
+ width: 100%;
+ height: 100%;
+ border-radius: inherit;
+ background: var(--accent);
+ transform-origin: left center;
+ transform: scaleX(0);
+ transition: transform 200ms var(--ease);
+}
+.progress.is-instant > span { transition: none; }
+.progress.is-waiting > span { width: 30%; transform: none; animation: progress-finding 1.2s var(--ease) infinite alternate; }
+@keyframes progress-finding { from { translate: -10% 0; } to { translate: 240% 0; } }
+@media (prefers-reduced-motion: reduce) {
+ .spinner { animation-duration: 2.4s !important; }
+ .progress.is-waiting > span { animation: none; width: 100%; opacity: 0.4; }
+}
+
+/* A line of status in place (components/StatusLine). */
+.status-line { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-size: var(--t-13); line-height: 1.4; }
+.status-line.is-error { color: var(--danger); }
+
+/* ---- empty and waiting ------------------------------------------------------------------- */
+
+.empty-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+ max-width: 40ch;
+ margin: 0 auto;
+ padding: 48px 20px;
+ color: var(--text-3);
+ text-align: center;
+}
+.empty-state p { margin: 0; color: var(--text-2); font-size: var(--t-13); line-height: 1.45; text-wrap: balance; }
+.empty-state-icon { display: grid; place-items: center; color: var(--text-3); }
+.empty-state .primary { margin-top: 4px; }
+
+/* ---- floating surfaces -------------------------------------------------------------------- */
+
+/* Menus, pop-ups, popovers: thick glass, rim, edge and lift — the whole recipe, one radius. */
+.popover {
+ border-radius: var(--r-float);
+ background: var(--glass-thick);
+ box-shadow: var(--glass-float);
+ color: var(--text);
+}
+
+/* ---- toasts (components/Toast) ------------------------------------------------------------ */
+
+/* At the foot of the content, centred over it — not the window: the sidebar is not where the
+ work is — and above whatever sits at the foot (--toast-clear). */
+.toast-host {
+ position: absolute;
+ z-index: 70;
+ left: var(--side, 220px);
+ right: 0;
+ bottom: calc(24px + var(--toast-clear, 0px));
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+ padding: 0 16px;
+ pointer-events: none;
+}
+@media (max-width: 900px) { .toast-host { left: 0; } }
+.toast {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ max-width: min(520px, 100%);
+ min-height: 38px;
+ padding: 5px 6px 5px 14px;
+ border-radius: var(--r-float);
+ background: var(--glass-thick);
+ box-shadow: var(--glass-float);
+ color: var(--text);
+ font-size: var(--t-13);
+ line-height: 1.35;
+ pointer-events: auto;
+}
+.toast p { flex: 1; min-width: 0; margin: 0; padding: 4px 0; overflow-wrap: anywhere; }
+.toast-glyph { flex: none; }
+.toast.is-done .toast-glyph { color: var(--sys-green); }
+.toast.is-error .toast-glyph { color: var(--danger); }
+.toast-action {
+ flex: none;
+ height: 26px;
+ padding: 0 10px;
+ border: 0;
+ border-radius: var(--r-pill);
+ background: var(--accent-tint);
+ color: var(--accent-strong);
+ font: inherit;
+ font-size: var(--t-13);
+ font-weight: 600;
+ white-space: nowrap;
+ cursor: default;
+}
+.toast-action:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
+.toast-action:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
+.toast-close { color: var(--text-3); }
+
+/* A change Apple turned down for good (components/Unsent): in the flow, until decided. */
+.unsent {
+ display: flex;
+ align-items: flex-start;
+ gap: 8px;
+ margin: 6px 10px 0;
+ padding: 10px 12px;
+ border-radius: var(--r-float);
+ background: color-mix(in srgb, var(--danger) 8%, var(--sheet));
+ box-shadow: 0 0 0 0.5px var(--glass-edge);
+ font-size: var(--t-13);
+}
+.unsent .toast-glyph { margin-top: 2px; color: var(--danger); }
+.unsent-body { flex: 1; min-width: 0; }
+.unsent p { margin: 0; }
+.unsent-content { color: var(--text-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
+.unsent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
+/* Beside something saved here that Apple does not have yet. */
+.sync-waiting { color: var(--text-3); font-size: var(--t-11); white-space: nowrap; }
+
+/* ---- sheets and questions (components/Confirm) -------------------------------------------- */
+
+/* A dimmed window behind a raised sheet, in a macOS sheet's proportions. The dim is a dim, not
+ a blur — a blur of the whole window under glass was glass on glass, and WebKitGTK's
+ costliest frame — and simply appears: the sheet on it fades in (lib/fade fadeSheetsIn). */
+.modal-veil {
+ position: fixed;
+ inset: 0;
+ z-index: 100;
+ display: grid;
+ place-items: center;
+ background: rgba(0, 0, 0, 0.2);
+}
+.modal-sheet {
+ position: relative;
+ width: min(440px, 92vw);
+ max-height: min(560px, 84vh);
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 20px 22px;
+ border-radius: var(--r-window);
+ background: var(--glass-thick);
+ box-shadow: var(--glass-float);
+ color: var(--text);
+}
+.modal-sheet h2 {
+ margin: 0;
+ font-size: var(--t-15);
+ font-weight: 700;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+/* A sheet's way out, at its corner. */
+.sheet-close { position: absolute; top: 10px; left: 10px; }
+/* A sheet's answers, at its foot: Cancel, then the action. */
+.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
+
+.confirm { width: min(320px, 92vw); align-items: center; gap: 6px; padding: 22px 20px 16px; text-align: center; }
+.confirm-symbol { display: grid; place-items: center; margin-bottom: 4px; color: var(--accent); }
+.confirm h2 { white-space: normal; line-height: 1.3; text-wrap: balance; }
+.confirm p { margin: 0; color: var(--text-2); font-size: var(--t-13); line-height: 1.45; text-wrap: balance; }
+.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 14px; }
+.confirm-actions.is-stacked { grid-template-columns: 1fr; }
+.confirm-actions > button { width: 100%; }
+
+/* ---- small controls ---------------------------------------------------------------------- */
+
+/* A segmented control: one recessed track, a raised cap over the chosen segment. */
+.segmented {
+ display: inline-flex;
+ padding: 2px;
+ gap: 2px;
+ border-radius: var(--r-pill);
+ background: var(--fill);
+}
+.segment {
+ border: 0;
+ background: none;
+ font: inherit;
+ font-size: var(--t-13);
+ font-weight: 510;
+ color: var(--text-2);
+ padding: 3px 12px;
+ border-radius: var(--r-pill);
+ cursor: pointer;
+}
+.segment:hover { color: var(--text); }
+.segment[aria-pressed="true"] {
+ background: var(--sheet);
+ color: var(--text);
+ font-weight: 590;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 0 0 0.5px var(--glass-edge);
+}
+.segment:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
+
+/* The switch, as macOS draws it: a capsule in the accent when on, the knob sliding on the
+ snappy spring (a small thing moving a short way, its own layer only). */
+.switch {
+ position: relative;
+ flex: none;
+ width: 38px;
+ height: 22px;
+ padding: 0;
+ border: 0;
+ border-radius: var(--r-pill);
+ background: color-mix(in srgb, var(--text) 16%, transparent);
+ cursor: pointer;
+ transition: background-color 160ms ease;
+}
+.switch[aria-checked="true"], input:checked + .switch { background: var(--accent-deep); }
+.switch-knob, .switch::after {
+ position: absolute;
+ top: 2px;
+ left: 2px;
+ width: 18px;
+ height: 18px;
+ border-radius: 50%;
+ background: #fff;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
+ transition: translate var(--spring-snappy-d) var(--spring-snappy);
+}
+/* A switch drawn for a checkbox carries its knob itself. */
+span.switch::after { content: ""; }
+.switch[aria-checked="true"] .switch-knob, input:checked + .switch::after { translate: 16px 0; }
+.switch:focus-visible, input:focus-visible + .switch { outline: var(--focus-ring); outline-offset: 2px; }
+.switch:disabled, input:disabled + .switch { opacity: 0.5; }
diff --git a/src/styles/notes.css b/src/styles/notes.css
index 0337b1b..55c99e0 100644
--- a/src/styles/notes.css
+++ b/src/styles/notes.css
@@ -27,38 +27,8 @@
padding: 2px 12px 12px;
border-right: 1px solid var(--separator);
}
-.notes-side-heading {
- margin: 0 0 4px;
- padding: 0 8px;
- color: var(--text-3);
- font-size: var(--t-11);
- font-weight: 600;
-}
-.notes-folder {
- display: flex;
- align-items: center;
- gap: 8px;
- height: 30px;
- padding: 0 8px;
- border: 0;
- border-radius: 7px;
- background: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- text-align: left;
- cursor: default;
-}
-/* On the row, not the button alone — the ⋯ over the row took the hover off the button and
- the highlight blinked (see .rx-list-row). */
-.notes-folder-row:hover .notes-folder, .notes-folder-row.is-menu .notes-folder,
-.notes-folder:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.notes-folder[aria-current="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
-.notes-folder:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
/* Apple's folders are drawn in the accent, which in Notes is its yellow — here, quince gold. */
.notes-folder-glyph { flex: none; color: var(--accent); }
-.notes-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.notes-folder-count { min-width: 26px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* ---- the list ------------------------------------------------------------------- */
@@ -70,57 +40,6 @@
padding: 0 10px;
border-right: 1px solid var(--separator);
}
-.notes-list-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- padding: 0 4px 10px;
-}
-.notes-list-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
-.notes-list-title h1 {
- margin: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: var(--t-17);
- font-weight: 700;
-}
-.notes-list-count { flex: none; color: var(--text-3); font-size: var(--t-13); }
-
-.notes-icon {
- display: grid;
- place-items: center;
- flex: none;
- width: 30px;
- height: 28px;
- padding: 0;
- border: 0;
- border-radius: 7px;
- background: none;
- color: var(--text-2);
- cursor: default;
-}
-.notes-icon:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
-.notes-icon.danger:hover { color: var(--danger); }
-.notes-icon:focus-visible { outline: 3px solid var(--accent-ring); }
-.notes-icon:disabled { opacity: 0.45; }
-
-.notes-search {
- width: 100%;
- height: 28px;
- margin-bottom: 8px;
- padding: 0 10px;
- border: 0;
- border-radius: var(--r-field);
- background: color-mix(in srgb, var(--text) 7%, transparent);
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- outline: none;
-}
-.notes-search::placeholder { color: var(--text-3); }
-.notes-search:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }
.notes-folder-picker { display: none; margin-bottom: 8px; }
.notes-folder-picker .picker { width: 100%; }
@@ -196,7 +115,8 @@
font-size: var(--t-11);
text-align: center;
}
-.note-bar-actions { display: flex; align-items: center; gap: 6px; }
+.notes-list-head { padding: 0 4px 10px; }
+.notes-search { margin-bottom: 8px; }
.note-bar-actions .picker { max-width: 170px; }
.note-editor {
@@ -241,7 +161,6 @@ textarea.note-title::placeholder { color: var(--text-3); }
}
.note-editor.is-readonly .note-text { flex: none; min-height: 0; }
.note-readonly { max-width: 62ch; margin: 18px 0 0; color: var(--text-3); font-size: var(--t-11); }
-.note-loading { margin: 0; padding: 10px 2px; color: var(--text-3); font-size: var(--t-13); }
/* ---- narrow windows --------------------------------------------------------------- */
@@ -264,24 +183,6 @@ textarea.note-title::placeholder { color: var(--text-3); }
}
/* A folder row: the folder, and its ⋯ on hover, as Notes on icloud.com draws it. */
.notes-folder-row { position: relative; display: flex; align-items: center; }
-.notes-folder-row > .notes-folder { flex: 1; min-width: 0; }
-.notes-folder-more {
- position: absolute; right: 6px; display: grid; place-items: center; width: 22px; height: 22px;
- padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--text) 12%, transparent);
- box-shadow: none; color: var(--text); font-size: 8px; letter-spacing: 1px; opacity: 0; cursor: pointer;
- /* Shown and hidden at once, never faded: a fade here is the compositor's, and flickered on
- his screen as the pointer crossed the rows. (Opacity, not visibility: hidden, it could
- not be reached with Tab.) */
-}
-.notes-folder-row:hover .notes-folder-more, .notes-folder-row.is-menu .notes-folder-more,
-.notes-folder-more:focus-visible { opacity: 1; }
-.notes-folder-row:hover .notes-folder-count, .notes-folder-row.is-menu .notes-folder-count { visibility: hidden; }
-.notes-folder-rename { width: 100%; box-sizing: border-box; border: 1px solid var(--accent); background: var(--bg); color: var(--text); font: inherit; outline: none; }
-.notes-new-folder {
- display: flex; align-items: center; gap: 6px; margin-top: auto; padding: 8px; border: 0;
- background: none; box-shadow: none; color: var(--accent-strong); font: inherit; font-size: var(--t-13); cursor: pointer;
-}
-.notes-new-folder:hover { text-decoration: underline; }
/* A note as Notes sets it, from Apple's own runs. Sizes after Notes on macOS: title 24,
heading 19, subheading 16, body 15. */
.note-read { cursor: text; outline: none; }
@@ -306,7 +207,7 @@ textarea.note-title::placeholder { color: var(--text-3); }
.nf-check.is-done > span:last-child { color: var(--text-3); }
.note-formatted a { color: var(--accent-strong); text-decoration: underline; }
/* Aa, as Notes writes it on its toolbar. */
-.notes-aa { font-weight: 600; font-size: 14px; letter-spacing: -0.02em; width: auto; padding-inline: 8px; }
+.notes-aa { font-weight: 600; font-size: 14px; letter-spacing: -0.02em; padding-inline: 8px; }
/* ---- the editor ------------------------------------------------------------------
One document, edited formatted, as Notes edits it. Sizes after Notes on the Mac: title
@@ -370,13 +271,20 @@ textarea.note-title::placeholder { color: var(--text-3); }
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 8.2l2.6 2.6L12 5.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/12px no-repeat;
}
.note-rich .nf-p[data-style="103"][data-checked="true"] { color: var(--text-3); }
+/* A table, drawing, picture or scan on a checklist line stands on its own, full width, as Notes
+ shows it: no circle floating over an empty first line above it, and no gutter beside it. */
+.note-rich .nf-p[data-style="103"]:has(> .nf-attachment:is(.is-table, .is-image, .is-doc, .is-drawing, .is-table-unread)) {
+ padding-inline-start: calc(var(--indent, 0) * 1.5em);
+}
+.note-rich .nf-p[data-style="103"]:has(> .nf-attachment:is(.is-table, .is-image, .is-doc, .is-drawing, .is-table-unread))::before {
+ content: none;
+}
.note-rich a { color: var(--accent-strong); text-decoration: underline; }
.note-rich .nf-attachment {
display: inline-block; padding: 0 6px; margin: 0 1px; border-radius: 5px;
background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); font-size: var(--t-13);
}
.note-rich ::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
-.notes-icon.is-on { background: color-mix(in srgb, var(--text) 10%, transparent); }
/* ---- Aa ----------------------------------------------------------------------------
As icloud.com and the Mac draw it: the four marks in a row, the styles beneath, each set
@@ -433,9 +341,25 @@ textarea.note-title::placeholder { color: var(--text-3); }
.fp-list-mark { width: 16px; color: var(--text-2); }
/* A table in a note, as Notes draws one: hairline cells, the text set as the note's. */
-.note-rich .nf-attachment.is-table { display: block; padding: 0; margin: 6px 0; background: none; color: inherit; font-size: inherit; overflow-x: auto; }
-.nf-table { border-collapse: collapse; min-width: 50%; }
-.nf-table td { min-width: 120px; padding: 4px 8px; border: 1px solid color-mix(in srgb, var(--text) 22%, transparent); vertical-align: top; white-space: pre-wrap; }
+/* As Notes on the phone sets one: the note's full width, its columns shared evenly, roomy cells
+ on hairlines. The frame scrolls sideways only for a table too wide to fit, and leaves room
+ round the grid so its outer lines and a selection ring are never clipped by that scroll. */
+.note-rich .nf-attachment.is-table {
+ display: block; padding: 3px; margin: 8px -3px; border-radius: 0; background: none;
+ color: inherit; font-size: inherit; overflow-x: auto; overflow-y: hidden;
+}
+.nf-table {
+ width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0;
+ border: 1px solid var(--table-line); border-radius: 8px; overflow: hidden;
+}
+.nf-table td {
+ min-width: 96px; padding: 8px 10px; height: 2.6em; line-height: 1.4;
+ border-right: 1px solid var(--table-line); border-bottom: 1px solid var(--table-line);
+ vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere;
+}
+.nf-table tr > td:last-child { border-right: none; }
+.nf-table tr:last-child > td { border-bottom: none; }
+.note-rich, .note-read { --table-line: color-mix(in srgb, var(--text) 16%, transparent); }
/* A table's cells, edited in place: a typed cell is a quiet field that lights when it is the
one being typed in; one Apple refused flashes red while it goes back. */
.nf-cell-edit { outline: none; min-height: 1.4em; border-radius: 3px; cursor: text; }
@@ -481,9 +405,6 @@ textarea.note-title::placeholder { color: var(--text-3); }
.nf-picture figcaption { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 12px;
background: var(--glass-thick); box-shadow: var(--glass-float); color: var(--text); font-size: var(--t-13); align-self: center; max-width: 100%; }
.nf-picture-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
-.nf-picture-close { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 0;
- background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); cursor: pointer; flex: none; }
-.nf-picture-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A block quote, as Notes draws one: a grey bar down the left of every quoted line, one
unbroken bar down a run of them; a quoted list keeps its marks, inside the bar. */
@@ -511,10 +432,15 @@ textarea.note-title::placeholder { color: var(--text-3); }
ring around the thing itself — a picture's own edges, a chip's own — never the box the
line gives it, which ran the width of the note. */
.note-rich .ProseMirror-selectednode { outline: none; }
-.note-rich .nf-attachment.ProseMirror-selectednode:not(.is-image) > *,
+.note-rich .nf-attachment.ProseMirror-selectednode:not(.is-image):not(.is-table) > *,
.note-rich .nf-attachment.ProseMirror-selectednode.is-image img {
outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
+/* A table chosen whole: its own frame takes the accent, as the phone rings a chosen table —
+ drawn on the frame itself, so the scroll box round it can never cut it to one edge. */
+.note-rich .nf-attachment.is-table.ProseMirror-selectednode > .nf-table {
+ border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent);
+}
.nf-file-meta.is-trouble { color: var(--danger); white-space: normal; }
/* A table not readable here yet: a quiet dashed frame where the grid will be. */
@@ -522,3 +448,7 @@ textarea.note-title::placeholder { color: var(--text-3); }
display: block; padding: 10px 12px; border: 1px dashed var(--separator); border-radius: 8px;
color: var(--text-3); font-size: var(--t-13, 13px);
}
+.notes-folder-rename { width: 100%; }
+
+/* An attachment not yet known takes no room and says nothing until it is drawn. */
+.note-rich .nf-attachment.is-pending { padding: 0; margin: 0; background: none; }
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 1435214..5d51e05 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -25,68 +25,13 @@
border-right: 1px solid var(--separator);
overflow-y: auto;
}
-.px-side-heading {
- margin: 6px 8px 4px;
- color: var(--text-3);
- font-size: var(--t-11);
- font-weight: 600;
-}
-.px-source {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 30px;
- padding: 0 10px;
- border: 0;
- border-radius: 7px;
- background: none;
- box-shadow: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- text-align: start;
- cursor: default;
-}
-.px-source { justify-content: flex-start; gap: 8px; }
.px-glyph { flex: none; color: var(--accent); }
-.px-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
-.px-source:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.px-source[aria-current="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
-.px-source:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
.px-albums { display: flex; flex-direction: column; gap: 1px; }
.px-side-gap { margin-top: 14px; }
.px-side-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.px-side-row .px-side-heading { margin-bottom: 4px; }
-.px-side-add {
- display: grid;
- place-items: center;
- width: 22px;
- height: 22px;
- margin-right: 4px;
- border: 0;
- border-radius: 6px;
- background: transparent;
- color: var(--text-3);
- opacity: 0;
- transition: none;
-}
-/* As in Finder and Photos: the + shows when the sidebar is pointed at or the keys reach it. */
-.px-side:hover .px-side-add,
-.px-side-add:focus-visible { opacity: 1; }
-.px-side-add:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
-.px-naming {
- width: 100%;
- font: inherit;
- outline: 2px solid var(--accent-ring);
- outline-offset: -2px;
- background: var(--surface, transparent);
- cursor: text;
-}
-.px-count { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: var(--t-12, 12px); }
/* ---- the library ------------------------------------------------------------------------- */
-/* Above the photo viewer too: a change refused while a photo was open said so behind it, unseen. */
-.px-notice { position: absolute; z-index: 7; top: 62px; left: 18px; right: 18px; max-width: 420px; }
.px-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.px-bar {
position: absolute;
@@ -106,69 +51,8 @@
/* The controls, as one: beside the title in a wide window, all together under it in a narrow
one — never split between the two rows. */
.px-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 8px; max-width: 100%; }
-.px-bar h1 {
- margin: 0;
- font-size: var(--t-22, 22px);
- font-weight: 700;
- letter-spacing: -0.015em;
- line-height: 1.15;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.px-span { margin: 1px 0 0; color: var(--text-2); font-size: var(--t-13); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-
-/* Liquid Glass, as Photos' toolbar has it: small capsules floating over the photos. The live
- blur is kept to these few small, still surfaces — never to what moves, which WebKitGTK
- would re-blur on every frame of a scroll. */
-.px-capsule {
- display: flex;
- height: 34px;
- padding: 0 3px;
- border-radius: 17px;
- /* No live blur: these sit over a scrolling grid and a photo that moves, and WebKitGTK blurs
- what is behind again on every frame of either — the stutter in scrolling and the flash as a
- photo opened. The glass is in the rim, the lift and a fill near enough to solid. */
- background: color-mix(in srgb, var(--sheet) 90%, transparent);
- box-shadow: var(--glass-float);
-}
-.px-cap {
- display: grid;
- place-items: center;
- width: 34px;
- height: 34px;
- padding: 0;
- border: 0;
- border-radius: 17px;
- background: transparent;
- color: var(--text);
- cursor: default;
- transition: background-color 120ms ease;
-}
-.px-cap:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); }
-.px-cap:active:not(:disabled) { transform: scale(0.9); }
-.px-cap:disabled { color: var(--text-3); opacity: 0.55; }
-.px-cap:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
+.px-span { font-weight: 500; }
-/* Words in a capsule — Recently Deleted's Recover, Delete, Delete All — as Photos sets them. */
-.px-words { padding: 0 4px; }
-.px-word {
- height: 34px;
- padding: 0 12px;
- border: 0;
- border-radius: 17px;
- background: transparent;
- color: var(--accent);
- font: inherit;
- font-size: var(--t-13);
- font-weight: 600;
- cursor: default;
- transition: background-color 120ms ease;
-}
-.px-word.is-danger { color: var(--danger); }
-.px-word:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
-.px-word:active { transform: scale(0.95); }
-.px-word:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
/* Time left on a deleted photo's tile; red in its last days. */
.px-badge.px-left { left: 6px; right: auto; }
.px-badge.px-left.is-soon { color: #ff6961; }
@@ -201,7 +85,6 @@
font-weight: 600;
pointer-events: none;
}
-.px-empty { margin: 18vh auto 0; max-width: 36ch; color: var(--text-2); text-align: center; }
/* The library runs up under the floating bar and fades out at the top edge — Apple's scroll
edge effect. Done with a still layer in the window's colour over the top, not a mask on the
@@ -341,11 +224,6 @@
.px-viewer-when { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.25; pointer-events: none; }
.px-viewer-when strong { font-size: var(--t-13); font-weight: 600; }
.px-viewer-when span { color: var(--text-2); font-size: var(--t-11); }
-.px-cap[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
-/* A button whose glyph already says which way it is set (square or whole photos), as
- icloud.com draws it: no pressed fill as well — a fill that never left read as a hover stuck
- on it. */
-.px-cap.is-glyph-state[aria-pressed="true"]:not(:hover) { background: none; }
.px-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 62px 64px 70px; container-type: size; }
.px-stage img, .px-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
/* The photo's frame: what zooms and pans. The full picture lies over the screen-sized one,
@@ -406,7 +284,7 @@
max-height: calc(100% - 72px);
margin: 0;
padding: 12px 16px 14px;
- border-radius: 16px;
+ border-radius: var(--r-float);
background: var(--glass-thick);
box-shadow: var(--glass-float);
font-size: var(--t-13);
@@ -415,17 +293,6 @@
.px-info dt { margin-top: 10px; color: var(--text-2); font-size: var(--t-11); font-weight: 600; }
.px-info dt:first-child { margin-top: 0; }
.px-info dd { margin: 2px 0 0; overflow-wrap: anywhere; }
-.px-saved {
- position: absolute;
- left: 232px;
- bottom: 14px;
- z-index: 6;
- margin: 0;
- padding: 7px 12px;
- border-radius: 9px;
- background: var(--glass-thick);
- box-shadow: var(--glass-specular), var(--glass-lift);
-}
.px-video {
position: relative;
display: grid;
@@ -451,8 +318,6 @@
}
.px-video:hover .px-play { background: rgba(0, 0, 0, 0.65); }
-/* An album under photos being dragged to it: lit, as a Mac sidebar lights a drop target. */
-.px-source[data-drop] { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }
/* What is dragged: the photo, with how many when it is more than one. */
.px-ghost { position: fixed; top: -200px; left: -200px; width: 72px; height: 72px; }
.px-ghost img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); }
@@ -584,20 +449,11 @@
/* Solid, as icloud.com's: the toolbar's controls must not show through the words. */
background: var(--sheet);
box-shadow: inset 0.5px 0 0 var(--separator), -18px 0 40px rgba(0, 0, 0, 0.18);
- animation: px-up-in 320ms var(--spring-smooth) both;
}
-.px-up.is-leaving { animation: px-up-out 240ms ease-in both; }
-@keyframes px-up-in { from { transform: translateX(100%); } to { transform: none; } }
-@keyframes px-up-out { from { transform: none; opacity: 1; } to { transform: translateX(100%); opacity: 0.6; } }
-@media (prefers-reduced-motion: reduce) { .px-up, .px-up.is-leaving { animation: none; } }
.px-up-head { padding: 12px 16px 0; }
-.px-up-link { padding: 4px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: var(--t-13); font-weight: 500; cursor: default; }
-.px-up-link:hover { text-decoration: underline; }
.px-up-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 22px 16px; text-align: center; }
.px-up-icon { color: var(--accent); }
.px-up-title { margin: 0; font-size: var(--t-15, 15px); font-weight: 700; }
-.px-up-bar { width: 100%; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
-.px-up-bar span { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 240ms ease-out; }
.px-up-rows { flex: 1; min-height: 0; margin: 0; padding: 0 8px 12px; list-style: none; overflow-y: auto; }
.px-up-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.px-up-thumb { flex: none; width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: color-mix(in srgb, var(--text) 8%, transparent); }
@@ -606,36 +462,13 @@
.px-up-sub { color: var(--text-2); font-size: var(--t-11); font-variant-numeric: tabular-nums; }
.px-up-row.is-failed .px-up-sub { color: var(--text-2); }
.px-up-end { flex: none; display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--t-12, 12px); }
-.px-up-stop {
- display: grid;
- place-items: center;
- width: 16px;
- height: 16px;
- padding: 0;
- border: 0;
- border-radius: 50%;
- background: var(--text-3);
- color: var(--bg);
- cursor: default;
-}
-.px-up-stop:hover { background: var(--text-2); }
.px-up-ok { color: #30d158; }
.px-up-why { color: var(--text-3); }
-.px-up-spin {
- width: 16px;
- height: 16px;
- border-radius: 50%;
- border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
- border-top-color: var(--accent);
- animation: px-spin 800ms linear infinite;
-}
-@keyframes px-spin { to { transform: rotate(360deg); } }
/* ---- the Albums page: every album as a card with its cover, as icloud.com's ------------------ */
.px-main[data-page="albums"] > :not(.px-albums-page) { display: none; }
.px-albums-page { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px 24px; }
.px-albums-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 18px; }
-.px-albums-head h1 { margin: 0; font-size: var(--t-22, 22px); font-weight: 700; letter-spacing: -0.015em; }
.px-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 18px; }
.px-card {
display: flex;
@@ -775,42 +608,14 @@
}
.px-keyword-field:focus { box-shadow: 0 0 0 2px var(--accent-ring); }
-/* ---- a sheet over Photos — Download Options — as icloud.com's: centred, solid, the rest dimmed */
-.px-sheet-scrim {
- position: fixed;
- inset: 0;
- z-index: 90;
- display: grid;
- place-items: center;
- background: rgba(0, 0, 0, 0.42);
-}
-.px-sheet {
- position: relative;
- width: min(380px, calc(100vw - 32px));
- padding: 22px 24px 18px;
- border-radius: 16px;
- background: var(--sheet);
- box-shadow: var(--glass-float);
- color: var(--text);
- /* Fades in from the page, frame by frame (fadeSheetsIn), never a compositor animation. */
-}
-.px-sheet h2 { margin: 6px 0 12px; text-align: center; font-size: var(--t-15, 15px); font-weight: 700; }
-.px-sheet-x {
- position: absolute;
- top: 12px;
- left: 12px;
- display: grid;
- place-items: center;
- width: 26px;
- height: 26px;
- padding: 0;
- border: 0;
- border-radius: 50%;
- background: transparent;
- color: var(--text);
- cursor: default;
-}
-.px-sheet-x:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
+.px-sheet { width: min(380px, calc(100vw - 32px)); gap: 0; padding: 22px 24px 18px; }
+.px-sheet h2 { margin: 6px 0 12px; text-align: center; }
+.px-dl-go { color: var(--accent-strong); background: var(--fill); }
+.px-date-field { padding: 6px 10px; font-variant-numeric: tabular-nums; }
+.px-search { width: 200px; }
+@media (max-width: 1000px) { .px-search { width: 140px; } }
+.px-naming { width: 100%; }
+.px-shared-name { width: 100%; min-height: 34px; font-size: var(--t-15); }
.px-dl-pics { display: flex; justify-content: center; gap: 4px; }
.px-dl-pics img { width: 58px; height: 58px; border-radius: 8px; object-fit: cover; background: color-mix(in srgb, var(--text) 8%, transparent); }
.px-dl-count { margin: 6px 0 14px; text-align: center; font-size: var(--t-13); font-weight: 600; }
@@ -819,21 +624,6 @@
.px-dl-row span { display: flex; flex-direction: column; }
.px-dl-row strong { font-size: var(--t-13); font-weight: 600; }
.px-dl-row small { color: var(--text-2); font-size: var(--t-12, 12px); }
-.px-dl-go {
- display: grid;
- place-items: center;
- width: 34px;
- height: 34px;
- padding: 0;
- border: 0;
- border-radius: 9px;
- background: color-mix(in srgb, var(--text) 9%, transparent);
- color: var(--accent);
- cursor: default;
- transition: none;
-}
-.px-dl-go:hover { background: color-mix(in srgb, var(--text) 14%, transparent); }
-.px-dl-go:active { transform: scale(0.92); }
/* Adjust Date and Time. */
.px-taken { display: block; }
@@ -841,7 +631,7 @@
.px-date-zone { margin: 8px 0 14px; text-align: center; color: var(--text-2); font-size: var(--t-12, 12px); }
.px-date-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 10px; align-items: center; font-size: var(--t-13); }
.px-date-grid > span, .px-date-grid > label { text-align: right; }
-.px-date-was, .px-date-field {
+.px-date-was {
padding: 7px 10px;
border-radius: 8px;
background: var(--field, transparent);
@@ -851,56 +641,6 @@
font-variant-numeric: tabular-nums;
}
.px-date-was { color: var(--text-2); }
-.px-date-field { border: 0; outline: none; }
-.px-date-field:focus { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-ring); }
-.px-sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
-.px-sheet-button {
- height: 34px;
- border: 0;
- border-radius: 9px;
- background: color-mix(in srgb, var(--text) 10%, transparent);
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- font-weight: 600;
- cursor: default;
- transition: none;
-}
-.px-sheet-button:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 15%, transparent); }
-.px-sheet-button:active:not(:disabled) { transform: scale(0.97); }
-.px-sheet-button.is-primary { background: var(--accent); color: #fff; }
-.px-sheet-button.is-primary:hover:not(:disabled) { background: var(--accent-strong); }
-.px-sheet-button:disabled { opacity: 0.45; }
-
-/* The search field, a capsule at the toolbar's end as icloud.com's. */
-.px-search { align-items: center; gap: 6px; width: 200px; padding: 0 10px; color: var(--text-2); cursor: text; }
-.px-search input {
- flex: 1;
- min-width: 0;
- height: 100%;
- border: 0;
- background: transparent;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- outline: none;
-}
-.px-search input::-webkit-search-cancel-button { display: none; }
-.px-search input::placeholder { color: var(--text-3); }
-.px-search:focus-within { box-shadow: var(--glass-float), 0 0 0 3px var(--accent-ring); }
-.px-search-clear {
- display: grid;
- place-items: center;
- width: 16px;
- height: 16px;
- padding: 0;
- border: 0;
- border-radius: 50%;
- background: var(--text-3);
- color: var(--sheet);
- cursor: default;
-}
-@media (max-width: 1000px) { .px-search { width: 140px; } }
/* Folders nest: each level a step in, as the Mac sidebar steps them. */
.px-albums .px-depth.px-source,
@@ -909,31 +649,6 @@
.px-albums .px-parent-row.px-depth .px-parent { padding-left: calc(30px + var(--depth, 0) * 14px); }
.px-card.is-folder .px-card-pic { color: var(--accent); }
-/* ---- a question before a change, as icloud.com's Photos asks it: centred, a symbol over the
- question in bold, one quiet line, Cancel and the action side by side and equal ----------- */
-.px-ask { width: min(400px, 92vw); align-items: center; text-align: center; gap: 10px; padding: 26px 30px 26px; }
-.px-ask-symbol { display: grid; place-items: center; color: var(--accent); margin-bottom: 4px; }
-.px-ask-symbol.is-danger { color: var(--accent); }
-.px-ask h2 { white-space: normal; font-size: var(--t-17); font-weight: 700; line-height: 1.3; text-wrap: balance; }
-.px-ask p { margin: 0; font-size: var(--t-13); color: var(--text-2, color-mix(in srgb, var(--text) 70%, transparent)); text-wrap: balance; }
-.px-ask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 14px; }
-.px-ask-actions button {
- height: 36px;
- border: 0;
- border-radius: 9px;
- font: inherit;
- font-size: var(--t-15, 15px);
- font-weight: 500;
- color: var(--text);
- background: color-mix(in srgb, var(--text) 12%, transparent);
-}
-.px-ask-actions button:hover { background: color-mix(in srgb, var(--text) 17%, transparent); }
-.px-ask-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
-.px-ask-actions .is-act { color: var(--accent); }
-.px-ask-actions.is-stacked { grid-template-columns: 1fr; gap: 8px; }
-.px-ask .signout-unsent { color: var(--text); font-weight: 500; }
-.px-ask-actions .is-act.danger { color: var(--danger); }
-
/* ---- a video, as Photos plays one: the film alone, its controls in a capsule floating over
its foot that fades while the pointer rests (always there while paused) ----------------- */
.px-player { position: relative; display: block; overflow: hidden; max-width: none; max-height: none; background: #000 center / 100% 100% no-repeat; }
@@ -1058,8 +773,8 @@
grid-template-columns: 84px 1fr;
width: 400px;
max-height: min(460px, 70vh);
- border-radius: 14px;
- background: var(--sheet);
+ border-radius: var(--r-float);
+ background: var(--glass-thick);
box-shadow: var(--glass-float);
overflow: hidden;
outline: none;
@@ -1109,23 +824,6 @@
white frame, a question mark, the file's name); what is under it shows. */
img[data-failed] { content: url("data:image/gif;base64,R0lGODlhAQABAAAAACw="); }
-/* Shared Albums: nothing shared yet, and the name for a new one. */
-.px-shared-empty { display: grid; justify-items: start; gap: 12px; }
-.px-shared-empty p { margin: 0; }
-.px-shared-name {
- width: 100%;
- height: 34px;
- margin: 4px 0 2px;
- padding: 0 10px;
- border: 0;
- border-radius: 8px;
- font: inherit;
- font-size: var(--t-15, 15px);
- color: var(--text);
- background: var(--field, color-mix(in srgb, var(--text) 8%, transparent));
- box-shadow: inset 0 0 0 1px var(--field-edge, var(--separator));
-}
-.px-shared-name:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-ring); }
/* The last picture painted, in the same place as the frame over it (the stage's one cell). */
.px-stage > .px-under, .px-stage > .px-pan { grid-area: 1 / 1; }
.px-under { background-size: 100% 100%; }
diff --git a/src/styles/reminders.css b/src/styles/reminders.css
index db8b013..d9b592d 100644
--- a/src/styles/reminders.css
+++ b/src/styles/reminders.css
@@ -4,31 +4,6 @@
* and collided — one class name meant a button in one place and a notice in another — so
* this file is the only place Reminders is styled. */
-:root {
- /* Apple's system colours, which are what its built-in views are drawn in. They shift
- between light and dark, so they are not the same six hex values in both. */
- --sys-blue: #0088ff;
- --sys-red: #ff383c;
- --sys-gray: #8e8e93;
- --sys-orange: #ff8d28;
-}
-
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme="light"]) {
- --sys-blue: #0091ff;
- --sys-red: #ff4245;
- --sys-gray: #98989d;
- --sys-orange: #ff9230;
- }
-}
-/* The same, when Settings chooses Dark whatever the system says. */
-:root[data-theme="dark"] {
- --sys-blue: #0091ff;
- --sys-red: #ff4245;
- --sys-gray: #98989d;
- --sys-orange: #ff9230;
- }
-
.content[data-screen="reminders"] { display: flex; flex-direction: column; overflow: hidden; }
.rx {
@@ -52,31 +27,6 @@
border-right: 1px solid var(--separator);
}
-.rx-search {
- display: flex;
- align-items: center;
- gap: 6px;
- height: 28px;
- margin-bottom: 10px;
- padding: 0 8px;
- border-radius: var(--r-field);
- background: color-mix(in srgb, var(--text) 7%, transparent);
- color: var(--text-3);
-}
-.rx-search svg { width: 13px; height: 13px; flex: none; }
-.rx-search input {
- flex: 1;
- min-width: 0;
- border: 0;
- background: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- outline: none;
-}
-.rx-search input::placeholder { color: var(--text-3); }
-.rx-search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sys-blue) 35%, transparent); }
-
/* The tiles: glyph top left, count top right, name beneath. Chosen, a tile takes its own
colour and everything on it turns white — which is how Apple marks the open one. */
.rx-tiles {
@@ -147,47 +97,11 @@
.rx-tile[aria-current="true"] .rx-tile-glyph { background: #fff; color: color-mix(in srgb, var(--tile) 82%, #000); }
.rx-tile[aria-current="true"] .rx-tile-name { color: #fff; }
-/* On the same left edge as the list badges beneath it, where a source list puts a heading. */
-.rx-side-heading {
- margin: 0 0 4px;
- padding: 0 5px;
- color: var(--text-3);
- font-size: var(--t-11);
- font-weight: 600;
-}
-
.rx-lists { display: flex; flex-direction: column; gap: 1px; }
.rx-list-row { position: relative; display: flex; align-items: center; }
.rx-list-row.nested { padding-left: 18px; }
-.rx-list,
-.rx-group-row {
- flex: 1;
- min-width: 0;
- display: flex;
- align-items: center;
- gap: 8px;
- height: 32px;
- padding: 0 8px 0 5px;
- border: 0;
- border-radius: 7px;
- background: none;
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- text-align: left;
- cursor: default;
-}
-/* The highlight follows the row, not the list's button alone: the ⋯ sits over the row
- beside the button, and moving onto it took the hover off the button — the highlight
- blinked out and back. Held while the row's menu is open too. */
-.rx-list-row:hover .rx-list, .rx-list-row.is-menu .rx-list,
-.rx-group-row:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
-.rx-list[aria-current="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
-.rx-list:focus-visible,
-.rx-group-row:focus-visible { outline: 3px solid color-mix(in srgb, var(--sys-blue) 40%, transparent); outline-offset: -1px; }
-
.rx-badge {
display: grid;
place-items: center;
@@ -209,64 +123,17 @@
}
.rx-group-glyph svg { width: 17px; height: 17px; }
-.rx-list-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-group-row { width: 100%; }
.rx-group-row .rx-list-name { font-weight: 600; }
-.rx-list-count {
- /* Wide enough for the ⋯ that takes its place, so nothing beside it moves when it does. */
- min-width: 26px;
- color: var(--text-3);
- font-size: var(--t-13);
- font-variant-numeric: tabular-nums;
- text-align: right;
-}
-
.rx-chevron { display: grid; place-items: center; color: var(--text-3); transition: transform 180ms var(--ease); }
.rx-chevron svg { width: 12px; height: 12px; }
.rx-group-row[aria-expanded="true"] .rx-chevron { transform: rotate(90deg); }
-/* The list's ⋯ waits until it is pointed at, over where its count sits — the same control
- Notes' and Contacts' rows have (.notes-folder-more). */
-.rx-list-more { right: 8px; }
-.rx-list-row:hover .rx-list-more, .rx-list-row:focus-within .rx-list-more { opacity: 1; }
-.rx-list-row:hover .rx-list-count,
-.rx-list-row:focus-within .rx-list-count { visibility: hidden; }
-.rx-list-row.is-menu .rx-list-more { opacity: 1; }
-.rx-list-row.is-menu .rx-list-count { visibility: hidden; }
-
-.rx-rename {
- flex: 1;
- height: 30px;
- padding: 0 8px;
- border: 1px solid var(--field-edge);
- border-radius: 7px;
- background: var(--field);
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- outline: none;
-}
-.rx-rename:focus { border-color: var(--sys-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sys-blue) 30%, transparent); }
.rx-new-list { display: flex; margin-top: 4px; }
-
-.rx-add-list {
- display: flex;
- align-items: center;
- gap: 6px;
- margin-top: auto;
- padding: 10px 8px 0;
- border: 0;
- background: none;
- color: var(--text-2);
- font: inherit;
- font-size: var(--t-13);
- cursor: default;
-}
-.rx-add-list svg { width: 14px; height: 14px; }
-.rx-add-list:hover { color: var(--text); }
-
-.rx-side-empty { margin: 4px 8px; color: var(--text-3); font-size: var(--t-13); }
+.rx-new-list .field, .rx-list-row > .field { flex: 1; }
+.rx-search { margin-bottom: 10px; }
+.rx-field .field { width: 100%; }
/* ---- the open view ---------------------------------------------------------- */
@@ -279,43 +146,9 @@
glance — while the pane scrolls at its own edge. */
.rx-main > * { max-width: 960px; }
-/* The view's name in its own colour, its count at the far end of the same line. */
-.rx-head {
- display: flex;
- align-items: baseline;
- justify-content: space-between;
- gap: 16px;
- padding: 2px 14px 10px 0;
- color: var(--accent-strong);
-}
-.rx-head h1 {
- margin: 0;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: 26px;
- font-weight: 700;
- letter-spacing: -0.02em;
- line-height: 1.15;
-}
-.rx-head-count { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
-
-.rx-subhead { display: flex; justify-content: flex-end; padding: 0 14px 6px 0; margin-top: -4px; }
-
-.rx-link {
- padding: 2px 0;
- border: 0;
- background: none;
- color: var(--sys-blue);
- font: inherit;
- font-size: var(--t-13);
- cursor: default;
-}
-.rx-link:hover { text-decoration: underline; }
-.rx-link.danger { color: var(--sys-red); }
-.rx-link:disabled { opacity: 0.5; }
-
+/* The view's name in its own colour (the kit's pane head). */
+.rx-head { padding: 2px 14px 10px 0; }
+.rx-head h1 { color: var(--accent-strong); }
.rx-capped {
margin: 0 14px 8px 0;
@@ -467,26 +300,6 @@
.rx-icon-button.rx-flag.on { opacity: 1; }
.rx-icon-button.rx-flag.on { color: var(--sys-orange); }
-.rx-icon-button {
- display: grid;
- place-items: center;
- width: 22px;
- height: 22px;
- padding: 0;
- border: 0;
- border-radius: 6px;
- background: none;
- color: var(--text-3);
- font: inherit;
- font-size: var(--t-13);
- cursor: default;
-}
-.rx-icon-button svg { width: 15px; height: 15px; }
-.rx-icon-button:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
-.rx-icon-button.danger:hover { color: var(--sys-red); }
-.rx-icon-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--sys-blue) 40%, transparent); opacity: 1; }
-.rx-icon-button:disabled { opacity: 0.4; }
-
.rx-detail {
display: flex;
flex-direction: column;
@@ -503,21 +316,6 @@
align-items: center;
}
.rx-field > span { color: var(--text-2); font-size: var(--t-11); }
-.rx-field input,
-.rx-field textarea {
- width: 100%;
- padding: 5px 8px;
- border: 1px solid var(--field-edge);
- border-radius: 6px;
- background: var(--field);
- color: var(--text);
- font: inherit;
- font-size: var(--t-13);
- outline: none;
- resize: vertical;
-}
-.rx-field input:focus,
-.rx-field textarea:focus { border-color: var(--sys-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sys-blue) 28%, transparent); }
.rx-hint { margin: -2px 0 0 74px; color: var(--text-3); font-size: var(--t-11); }
.rx-detail-actions { display: flex; justify-content: space-between; margin-top: 2px; }
@@ -544,8 +342,6 @@
.rx-add-target { max-width: 160px; }
.rx-add-target .picker-button { font-size: var(--t-11); padding: 3px 8px; }
-.rx-empty { margin: 28px 0 0; color: var(--text-3); font-size: var(--t-15); text-align: center; }
-
/* One column at a time, as on iPhone: the lists, or the list picked from them. Searching
keeps the field and shows what it found beneath it. */
@media (max-width: 720px) {
@@ -565,27 +361,19 @@
.rx-info h2 { margin: 0; font-size: var(--t-15); font-weight: 600; }
.rx-info-mark { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, currentColor 0%, rgba(0,0,0,0.35)); transition: background 160ms ease; }
.rx-info-mark svg { width: 40px; height: 40px; }
-.rx-info-name { width: 100%; padding: 8px 10px; border: 1px solid var(--separator); border-radius: 8px; background: color-mix(in srgb, var(--text) 5%, transparent); font: inherit; font-size: var(--t-15); font-weight: 600; text-align: center; outline: none; }
-.rx-info-name:focus { border-color: currentColor; }
+.rx-info-name { width: 100%; font-size: var(--t-15); font-weight: 600; text-align: center; }
+.rx-info .sheet-actions { width: 100%; justify-content: space-between; }
.rx-info-colours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.rx-info-swatch { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; box-shadow: none; cursor: pointer; transition: transform 120ms ease; }
.rx-info-swatch.is-on { box-shadow: 0 0 0 2px var(--sheet, var(--bg)), 0 0 0 4px var(--text-3); }
-.rx-info-actions { display: flex; justify-content: space-between; width: 100%; margin-top: 4px; }
/* Date, then the Time switch, then the time once it is on — the phone's order, on one line. */
.rx-due { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rx-field .rx-due .rx-due-day { width: auto; flex: 0 1 11em; }
.rx-field .rx-due .time-field { width: 10.5ch; flex: none; }
-/* The phone's switch: a pill that fills with the accent when on. */
+/* The kit's switch, drawn for a checkbox: the input itself out of sight, still there to reach. */
.rx-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--text-2); font-size: var(--t-13); cursor: pointer; }
.rx-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
-.rx-switch-track { position: relative; width: 34px; height: 20px; border-radius: 10px; background: color-mix(in srgb, var(--text) 22%, transparent); transition: background 160ms ease; }
-.rx-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 160ms ease; }
-/* On, it takes the accent, as a macOS switch does — green is the phone's. */
-.rx-switch input:checked + .rx-switch-track { background: var(--sys-blue, #0a84ff); }
-.rx-switch input:checked + .rx-switch-track::after { transform: translateX(14px); }
-.rx-switch input:focus-visible + .rx-switch-track { outline: 2px solid var(--sys-blue); outline-offset: 2px; }
-.rx-switch input:disabled + .rx-switch-track { opacity: 0.4; }
/* Dragging: the row lifted, and a line where it would land, as Reminders draws them. */
.rx-row[draggable="true"] { cursor: grab; }
diff --git a/src/styles/tokens.css b/src/styles/tokens.css
index 994d2e6..64e9013 100644
--- a/src/styles/tokens.css
+++ b/src/styles/tokens.css
@@ -92,6 +92,21 @@
/* .bouncy — the one moment that earns it: something arriving, the library opening. */
--spring-bouncy: linear(0, 0.0167, 0.0609, 0.1247, 0.2015, 0.2858, 0.3731, 0.4599, 0.5437, 0.6223, 0.6945, 0.7596, 0.817, 0.8669, 0.9092, 0.9446, 0.9734, 0.9963, 1.0139, 1.0269, 1.0361, 1.0419, 1.045, 1.046, 1.0452, 1.0432, 1.0403, 1.0368, 1.0329, 1.0289, 1.0249, 1.0211, 1.0174, 1.0141, 1.0111, 1.0085, 1.0062, 1.0042, 1.0026, 1.0012, 1.0002, 0.9994, 0.9988, 0.9983, 0.9981, 0.9979, 0.9979, 0.9979, 1);
--spring-bouncy-d: 700ms;
+ /* The shell's motion, in one place. On his WebKitGTK every animation that moved or scaled
+ a large layer — the content, the photo viewer, the sidebar — flickered, so the rules are:
+ large surfaces change at once (or fade colour, never opacity, at most --motion-fade);
+ only small things — a highlight, a chip — move, and never further than this. */
+ /* A hover or highlight answering the pointer: quick enough never to trail it. */
+ --motion-hover: 100ms;
+ /* Something small arriving or leaving in place: a notice. */
+ --motion-fade: 140ms;
+ /* Arriving: fast out of the gate, settling gently (decelerate). */
+ --motion-ease-out: cubic-bezier(0.2, 0, 0, 1);
+ /* Leaving: gathering pace as it goes (accelerate), so the end is not watched. */
+ --motion-ease-in: cubic-bezier(0.4, 0, 1, 1);
+ /* Keyboard focus, the same ring on everything in the shell. */
+ --focus-ring: 3px solid var(--accent-ring);
+
/* A press: in fast, so the control answers the finger; out on the snappy spring. */
--press-scale: 0.96;
--press-in: 90ms;
@@ -102,6 +117,37 @@
--r-plateau: 10px;
--r-field: 7px;
--r-pill: 999px;
+ /* A menu, popover or toast: the floating surfaces, all one radius. */
+ --r-float: 12px;
+
+ /* The kit's sizes (styles/kit.css). One height per kind of control, everywhere:
+ a button, field or pop-up 28; a toolbar capsule 32, its controls 28 inside it; a row
+ of a source list 30; a small icon button inside a row 22. */
+ --h-control: 28px;
+ --h-tool: 32px;
+ --h-row: 30px;
+ --h-mini: 22px;
+
+ /* The neutral fills every control and row is drawn with, so a hover, a press and a
+ selection read the same in every app. */
+ --fill: color-mix(in srgb, var(--text) 7%, transparent);
+ --fill-hover: color-mix(in srgb, var(--text) 6%, transparent);
+ --fill-press: color-mix(in srgb, var(--text) 12%, transparent);
+ --fill-selected: color-mix(in srgb, var(--text) 11%, transparent);
+ --ring: 0 0 0 3px var(--accent-ring);
+ /* Filled red, under white text at 4.5:1 in either appearance. */
+ --danger-deep: #c1121f;
+ /* A toolbar's capsules (kit.css .toolbar-group): nearly solid, a rim, a short lift. */
+ --tool-bg: color-mix(in srgb, var(--sheet) 90%, transparent);
+ --tool-drop: 0 2px 8px rgba(0, 0, 0, 0.08);
+ --tool-lift: var(--glass-specular), 0 0 0 0.5px var(--glass-edge), var(--tool-drop);
+
+ /* Apple's system colours, as its built-in views draw them; the dark set shifts them. */
+ --sys-blue: #0088ff;
+ --sys-red: #ff383c;
+ --sys-gray: #8e8e93;
+ --sys-orange: #ff8d28;
+ --sys-green: #34c759;
/* Apple's sheet-presentation curve. Decisive out, no bounce. */
--ease: cubic-bezier(0.32, 0.72, 0, 1);
@@ -135,6 +181,8 @@
--field-edge-hover: rgba(255, 255, 255, 0.28);
--danger: #ff6b6b;
--note-c1: #bf5af2; --note-c2: #ff375f; --note-c3: #ff9f0a; --note-c4: #63e6e2; --note-c5: #0a84ff;
+ --sys-blue: #0091ff; --sys-red: #ff4245; --sys-gray: #98989d; --sys-orange: #ff9230; --sys-green: #30d158;
+ --tool-drop: 0 2px 10px rgba(0, 0, 0, 0.4);
--shadow-sheet: 0 18px 50px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.4);
--shadow-field: inset 0 1px 1px rgba(0, 0, 0, 0.25);
--glass: rgba(40, 40, 44, 0.56);
@@ -160,6 +208,8 @@
--field-edge-hover: rgba(255, 255, 255, 0.28);
--danger: #ff6b6b;
--note-c1: #bf5af2; --note-c2: #ff375f; --note-c3: #ff9f0a; --note-c4: #63e6e2; --note-c5: #0a84ff;
+ --sys-blue: #0091ff; --sys-red: #ff4245; --sys-gray: #98989d; --sys-orange: #ff9230; --sys-green: #30d158;
+ --tool-drop: 0 2px 10px rgba(0, 0, 0, 0.4);
--shadow-sheet: 0 18px 50px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.4);
--shadow-field: inset 0 1px 1px rgba(0, 0, 0, 0.25);
--glass: rgba(40, 40, 44, 0.56);
@@ -210,23 +260,20 @@ body {
/* A control gives under a press and springs back, as Apple's do — buttons, icons, pop-up
buttons, segments. Not a row of a list: Apple's rows take a highlight, they do not
shrink. Only the pressed thing moves; hovering changes nothing but colour. */
-:is(.quiet, .primary, .danger, .rx-icon-button, .notes-icon, .cx-icon, .cx-today, .cx-more,
- .sidebar-toggle, .segment, .picker-button, .notes-aa, .notes-new-folder, .rx-add-list,
- .info-done, .compact-back, .notice-close, .upload-tray-close, .with-glyph, .cx-toast-undo,
- .cx-pop-delete):not(:disabled) {
+:is(.quiet, .primary, .icon-button, .tool, .segment, .picker-button, .sidebar-toggle,
+ .compact-back, .toast-action, .search-clear):not(:disabled) {
/* `scale`, not `transform`: a control placed with a transform keeps it. */
transition: scale var(--spring-snappy-d) var(--spring-snappy), background-color 120ms ease,
background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 160ms ease;
}
-:is(.quiet, .primary, .danger, .rx-icon-button, .notes-icon, .cx-icon, .cx-today, .cx-more,
- .sidebar-toggle, .segment, .picker-button, .notes-aa, .notes-new-folder, .rx-add-list,
- .info-done, .compact-back, .notice-close, .upload-tray-close, .with-glyph, .cx-toast-undo,
- .cx-pop-delete):not(:disabled):active {
+:is(.quiet, .primary, .icon-button, .tool, .segment, .picker-button, .sidebar-toggle,
+ .compact-back, .toast-action, .search-clear):not(:disabled):active {
scale: var(--press-scale);
transition-duration: var(--press-in), 0ms, 0ms, 0ms, 0ms, 160ms;
}
@media (prefers-reduced-motion: reduce) {
+ :root { --motion-hover: 0ms; --motion-fade: 0ms; }
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;