Replace the Notebook tab toolbar with an x, a rename dialog and drag-only reordering

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-20 12:01:37 -07:00
1 parent d4adb53a3a
commit 086c735c65
7 files changed
+194 -182

No files matched your search

+6 -6
View File
@@ -419,12 +419,12 @@ working in.
- **Tabs.** A row of named tabs sits across the top, each with its own text and - **Tabs.** A row of named tabs sits across the top, each with its own text and
its own pictures. **+ New tab** asks for a name first (1 to 40 characters, no its own pictures. **+ New tab** asks for a name first (1 to 40 characters, no
two the same in any case, up to 20 tabs). Under the row, **Rename** changes two the same in any case, up to 20 tabs), in a small dialog. There is no
the current tab's name (a double-click or **F2** on a tab does too), **Move toolbar under the row: a double-click (or **F2**) on a tab renames it, the **x**
left** and **Move right** (or **Alt** with the arrow keys) reorder it, and beside its name deletes it (the **Delete** key does too), and tabs are moved
tabs can be dragged. The tab you left open is the one you come back to. only by dragging them. The tab you left open is the one you come back to.
**Delete** asks twice and takes the tab's text and pictures with it; with no Delete opens a dialog that asks twice and takes the tab's text and pictures
tab left, the dialog asks you to make one. A notebook from before tabs opens with it; with no tab left, the dialog asks you to make one. A notebook from before tabs opens
as one tab called **Notes**. as one tab called **Notes**.
- **Markdown, styled as you type.** The editor shows Markdown in place: - **Markdown, styled as you type.** The editor shows Markdown in place:
headings grow, bullets draw, bold, code, quotes and links take their look, and headings grow, bullets draw, bold, code, quotes and links take their look, and
+63 -65
View File
@@ -405,16 +405,19 @@ const tabNames = (s) => tabButtons(s).evaluateAll((bs) => bs.map((b) => b.textCo
const selectedName = (s) => s.page.locator('#notepad-tabs .notepad-tab[aria-selected="true"]').evaluateAll((bs) => bs.map((b) => b.textContent)); const selectedName = (s) => s.page.locator('#notepad-tabs .notepad-tab[aria-selected="true"]').evaluateAll((bs) => bs.map((b) => b.textContent));
const status = (s) => s.page.locator("#notepad-status").textContent(); const status = (s) => s.page.locator("#notepad-status").textContent();
const idOf = (s, name) => listTabs(s.project).tabs.find((tab) => tab.name === name)?.id; const idOf = (s, name) => listTabs(s.project).tabs.find((tab) => tab.name === name)?.id;
// The x beside a tab's name: the current tab's, or the one named.
const X_SELECTED = '#notepad-tabs .notepad-tab[aria-selected="true"] + .notepad-tab-x';
const xOf = (s, name) => s.page.locator(`#notepad-tabs .notepad-tab-x[aria-label="Delete ${name}"]`);
const nameError = (s) => s.page.locator("#notepad-name-error").textContent(); const nameError = (s) => s.page.locator("#notepad-name-error").textContent();
// Makes a tab through the page: the button, the name form, Enter. // Makes a tab through the page: the button, the name form, Enter.
async function newTab(s, name, shown = name) { async function newTab(s, name, shown = name) {
await s.page.click("#notepad-tab-new"); await s.page.click("#notepad-tab-new");
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await s.page.locator("#notepad-name-dlg[open]").waitFor();
await s.page.fill("#notepad-name", name); await s.page.fill("#notepad-name", name);
await s.page.keyboard.press("Enter"); await s.page.keyboard.press("Enter");
await s.page.waitForFunction((n) => [...document.querySelectorAll("#notepad-tabs .notepad-tab")].some((b) => b.textContent === n && b.getAttribute("aria-selected") === "true"), shown); await s.page.waitForFunction((n) => [...document.querySelectorAll("#notepad-tabs .notepad-tab")].some((b) => b.textContent === n && b.getAttribute("aria-selected") === "true"), shown);
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden); await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
} }
// A notepad in its first shape: meta.json v1, note.md and images/ at the top. // A notepad in its first shape: meta.json v1, note.md and images/ at the top.
@@ -455,7 +458,7 @@ test("New tab asks for a name, refuses a bad or duplicate one, and Escape backs
const violations = await watchViolations(s); const violations = await watchViolations(s);
await openNotepad(s); await openNotepad(s);
await s.page.click("#notepad-tab-new"); await s.page.click("#notepad-tab-new");
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await s.page.locator("#notepad-name-dlg[open]").waitFor();
assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Name this tab"); assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Name this tab");
assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-name", "the field has the focus"); assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-name", "the field has the focus");
assert.equal(await s.page.inputValue("#notepad-name"), ""); assert.equal(await s.page.inputValue("#notepad-name"), "");
@@ -476,13 +479,13 @@ test("New tab asks for a name, refuses a bad or duplicate one, and Escape backs
// Escape closes the form, not the Notebook, and gives the focus back. // Escape closes the form, not the Notebook, and gives the focus back.
await s.page.keyboard.press("Escape"); await s.page.keyboard.press("Escape");
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden); await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true); assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true);
assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-tab-new"); assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-tab-new");
// Cancel does the same. // Cancel does the same.
await s.page.click("#notepad-tab-new"); await s.page.click("#notepad-tab-new");
await s.page.click("#notepad-name-cancel"); await s.page.click("#notepad-name-cancel");
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden); await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
await newTab(s, " Big ideas ", "Big ideas"); await newTab(s, " Big ideas ", "Big ideas");
assert.deepEqual(await tabNames(s), ["Notes", "Big ideas"]); assert.deepEqual(await tabNames(s), ["Notes", "Big ideas"]);
@@ -559,27 +562,28 @@ test("each tab keeps its own text and pictures, and switching never saves into t
assert.deepEqual(await violations(), []); assert.deepEqual(await violations(), []);
}); });
test("Rename opens the same form with the name selected; F2 and double-click work too", async (t) => { test("Double-click opens the rename modal with the name selected; F2 works too, and there is no Rename button", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION }); const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
await openNotepad(s); await openNotepad(s);
await newTab(s, "Ideas"); await newTab(s, "Ideas");
const ideas = idOf(s, "Ideas"); const ideas = idOf(s, "Ideas");
await s.page.click("#notepad-tab-rename"); assert.equal(await s.page.locator("#notepad-tab-rename, #notepad-tab-tools").count(), 0, "the bottom toolbar is gone");
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await tabNamed(s, "Ideas").dblclick();
await s.page.locator("#notepad-name-dlg[open]").waitFor();
assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Rename this tab"); assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Rename this tab");
assert.equal(await s.page.inputValue("#notepad-name"), "Ideas"); assert.equal(await s.page.inputValue("#notepad-name"), "Ideas");
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-name").selectionEnd - document.getElementById("notepad-name").selectionStart), 5, "the name is selected"); assert.equal(await s.page.evaluate(() => document.getElementById("notepad-name").selectionEnd - document.getElementById("notepad-name").selectionStart), 5, "the name is selected");
// Its own name is not a duplicate; another tab's is. // Its own name is not a duplicate; another tab's is.
await s.page.keyboard.press("Enter"); await s.page.keyboard.press("Enter");
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden); await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
await s.page.click("#notepad-tab-rename"); await tabNamed(s, "Ideas").dblclick();
await s.page.fill("#notepad-name", "notes"); await s.page.fill("#notepad-name", "notes");
await s.page.keyboard.press("Enter"); await s.page.keyboard.press("Enter");
assert.equal(await nameError(s), errorSentence("duplicate-name")); assert.equal(await nameError(s), errorSentence("duplicate-name"));
await s.page.fill("#notepad-name", "Plans"); await s.page.fill("#notepad-name", "Plans");
await s.page.keyboard.press("Enter"); await s.page.keyboard.press("Enter");
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden); await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
assert.deepEqual(await tabNames(s), ["Notes", "Plans"]); assert.deepEqual(await tabNames(s), ["Notes", "Plans"]);
assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === ideas).name, "Plans"); assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === ideas).name, "Plans");
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Plans", "the focus is back on the tab"); assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Plans", "the focus is back on the tab");
@@ -587,11 +591,11 @@ test("Rename opens the same form with the name selected; F2 and double-click wor
// F2 on a focused tab, and a double-click. // F2 on a focused tab, and a double-click.
await tabNamed(s, "Plans").focus(); await tabNamed(s, "Plans").focus();
await s.page.keyboard.press("F2"); await s.page.keyboard.press("F2");
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await s.page.locator("#notepad-name-dlg[open]").waitFor();
assert.equal(await s.page.inputValue("#notepad-name"), "Plans"); assert.equal(await s.page.inputValue("#notepad-name"), "Plans");
await s.page.keyboard.press("Escape"); await s.page.keyboard.press("Escape");
await tabNamed(s, "Notes").dblclick(); await tabNamed(s, "Notes").dblclick();
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await s.page.locator("#notepad-name-dlg[open]").waitFor();
assert.equal(await s.page.inputValue("#notepad-name"), "Notes"); assert.equal(await s.page.inputValue("#notepad-name"), "Notes");
assert.deepEqual(await selectedName(s), ["Notes"], "double-click picked the tab it renames"); assert.deepEqual(await selectedName(s), ["Notes"], "double-click picked the tab it renames");
}); });
@@ -617,42 +621,29 @@ const drag = (s, from, to, { kind = "tab" } = {}) =>
{ from, to, kind }, { from, to, kind },
); );
test("tabs reorder by drag and by keyboard, and the order is kept", async (t) => { test("tabs reorder by drag only, and the order is kept", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION }); const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
await openNotepad(s); await openNotepad(s);
for (const name of ["Ideas", "Plans", "Done"]) await newTab(s, name); for (const name of ["Ideas", "Plans", "Done"]) await newTab(s, name);
assert.deepEqual(await tabNames(s), ["Notes", "Ideas", "Plans", "Done"]); assert.deepEqual(await tabNames(s), ["Notes", "Ideas", "Plans", "Done"]);
const order = () => listTabs(s.project).tabs.map((tab) => tab.name); const order = () => listTabs(s.project).tabs.map((tab) => tab.name);
// Keyboard: Alt+Left and Alt+Right on a focused tab, focus stays on it. // No buttons and no Alt+Arrow: a drag is the only way to move a tab.
assert.equal(await s.page.locator("#notepad-tab-left, #notepad-tab-right").count(), 0);
await tabNamed(s, "Done").focus(); await tabNamed(s, "Done").focus();
await s.page.keyboard.press("Alt+ArrowLeft"); await s.page.keyboard.press("Alt+ArrowLeft");
await until(() => order().join() === "Notes,Ideas,Done,Plans", 4000); await s.page.waitForTimeout(300);
assert.deepEqual(await tabNames(s), ["Notes", "Ideas", "Done", "Plans"]); assert.equal(order().join(), "Notes,Ideas,Plans,Done", "Alt+Arrow moved nothing");
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Done"); // Arrows only move the focus, with or without Alt, and never the tab.
assert.equal(await status(s), "Moved Done to position 3 of 4", "the move is announced"); assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Plans");
await s.page.keyboard.press("Alt+ArrowLeft"); await s.page.keyboard.press("ArrowLeft");
await s.page.keyboard.press("Alt+ArrowLeft"); assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Ideas");
await s.page.keyboard.press("Alt+ArrowLeft"); assert.equal(order().join(), "Notes,Ideas,Plans,Done");
await until(() => order().join() === "Done,Notes,Ideas,Plans", 4000);
assert.equal(await status(s), "Moved Done to position 1 of 4", "and it stops at the first place");
// Plain arrows move the focus without moving the tab.
await s.page.keyboard.press("ArrowRight");
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Notes");
assert.equal(order().join(), "Done,Notes,Ideas,Plans");
// The visible buttons act on the current tab.
await tabNamed(s, "Plans").click();
await s.page.click("#notepad-tab-left");
await until(() => order().join() === "Done,Notes,Plans,Ideas", 4000);
await s.page.click("#notepad-tab-right");
await until(() => order().join() === "Done,Notes,Ideas,Plans", 4000);
assert.equal(await s.page.locator("#notepad-tab-right").isDisabled(), true, "the last tab cannot move right");
// Drag: the target shows a mark, the dragged tab lands just before it. // Drag: the target shows a mark, the dragged tab lands just before it.
assert.equal(await drag(s, "Plans", "Done"), true, "the target is marked while dragged over"); assert.equal(await drag(s, "Done", "Notes"), true, "the target is marked while dragged over");
await until(() => order().join() === "Plans,Done,Notes,Ideas", 4000); await until(() => order().join() === "Done,Notes,Ideas,Plans", 4000);
assert.deepEqual(await tabNames(s), ["Plans", "Done", "Notes", "Ideas"]); assert.deepEqual(await tabNames(s), ["Done", "Notes", "Ideas", "Plans"]);
assert.equal(await s.page.locator("#notepad-tabs .is-drop-before").count(), 0, "the mark is gone after the drop"); assert.equal(await s.page.locator("#notepad-tabs .is-drop-before").count(), 0, "the mark is gone after the drop");
// Text dragged over a tab does nothing. // Text dragged over a tab does nothing.
@@ -660,14 +651,14 @@ test("tabs reorder by drag and by keyboard, and the order is kept", async (t) =>
s.page.on("request", (r) => r.url().includes("/notepad/tab/order") && posted.push(r.url())); s.page.on("request", (r) => r.url().includes("/notepad/tab/order") && posted.push(r.url()));
assert.equal(await drag(s, "Plans", "Ideas", { kind: "text" }), false); assert.equal(await drag(s, "Plans", "Ideas", { kind: "text" }), false);
await s.page.waitForTimeout(300); await s.page.waitForTimeout(300);
assert.equal(order().join(), "Plans,Done,Notes,Ideas"); assert.equal(order().join(), "Done,Notes,Ideas,Plans");
assert.equal(posted.length, 0); assert.equal(posted.length, 0);
// Reopened, the order stands. // Reopened, the order stands.
await s.page.reload({ waitUntil: "domcontentloaded" }); await s.page.reload({ waitUntil: "domcontentloaded" });
await drawn(s.page); await drawn(s.page);
await openNotepad(s); await openNotepad(s);
assert.deepEqual(await tabNames(s), ["Plans", "Done", "Notes", "Ideas"]); assert.deepEqual(await tabNames(s), ["Done", "Notes", "Ideas", "Plans"]);
}); });
test("Delete asks twice, Escape backs out of either, and only the second confirm removes the tab and its folder", async (t) => { test("Delete asks twice, Escape backs out of either, and only the second confirm removes the tab and its folder", async (t) => {
@@ -688,7 +679,7 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
const panel = s.page.locator("#notepad-delete"); const panel = s.page.locator("#notepad-delete");
const text = () => s.page.locator("#notepad-delete-text").textContent(); const text = () => s.page.locator("#notepad-delete-text").textContent();
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await panel.waitFor({ state: "visible" }); await panel.waitFor({ state: "visible" });
assert.equal(await text(), "This deletes the tab Ideas, its text and its 2 pictures. This cannot be undone."); assert.equal(await text(), "This deletes the tab Ideas, its text and its 2 pictures. This cannot be undone.");
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Keep tab", "Keep tab has the focus"); assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Keep tab", "Keep tab has the focus");
@@ -700,7 +691,7 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Ideas"); assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Ideas");
// Step one then Escape: nothing deleted, and the Notebook stays open. // Step one then Escape: nothing deleted, and the Notebook stays open.
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
assert.equal(await text(), "Really delete Ideas for good?"); assert.equal(await text(), "Really delete Ideas for good?");
assert.equal(await s.page.locator("#notepad-delete-go").textContent(), "Yes, delete it"); assert.equal(await s.page.locator("#notepad-delete-go").textContent(), "Yes, delete it");
@@ -710,13 +701,13 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true); assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true);
assert.equal(fs.existsSync(folder), true); assert.equal(fs.existsSync(folder), true);
// Escape at the first step too. // Escape at the first step too.
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.keyboard.press("Escape"); await s.page.keyboard.press("Escape");
await panel.waitFor({ state: "hidden" }); await panel.waitFor({ state: "hidden" });
assert.equal(fs.existsSync(folder), true); assert.equal(fs.existsSync(folder), true);
// Both confirms: gone, with its folder, and the neighbour is shown. // Both confirms: gone, with its folder, and the neighbour is shown.
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await until(() => !fs.existsSync(folder), 4000); await until(() => !fs.existsSync(folder), 4000);
@@ -726,7 +717,7 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
assert.equal(listTabs(s.project).last, idOf(s, "Notes"), "the neighbour became the last tab"); assert.equal(listTabs(s.project).last, idOf(s, "Notes"), "the neighbour became the last tab");
// Delete the last tab: the empty state, with the focus on its button. // Delete the last tab: the empty state, with the focus on its button.
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.locator("#notepad-empty").waitFor({ state: "visible" }); await s.page.locator("#notepad-empty").waitFor({ state: "visible" });
@@ -754,7 +745,7 @@ test("text typed into a tab that is then deleted is never saved, and a tab delet
const saves = []; const saves = [];
s.page.on("request", (r) => r.url().includes("/notepad/text") && saves.push(r.url())); s.page.on("request", (r) => r.url().includes("/notepad/text") && saves.push(r.url()));
await typeInto(s, "typed then deleted"); await typeInto(s, "typed then deleted");
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1); await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
@@ -772,31 +763,38 @@ test("text typed into a tab that is then deleted is never saved, and a tab delet
assert.deepEqual(await tabNames(s), ["Notes"]); assert.deepEqual(await tabNames(s), ["Notes"]);
}); });
test("a name form or delete question open on one tab closes when another tab is picked", async (t) => { test("a double-click or an x acts on the tab it was made on, even when another is showing", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION }); const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
await openNotepad(s); await openNotepad(s);
await newTab(s, "Ideas"); await newTab(s, "Ideas");
const notes = idOf(s, "Notes"); const notes = idOf(s, "Notes");
assert.deepEqual(await selectedName(s), ["Ideas"]);
// Rename opened on Ideas, then Notes picked: the form goes, and Notes keeps its name. // Double-click on Notes while Ideas shows: Notes is picked and is the one renamed.
await s.page.click("#notepad-tab-rename"); await tabNamed(s, "Notes").dblclick();
await s.page.locator("#notepad-name-form:not([hidden])").waitFor(); await s.page.locator("#notepad-name-dlg[open]").waitFor();
await tabNamed(s, "Notes").click(); assert.equal(await s.page.inputValue("#notepad-name"), "Notes");
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
await until(async () => (await selectedName(s)).join() === "Notes", 4000); await until(async () => (await selectedName(s)).join() === "Notes", 4000);
assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === notes).name, "Notes"); await s.page.keyboard.press("Escape");
await s.page.waitForFunction(() => !document.getElementById("notepad-name-dlg").open);
assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === notes).name, "Notes", "Escape left the name alone");
// Delete opened (and moved on to its second step) on Notes, then Ideas picked: the question goes. // The x on Ideas while Notes shows: the question names Ideas, and Keep leaves both.
await s.page.click("#notepad-tab-delete"); await xOf(s, "Ideas").click();
await s.page.click("#notepad-delete-go"); await s.page.locator("#notepad-delete").waitFor({ state: "visible" });
assert.equal(await s.page.locator("#notepad-delete-text").textContent(), "Really delete Notes for good?");
await tabNamed(s, "Ideas").click();
await s.page.locator("#notepad-delete").waitFor({ state: "hidden" });
await until(async () => (await selectedName(s)).join() === "Ideas", 4000);
assert.deepEqual(await tabNames(s), ["Notes", "Ideas"], "nothing was deleted");
// Asking again starts at the first step, naming the tab now open.
await s.page.click("#notepad-tab-delete");
assert.match(await s.page.locator("#notepad-delete-text").textContent(), /^This deletes the tab Ideas,/); assert.match(await s.page.locator("#notepad-delete-text").textContent(), /^This deletes the tab Ideas,/);
await s.page.click("#notepad-delete-keep");
await s.page.locator("#notepad-delete").waitFor({ state: "hidden" });
assert.deepEqual(await tabNames(s), ["Notes", "Ideas"], "nothing was deleted");
// Both confirms on the x of the tab that is not showing now remove that one.
await tabNamed(s, "Notes").click();
await until(async () => (await selectedName(s)).join() === "Notes", 4000);
await xOf(s, "Ideas").click();
await s.page.click("#notepad-delete-go");
await s.page.click("#notepad-delete-go");
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
assert.deepEqual(await tabNames(s), ["Notes"]);
}); });
test("when the tab after a delete cannot be loaded, the deleted text is not left on screen", async (t) => { test("when the tab after a delete cannot be loaded, the deleted text is not left on screen", async (t) => {
@@ -809,7 +807,7 @@ test("when the tab after a delete cannot be loaded, the deleted text is not left
await until(() => readNotepad(s.project, ideas).text === "doomed text", 4000); await until(() => readNotepad(s.project, ideas).text === "doomed text", 4000);
// The neighbour's read fails, as if the connection dropped right after the delete. // The neighbour's read fails, as if the connection dropped right after the delete.
await s.page.route("**/notepad?tab=*", (route) => route.abort()); await s.page.route("**/notepad?tab=*", (route) => route.abort());
await s.page.click("#notepad-tab-delete"); await s.page.click(X_SELECTED);
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.click("#notepad-delete-go"); await s.page.click("#notepad-delete-go");
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1); await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
+24 -22
View File
@@ -2615,28 +2615,6 @@
<div class="notepad-tabs" id="notepad-tabs" role="tablist" aria-label="Notebook tabs"></div> <div class="notepad-tabs" id="notepad-tabs" role="tablist" aria-label="Notebook tabs"></div>
<button type="button" class="btn small ghost notepad-tab-new" id="notepad-tab-new">+ New tab</button> <button type="button" class="btn small ghost notepad-tab-new" id="notepad-tab-new">+ New tab</button>
</div> </div>
<div class="notepad-tab-tools" id="notepad-tab-tools" role="group" aria-label="This tab" hidden>
<button type="button" class="btn tiny ghost" id="notepad-tab-rename">Rename</button>
<button type="button" class="btn tiny ghost" id="notepad-tab-left">Move left</button>
<button type="button" class="btn tiny ghost" id="notepad-tab-right">Move right</button>
<button type="button" class="btn tiny ghost notepad-tab-delete" id="notepad-tab-delete">Delete</button>
</div>
<form class="notepad-name-form" id="notepad-name-form" hidden novalidate>
<label for="notepad-name" id="notepad-name-label">Name this tab</label>
<div class="notepad-name-row">
<input type="text" id="notepad-name" autocomplete="off" spellcheck="false" aria-describedby="notepad-name-error" />
<button type="submit" class="btn small primary" id="notepad-name-save">Save</button>
<button type="button" class="btn small ghost" id="notepad-name-cancel">Cancel</button>
</div>
<p class="help notepad-name-error" id="notepad-name-error" aria-live="polite"></p>
</form>
<div class="notepad-delete" id="notepad-delete" role="group" aria-labelledby="notepad-delete-text" hidden>
<p id="notepad-delete-text"></p>
<div class="notepad-delete-row">
<button type="button" class="btn small" id="notepad-delete-keep">Keep tab</button>
<button type="button" class="btn small danger" id="notepad-delete-go">Delete tab…</button>
</div>
</div>
<div class="notepad-empty" id="notepad-empty" hidden> <div class="notepad-empty" id="notepad-empty" hidden>
<p>No tabs yet. Make one to start writing.</p> <p>No tabs yet. Make one to start writing.</p>
<button type="button" class="btn small primary" id="notepad-empty-new">+ New tab</button> <button type="button" class="btn small primary" id="notepad-empty-new">+ New tab</button>
@@ -2655,6 +2633,30 @@
</div> </div>
</dialog> </dialog>
<!-- The Notebook's name and delete questions: small dialogs over the Notebook.
A tab's double-click (or F2) opens the name one for Rename, + New tab
opens it for a new name, and a tab's x opens the delete one, which asks twice. -->
<dialog class="modal notepad-sub" id="notepad-name-dlg" aria-labelledby="notepad-name-label">
<form class="notepad-name-form" id="notepad-name-form" novalidate>
<h2 id="notepad-name-label">Name this tab</h2>
<input type="text" id="notepad-name" autocomplete="off" spellcheck="false" aria-describedby="notepad-name-error" />
<p class="help notepad-name-error" id="notepad-name-error" aria-live="polite"></p>
<div class="modal-actions">
<button type="button" class="btn ghost" id="notepad-name-cancel">Cancel</button>
<button type="submit" class="btn primary" id="notepad-name-save">Save</button>
</div>
</form>
</dialog>
<dialog class="modal notepad-sub notepad-delete" id="notepad-delete" aria-labelledby="notepad-delete-title" aria-describedby="notepad-delete-text">
<h2 id="notepad-delete-title">Delete this tab?</h2>
<p id="notepad-delete-text"></p>
<div class="modal-actions">
<button type="button" class="btn ghost" id="notepad-delete-keep">Keep tab</button>
<button type="button" class="btn danger" id="notepad-delete-go">Delete tab…</button>
</div>
</dialog>
<!-- The Notebook's full-screen picture preview, opened over the Notebook <!-- The Notebook's full-screen picture preview, opened over the Notebook
from a thumbnail by screens/notepad.js. --> from a thumbnail by screens/notepad.js. -->
<dialog class="modal notepad-preview" id="notepad-preview" aria-label="Image preview"> <dialog class="modal notepad-preview" id="notepad-preview" aria-label="Image preview">
+24 -13
View File
@@ -1,11 +1,12 @@
// Plan2Code Web Console - the Notebook's tab bar. // Plan2Code Web Console - the Notebook's tab bar.
// //
// Draws #notepad-tabs from a list of { id, name } and tells screens/notepad.js // Draws #notepad-tabs from a list of { id, name } and tells screens/notepad.js
// what the person did: pick a tab (onSwitch), reorder with the keyboard or a // what the person did: pick a tab (onSwitch), reorder with a drag, ask to
// drag, or ask to rename (onChange). No fetches here: the screen owns every // rename (a double-click or F2) or ask to delete (the x beside the name, or the
// request, and notepad.js owns the rules for order. // Delete key) (onChange). No fetches here: the screen owns every request, and
// notepad.js owns the rules for order.
import { dropTab, moveTab } from "./notepad.js"; import { dropTab } from "./notepad.js";
import { el } from "./render.js"; import { el } from "./render.js";
const $ = (id) => document.getElementById(id); const $ = (id) => document.getElementById(id);
@@ -15,7 +16,7 @@ const DRAG_TYPE = "application/x-plan2code-notepad-tab";
/** /**
* `onSwitch(id)` runs when a tab is picked. `onChange(event)` runs for * `onSwitch(id)` runs when a tab is picked. `onChange(event)` runs for
* `{ type: "order", order, focus }` (a new order to save, focus the moved tab * `{ type: "order", order, focus }` (a new order to save, focus the moved tab
* afterwards) and `{ type: "rename", id }`. * afterwards), `{ type: "rename", id }` and `{ type: "delete", id }`.
*/ */
export function createTabs({ onSwitch, onChange }) { export function createTabs({ onSwitch, onChange }) {
const bar = $("notepad-tabs"); const bar = $("notepad-tabs");
@@ -25,6 +26,7 @@ export function createTabs({ onSwitch, onChange }) {
// or text dragged over the bar does nothing. // or text dragged over the bar does nothing.
let dragging = null; let dragging = null;
// The tab buttons; each sits in a wrapper with its x.
const buttons = () => Array.from(bar.querySelectorAll(".notepad-tab")); const buttons = () => Array.from(bar.querySelectorAll(".notepad-tab"));
const buttonFor = (id) => buttons().find((b) => b.dataset.id === id) || null; const buttonFor = (id) => buttons().find((b) => b.dataset.id === id) || null;
const ids = () => tabs.map((t) => t.id); const ids = () => tabs.map((t) => t.id);
@@ -43,7 +45,6 @@ export function createTabs({ onSwitch, onChange }) {
const left = e.key === "ArrowLeft"; const left = e.key === "ArrowLeft";
if (left || e.key === "ArrowRight") { if (left || e.key === "ArrowRight") {
e.preventDefault(); e.preventDefault();
if (e.altKey) return reorder(moveTab(ids(), id, left ? -1 : 1), id);
const list = buttons(); const list = buttons();
const at = list.findIndex((b) => b.dataset.id === id); const at = list.findIndex((b) => b.dataset.id === id);
const next = list[Math.max(0, Math.min(list.length - 1, at + (left ? -1 : 1)))]; const next = list[Math.max(0, Math.min(list.length - 1, at + (left ? -1 : 1)))];
@@ -55,6 +56,9 @@ export function createTabs({ onSwitch, onChange }) {
} else if (e.key === "F2") { } else if (e.key === "F2") {
e.preventDefault(); e.preventDefault();
onChange({ type: "rename", id }); onChange({ type: "rename", id });
} else if (e.key === "Delete") {
e.preventDefault();
onChange({ type: "delete", id });
} }
} }
@@ -82,14 +86,25 @@ export function createTabs({ onSwitch, onChange }) {
dragging = null; dragging = null;
clearMarks(); clearMarks();
}); });
b.addEventListener("dragover", (e) => { // The x is a button of its own beside the name, so the tab's text stays
// its name and a double-click or a drag on the name never reaches it.
const x = el("button", "notepad-tab-x", "×");
x.type = "button";
x.setAttribute("aria-label", "Delete " + tab.name);
x.title = "Delete tab";
x.tabIndex = active ? 0 : -1;
x.addEventListener("click", () => onChange({ type: "delete", id: tab.id }));
const wrap = el("div", "notepad-tabwrap");
wrap.setAttribute("role", "presentation");
wrap.append(b, x);
wrap.addEventListener("dragover", (e) => {
if (dragging === null) return; if (dragging === null) return;
e.preventDefault(); e.preventDefault();
e.dataTransfer.dropEffect = "move"; e.dataTransfer.dropEffect = "move";
clearMarks(); clearMarks();
if (tab.id !== dragging) b.classList.add("is-drop-before"); if (tab.id !== dragging) b.classList.add("is-drop-before");
}); });
b.addEventListener("drop", (e) => { wrap.addEventListener("drop", (e) => {
if (dragging === null) return; if (dragging === null) return;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@@ -98,7 +113,7 @@ export function createTabs({ onSwitch, onChange }) {
clearMarks(); clearMarks();
reorder(dropTab(ids(), id, tab.id), id); reorder(dropTab(ids(), id, tab.id), id);
}); });
return b; return wrap;
} }
// Dropping on the empty part of the bar moves the tab to the end. // Dropping on the empty part of the bar moves the tab to the end.
@@ -131,10 +146,6 @@ export function createTabs({ onSwitch, onChange }) {
const empty = tabs.length === 0; const empty = tabs.length === 0;
$("notepad-empty").hidden = !empty; $("notepad-empty").hidden = !empty;
$("notepad-body").hidden = empty; $("notepad-body").hidden = empty;
$("notepad-tab-tools").hidden = empty;
const at = tabs.findIndex((t) => t.id === activeId);
$("notepad-tab-left").disabled = at <= 0;
$("notepad-tab-right").disabled = at < 0 || at >= tabs.length - 1;
// A long row scrolls the current tab into view. // A long row scrolls the current tab into view.
buttonFor(activeId)?.scrollIntoView?.({ block: "nearest", inline: "nearest" }); buttonFor(activeId)?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
}, },
+15 -37
View File
@@ -21,7 +21,6 @@ import {
cleanTabName, cleanTabName,
errorSentence, errorSentence,
keepsText, keepsText,
moveTab,
nextDelete, nextDelete,
nextSave, nextSave,
noteBytes, noteBytes,
@@ -246,19 +245,10 @@ async function readNote(tab) {
const nameOf = (id) => (tabs.find((t) => t.id === id) || {}).name || ""; const nameOf = (id) => (tabs.find((t) => t.id === id) || {}).name || "";
const ids = () => tabs.map((t) => t.id);
function drawTabs() { function drawTabs() {
tabBar.draw(tabs, activeId); tabBar.draw(tabs, activeId);
const none = !activeId;
$("notepad-tab-rename").disabled = none || busy;
$("notepad-tab-delete").disabled = none || busy;
$("notepad-tab-new").disabled = busy; $("notepad-tab-new").disabled = busy;
$("notepad-empty-new").disabled = busy; $("notepad-empty-new").disabled = busy;
if (busy) {
$("notepad-tab-left").disabled = true;
$("notepad-tab-right").disabled = true;
}
$("notepad-name-save").disabled = busy; $("notepad-name-save").disabled = busy;
} }
@@ -342,13 +332,6 @@ async function reorder(order, focus) {
drawTabs(); drawTabs();
} }
// The current tab one place to the left or right.
function moveCurrent(delta) {
if (!activeId || busy) return;
const order = moveTab(ids(), activeId, delta);
if (order.join() !== ids().join()) reorder(order, activeId);
}
// A tab is no longer there (deleted here, or from another page): off the bar, // A tab is no longer there (deleted here, or from another page): off the bar,
// its unsaved text dropped without a save, and its neighbour on screen. // its unsaved text dropped without a save, and its neighbour on screen.
async function gone(id, index = tabs.findIndex((t) => t.id === id), announce = true) { async function gone(id, index = tabs.findIndex((t) => t.id === id), announce = true) {
@@ -387,8 +370,8 @@ function openNameForm(mode) {
closeDelete(); closeDelete();
naming = mode; naming = mode;
$("notepad-name-label").textContent = mode === "new" ? "Name this tab" : "Rename this tab"; $("notepad-name-label").textContent = mode === "new" ? "Name this tab" : "Rename this tab";
$("notepad-name-form").hidden = false;
$("notepad-name-error").textContent = ""; $("notepad-name-error").textContent = "";
if (!$("notepad-name-dlg").open) $("notepad-name-dlg").showModal();
const input = $("notepad-name"); const input = $("notepad-name");
input.value = mode === "rename" ? nameOf(activeId) : ""; input.value = mode === "rename" ? nameOf(activeId) : "";
input.focus(); input.focus();
@@ -399,7 +382,7 @@ function closeNameForm(toFocus = true) {
if (!naming) return; if (!naming) return;
const was = naming; const was = naming;
naming = null; naming = null;
$("notepad-name-form").hidden = true; $("notepad-name-dlg").close();
if (!toFocus) return; if (!toFocus) return;
if (was === "rename") tabBar.focusTab(activeId); if (was === "rename") tabBar.focusTab(activeId);
else (tabs.length ? $("notepad-tab-new") : $("notepad-empty-new")).focus(); else (tabs.length ? $("notepad-tab-new") : $("notepad-empty-new")).focus();
@@ -456,8 +439,9 @@ async function submitName() {
/* ------------------------------------------------------------ delete */ /* ------------------------------------------------------------ delete */
function paintDelete() { function paintDelete() {
$("notepad-delete").hidden = stage === "none"; const dlg = $("notepad-delete");
if (stage === "none") return; if (stage === "none") return void (dlg.open && dlg.close());
if (!dlg.open) dlg.showModal();
const name = nameOf(activeId); const name = nameOf(activeId);
const count = images.filter((img) => img.id).length; const count = images.filter((img) => img.id).length;
const pics = count === 1 ? "1 picture" : `${count} pictures`; const pics = count === 1 ? "1 picture" : `${count} pictures`;
@@ -914,7 +898,7 @@ export async function openNotepad() {
tell(""); tell("");
inform(""); inform("");
naming = null; naming = null;
$("notepad-name-form").hidden = true; $("notepad-name-dlg").close();
stage = "none"; stage = "none";
paintDelete(); paintDelete();
if (!dlg.open) dlg.showModal(); if (!dlg.open) dlg.showModal();
@@ -928,9 +912,12 @@ export function wireNotepad() {
onSwitch: (id) => switchTo(id), onSwitch: (id) => switchTo(id),
onChange: async (event) => { onChange: async (event) => {
if (event.type === "order") return reorder(event.order, event.focus); if (event.type === "order") return reorder(event.order, event.focus);
// Rename acts on the current tab: a double-click or F2 on another one picks it first. // Rename and delete act on the current tab: a double-click, F2 or x on
// another one picks it first.
if (event.id && event.id !== activeId) await switchTo(event.id); if (event.id && event.id !== activeId) await switchTo(event.id);
if (!event.id || event.id === activeId) openNameForm("rename"); if (event.id && event.id !== activeId) return;
if (event.type === "delete") openDelete();
else openNameForm("rename");
}, },
}); });
lightDismiss(dlg); lightDismiss(dlg);
@@ -940,10 +927,6 @@ export function wireNotepad() {
$("notepad-close").addEventListener("click", () => dlg.close()); $("notepad-close").addEventListener("click", () => dlg.close());
$("notepad-tab-new").addEventListener("click", () => openNameForm("new")); $("notepad-tab-new").addEventListener("click", () => openNameForm("new"));
$("notepad-empty-new").addEventListener("click", () => openNameForm("new")); $("notepad-empty-new").addEventListener("click", () => openNameForm("new"));
$("notepad-tab-rename").addEventListener("click", () => openNameForm("rename"));
$("notepad-tab-left").addEventListener("click", () => moveCurrent(-1));
$("notepad-tab-right").addEventListener("click", () => moveCurrent(1));
$("notepad-tab-delete").addEventListener("click", openDelete);
$("notepad-delete-keep").addEventListener("click", () => closeDelete(true)); $("notepad-delete-keep").addEventListener("click", () => closeDelete(true));
$("notepad-delete-go").addEventListener("click", confirmDelete); $("notepad-delete-go").addEventListener("click", confirmDelete);
$("notepad-name-cancel").addEventListener("click", () => closeNameForm()); $("notepad-name-cancel").addEventListener("click", () => closeNameForm());
@@ -951,15 +934,10 @@ export function wireNotepad() {
e.preventDefault(); e.preventDefault();
submitName(); submitName();
}); });
// Esc backs out of the name form or the delete question first, and only // The two small dialogs are modal over the Notebook, so Esc (or any other
// then closes the dialog. // way they close) backs out of them alone and the state follows the dialog.
dlg.addEventListener("keydown", (e) => { $("notepad-name-dlg").addEventListener("close", () => closeNameForm());
if (e.key !== "Escape" || (!naming && stage === "none")) return; $("notepad-delete").addEventListener("close", () => closeDelete(true));
e.preventDefault();
e.stopPropagation();
if (naming) closeNameForm();
else closeDelete(true);
});
dlg.addEventListener("close", () => { dlg.addEventListener("close", () => {
flush(); flush();
$("btn-notepad").focus(); $("btn-notepad").focus();
+58 -34
View File
@@ -38,7 +38,7 @@
flex: 1 1 auto; flex: 1 1 auto;
min-height: 0; min-height: 0;
border: 1px solid var(--rule-2); border: 1px solid var(--rule-2);
border-radius: 8px; border-radius: 0;
overflow: hidden; overflow: hidden;
background: var(--panel); background: var(--panel);
} }
@@ -165,18 +165,35 @@
.notepad-status { margin: 0 auto 0 0; min-height: 1.4em; font-size: 12.5px; color: var(--ink-3); } .notepad-status { margin: 0 auto 0 0; min-height: 1.4em; font-size: 12.5px; color: var(--ink-3); }
.notepad-status.is-problem { color: var(--warn); } .notepad-status.is-problem { color: var(--warn); }
/* The tab bar: a scrolling row of tab buttons with the current one marked, /* The tab bar: a scrolling row of tabs, each its name and an x, with the
then New tab. The tools under it act on the current tab. */ current one marked, then New tab. A double-click renames, the x deletes and
.notepad-tabbar { flex: none; display: flex; align-items: flex-end; gap: 8px; margin-bottom: 4px; } a drag moves; the questions open in the small dialogs below. */
.notepad-tabs { flex: 1 1 auto; min-width: 0; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; } .notepad-tabbar { flex: none; display: flex; align-items: flex-end; gap: 8px; margin-bottom: -1px; position: relative; z-index: 1; }
.notepad-tab { .notepad-tabs { flex: 1 1 auto; min-width: 0; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 0; }
.notepad-tabwrap {
flex: none; flex: none;
max-width: 220px; max-width: 240px;
padding: 6px 12px; display: flex;
align-items: center;
border: 1px solid var(--rule-2); border: 1px solid var(--rule-2);
border-radius: 8px 8px 0 0; border-radius: 8px 8px 0 0;
background: var(--panel-2); background: var(--panel-2);
color: var(--ink-2); color: var(--ink-2);
}
.notepad-tabwrap:hover { color: var(--accent); border-color: var(--accent-line); }
.notepad-tabwrap:has(.notepad-tab[aria-selected="true"]) {
background: var(--accent-soft);
border-color: var(--accent);
border-bottom-color: var(--panel);
color: var(--ink);
}
.notepad-tab {
flex: 0 1 auto;
min-width: 0;
padding: 6px 4px 6px 12px;
border: 0;
background: none;
color: inherit;
font: inherit; font: inherit;
font-size: 13px; font-size: 13px;
line-height: 1.2; line-height: 1.2;
@@ -185,27 +202,37 @@
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.notepad-tab:hover { color: var(--accent); border-color: var(--accent-line); } .notepad-tab[aria-selected="true"] { font-weight: 600; }
.notepad-tab[aria-selected="true"] { .notepad-tab-x {
background: var(--accent-soft); flex: none;
border-color: var(--accent); width: 20px;
color: var(--ink); height: 20px;
font-weight: 600; margin-right: 6px;
padding: 0;
border: 0;
border-radius: 4px;
background: none;
color: inherit;
font: inherit;
font-size: 16px;
line-height: 1;
cursor: pointer;
opacity: 0.6;
} }
.notepad-tabwrap:hover .notepad-tab-x,
.notepad-tabwrap:has(.notepad-tab[aria-selected="true"]) .notepad-tab-x,
.notepad-tab-x:focus-visible { opacity: 1; }
.notepad-tab-x:hover { background: var(--panel); color: var(--warn); }
.notepad-tab:focus-visible, .notepad-tab:focus-visible,
.notepad-tab-x:focus-visible,
.notepad-tab-new:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } .notepad-tab-new:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.notepad-tab.is-dragging { opacity: 0.5; } .notepad-tabwrap:has(.is-dragging) { opacity: 0.5; }
.notepad-tab.is-drop-before { box-shadow: -3px 0 0 0 var(--accent); } .notepad-tabwrap:has(.is-drop-before) { box-shadow: -3px 0 0 0 var(--accent); }
.notepad-tabs.is-drop-end { box-shadow: inset -3px 0 0 0 var(--accent); } .notepad-tabs.is-drop-end { box-shadow: inset -3px 0 0 0 var(--accent); }
.notepad-tab-new { flex: none; margin-bottom: 2px; } .notepad-tab-new { flex: none; margin-bottom: 4px; }
.notepad-tab-tools { flex: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.notepad-tab-tools[hidden] { display: none; }
.notepad-tab-tools .btn.tiny { margin-bottom: 0; }
/* The name form (New tab and Rename) and the delete question sit between the /* The name and delete questions: small dialogs over the Notebook, never a
tools and the editor, in the dialog, never in a browser prompt. */ browser prompt. The empty state sits where the editor would. */
.notepad-name-form,
.notepad-delete,
.notepad-empty { .notepad-empty {
flex: none; flex: none;
margin: 0 0 10px; margin: 0 0 10px;
@@ -214,14 +241,12 @@
border-radius: 8px; border-radius: 8px;
background: var(--panel-2); background: var(--panel-2);
} }
.notepad-name-form[hidden],
.notepad-delete[hidden],
.notepad-empty[hidden] { display: none; } .notepad-empty[hidden] { display: none; }
.notepad-name-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; } .modal.notepad-sub { width: min(420px, calc(100vw - 32px)); }
.notepad-name-row { display: flex; gap: 8px; align-items: center; } .modal.notepad-sub h2 { margin: 0 0 10px; }
.notepad-name-row input { .notepad-name-form input {
flex: 1 1 auto; display: block;
min-width: 0; width: 100%;
padding: 6px 8px; padding: 6px 8px;
border: 1px solid var(--rule-2); border: 1px solid var(--rule-2);
border-radius: 6px; border-radius: 6px;
@@ -229,12 +254,11 @@
color: var(--ink); color: var(--ink);
font: inherit; font: inherit;
} }
.notepad-name-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; } .notepad-name-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.notepad-name-error { min-height: 1.2em; margin: 6px 0 0; } .notepad-name-error { min-height: 1.2em; margin: 6px 0 0; }
.notepad-name-error:not(:empty) { color: var(--warn); } .notepad-name-error:not(:empty) { color: var(--warn); }
.modal.notepad-delete { border-color: var(--warn); }
.notepad-delete p { margin: 0 0 8px; } .notepad-delete p { margin: 0 0 8px; }
.notepad-delete { border-color: var(--warn); }
.notepad-delete-row { display: flex; gap: 8px; }
.notepad-empty { text-align: center; padding: 28px 12px; } .notepad-empty { text-align: center; padding: 28px 12px; }
.notepad-empty p { margin: 0 0 12px; color: var(--ink-2); } .notepad-empty p { margin: 0 0 12px; color: var(--ink-2); }
/* Editor and pictures together, so the empty state hides both at once. */ /* Editor and pictures together, so the empty state hides both at once. */
+4 -5
View File
@@ -64,11 +64,10 @@
.notepad-images { flex-direction: column; align-items: stretch; } .notepad-images { flex-direction: column; align-items: stretch; }
.notepad-tabbar { flex-wrap: wrap; } .notepad-tabbar { flex-wrap: wrap; }
.modal.notepad .notepad-tab-new, .modal.notepad .notepad-tab-new,
.modal.notepad .notepad-tab-tools .btn, .modal.notepad-sub .modal-actions .btn,
.modal.notepad .notepad-name-row .btn, .notepad-tab,
.modal.notepad .notepad-delete-row .btn, .notepad-tab-x { min-height: 44px; }
.notepad-tab { min-height: 44px; } .notepad-tab-x { width: 32px; }
.notepad-name-row { flex-wrap: wrap; }
.notepad-add { align-self: flex-start; } .notepad-add { align-self: flex-start; }
.notepad-thumb .notepad-thumb-delete { width: 30px; height: 30px; font-size: 18px; } .notepad-thumb .notepad-thumb-delete { width: 30px; height: 30px; font-size: 18px; }
.modal.notepad-preview[open] { grid-template-columns: 52px minmax(0, 1fr) 52px; } .modal.notepad-preview[open] { grid-template-columns: 52px minmax(0, 1fr) 52px; }