Pages: below 900 px auto shows the panes one column at a time, swiped like pages
The same forest of forks, laid out a column per page as wide as the screen, each column's panes stacked down it as on a wide screen (tabs a finger high). A tap on a row, a link or a section opens it and goes to it; a swipe ends on a page and makes its pane the active one (read at scrollend, never per frame); the active pane's page is always the one on screen. The trail at the foot names the focused branch in the panes' colours; its map lists every open pane to go to, pin or close. No curves: what a pane was opened from takes its colour. Each step from pane to pane is an entry in the browser's history, so Back goes back a pane and a swipe back is Back. Crossing 900 px keeps the forest and the active pane. Pane buttons always shown, 40 px; status line detail, key hints and `?` left to the menus; safe areas, 100dvh, the on-screen keyboard; a long press on a link shows its card above its menu. `/view panes` and `/view column` as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
e7c5634a38
commit
eb946980b3
9 files changed
+671
-71
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
|
||||||
<title>Infinispand</title>
|
<title>Infinispand</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
+37
-4
@@ -9,10 +9,11 @@ import { DocBar, LibrariesPanel } from "./Menu";
|
|||||||
import { LinkCard, LinkPicker, LinksPanel, NodeBacklinks, NodeRelated, TargetRow } from "./Links";
|
import { LinkCard, LinkPicker, LinksPanel, NodeBacklinks, NodeRelated, TargetRow } from "./Links";
|
||||||
import { NodeBody, Outline, PendingSections, TopMatter } from "./Node";
|
import { NodeBody, Outline, PendingSections, TopMatter } from "./Node";
|
||||||
import { Panes } from "./Panes";
|
import { Panes } from "./Panes";
|
||||||
|
import { PaneMap, Trail } from "./Pages";
|
||||||
import { PANES_MIN_WIDTH, store, type Aux, type WRow } from "./store";
|
import { PANES_MIN_WIDTH, store, type Aux, type WRow } from "./store";
|
||||||
import { WikiPage, WikiView } from "./Wiki";
|
import { WikiPage, WikiView } from "./Wiki";
|
||||||
import { Usage } from "./Usage";
|
import { Usage } from "./Usage";
|
||||||
import { FirstRun, Hints, Key, MenuHost, SelBar, closeMenu, hideBar, locate, locateIn, menuAt, menuShown, setPrompt, showBar, type Hint } from "./Mouse";
|
import { FirstRun, Hints, Key, MenuHost, SelBar, closeMenu, hideBar, locate, locateIn, menuAt, menuShown, setCard, setPrompt, showBar, type Hint } from "./Mouse";
|
||||||
import { press } from "./press";
|
import { press } from "./press";
|
||||||
|
|
||||||
function Page() {
|
function Page() {
|
||||||
@@ -479,8 +480,15 @@ export function App() {
|
|||||||
setPrefill(text);
|
setPrefill(text);
|
||||||
store.setMode("command");
|
store.setMode("command");
|
||||||
});
|
});
|
||||||
|
// A long press on a link (touch) shows what it opens above its menu.
|
||||||
|
setCard((note) => <PopupBody note={note} />);
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
clearTimeout(hover);
|
clearTimeout(hover);
|
||||||
|
// Esc puts the map of panes away first.
|
||||||
|
if (e.key === "Escape" && store.paneMap) {
|
||||||
|
e.preventDefault();
|
||||||
|
return store.showMap(false);
|
||||||
|
}
|
||||||
// The keys take over from the pointer: its bar and menu go (not for a modifier, or the copy key).
|
// The keys take over from the pointer: its bar and menu go (not for a modifier, or the copy key).
|
||||||
if (!e.ctrlKey && !e.metaKey && !e.altKey && !["Shift", "Control", "Alt", "Meta"].includes(e.key)) {
|
if (!e.ctrlKey && !e.metaKey && !e.altKey && !["Shift", "Control", "Alt", "Meta"].includes(e.key)) {
|
||||||
hideBar();
|
hideBar();
|
||||||
@@ -527,10 +535,29 @@ export function App() {
|
|||||||
const wide = window.innerWidth >= PANES_MIN_WIDTH;
|
const wide = window.innerWidth >= PANES_MIN_WIDTH;
|
||||||
if (wide === store.wide) return;
|
if (wide === store.wide) return;
|
||||||
store.wide = wide;
|
store.wide = wide;
|
||||||
|
store.paneMap = false;
|
||||||
if (store.settings.view === "auto") store.emit();
|
if (store.settings.view === "auto") store.emit();
|
||||||
};
|
};
|
||||||
window.addEventListener("resize", onResize);
|
window.addEventListener("resize", onResize);
|
||||||
return () => window.removeEventListener("resize", onResize);
|
// An on-screen keyboard covers the foot of the screen without resizing the page (iOS): what sits
|
||||||
|
// at the foot (the status line, the command line, the selection bar) is raised above it.
|
||||||
|
const vv = window.visualViewport;
|
||||||
|
const onViewport = () => {
|
||||||
|
if (!vv) return;
|
||||||
|
const typing = (document.activeElement as HTMLElement | null)?.matches?.("input, textarea, [contenteditable]");
|
||||||
|
const kb = typing && Math.abs(vv.scale - 1) < 0.01 ? Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop)) : 0;
|
||||||
|
const v = `${kb}px`;
|
||||||
|
if (document.documentElement.style.getPropertyValue("--kb") !== v) document.documentElement.style.setProperty("--kb", v);
|
||||||
|
};
|
||||||
|
vv?.addEventListener("resize", onViewport);
|
||||||
|
window.addEventListener("focusin", onViewport);
|
||||||
|
window.addEventListener("focusout", onViewport);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", onResize);
|
||||||
|
vv?.removeEventListener("resize", onViewport);
|
||||||
|
window.removeEventListener("focusin", onViewport);
|
||||||
|
window.removeEventListener("focusout", onViewport);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Keep the focused thing in view, and time keypress → paint.
|
// Keep the focused thing in view, and time keypress → paint.
|
||||||
@@ -696,7 +723,11 @@ export function App() {
|
|||||||
store.go(id);
|
store.go(id);
|
||||||
store.open.add(id);
|
store.open.add(id);
|
||||||
const holder = store.trail[paneIndex];
|
const holder = store.trail[paneIndex];
|
||||||
if (store.snap.nodes[id]?.kind === "section" && holder?.kind === "node" && store.snap.nodes[id].parent === holder.id) store.openPane(paneIndex, { kind: "node", id });
|
if (store.snap.nodes[id]?.kind === "section" && holder?.kind === "node" && store.snap.nodes[id].parent === holder.id) {
|
||||||
|
store.openPane(paneIndex, { kind: "node", id });
|
||||||
|
// As pages, a tap on a row goes to its pane: the next page.
|
||||||
|
if (store.pages) store.land(paneIndex + 1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
store.go(id);
|
store.go(id);
|
||||||
@@ -740,7 +771,7 @@ export function App() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={`app mode-${store.mode}${store.mode === "history" || store.mode === "review" ? " with-panel" : ""}${store.libs ? " with-left" : ""}${panes ? " view-panes" : ""}`} onMouseOver={onOver} onContextMenu={onContext}>
|
<div class={`app mode-${store.mode}${store.mode === "history" || store.mode === "review" ? " with-panel" : ""}${store.libs ? " with-left" : ""}${panes ? " view-panes" : ""}${store.pages ? " view-pages" : ""}`} onMouseOver={onOver} onContextMenu={onContext}>
|
||||||
<main
|
<main
|
||||||
class="page"
|
class="page"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
@@ -755,8 +786,10 @@ export function App() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{panes ? <Panes /> : <Page />}
|
{panes ? <Panes /> : <Page />}
|
||||||
|
{store.pages && <Trail />}
|
||||||
</main>
|
</main>
|
||||||
<LibrariesPanel />
|
<LibrariesPanel />
|
||||||
|
<PaneMap />
|
||||||
{store.mode === "history" && <HistoryPanel verdict={verdict} />}
|
{store.mode === "history" && <HistoryPanel verdict={verdict} />}
|
||||||
{store.mode === "review" && <LinksPanel />}
|
{store.mode === "review" && <LinksPanel />}
|
||||||
{store.mode === "help" && <Help />}
|
{store.mode === "help" && <Help />}
|
||||||
|
|||||||
+18
-9
@@ -53,6 +53,9 @@ export const touch = () => typeof matchMedia === "function" && matchMedia("(hove
|
|||||||
let promptHook: (prefill: string) => void = () => {};
|
let promptHook: (prefill: string) => void = () => {};
|
||||||
/** The page's command bar, to open with text already typed (App.tsx). */
|
/** The page's command bar, to open with text already typed (App.tsx). */
|
||||||
export const setPrompt = (fn: (prefill: string) => void) => (promptHook = fn);
|
export const setPrompt = (fn: (prefill: string) => void) => (promptHook = fn);
|
||||||
|
let cardHook: (note: NodeId) => ComponentChildren = () => null;
|
||||||
|
/** What a link's card is drawn with, above a menu on touch (App.tsx: the hover preview's body). */
|
||||||
|
export const setCard = (fn: (note: NodeId) => ComponentChildren) => (cardHook = fn);
|
||||||
export const act = pageAct({ command: (t) => store.command(t), prompt: (p) => promptHook(p) });
|
export const act = pageAct({ command: (t) => store.command(t), prompt: (p) => promptHook(p) });
|
||||||
|
|
||||||
// ---- what is focused, for the menus ----
|
// ---- what is focused, for the menus ----
|
||||||
@@ -77,7 +80,7 @@ function selCtx(): SelCtx {
|
|||||||
const text = plain(store.selectedText() ?? "");
|
const text = plain(store.selectedText() ?? "");
|
||||||
const s = store.snap;
|
const s = store.snap;
|
||||||
const a = store.aux;
|
const a = store.aux;
|
||||||
if (a?.kind === "wiki") return { text, article: true, link: store.auxLink(a) ? "wiki" : undefined, note: !!store.articleNoteHere(), panes: store.panes };
|
if (a?.kind === "wiki") return { text, article: true, link: store.auxLink(a) ? "wiki" : undefined, note: !!store.articleNoteHere(), panes: store.panes, pages: store.pages };
|
||||||
const f = store.focus;
|
const f = store.focus;
|
||||||
const id = store.noteAt(f.range);
|
const id = store.noteAt(f.range);
|
||||||
const r = id ? store.targetOf(id) : undefined;
|
const r = id ? store.targetOf(id) : undefined;
|
||||||
@@ -92,6 +95,7 @@ function selCtx(): SelCtx {
|
|||||||
return { title: x.title, where: t && t !== x.node ? s.nodes[t].title : undefined };
|
return { title: x.title, where: t && t !== x.node ? s.nodes[t].title : undefined };
|
||||||
}),
|
}),
|
||||||
panes: store.panes,
|
panes: store.panes,
|
||||||
|
pages: store.pages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +111,7 @@ export function menuHere(where: Where): Entry[] {
|
|||||||
if (a?.kind === "wiki") {
|
if (a?.kind === "wiki") {
|
||||||
const h = store.wikiHost(a.host);
|
const h = store.wikiHost(a.host);
|
||||||
if (store.panes && (where === "pane" || a.row.t === "head")) return paneEntries(a.host.startsWith("n") ? { node: nodeCtx(a.host.slice(1) as NodeId), pinned } : { article: h?.title, pinned }, act);
|
if (store.panes && (where === "pane" || a.row.t === "head")) return paneEntries(a.host.startsWith("n") ? { node: nodeCtx(a.host.slice(1) as NodeId), pinned } : { article: h?.title, pinned }, act);
|
||||||
if (a.row.t === "sec" || a.row.t === "sense") return articleRowEntries(h?.title ?? "Wikipedia", store.panes, act);
|
if (a.row.t === "sec" || a.row.t === "sense") return articleRowEntries(h?.title ?? "Wikipedia", store.panes, act, store.pages);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (a) return [];
|
if (a) return [];
|
||||||
@@ -221,7 +225,9 @@ export function menuAt(target: HTMLElement, at: { x: number; y: number } | HTMLE
|
|||||||
if (!where) return false;
|
if (!where) return false;
|
||||||
const entries = menuHere(where);
|
const entries = menuHere(where);
|
||||||
if (!entries.length) return false;
|
if (!entries.length) return false;
|
||||||
showMenu(entries, at);
|
// On touch there is no hover to preview a link: a long press on one shows what it opens above its menu.
|
||||||
|
const note = touch() && !store.aux && store.selectedText() !== null ? store.noteAt(store.focus.range) : undefined;
|
||||||
|
showMenu(entries, at, note && store.snap.nodes[note]?.ref ? note : undefined);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +236,8 @@ export function menuAt(target: HTMLElement, at: { x: number; y: number } | HTMLE
|
|||||||
interface Shown {
|
interface Shown {
|
||||||
entries: Entry[];
|
entries: Entry[];
|
||||||
at: { x: number; y: number } | HTMLElement;
|
at: { x: number; y: number } | HTMLElement;
|
||||||
|
/** A link whose card shows above the items (a long press on it, on touch). */
|
||||||
|
card?: NodeId;
|
||||||
/** Where the focus was, to go back to when the menu closes. */
|
/** Where the focus was, to go back to when the menu closes. */
|
||||||
restore: HTMLElement | null;
|
restore: HTMLElement | null;
|
||||||
}
|
}
|
||||||
@@ -240,12 +248,12 @@ const changed = () => watchers.forEach((f) => f());
|
|||||||
/** The button whose menu a press on it just closed: the click that follows that press is not one to open it again. */
|
/** The button whose menu a press on it just closed: the click that follows that press is not one to open it again. */
|
||||||
let closedBy: { el: HTMLElement; at: number } | null = null;
|
let closedBy: { el: HTMLElement; at: number } | null = null;
|
||||||
|
|
||||||
export function showMenu(entries: Entry[], at: Shown["at"]) {
|
export function showMenu(entries: Entry[], at: Shown["at"], card?: NodeId) {
|
||||||
if (at instanceof HTMLElement && closedBy?.el === at && performance.now() - closedBy.at < 1000) return void (closedBy = null);
|
if (at instanceof HTMLElement && closedBy?.el === at && performance.now() - closedBy.at < 1000) return void (closedBy = null);
|
||||||
closedBy = null;
|
closedBy = null;
|
||||||
if (shown?.at instanceof HTMLElement) shown.at.removeAttribute("aria-expanded");
|
if (shown?.at instanceof HTMLElement) shown.at.removeAttribute("aria-expanded");
|
||||||
const active = document.activeElement as HTMLElement | null;
|
const active = document.activeElement as HTMLElement | null;
|
||||||
shown = { entries, at, restore: active && active !== document.body && !active.closest(".menu") ? active : shown?.restore ?? null };
|
shown = { entries, at, card, restore: active && active !== document.body && !active.closest(".menu") ? active : shown?.restore ?? null };
|
||||||
if (at instanceof HTMLElement) at.setAttribute("aria-expanded", "true");
|
if (at instanceof HTMLElement) at.setAttribute("aria-expanded", "true");
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
@@ -271,7 +279,7 @@ export const keyText = (k: string) => KEY_TEXT[k] ?? (k.startsWith("A-") ? `Alt+
|
|||||||
* hangs from; on touch, a sheet from the foot of the screen. ↑ ↓ (and Home End) move, Enter runs,
|
* hangs from; on touch, a sheet from the foot of the screen. ↑ ↓ (and Home End) move, Enter runs,
|
||||||
* Esc closes and puts the focus back where it was; a press outside closes it too.
|
* Esc closes and puts the focus back where it was; a press outside closes it too.
|
||||||
*/
|
*/
|
||||||
export function Menu({ entries, at, sheet, onClose }: { entries: Entry[]; at: Shown["at"]; sheet: boolean; onClose: (refocus: boolean) => void }) {
|
export function Menu({ entries, at, sheet, card, onClose }: { entries: Entry[]; at: Shown["at"]; sheet: boolean; card?: NodeId; onClose: (refocus: boolean) => void }) {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const el = ref.current!;
|
const el = ref.current!;
|
||||||
@@ -335,6 +343,7 @@ export function Menu({ entries, at, sheet, onClose }: { entries: Entry[]; at: Sh
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div class={`menu${sheet ? " sheet" : ""}`} role="menu" tabIndex={-1} ref={ref} onKeyDown={onKey} onContextMenu={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}>
|
<div class={`menu${sheet ? " sheet" : ""}`} role="menu" tabIndex={-1} ref={ref} onKeyDown={onKey} onContextMenu={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}>
|
||||||
|
{card && store.snap.nodes[card] && <div class="menu-card">{cardHook(card)}</div>}
|
||||||
{entries.map((x, i) => {
|
{entries.map((x, i) => {
|
||||||
if (x.t === "sep") return <div key={i} class="sep" role="separator" />;
|
if (x.t === "sep") return <div key={i} class="sep" role="separator" />;
|
||||||
if (x.t === "head") return <div key={i} class="mh">{x.text}</div>;
|
if (x.t === "head") return <div key={i} class="mh">{x.text}</div>;
|
||||||
@@ -377,7 +386,7 @@ export function MenuHost() {
|
|||||||
return () => void watchers.delete(f);
|
return () => void watchers.delete(f);
|
||||||
}, []);
|
}, []);
|
||||||
if (!shown) return null;
|
if (!shown) return null;
|
||||||
return <Menu entries={shown.entries} at={shown.at} sheet={touch()} onClose={closeMenu} />;
|
return <Menu entries={shown.entries} at={shown.at} sheet={touch()} card={shown.card} onClose={closeMenu} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- the selection bar ----
|
// ---- the selection bar ----
|
||||||
@@ -418,7 +427,7 @@ function placeBar(el: HTMLElement | null, shown = false) {
|
|||||||
const host = pane ? pane.getBoundingClientRect() : null;
|
const host = pane ? pane.getBoundingClientRect() : null;
|
||||||
// The room it has: below the top bar, and in a pane below its tab when the tab shows (folded, or scrolled past its title) and above what covers its foot.
|
// The room it has: below the top bar, and in a pane below its tab when the tab shows (folded, or scrolled past its title) and above what covers its foot.
|
||||||
const tabbed = pane && (pane.hasAttribute("data-scrolled") || pane.hasAttribute("data-covered"));
|
const tabbed = pane && (pane.hasAttribute("data-scrolled") || pane.hasAttribute("data-covered"));
|
||||||
const roof = Math.max(bar, host ? host.top + (tabbed ? 30 : 0) : 0) + 4;
|
const roof = Math.max(bar, host ? host.top + (tabbed ? (pane.querySelector<HTMLElement>(":scope > .tabline")?.offsetHeight ?? 30) : 0) : 0) + 4;
|
||||||
const next = pane?.parentElement?.classList.contains("crowded") ? (pane.nextElementSibling as HTMLElement | null)?.getBoundingClientRect().top : undefined;
|
const next = pane?.parentElement?.classList.contains("crowded") ? (pane.nextElementSibling as HTMLElement | null)?.getBoundingClientRect().top : undefined;
|
||||||
const floor = Math.min(window.innerHeight - 28, host?.bottom ?? Infinity, next ?? Infinity) - 4;
|
const floor = Math.min(window.innerHeight - 28, host?.bottom ?? Infinity, next ?? Infinity) - 4;
|
||||||
// Over the words if it fits there, else under them; never on them.
|
// Over the words if it fits there, else under them; never on them.
|
||||||
@@ -581,7 +590,7 @@ export function FirstRun() {
|
|||||||
if (!firstRun) return null;
|
if (!firstRun) return null;
|
||||||
return (
|
return (
|
||||||
<span class="firstrun">
|
<span class="firstrun">
|
||||||
{touch() ? "Tap a sentence for what you can do with it" : <>Click a sentence for what you can do with it · <Key k="?" what="lists every key" /></>}
|
{touch() ? (store.pages ? "Tap a sentence for what you can do with it · swipe, or tap the trail below, to go from pane to pane" : "Tap a sentence for what you can do with it") : <>Click a sentence for what you can do with it · <Key k="?" what="lists every key" /></>}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,172 @@
|
|||||||
|
/**
|
||||||
|
* What the pages layout adds to the panes (pages.ts): the trail at the foot of the screen, where a
|
||||||
|
* thumb reaches, naming the focused branch pane by pane in each pane's colour, the one on screen
|
||||||
|
* marked; a tap on a step goes to that pane. Its last button opens the map: every open pane, as an
|
||||||
|
* outline of the forest of forks, each with its colour, to go to, pin or close.
|
||||||
|
*/
|
||||||
|
import { useLayoutEffect, useRef } from "preact/hooks";
|
||||||
|
import { label } from "../core/model";
|
||||||
|
import { store, type PaneRef } from "./store";
|
||||||
|
import { article } from "./wiki";
|
||||||
|
|
||||||
|
/** What a pane is called: its node's title, or its article's (a section of one by its heading). */
|
||||||
|
export function paneTitle(p: PaneRef): string {
|
||||||
|
if (p.kind === "node") return store.snap.nodes[p.id] ? label(store.snap, p.id) : "…";
|
||||||
|
const a = article(p.title, p.lang);
|
||||||
|
const sec = p.sec !== undefined && a.state === "ready" ? a.value.sections.find((x) => x.id === p.sec) : undefined;
|
||||||
|
return sec ? sec.heading : a.state === "ready" ? a.value.title : p.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
const W = () => <b class="wmark">W</b>;
|
||||||
|
|
||||||
|
/** The trail: the focused branch, a step per pane, and the map's button. */
|
||||||
|
export function Trail() {
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
const nodes = store.branchNodes;
|
||||||
|
const at = store.paneAt;
|
||||||
|
const here = nodes[at]?.id;
|
||||||
|
// The step on screen is kept in view along the trail (only when it changes, never as anything scrolls).
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const row = ref.current;
|
||||||
|
const el = row?.querySelector<HTMLElement>(".trail-step.here");
|
||||||
|
if (!row || !el) return;
|
||||||
|
const l = el.offsetLeft - row.offsetLeft;
|
||||||
|
if (l < row.scrollLeft + 8) row.scrollLeft = Math.max(0, l - 24);
|
||||||
|
else if (l + el.offsetWidth > row.scrollLeft + row.clientWidth - 8) row.scrollLeft = l + el.offsetWidth - row.clientWidth + 24;
|
||||||
|
}, [here, nodes.length]);
|
||||||
|
const count = store.panesPlaced.length;
|
||||||
|
return (
|
||||||
|
<nav class="trail" aria-label="The panes on the way to this one">
|
||||||
|
<div class="trail-steps" ref={ref}>
|
||||||
|
{nodes.map((n, i) => (
|
||||||
|
<button
|
||||||
|
key={n.id}
|
||||||
|
type="button"
|
||||||
|
class={`trail-step${i === at ? " here" : ""}${i > at ? " ahead" : ""}`}
|
||||||
|
data-trail={n.id}
|
||||||
|
data-hue={n.hue}
|
||||||
|
aria-current={i === at ? "page" : undefined}
|
||||||
|
title={paneTitle(n.ref)}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
store.showMap(false);
|
||||||
|
store.toPane(n.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{n.ref.kind === "wiki" && <W />}
|
||||||
|
<span class="trail-t">{paneTitle(n.ref)}</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="trail-map"
|
||||||
|
data-map-open
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-expanded={store.paneMap ? "true" : "false"}
|
||||||
|
title="Every open pane: go to one, pin it or close it"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
store.showMap();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
map <span class="trail-n">{count}</span>
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Pin = () => (
|
||||||
|
<svg viewBox="0 0 12 12" aria-hidden="true">
|
||||||
|
<path d="M4 1.5h4M4.6 1.5v3.6L2.8 7.2h6.4L7.4 5.1V1.5M6 7.2V11" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
const Close = () => (
|
||||||
|
<svg viewBox="0 0 12 12" aria-hidden="true">
|
||||||
|
<path d="M3 3l6 6M9 3l-6 6" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map: every open pane, tree by tree, each indented by its column under the pane it was
|
||||||
|
* opened from, with its colour; the active pane marked, the focused branch in the text's ink. A
|
||||||
|
* tap on a pane goes to it; its pin and × act on it where it is. A press outside, Esc or the
|
||||||
|
* trail's map button puts it away.
|
||||||
|
*/
|
||||||
|
export function PaneMap() {
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
const on = store.paneMap && store.pages;
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (!on) return;
|
||||||
|
ref.current?.querySelector<HTMLElement>(".map-row.here")?.scrollIntoView({ block: "nearest" });
|
||||||
|
const outside = (e: PointerEvent) => {
|
||||||
|
const t = e.target as HTMLElement;
|
||||||
|
if (ref.current?.contains(t) || t.closest?.("[data-map-open]")) return;
|
||||||
|
store.showMap(false);
|
||||||
|
// The press that puts it away does nothing else.
|
||||||
|
const swallow = (c: MouseEvent) => (c.stopPropagation(), c.preventDefault());
|
||||||
|
window.addEventListener("click", swallow, { capture: true, once: true });
|
||||||
|
setTimeout(() => window.removeEventListener("click", swallow, { capture: true }), 800);
|
||||||
|
};
|
||||||
|
document.addEventListener("pointerdown", outside, true);
|
||||||
|
return () => document.removeEventListener("pointerdown", outside, true);
|
||||||
|
}, [on]);
|
||||||
|
if (!on) return null;
|
||||||
|
const placed = store.panesPlaced;
|
||||||
|
const branch = new Set(store.branchNodes.map((n) => n.id));
|
||||||
|
const active = store.branchNodes[store.paneAt]?.id;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
class="pane-map"
|
||||||
|
role="dialog"
|
||||||
|
aria-label="Open panes"
|
||||||
|
ref={ref}
|
||||||
|
tabIndex={-1}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key !== "Escape") return;
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
store.showMap(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="map-head">
|
||||||
|
Open panes · {placed.length}
|
||||||
|
<span class="map-hint">swipe sideways to go from pane to pane</span>
|
||||||
|
</div>
|
||||||
|
<ul class="map-rows">
|
||||||
|
{placed.map((x) => {
|
||||||
|
const id = x.node.id;
|
||||||
|
const first = x.ti === 0 && x.depth === 0;
|
||||||
|
const orphan = x.ti > 0 && x.depth === 0;
|
||||||
|
const pinned = !!x.node.pinned;
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
key={id}
|
||||||
|
class={`map-row${id === active ? " here" : ""}${branch.has(id) ? " on-branch" : ""}${pinned ? " pinned" : ""}`}
|
||||||
|
data-map={id}
|
||||||
|
data-hue={x.node.hue}
|
||||||
|
style={{ "--depth": Math.min(x.col, 8) }}
|
||||||
|
>
|
||||||
|
<button type="button" class="map-go" aria-current={id === active ? "page" : undefined} onClick={() => (store.showMap(false), store.toPane(id))}>
|
||||||
|
<span class="map-dash" aria-hidden="true" />
|
||||||
|
{x.node.ref.kind === "wiki" && <W />}
|
||||||
|
<span class="map-t">{paneTitle(x.node.ref)}</span>
|
||||||
|
{orphan && <span class="map-sub">its source closed</span>}
|
||||||
|
</button>
|
||||||
|
<button type="button" class={`map-btn pin${pinned ? " on" : ""}`} data-map-pin={id} aria-label={pinned ? "Unpin" : "Pin"} title={pinned ? "Unpin this pane" : "Pin this pane: it stays when what opened it closes"} onClick={() => store.togglePanePin(id)}>
|
||||||
|
<Pin />
|
||||||
|
</button>
|
||||||
|
{first ? (
|
||||||
|
<span class="map-btn none" />
|
||||||
|
) : (
|
||||||
|
<button type="button" class="map-btn close" data-map-close={id} aria-label="Close" title="Close this pane and what was opened from it" onClick={() => store.closePane(id)}>
|
||||||
|
<Close />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
+150
-16
@@ -21,6 +21,7 @@ import { ancestors, label, sections, staleness, type NodeId } from "../core/mode
|
|||||||
import { LANES, LANE_FIRST, LANE_LAST, LANE_PITCH, laneOrder } from "./lanes";
|
import { LANES, LANE_FIRST, LANE_LAST, LANE_PITCH, laneOrder } from "./lanes";
|
||||||
import { ACROSS, DOWN, mark, offsets, reveal, starts, stick, unmark, whole } from "./stack";
|
import { ACROSS, DOWN, mark, offsets, reveal, starts, stick, unmark, whole } from "./stack";
|
||||||
import { NodeBacklinks, NodeRelated, PaneCtx, TargetRow } from "./Links";
|
import { NodeBacklinks, NodeRelated, PaneCtx, TargetRow } from "./Links";
|
||||||
|
import { pageAt, paneOfPage } from "./pages";
|
||||||
import { Abstract, Flags, NodeBody, PendingSections, Row, TitleEditor, TopMatter, isPrompt } from "./Node";
|
import { Abstract, Flags, NodeBody, PendingSections, Row, TitleEditor, TopMatter, isPrompt } from "./Node";
|
||||||
import { kidClass, refKey, store, type Aux, type Pane as PaneNode, type PaneRef } from "./store";
|
import { kidClass, refKey, store, type Aux, type Pane as PaneNode, type PaneRef } from "./store";
|
||||||
import { WikiView } from "./Wiki";
|
import { WikiView } from "./Wiki";
|
||||||
@@ -81,7 +82,7 @@ export const GEOMETRY = "ie:geometry";
|
|||||||
* observer on the title's rule, against the pane's own scroll box less the tab, so nothing is done
|
* observer on the title's rule, against the pane's own scroll box less the tab, so nothing is done
|
||||||
* per scroll or per key, and the tab comes exactly as the rule goes under it.
|
* per scroll or per key, and the tab comes exactly as the rule goes under it.
|
||||||
*/
|
*/
|
||||||
const watched = new Map<number, { io: IntersectionObserver; target: Element }>();
|
const watched = new Map<number, { io: IntersectionObserver; target: Element; tab: number }>();
|
||||||
function watchHead(tid: number) {
|
function watchHead(tid: number) {
|
||||||
const pane = document.querySelector<HTMLElement>(`.strip .pane[data-tid="${tid}"]`);
|
const pane = document.querySelector<HTMLElement>(`.strip .pane[data-tid="${tid}"]`);
|
||||||
if (!pane || typeof IntersectionObserver === "undefined") return;
|
if (!pane || typeof IntersectionObserver === "undefined") return;
|
||||||
@@ -89,7 +90,7 @@ function watchHead(tid: number) {
|
|||||||
const head = pane.querySelector<HTMLElement>(HEADS);
|
const head = pane.querySelector<HTMLElement>(HEADS);
|
||||||
const target = head?.matches(".top") ? head.querySelector("h1") : head;
|
const target = head?.matches(".top") ? head.querySelector("h1") : head;
|
||||||
const w = watched.get(tid);
|
const w = watched.get(tid);
|
||||||
if (w && w.target === target) return;
|
if (w && w.target === target && w.tab === TAB) return;
|
||||||
w?.io.disconnect();
|
w?.io.disconnect();
|
||||||
watched.delete(tid);
|
watched.delete(tid);
|
||||||
if (!target || !scroll) return void pane.removeAttribute("data-scrolled");
|
if (!target || !scroll) return void pane.removeAttribute("data-scrolled");
|
||||||
@@ -104,7 +105,7 @@ function watchHead(tid: number) {
|
|||||||
{ root: scroll, rootMargin: `-${TAB}px 0px 0px 0px` },
|
{ root: scroll, rootMargin: `-${TAB}px 0px 0px 0px` },
|
||||||
);
|
);
|
||||||
io.observe(target);
|
io.observe(target);
|
||||||
watched.set(tid, { io, target });
|
watched.set(tid, { io, target, tab: TAB });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The attributes every pane has: which it is, its place in its tree, its id there, and its branch's colour (forks.ts; style.css draws it). */
|
/** The attributes every pane has: which it is, its place in its tree, its id there, and its branch's colour (forks.ts; style.css draws it). */
|
||||||
@@ -294,8 +295,10 @@ const setAttr = (el: Element | undefined, name: string, on: boolean) => {
|
|||||||
|
|
||||||
/** The least height a pane keeps in a column while all its panes fit; below it, the column stacks them. */
|
/** The least height a pane keeps in a column while all its panes fit; below it, the column stacks them. */
|
||||||
export const PANE_MIN = 260;
|
export const PANE_MIN = 260;
|
||||||
/** A covered pane's tab, the strip a pane leaves down a crowded column (as a spine does across). */
|
/** A covered pane's tab, the strip a pane leaves down a crowded column (as a spine does across): as pages, a finger's height (PAGE_TAB). Set as the panes are drawn. */
|
||||||
export const TAB = 30;
|
export let TAB = 30;
|
||||||
|
const DESK_TAB = 30;
|
||||||
|
export const PAGE_TAB = 44;
|
||||||
/** How long the mouse rests on a covered pane before it peeks out. */
|
/** How long the mouse rests on a covered pane before it peeks out. */
|
||||||
export const PEEK_MS = 200;
|
export const PEEK_MS = 200;
|
||||||
|
|
||||||
@@ -327,6 +330,9 @@ const kidsKey = (t: PaneNode) => `${t.pick}:${t.kids.map((k) => refKey(k.ref)).j
|
|||||||
|
|
||||||
export function Panes() {
|
export function Panes() {
|
||||||
store.syncTrail();
|
store.syncTrail();
|
||||||
|
/** As pages (pages.ts): one column at a time, each a page as wide as the strip, swiped from one to the next. */
|
||||||
|
const pages = store.pages;
|
||||||
|
TAB = pages ? PAGE_TAB : DESK_TAB;
|
||||||
const strip = useRef<HTMLDivElement>(null);
|
const strip = useRef<HTMLDivElement>(null);
|
||||||
const svg = useRef<SVGSVGElement>(null);
|
const svg = useRef<SVGSVGElement>(null);
|
||||||
const followed = useRef("");
|
const followed = useRef("");
|
||||||
@@ -347,6 +353,14 @@ export function Panes() {
|
|||||||
const latest = useRef<(all?: boolean) => void>(() => {});
|
const latest = useRef<(all?: boolean) => void>(() => {});
|
||||||
/** The active pane's column when the strip last followed it. */
|
/** The active pane's column when the strip last followed it. */
|
||||||
const lastCol = useRef(-1);
|
const lastCol = useRef(-1);
|
||||||
|
/** As pages: the strip is being scrolled to the active pane's page by the page itself, not a finger. */
|
||||||
|
const programmatic = useRef(false);
|
||||||
|
/** As pages: the next scroll to the active pane's page is at once (the window changed size, or the layout became pages). */
|
||||||
|
const instant = useRef(true);
|
||||||
|
/** The follow of the latest render (the swipe handlers use it). */
|
||||||
|
const followNow = useRef<() => void>(() => {});
|
||||||
|
/** The layout last drawn: pages or side by side. */
|
||||||
|
const wasPages = useRef<boolean | null>(null);
|
||||||
|
|
||||||
const branch = store.branchNodes;
|
const branch = store.branchNodes;
|
||||||
const onBranch = new Set(branch.map((n) => n.id));
|
const onBranch = new Set(branch.map((n) => n.id));
|
||||||
@@ -372,13 +386,19 @@ export function Panes() {
|
|||||||
const spine = colEls[0].querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0;
|
const spine = colEls[0].querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0;
|
||||||
// With no scrollbar under the panes (none needed, or one drawn over them) their last bottom edge meets the status line's: one line, not two.
|
// With no scrollbar under the panes (none needed, or one drawn over them) their last bottom edge meets the status line's: one line, not two.
|
||||||
setAttr(el, "data-flush", el.offsetHeight - el.clientHeight < 1);
|
setAttr(el, "data-flush", el.offsetHeight - el.clientHeight < 1);
|
||||||
lefts.current = offsets(
|
if (pages) {
|
||||||
colEls.map(() => w),
|
// As pages nothing is stacked across: each column is a page of its own.
|
||||||
colEls.map((c) => c.hasAttribute("data-pinned")),
|
lefts.current = colEls.map(() => 0);
|
||||||
spine,
|
for (const c of colEls) if (c.style.left) c.style.left = "";
|
||||||
el.clientWidth,
|
} else {
|
||||||
);
|
lefts.current = offsets(
|
||||||
stick(colEls, lefts.current, ACROSS);
|
colEls.map(() => w),
|
||||||
|
colEls.map((c) => c.hasAttribute("data-pinned")),
|
||||||
|
spine,
|
||||||
|
el.clientWidth,
|
||||||
|
);
|
||||||
|
stick(colEls, lefts.current, ACROSS);
|
||||||
|
}
|
||||||
let deferred = false;
|
let deferred = false;
|
||||||
for (const c of colEls) {
|
for (const c of colEls) {
|
||||||
const ps = [...c.children].filter((p): p is HTMLElement => p.classList.contains("pane"));
|
const ps = [...c.children].filter((p): p is HTMLElement => p.classList.contains("pane"));
|
||||||
@@ -466,7 +486,8 @@ export function Panes() {
|
|||||||
const el = strip.current;
|
const el = strip.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const colEls = [...el.querySelectorAll<HTMLElement>(":scope > .col")];
|
const colEls = [...el.querySelectorAll<HTMLElement>(":scope > .col")];
|
||||||
mark(el, colEls, ACROSS, false, colEls[0]?.querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0);
|
if (store.pages) unmark(colEls);
|
||||||
|
else mark(el, colEls, ACROSS, false, colEls[0]?.querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0);
|
||||||
for (const c of colEls) {
|
for (const c of colEls) {
|
||||||
const ps = [...c.querySelectorAll<HTMLElement>(":scope > .pane")];
|
const ps = [...c.querySelectorAll<HTMLElement>(":scope > .pane")];
|
||||||
if (!c.classList.contains("crowded")) {
|
if (!c.classList.contains("crowded")) {
|
||||||
@@ -508,6 +529,20 @@ export function Panes() {
|
|||||||
}
|
}
|
||||||
const colEls = [...el.querySelectorAll<HTMLElement>(":scope > .col")];
|
const colEls = [...el.querySelectorAll<HTMLElement>(":scope > .col")];
|
||||||
const colOf = (p: HTMLElement | undefined) => (p ? colEls.indexOf(p.parentElement as HTMLElement) : -1);
|
const colOf = (p: HTMLElement | undefined) => (p ? colEls.indexOf(p.parentElement as HTMLElement) : -1);
|
||||||
|
if (store.pages) {
|
||||||
|
// As pages: the page on screen is the active pane's column, whole.
|
||||||
|
const c = colOf(panes[at]);
|
||||||
|
lastCol.current = c;
|
||||||
|
if (c < 0) return;
|
||||||
|
const target = Math.min(c * el.clientWidth, el.scrollWidth - el.clientWidth);
|
||||||
|
const now = instant.current;
|
||||||
|
instant.current = false;
|
||||||
|
if (Math.abs(target - el.scrollLeft) > 1) {
|
||||||
|
programmatic.current = !now;
|
||||||
|
el.scrollTo({ left: target, behavior: now || reducedMotion() ? "auto" : "smooth" });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
const w = colEls[0].offsetWidth;
|
const w = colEls[0].offsetWidth;
|
||||||
const view = el.clientWidth;
|
const view = el.clientWidth;
|
||||||
const max = el.scrollWidth - view;
|
const max = el.scrollWidth - view;
|
||||||
@@ -530,7 +565,8 @@ export function Panes() {
|
|||||||
if (!frame.current)
|
if (!frame.current)
|
||||||
frame.current = requestAnimationFrame(() => {
|
frame.current = requestAnimationFrame(() => {
|
||||||
frame.current = 0;
|
frame.current = 0;
|
||||||
curves(strip.current, svg.current);
|
if (store.pages) pageMarks(strip.current, svg.current);
|
||||||
|
else curves(strip.current, svg.current);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -556,7 +592,15 @@ export function Panes() {
|
|||||||
const watchedBodies = useRef(new WeakSet<Element>());
|
const watchedBodies = useRef(new WeakSet<Element>());
|
||||||
|
|
||||||
latest.current = layout;
|
latest.current = layout;
|
||||||
|
followNow.current = follow;
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
|
if (wasPages.current !== pages) {
|
||||||
|
// The layout changed (the window crossed PANES_MIN_WIDTH): the same panes, laid out again, the active pane's column shown at once.
|
||||||
|
wasPages.current = pages;
|
||||||
|
instant.current = true;
|
||||||
|
followed.current = "";
|
||||||
|
lastCol.current = -1;
|
||||||
|
}
|
||||||
sources();
|
sources();
|
||||||
layout();
|
layout();
|
||||||
follow();
|
follow();
|
||||||
@@ -570,13 +614,54 @@ export function Panes() {
|
|||||||
});
|
});
|
||||||
for (const b of strip.current?.querySelectorAll(".pane-body") ?? []) if (!watchedBodies.current.has(b)) (watchedBodies.current.add(b), bodies.current.observe(b));
|
for (const b of strip.current?.querySelectorAll(".pane-body") ?? []) if (!watchedBodies.current.has(b)) (watchedBodies.current.add(b), bodies.current.observe(b));
|
||||||
}
|
}
|
||||||
|
// As pages, a step from pane to pane is a step in the browser's history.
|
||||||
|
if (pages) store.trackPane();
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = strip.current!;
|
const el = strip.current!;
|
||||||
const wrap = el.parentElement!;
|
const wrap = el.parentElement!;
|
||||||
|
/*
|
||||||
|
* As pages, a swipe ends on a page: its pane becomes the active one (the one on the focused
|
||||||
|
* branch there, else the one last on it, else the first), so the page on screen is always the
|
||||||
|
* active pane's column. Read once the scroll has come to rest (scrollend, or a pause where the
|
||||||
|
* browser has none), never per frame.
|
||||||
|
*/
|
||||||
|
let rest: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
let touching = false;
|
||||||
|
const settle = () => {
|
||||||
|
clearTimeout(rest);
|
||||||
|
if (!store.pages) return;
|
||||||
|
if (touching) return void (rest = setTimeout(settle, 120));
|
||||||
|
const colEls = [...el.querySelectorAll<HTMLElement>(":scope > .col")];
|
||||||
|
const c = colEls[pageAt(el.scrollLeft, el.clientWidth, colEls.length)];
|
||||||
|
const ours = programmatic.current;
|
||||||
|
programmatic.current = false;
|
||||||
|
if (!c) return;
|
||||||
|
const ids = [...c.querySelectorAll<HTMLElement>(":scope > .pane")].map((p) => Number(p.dataset.tid));
|
||||||
|
const active = store.branchNodes[store.paneAt]?.id;
|
||||||
|
if (active !== undefined && ids.includes(active)) return;
|
||||||
|
// A scroll the page made that ended elsewhere (the active pane changed meanwhile): to the active pane's page.
|
||||||
|
if (ours) {
|
||||||
|
followed.current = "";
|
||||||
|
return followNow.current();
|
||||||
|
}
|
||||||
|
const id = paneOfPage(ids, new Set(store.branchNodes.map((n) => n.id)), lastIn.current.get(Number(c.dataset.col)));
|
||||||
|
if (id !== undefined) store.toPane(id);
|
||||||
|
};
|
||||||
|
const ends = "onscrollend" in window;
|
||||||
|
const onTouch = (e: TouchEvent) => (touching = e.type === "touchstart" || e.touches.length > 0);
|
||||||
|
el.addEventListener("touchstart", onTouch, { passive: true });
|
||||||
|
el.addEventListener("touchend", onTouch, { passive: true });
|
||||||
|
el.addEventListener("touchcancel", onTouch, { passive: true });
|
||||||
|
if (ends) el.addEventListener("scrollend", settle);
|
||||||
const onScroll = (e: Event) => {
|
const onScroll = (e: Event) => {
|
||||||
const t = e.target as HTMLElement;
|
const t = e.target as HTMLElement;
|
||||||
|
if (t === el && store.pages) {
|
||||||
|
// Only when the swipe has ended; nothing is measured while it moves.
|
||||||
|
if (!ends) (clearTimeout(rest), (rest = setTimeout(settle, 150)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The strip, a crowded column, or a pane in one (whose title's rule may come or go under its tab).
|
// The strip, a crowded column, or a pane in one (whose title's rule may come or go under its tab).
|
||||||
if (t === el || t.classList?.contains("col") || t.parentElement?.parentElement?.classList.contains("crowded")) measure();
|
if (t === el || t.classList?.contains("col") || t.parentElement?.parentElement?.classList.contains("crowded")) measure();
|
||||||
// A scroll inside what peeks (the wheel over it) keeps it out; any other moves things from under it.
|
// A scroll inside what peeks (the wheel over it) keeps it out; any other moves things from under it.
|
||||||
@@ -586,7 +671,8 @@ export function Panes() {
|
|||||||
const onResize = () => {
|
const onResize = () => {
|
||||||
latest.current(true);
|
latest.current(true);
|
||||||
followed.current = "";
|
followed.current = "";
|
||||||
follow();
|
instant.current = true;
|
||||||
|
followNow.current();
|
||||||
measure();
|
measure();
|
||||||
schedule();
|
schedule();
|
||||||
};
|
};
|
||||||
@@ -811,6 +897,11 @@ export function Panes() {
|
|||||||
cancelAnimationFrame(frame.current);
|
cancelAnimationFrame(frame.current);
|
||||||
clearTimeout(later.current);
|
clearTimeout(later.current);
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
|
clearTimeout(rest);
|
||||||
|
el.removeEventListener("touchstart", onTouch);
|
||||||
|
el.removeEventListener("touchend", onTouch);
|
||||||
|
el.removeEventListener("touchcancel", onTouch);
|
||||||
|
if (ends) el.removeEventListener("scrollend", settle);
|
||||||
wrap.removeEventListener("scroll", onScroll, { capture: true });
|
wrap.removeEventListener("scroll", onScroll, { capture: true });
|
||||||
window.removeEventListener(GEOMETRY, schedule);
|
window.removeEventListener(GEOMETRY, schedule);
|
||||||
wrap.removeEventListener("transitionrun", onRun);
|
wrap.removeEventListener("transitionrun", onRun);
|
||||||
@@ -833,7 +924,7 @@ export function Panes() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="panes" data-colors={store.settings.colors} data-curves={store.settings.curves ? undefined : "off"}>
|
<div class="panes" data-layout={pages ? "pages" : undefined} data-colors={store.settings.colors} data-curves={store.settings.curves ? undefined : "off"}>
|
||||||
<div class="strip" ref={strip}>
|
<div class="strip" ref={strip}>
|
||||||
{order.map((c) => {
|
{order.map((c) => {
|
||||||
const items = cols.get(c)!;
|
const items = cols.get(c)!;
|
||||||
@@ -936,6 +1027,8 @@ const lanesUsed = new Map<number, string[]>();
|
|||||||
*/
|
*/
|
||||||
function curves(el: HTMLElement | null, svg: SVGSVGElement | null) {
|
function curves(el: HTMLElement | null, svg: SVGSVGElement | null) {
|
||||||
if (!el || !svg) return;
|
if (!el || !svg) return;
|
||||||
|
if (store.pages) return pageMarks(el, svg);
|
||||||
|
if (tinted.size) untint();
|
||||||
if (!store.settings.curves) {
|
if (!store.settings.curves) {
|
||||||
for (const p of svg.querySelectorAll("path")) p.remove();
|
for (const p of svg.querySelectorAll("path")) p.remove();
|
||||||
for (const s of underlined) s.removeAttribute("data-curved");
|
for (const s of underlined) s.removeAttribute("data-curved");
|
||||||
@@ -1285,6 +1378,47 @@ function layers(svg: SVGSVGElement, area: DOMRect, holes: { x: number; y: number
|
|||||||
return { under, over };
|
return { under, over };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The words, rows and links the panes were opened from, coloured as pages (pageMarks). */
|
||||||
|
let tinted = new Set<HTMLElement>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As pages, the panes are not side by side, so no curve runs between them: what each pane was
|
||||||
|
* opened from (the words, a row, a link) takes that pane's colour instead, the colour of the rule
|
||||||
|
* under its title, of its tab and of its place in the trail (style.css, data-src-hue). Drawn when
|
||||||
|
* the panes change, not as anything scrolls.
|
||||||
|
*/
|
||||||
|
function pageMarks(el: HTMLElement | null, svg: SVGSVGElement | null) {
|
||||||
|
if (!el) return;
|
||||||
|
if (svg) for (const p of svg.querySelectorAll("path")) p.remove();
|
||||||
|
for (const s of underlined) s.removeAttribute("data-curved");
|
||||||
|
underlined = new Set();
|
||||||
|
const els = paneEls(el);
|
||||||
|
markRuled(els, new Map());
|
||||||
|
const branch = new Set(store.branchNodes.map((n) => n.id));
|
||||||
|
const now = new Set<HTMLElement>();
|
||||||
|
for (const x of store.panesPlaced) {
|
||||||
|
const pe = x.parent && els.get(x.parent.id);
|
||||||
|
if (!pe) continue;
|
||||||
|
const hue = x.node.hue === undefined ? "none" : String(x.node.hue);
|
||||||
|
for (const s of pe.querySelectorAll<HTMLElement>(`.${kidClass(refKey(x.node.ref))}`)) {
|
||||||
|
now.add(s);
|
||||||
|
if (s.dataset.srcHue !== hue) s.dataset.srcHue = hue;
|
||||||
|
setAttr(s, "data-src-on", branch.has(x.node.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
untint(now);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Take the colour off what no longer opens a pane (all of it, when the panes are side by side again). */
|
||||||
|
function untint(keep = new Set<HTMLElement>()) {
|
||||||
|
for (const s of tinted)
|
||||||
|
if (!keep.has(s)) {
|
||||||
|
delete s.dataset.srcHue;
|
||||||
|
s.removeAttribute("data-src-on");
|
||||||
|
}
|
||||||
|
tinted = keep;
|
||||||
|
}
|
||||||
|
|
||||||
/** A pane's own head, whose rule a curve into it lands in: a section's, a page's title, an article's (not an article set under a node). */
|
/** A pane's own head, whose rule a curve into it lands in: a section's, a page's title, an article's (not an article set under a node). */
|
||||||
const HEADS = ":scope > .pane-scroll > .pane-body > .pane-head, :scope > .pane-scroll > .pane-body > .top, :scope > .pane-scroll > .pane-body > .wiki:not(.embedded) > .wiki-head";
|
const HEADS = ":scope > .pane-scroll > .pane-body > .pane-head, :scope > .pane-scroll > .pane-body > .top, :scope > .pane-scroll > .pane-body > .wiki:not(.embedded) > .wiki-head";
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -84,6 +84,8 @@ export interface SelCtx {
|
|||||||
/** The node's Related list, numbered 1–5, each with where it is. */
|
/** The node's Related list, numbered 1–5, each with where it is. */
|
||||||
related?: { title: string; where?: string }[];
|
related?: { title: string; where?: string }[];
|
||||||
panes: boolean;
|
panes: boolean;
|
||||||
|
/** The panes as pages (a phone): an open goes to the next page rather than beside. */
|
||||||
|
pages?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The lenses, as the bar shows them and the menus list them. */
|
/** The lenses, as the bar shows them and the menus list them. */
|
||||||
@@ -111,7 +113,7 @@ export function selectionEntries(c: SelCtx, act: Act): Entry[] {
|
|||||||
head(quote(c.text)),
|
head(quote(c.text)),
|
||||||
c.text && { t: "item", label: "Copy", keyText: COPY, run: () => act.copy(c.text) },
|
c.text && { t: "item", label: "Copy", keyText: COPY, run: () => act.copy(c.text) },
|
||||||
SEP,
|
SEP,
|
||||||
c.link && key(act, c.panes ? "Open the link beside" : "Open the link", "Enter"),
|
c.link && key(act, c.panes && !c.pages ? "Open the link beside" : "Open the link", "Enter"),
|
||||||
c.link && c.panes && key(act, "Open it in place", "Enter", { keyText: "⇧⏎", shift: true, sub: "instead of the pane there" }),
|
c.link && c.panes && key(act, "Open it in place", "Enter", { keyText: "⇧⏎", shift: true, sub: "instead of the pane there" }),
|
||||||
c.link === "wiki" && key(act, "Open on wikipedia.org", "W"),
|
c.link === "wiki" && key(act, "Open on wikipedia.org", "W"),
|
||||||
c.note && key(act, "Open the note", "Enter"),
|
c.note && key(act, "Open the note", "Enter"),
|
||||||
@@ -223,10 +225,10 @@ export function paneEntries(c: PaneCtx, act: Act): Entry[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A row of an article (a section, a sense): open it. */
|
/** A row of an article (a section, a sense): open it. */
|
||||||
export function articleRowEntries(title: string, panes: boolean, act: Act): Entry[] {
|
export function articleRowEntries(title: string, panes: boolean, act: Act, pages = false): Entry[] {
|
||||||
return tidy([
|
return tidy([
|
||||||
head(title),
|
head(title),
|
||||||
key(act, panes ? "Open beside" : "Open", "Enter"),
|
key(act, panes && !pages ? "Open beside" : "Open", "Enter"),
|
||||||
panes && key(act, "Open in place", "Enter", { keyText: "⇧⏎", shift: true, sub: "instead of the pane there" }),
|
panes && key(act, "Open in place", "Enter", { keyText: "⇧⏎", shift: true, sub: "instead of the pane there" }),
|
||||||
key(act, "Open on wikipedia.org", "W"),
|
key(act, "Open on wikipedia.org", "W"),
|
||||||
]);
|
]);
|
||||||
|
|||||||
+146
-24
@@ -39,8 +39,9 @@ import { remoteLLM } from "./remote";
|
|||||||
import { Session } from "./session";
|
import { Session } from "./session";
|
||||||
import { refreshAfterCalls } from "./usage";
|
import { refreshAfterCalls } from "./usage";
|
||||||
import { Linker, type AutoMode, type JobState, type LinkRow, type Status, type Sugg } from "./linker";
|
import { Linker, type AutoMode, type JobState, type LinkRow, type Status, type Sugg } from "./linker";
|
||||||
import { all, besideInColumn, close as closeIn, columns as columnsOf, reorder, focus as focusIn, focused, open as openIn, path, pin as pinIn, prune, restore as restoreForest, rooted, save as saveTree, setSources, updateIn, withBranch, type Forest, type Placed, type Tree } from "./forks";
|
import { all, besideInColumn, close as closeIn, columns as columnsOf, find as findPane, reorder, focus as focusIn, focused, open as openIn, path, pin as pinIn, prune, restore as restoreForest, rooted, save as saveTree, setSources, updateIn, withBranch, type Forest, type Placed, type Tree } from "./forks";
|
||||||
import { stripMarks, type Mark } from "../core/marks";
|
import { stripMarks, type Mark } from "../core/marks";
|
||||||
|
import { arrived, findKey, loadVisits, paneKey, visit, type Visits } from "./pages";
|
||||||
|
|
||||||
export type Grain = "node" | "sentence" | "word";
|
export type Grain = "node" | "sentence" | "word";
|
||||||
export interface Focus {
|
export interface Focus {
|
||||||
@@ -119,7 +120,7 @@ export type View = "auto" | "column" | "panes";
|
|||||||
/** Where a fork's colour shows in the panes view: along its curves and title rules, across its panes' tops, down their left edges, or nowhere. */
|
/** Where a fork's colour shows in the panes view: along its curves and title rules, across its panes' tops, down their left edges, or nowhere. */
|
||||||
export type Colors = "line" | "top" | "edge" | "off";
|
export type Colors = "line" | "top" | "edge" | "off";
|
||||||
const COLORS: Colors[] = ["line", "top", "edge", "off"];
|
const COLORS: Colors[] = ["line", "top", "edge", "off"];
|
||||||
/** The narrowest window, in CSS px, on which `auto` chooses panes. */
|
/** The narrowest window, in CSS px, on which `auto` shows panes side by side; below it, `auto` shows them as pages (pages.ts). */
|
||||||
export const PANES_MIN_WIDTH = 900;
|
export const PANES_MIN_WIDTH = 900;
|
||||||
|
|
||||||
/** Text being generated that is not in the library yet. */
|
/** Text being generated that is not in the library yet. */
|
||||||
@@ -433,12 +434,20 @@ class Store {
|
|||||||
return this.llm.kind !== "off";
|
return this.llm.kind !== "off";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The layout on screen now. */
|
/** Whether the panes are on screen (side by side, or as pages): the forest of forks is what the keys move through. Not in the one column. */
|
||||||
get panes(): boolean {
|
get panes(): boolean {
|
||||||
const v = this.settings.view;
|
const v = this.settings.view;
|
||||||
return v === "panes" || (v === "auto" && this.wide);
|
return v === "panes" || v === "auto";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The pages layout (pages.ts): the panes one column at a time, swiped like pages; `auto` on a window narrower than PANES_MIN_WIDTH, a phone's. */
|
||||||
|
get pages(): boolean {
|
||||||
|
return this.settings.view === "auto" && !this.wide;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The map of every open pane (the pages layout's trail opens it). */
|
||||||
|
paneMap = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node the reader is on, for what acts on a node and everything under it (export, duplicate,
|
* The node the reader is on, for what acts on a node and everything under it (export, duplicate,
|
||||||
* import under it, move under, /linkhere, history's f and r): the focused section, or the section
|
* import under it, move under, /linkhere, history's f and r): the focused section, or the section
|
||||||
@@ -679,6 +688,20 @@ class Store {
|
|||||||
this.land(hit.depth);
|
this.land(hit.depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Make any open pane the active one (the pages layout's swipes, trail and map): back where the reader was in it, or at its head. */
|
||||||
|
toPane(id: number) {
|
||||||
|
this.syncTrail();
|
||||||
|
if (!this.forkNode(id) || this.branchNodes[this.paneAt]?.id === id) return;
|
||||||
|
this.goPane(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The map of open panes (pages): shown or put away. */
|
||||||
|
showMap(on = !this.paneMap) {
|
||||||
|
if (this.paneMap === on) return;
|
||||||
|
this.paneMap = on;
|
||||||
|
this.emit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alt+h and Alt+l: the pane the active one was opened from (left), or one opened from it (right):
|
* Alt+h and Alt+l: the pane the active one was opened from (left), or one opened from it (right):
|
||||||
* the one opened from the focused row or link if it is open, else the one last visited there.
|
* the one opened from the focused row or link if it is open, else the one last visited there.
|
||||||
@@ -1185,7 +1208,7 @@ class Store {
|
|||||||
sessionStorage.removeItem("ie:switch");
|
sessionStorage.removeItem("ie:switch");
|
||||||
const at = splitLibrary(location.pathname).part;
|
const at = splitLibrary(location.pathname).part;
|
||||||
if (switched && (at === "/" || at === "")) {
|
if (switched && (at === "/" || at === "")) {
|
||||||
window.history.replaceState(null, "", this.here());
|
window.history.replaceState(window.history.state, "", this.here());
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
} else this.navigate(at, "replace");
|
} else this.navigate(at, "replace");
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
@@ -1208,13 +1231,8 @@ class Store {
|
|||||||
document.addEventListener("visibilitychange", () => document.visibilityState === "hidden" && this.session.flush());
|
document.addEventListener("visibilitychange", () => document.visibilityState === "hidden" && this.session.flush());
|
||||||
this.session.connect();
|
this.session.connect();
|
||||||
}
|
}
|
||||||
// Back and forward move between places in the library.
|
// Back and forward move between places in the library (as pages, between panes).
|
||||||
addEventListener("popstate", () => {
|
addEventListener("popstate", () => this.popped());
|
||||||
const at = splitLibrary(location.pathname);
|
|
||||||
// Another library's address (one this page did not push): that library, by a page load.
|
|
||||||
if (at.library && at.library !== this.library) location.reload();
|
|
||||||
else this.navigate(at.part, "none");
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.fatal = err instanceof Error ? err.message : String(err);
|
this.fatal = err instanceof Error ? err.message : String(err);
|
||||||
this.emit();
|
this.emit();
|
||||||
@@ -1501,22 +1519,120 @@ class Store {
|
|||||||
/**
|
/**
|
||||||
* Put the address in the bar. Moving the focus replaces the entry (after a pause: browsers
|
* Put the address in the bar. Moving the focus replaces the entry (after a pause: browsers
|
||||||
* throttle a page that rewrites its address on every keystroke); changing the page (hoisting,
|
* throttle a page that rewrites its address on every keystroke); changing the page (hoisting,
|
||||||
* stepping out) or jumping makes a new one, so Back returns to where the reader was.
|
* stepping out) or jumping makes a new one, so Back returns to where the reader was. As pages,
|
||||||
|
* the entries are made pane by pane instead (trackPane), and this only writes the address.
|
||||||
*/
|
*/
|
||||||
private remember(push = false) {
|
private remember(push = false) {
|
||||||
clearTimeout(this.addressTimer);
|
clearTimeout(this.addressTimer);
|
||||||
if (this.preview || !this.ready) return;
|
if (this.preview || !this.ready) return;
|
||||||
|
const pushing = push && !this.pages;
|
||||||
const write = () => {
|
const write = () => {
|
||||||
const path = this.here();
|
const path = this.here();
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
if (location.pathname === path) return;
|
if (location.pathname === path) return;
|
||||||
if (push) window.history.pushState(null, "", path);
|
if (pushing) window.history.pushState(null, "", path);
|
||||||
else window.history.replaceState(null, "", path);
|
else window.history.replaceState(window.history.state, "", path);
|
||||||
};
|
};
|
||||||
if (push) write();
|
if (pushing) write();
|
||||||
else this.addressTimer = setTimeout(write, 250);
|
else this.addressTimer = setTimeout(write, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- the pages layout's history ----
|
||||||
|
|
||||||
|
/** The entries this tab's history has for panes, as the page knows them (pages.ts). */
|
||||||
|
private visits: Visits = { keys: [], i: 0 };
|
||||||
|
/** Back or Forward steps the page has asked the browser for that it has not yet made. */
|
||||||
|
private traversing = 0;
|
||||||
|
private traverseTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
private visitsKey() {
|
||||||
|
return `ie:visits:${this.library}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The active pane's name in the history (pages.ts paneKey). */
|
||||||
|
private activeKey(): string | null {
|
||||||
|
const n = this.branchNodes[this.paneAt];
|
||||||
|
const hit = n && findPane(this.forest, n.id);
|
||||||
|
return hit ? paneKey(hit.path, refKey) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Name the entry the browser is on after the active pane; `fresh`: the entries the page knew are forgotten, and this one starts them. */
|
||||||
|
private markEntry(fresh = false) {
|
||||||
|
const key = this.activeKey();
|
||||||
|
if (!key) return;
|
||||||
|
const v = this.visits;
|
||||||
|
this.visits = fresh || !v.keys.length ? { keys: [key], i: 0 } : { keys: v.keys.map((k, j) => (j === v.i ? key : k)), i: v.i };
|
||||||
|
this.saveVisits();
|
||||||
|
window.history.replaceState({ ie: "pane", key, i: this.visits.i }, "", location.pathname);
|
||||||
|
}
|
||||||
|
private saveVisits() {
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem(this.visitsKey(), JSON.stringify(this.visits));
|
||||||
|
} catch {
|
||||||
|
/* storage may be unavailable: Back still works within this page load */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As pages, after each render: when the active pane has changed, the history takes a step, so
|
||||||
|
* the browser's Back (its button, or the edge swipe) goes back a pane. Going to the pane of the
|
||||||
|
* entry just before is Back itself, to the one just after is Forward; anything else is a new entry.
|
||||||
|
*/
|
||||||
|
trackPane() {
|
||||||
|
if (!this.pages || !this.ready || this.preview || this.traversing > 0) return;
|
||||||
|
const key = this.activeKey();
|
||||||
|
if (!key) return;
|
||||||
|
const st = window.history.state as { ie?: string; key?: string; i?: number } | null;
|
||||||
|
const here = st?.ie === "pane" && st.i === this.visits.i && this.visits.keys[this.visits.i] === st.key;
|
||||||
|
if (!here) {
|
||||||
|
// The entry the browser is on is not the one the page thinks (the first render as pages, a reload, a step made as panes side by side).
|
||||||
|
let kept: Visits | null = null;
|
||||||
|
try {
|
||||||
|
kept = loadVisits(JSON.parse(sessionStorage.getItem(this.visitsKey()) ?? "null"));
|
||||||
|
} catch {
|
||||||
|
/* none kept */
|
||||||
|
}
|
||||||
|
if (kept && st?.ie === "pane" && typeof st.key === "string" && typeof st.i === "number" && kept.keys[st.i] === st.key) {
|
||||||
|
this.visits = { keys: kept.keys, i: st.i };
|
||||||
|
if (st.key === key) return;
|
||||||
|
} else return this.markEntry(true);
|
||||||
|
}
|
||||||
|
const { step, visits } = visit(this.visits, key);
|
||||||
|
if (step === "same") return;
|
||||||
|
this.visits = visits;
|
||||||
|
this.saveVisits();
|
||||||
|
if (step === "push") return window.history.pushState({ ie: "pane", key, i: visits.i }, "", this.here());
|
||||||
|
this.traversing++;
|
||||||
|
clearTimeout(this.traverseTimer);
|
||||||
|
// Should the browser not make the step (it always does, for an entry this page made), the page carries on.
|
||||||
|
this.traverseTimer = setTimeout(() => (this.traversing = 0), 1500);
|
||||||
|
if (step === "back") window.history.back();
|
||||||
|
else window.history.forward();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Back or Forward, by the browser (its buttons, a gesture, or a step trackPane asked for). */
|
||||||
|
private popped() {
|
||||||
|
const at = splitLibrary(location.pathname);
|
||||||
|
// Another library's address (one this page did not push): that library, by a page load.
|
||||||
|
if (at.library && at.library !== this.library) return location.reload();
|
||||||
|
if (!this.pages) return this.navigate(at.part, "none");
|
||||||
|
if (this.traversing > 0) {
|
||||||
|
// A step the page asked for: it shows that pane already.
|
||||||
|
if (--this.traversing === 0) this.trackPane();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// As pages each entry names a pane, so Back goes back a pane, even one with no address of its own (an article's).
|
||||||
|
const st = window.history.state as { ie?: string; key?: string; i?: number } | null;
|
||||||
|
const named = st?.ie === "pane" && typeof st.key === "string";
|
||||||
|
this.visits = named ? arrived(this.visits, st.key!, typeof st.i === "number" ? st.i : -1) : { keys: [], i: 0 };
|
||||||
|
const id = named ? findKey(this.forest, st.key!, refKey) : null;
|
||||||
|
this.paneMap = false;
|
||||||
|
if (id !== null) {
|
||||||
|
this.toPane(id);
|
||||||
|
this.emit();
|
||||||
|
} else this.navigate(at.part, "none");
|
||||||
|
this.markEntry(!named);
|
||||||
|
}
|
||||||
|
|
||||||
/** Show what a path within the library names (`/`, `/n/<id>`, `/w/<lang>/<title>`): on boot, and on Back and Forward. */
|
/** Show what a path within the library names (`/`, `/n/<id>`, `/w/<lang>/<title>`): on boot, and on Back and Forward. */
|
||||||
navigate(path: string, history: "replace" | "none") {
|
navigate(path: string, history: "replace" | "none") {
|
||||||
const s = this.snap;
|
const s = this.snap;
|
||||||
@@ -1531,7 +1647,7 @@ class Store {
|
|||||||
}
|
}
|
||||||
title = title.replace(/_/g, " ");
|
title = title.replace(/_/g, " ");
|
||||||
if (this.colWiki?.title !== title) this.openColWiki(title, w[1], false);
|
if (this.colWiki?.title !== title) this.openColWiki(title, w[1], false);
|
||||||
if (history === "replace") window.history.replaceState(null, "", this.here());
|
if (history === "replace") window.history.replaceState(window.history.state, "", this.here());
|
||||||
return this.emit();
|
return this.emit();
|
||||||
}
|
}
|
||||||
if (this.colWiki) {
|
if (this.colWiki) {
|
||||||
@@ -1566,7 +1682,7 @@ class Store {
|
|||||||
this.repairView();
|
this.repairView();
|
||||||
this.saveView();
|
this.saveView();
|
||||||
this.prefetchLinks(this.focus.node);
|
this.prefetchLinks(this.focus.node);
|
||||||
if (history === "replace") window.history.replaceState(null, "", this.here());
|
if (history === "replace") window.history.replaceState(window.history.state, "", this.here());
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
this.emit();
|
this.emit();
|
||||||
}
|
}
|
||||||
@@ -1706,7 +1822,9 @@ class Store {
|
|||||||
}
|
}
|
||||||
this.open.add(f.node);
|
this.open.add(f.node);
|
||||||
this.openPane(i, { kind: "node", id: f.node });
|
this.openPane(i, { kind: "node", id: f.node });
|
||||||
this.remember();
|
// As pages, what opens is gone to: the page on screen is always the active pane's column.
|
||||||
|
if (this.pages) this.land(i + 1);
|
||||||
|
else this.remember();
|
||||||
return this.onOpened(f.node);
|
return this.onOpened(f.node);
|
||||||
}
|
}
|
||||||
// A head: into its first row.
|
// A head: into its first row.
|
||||||
@@ -1777,8 +1895,11 @@ class Store {
|
|||||||
if (!this.panes) return;
|
if (!this.panes) return;
|
||||||
this.syncTrail();
|
this.syncTrail();
|
||||||
const p = this.trail[this.paneAt];
|
const p = this.trail[this.paneAt];
|
||||||
if (open && p?.kind === "node" && this.snap.nodes[id]?.parent === p.id && this.snap.nodes[id].kind === "section") this.openPane(this.paneAt, { kind: "node", id });
|
if (open && p?.kind === "node" && this.snap.nodes[id]?.parent === p.id && this.snap.nodes[id].kind === "section") {
|
||||||
else if (!open) this.closeRow(this.paneAt, id);
|
const i = this.paneAt;
|
||||||
|
this.openPane(i, { kind: "node", id });
|
||||||
|
if (this.pages) this.land(i + 1);
|
||||||
|
} else if (!open) this.closeRow(this.paneAt, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOpen(id: NodeId, open: boolean) {
|
setOpen(id: NodeId, open: boolean) {
|
||||||
@@ -2831,6 +2952,7 @@ class Store {
|
|||||||
return this.setFocus(this.focus, { kind: "wiki", host: `p${i + 1}`, row: { t: "head" } });
|
return this.setFocus(this.focus, { kind: "wiki", host: `p${i + 1}`, row: { t: "head" } });
|
||||||
}
|
}
|
||||||
this.openPane(i, { kind: "wiki", title: h.title, lang: h.lang, sec: row.id });
|
this.openPane(i, { kind: "wiki", title: h.title, lang: h.lang, sec: row.id });
|
||||||
|
if (this.pages) this.land(i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** h on an aux row: up to its head, then out of the view, back to where it was opened from. */
|
/** h on an aux row: up to its head, then out of the view, back to where it was opened from. */
|
||||||
@@ -2991,14 +3113,14 @@ class Store {
|
|||||||
lsSet("ie:settings", this.settings);
|
lsSet("ie:settings", this.settings);
|
||||||
this.repairView();
|
this.repairView();
|
||||||
this.say(
|
this.say(
|
||||||
view === "auto" ? `view: auto (${this.panes ? "panes" : "one column"} at this width)`
|
view === "auto" ? `view: auto (${this.pages ? "panes as pages, one column at a time" : "panes"} at this width)`
|
||||||
: view === "panes" ? "view: panes (v for one column)"
|
: view === "panes" ? "view: panes (v for one column)"
|
||||||
: "view: one column (v for panes)",
|
: "view: one column (v for panes)",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/** v: switch to whichever layout is not on screen. */
|
/** v: switch to whichever layout is not on screen: from the panes (side by side or as pages) to one column, and back to the panes this width shows. */
|
||||||
cycleView() {
|
cycleView() {
|
||||||
this.setView(this.panes ? "column" : "panes");
|
this.setView(this.panes ? "column" : this.wide ? "panes" : "auto");
|
||||||
}
|
}
|
||||||
|
|
||||||
private set(key: "auto" | "speculate" | "curves", on: boolean) {
|
private set(key: "auto" | "speculate" | "curves", on: boolean) {
|
||||||
|
|||||||
+139
-14
@@ -27,6 +27,8 @@
|
|||||||
--col: 700px;
|
--col: 700px;
|
||||||
--margin: 300px;
|
--margin: 300px;
|
||||||
--gap: 44px;
|
--gap: 44px;
|
||||||
|
/* Where what sits at the foot of the screen starts: above the status line, the home indicator (safe area) and an on-screen keyboard (--kb, App.tsx). All 1.75rem on a desktop. */
|
||||||
|
--foot-at: calc(1.75rem + env(safe-area-inset-bottom, 0px) + var(--kb, 0px));
|
||||||
color-scheme: light dark;
|
color-scheme: light dark;
|
||||||
}
|
}
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
@@ -63,12 +65,12 @@ body {
|
|||||||
}
|
}
|
||||||
::selection { background: var(--sel-strong); }
|
::selection { background: var(--sel-strong); }
|
||||||
|
|
||||||
.app { min-height: 100vh; }
|
.app { min-height: 100vh; min-height: 100dvh; }
|
||||||
.loading, .fatal { max-width: 34em; margin: 20vh auto; padding: 0 20px; font-family: var(--sans); color: var(--dim); }
|
.loading, .fatal { max-width: 34em; margin: 20vh auto; padding: 0 20px; font-family: var(--sans); color: var(--dim); }
|
||||||
|
|
||||||
/* The page's widest: the column, its gap and the margin for notes (only the column where no margin fits). */
|
/* The page's widest: the column, its gap and the margin for notes (only the column where no margin fits). */
|
||||||
:root { --page-w: calc(var(--col) + var(--gap) + var(--margin) + 40px); }
|
:root { --page-w: calc(var(--col) + var(--gap) + var(--margin) + 40px); }
|
||||||
.page { max-width: var(--page-w); margin: 0 auto; padding: 44px 20px 30vh; }
|
.page { max-width: var(--page-w); margin: 0 auto; padding: 44px max(20px, env(safe-area-inset-right, 0px)) 30vh max(20px, env(safe-area-inset-left, 0px)); }
|
||||||
article { width: min(100%, var(--col)); }
|
article { width: min(100%, var(--col)); }
|
||||||
|
|
||||||
/* ---- the top of the page ---- */
|
/* ---- the top of the page ---- */
|
||||||
@@ -212,7 +214,7 @@ article > .outline > .node { margin-top: 0.12rem; }
|
|||||||
article.preview { opacity: 0.92; }
|
article.preview { opacity: 0.92; }
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
position: fixed; top: 0; right: 0; bottom: 1.75rem; width: min(440px, 92vw); overflow-y: auto;
|
position: fixed; top: 0; right: 0; bottom: var(--foot-at); width: min(440px, 92vw); overflow-y: auto;
|
||||||
background: var(--bg); border-left: 3px double var(--rule); padding: 0 0.9rem 2rem; font-family: var(--sans); font-size: 0.74rem; line-height: 1.4; z-index: 5;
|
background: var(--bg); border-left: 3px double var(--rule); padding: 0 0.9rem 2rem; font-family: var(--sans); font-size: 0.74rem; line-height: 1.4; z-index: 5;
|
||||||
}
|
}
|
||||||
.panel-head { position: sticky; top: 0; background: var(--bg); padding: 0.7rem 0 0.45rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1em; border-bottom: 1px solid var(--hair); font-weight: 600; z-index: 1; }
|
.panel-head { position: sticky; top: 0; background: var(--bg); padding: 0.7rem 0 0.45rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1em; border-bottom: 1px solid var(--hair); font-weight: 600; z-index: 1; }
|
||||||
@@ -281,18 +283,18 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
.popup {
|
.popup {
|
||||||
position: fixed; width: 440px; max-height: 320px; overflow: auto; z-index: 15;
|
position: fixed; width: 440px; max-height: 320px; overflow: auto; z-index: 15;
|
||||||
background: var(--bg); border: 3px double var(--rule); box-shadow: 1px 2px 8px 0 color-mix(in srgb, var(--fg) 16%, transparent);
|
background: var(--bg); border: 3px double var(--rule); box-shadow: 1px 2px 8px 0 color-mix(in srgb, var(--fg) 16%, transparent);
|
||||||
padding: 0.6rem 0.85rem 0.7rem; font-size: 0.82rem; line-height: 1.45; pointer-events: none;
|
padding: 0.6rem 0.85rem 0.7rem; font-size: 0.82rem; line-height: 1.45; pointer-events: none; max-width: calc(100vw - 24px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- the command bar and status line ---- */
|
/* ---- the command bar and status line ---- */
|
||||||
.command { position: fixed; left: 0; right: 0; bottom: 1.75rem; display: flex; align-items: baseline; gap: 0.7em; background: var(--bg); border-top: 1px solid var(--fg); padding: 0.4rem 0.9rem; font-family: var(--sans); font-size: 0.8rem; z-index: 12; }
|
.command { position: fixed; left: 0; right: 0; bottom: var(--foot-at); display: flex; align-items: baseline; gap: 0.7em; background: var(--bg); border-top: 1px solid var(--fg); padding: 0.4rem 0.9rem; font-family: var(--sans); font-size: 0.8rem; z-index: 12; }
|
||||||
.command .prompt { color: var(--faint); font-size: 0.7rem; white-space: nowrap; }
|
.command .prompt { color: var(--faint); font-size: 0.7rem; white-space: nowrap; }
|
||||||
.command .prompt::after { content: " ›"; }
|
.command .prompt::after { content: " ›"; }
|
||||||
.command input { flex: 1; font: inherit; border: 0; outline: none; background: transparent; color: var(--fg); }
|
.command input { flex: 1; font: inherit; border: 0; outline: none; background: transparent; color: var(--fg); }
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
position: fixed; left: 0; right: 0; bottom: 0; height: 1.75rem; display: flex; align-items: center; gap: 0.9em;
|
position: fixed; left: 0; right: 0; bottom: var(--kb, 0px); height: calc(1.75rem + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 0.9em;
|
||||||
background: var(--wash); border-top: 1px solid var(--hair); padding: 0 0.9rem; font-family: var(--sans); font-size: 0.66rem; color: var(--dim); white-space: nowrap; z-index: 10;
|
background: var(--wash); border-top: 1px solid var(--hair); padding: 0 max(0.9rem, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(0.9rem, env(safe-area-inset-left, 0px)); font-family: var(--sans); font-size: 0.66rem; color: var(--dim); white-space: nowrap; z-index: 10;
|
||||||
}
|
}
|
||||||
.grain { font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bg); background: var(--fg); padding: 0 0.5em; border-radius: 2px; }
|
.grain { font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bg); background: var(--fg); padding: 0 0.5em; border-radius: 2px; }
|
||||||
.grain.sentence, .grain.word { background: var(--dim); }
|
.grain.sentence, .grain.word { background: var(--dim); }
|
||||||
@@ -313,7 +315,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
|
|
||||||
/* ---- the editor's research run, above the status line (AgentPanel in App.tsx) ---- */
|
/* ---- the editor's research run, above the status line (AgentPanel in App.tsx) ---- */
|
||||||
.agent-panel {
|
.agent-panel {
|
||||||
position: fixed; left: 0; right: 0; bottom: 1.75rem; max-height: 11rem; overflow: auto; z-index: 11;
|
position: fixed; left: 0; right: 0; bottom: var(--foot-at); max-height: 11rem; overflow: auto; z-index: 11;
|
||||||
background: var(--wash); border-top: 1px solid var(--hair); padding: 0.35rem 0.9rem 0.4rem;
|
background: var(--wash); border-top: 1px solid var(--hair); padding: 0.35rem 0.9rem 0.4rem;
|
||||||
font-family: var(--sans); font-size: 0.7rem; line-height: 1.5; color: var(--dim);
|
font-family: var(--sans); font-size: 0.7rem; line-height: 1.5; color: var(--dim);
|
||||||
}
|
}
|
||||||
@@ -369,7 +371,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.view-panes .page {
|
.view-panes .page {
|
||||||
position: fixed; top: 0; left: 0; right: 0; bottom: 1.75rem;
|
position: fixed; top: 0; left: 0; right: 0; bottom: var(--foot-at);
|
||||||
max-width: none; margin: 0; padding: 0; display: flex; flex-direction: column;
|
max-width: none; margin: 0; padding: 0; display: flex; flex-direction: column;
|
||||||
}
|
}
|
||||||
.view-panes.with-panel .page { right: min(440px, 92vw); }
|
.view-panes.with-panel .page { right: min(440px, 92vw); }
|
||||||
@@ -517,7 +519,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
--hue-none: oklch(80% 0 0);
|
--hue-none: oklch(80% 0 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:where(.pane, .curves path) { --hue: var(--hue-none); }
|
:where(.pane, .curves path, .trail-step, .map-row) { --hue: var(--hue-none); }
|
||||||
[data-hue="0"] { --hue: var(--hue-0); }
|
[data-hue="0"] { --hue: var(--hue-0); }
|
||||||
[data-hue="1"] { --hue: var(--hue-1); }
|
[data-hue="1"] { --hue: var(--hue-1); }
|
||||||
[data-hue="2"] { --hue: var(--hue-2); }
|
[data-hue="2"] { --hue: var(--hue-2); }
|
||||||
@@ -526,7 +528,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
[data-hue="5"] { --hue: var(--hue-5); }
|
[data-hue="5"] { --hue: var(--hue-5); }
|
||||||
[data-hue="6"] { --hue: var(--hue-6); }
|
[data-hue="6"] { --hue: var(--hue-6); }
|
||||||
/* Fainter off the focused branch. Both are fixed per pane, so moving the branch changes no custom property (which every element in the pane would inherit). */
|
/* Fainter off the focused branch. Both are fixed per pane, so moving the branch changes no custom property (which every element in the pane would inherit). */
|
||||||
.pane, .curves path { --hue-faint: color-mix(in oklab, var(--hue) 70%, transparent); }
|
.pane, .curves path, .trail-step, .map-row { --hue-faint: color-mix(in oklab, var(--hue) 70%, transparent); }
|
||||||
.panes:not([data-colors="off"]) .curves path { stroke: var(--hue-faint); stroke-width: var(--hair, 1px); }
|
.panes:not([data-colors="off"]) .curves path { stroke: var(--hue-faint); stroke-width: var(--hair, 1px); }
|
||||||
.panes:not([data-colors="off"]) .curves path.on { stroke: var(--hue); }
|
.panes:not([data-colors="off"]) .curves path.on { stroke: var(--hue); }
|
||||||
/*
|
/*
|
||||||
@@ -854,13 +856,13 @@ html { scroll-padding-top: 48px; }
|
|||||||
|
|
||||||
/* Touch: no hover, no right-click, no keys. The bar docks at the foot; a menu is a sheet. */
|
/* Touch: no hover, no right-click, no keys. The bar docks at the foot; a menu is a sheet. */
|
||||||
.selbar.docked {
|
.selbar.docked {
|
||||||
left: 0; right: 0; bottom: 1.75rem; top: auto !important; border-width: 1px 0 0; border-radius: 0; box-shadow: none;
|
left: 0; right: 0; bottom: var(--foot-at); top: auto !important; border-width: 1px 0 0; border-radius: 0; box-shadow: none;
|
||||||
padding: 0.3rem 0.4rem; background: var(--bg); flex-wrap: wrap; justify-content: center;
|
padding: 0.3rem 0.4rem; background: var(--bg); flex-wrap: wrap; justify-content: center;
|
||||||
}
|
}
|
||||||
.selbar.docked::after, .selbar.docked .k, .selbar.docked .bar-sep { display: none; }
|
.selbar.docked::after, .selbar.docked .k, .selbar.docked .bar-sep { display: none; }
|
||||||
.selbar.docked button { padding: 0.45rem 0.6rem; font-size: 0.95rem; }
|
.selbar.docked button { padding: 0.45rem 0.6rem; font-size: 0.95rem; min-height: 44px; min-width: 44px; }
|
||||||
.menu.sheet {
|
.menu.sheet {
|
||||||
left: 0; right: 0; bottom: 1.75rem; top: auto; max-width: none; max-height: 70vh; overflow-y: auto;
|
left: 0; right: 0; bottom: var(--foot-at); top: auto; max-width: none; max-height: 70vh; max-height: 70dvh; overflow-y: auto;
|
||||||
border-width: 3px 0 0; padding-bottom: 0.4rem; font-size: 0.86rem; box-shadow: 0 -2px 10px 0 color-mix(in srgb, var(--fg) 12%, transparent);
|
border-width: 3px 0 0; padding-bottom: 0.4rem; font-size: 0.86rem; box-shadow: 0 -2px 10px 0 color-mix(in srgb, var(--fg) 12%, transparent);
|
||||||
}
|
}
|
||||||
.menu.sheet .mi { padding: 0.62rem 1rem; }
|
.menu.sheet .mi { padding: 0.62rem 1rem; }
|
||||||
@@ -923,3 +925,126 @@ html { scroll-padding-top: 48px; }
|
|||||||
.panel.left { width: auto; right: 0; border-right: 0; }
|
.panel.left { width: auto; right: 0; border-right: 0; }
|
||||||
}
|
}
|
||||||
/* ---- end libraries panel ---- */
|
/* ---- end libraries panel ---- */
|
||||||
|
|
||||||
|
/* ---- pages (src/ui/Pages.tsx, pages.ts) ----
|
||||||
|
* The panes on a phone (auto, narrower than 900 px): each column of the panes view is a page as
|
||||||
|
* wide as the screen, its panes stacked down it as on a wide screen, and the pages are swiped
|
||||||
|
* sideways, snapping one at a time. No curves (the panes are never side by side): what a pane was
|
||||||
|
* opened from takes its colour instead, the colour of the rule under its title, its tab and its
|
||||||
|
* step in the trail. Everything a finger presses is at least 40 px each way; nothing waits for a
|
||||||
|
* hover. The trail and the map's button sit at the foot, where a thumb reaches.
|
||||||
|
*/
|
||||||
|
.view-pages { --spine: 16px; --pane-pad: 16px; }
|
||||||
|
.view-pages .page { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
|
||||||
|
.panes[data-layout="pages"] { --tab: 44px; }
|
||||||
|
.panes[data-layout="pages"] .strip { scroll-snap-type: x mandatory; scrollbar-width: none; }
|
||||||
|
.panes[data-layout="pages"] .strip::-webkit-scrollbar { display: none; }
|
||||||
|
.panes[data-layout="pages"] .col { position: relative; width: 100%; scroll-snap-align: start; scroll-snap-stop: always; }
|
||||||
|
.panes[data-layout="pages"] .pane { border-right: 0; }
|
||||||
|
/* Room above the title for the pane's buttons, a finger's size; on a tablet the text keeps its measure. */
|
||||||
|
.panes[data-layout="pages"] .pane-scroll { padding-top: 46px; }
|
||||||
|
.panes[data-layout="pages"] .col.split .pane-scroll { padding-bottom: 1.4rem; }
|
||||||
|
.panes[data-layout="pages"] .pane-body { max-width: var(--pane-text); margin: 0 auto; }
|
||||||
|
.panes[data-layout="pages"] .pane-ctl { top: 2px; right: 4px; gap: 0; }
|
||||||
|
.panes[data-layout="pages"] .pane-btn { width: 40px; height: 40px; padding: 12px; color: var(--faint); }
|
||||||
|
.panes[data-layout="pages"] .pane-btn.more { padding: 0; margin: 0; font-size: 1rem; opacity: 1; pointer-events: auto; }
|
||||||
|
/* The first pane never closes. */
|
||||||
|
.panes[data-layout="pages"] .pane.root > .pane-ctl > .close { display: none; }
|
||||||
|
.panes[data-layout="pages"] .pane-btn.pin.on { color: var(--fg); }
|
||||||
|
.panes[data-layout="pages"] .grip { display: none; }
|
||||||
|
/* A tab: a swipe across it still turns the page; one down it drags the pane up or down its column. */
|
||||||
|
.panes[data-layout="pages"] .tabline { padding: 0 128px 0 var(--spine); font-size: 0.8rem; touch-action: pan-x; }
|
||||||
|
/* The heavy rule marks the active pane among others in its column; alone on its page it needs none. */
|
||||||
|
.panes[data-layout="pages"] .pane.active::after,
|
||||||
|
.panes[data-layout="pages"][data-curves="off"] .pane.active::after { bottom: auto; height: 3px; border: 0; background: var(--fg); }
|
||||||
|
.panes[data-layout="pages"] .col:not(.split) > .pane::after { height: 0; }
|
||||||
|
/* Rows a finger opens. (Links in running text are words, and stay as tall as the line.) */
|
||||||
|
.panes[data-layout="pages"] :is(.rows, .wrows) .row { min-height: 40px; align-items: center; }
|
||||||
|
.panes[data-layout="pages"] :is(.backlinks, .related-list) li { min-height: 40px; align-content: center; }
|
||||||
|
.panes[data-layout="pages"] .target-row { min-height: 40px; }
|
||||||
|
/* What a pane was opened from, in that pane's colour (Panes.tsx pageMarks): fainter for a pane off the focused branch. */
|
||||||
|
[data-src-hue] { --src-hue: var(--hue-none); }
|
||||||
|
[data-src-hue="0"] { --src-hue: var(--hue-0); }
|
||||||
|
[data-src-hue="1"] { --src-hue: var(--hue-1); }
|
||||||
|
[data-src-hue="2"] { --src-hue: var(--hue-2); }
|
||||||
|
[data-src-hue="3"] { --src-hue: var(--hue-3); }
|
||||||
|
[data-src-hue="4"] { --src-hue: var(--hue-4); }
|
||||||
|
[data-src-hue="5"] { --src-hue: var(--hue-5); }
|
||||||
|
[data-src-hue="6"] { --src-hue: var(--hue-6); }
|
||||||
|
[data-src-hue]:not([data-src-on]) { --src-hue-now: color-mix(in oklab, var(--src-hue) 70%, transparent); }
|
||||||
|
[data-src-hue][data-src-on] { --src-hue-now: var(--src-hue); }
|
||||||
|
.panes[data-layout="pages"]:not([data-colors="off"]) :is(.lnk, .wiki-text a)[data-src-hue] { text-decoration-color: var(--src-hue-now); text-decoration-thickness: 2px; }
|
||||||
|
.panes[data-layout="pages"]:not([data-colors="off"]) .anchor[data-src-hue] { background-image: linear-gradient(var(--src-hue-now), var(--src-hue-now)); background-size: 1px 2px; }
|
||||||
|
.panes[data-layout="pages"]:not([data-colors="off"]) :is(.node, .wrow)[data-src-hue] > .row { box-shadow: inset 2px 0 0 var(--src-hue-now); }
|
||||||
|
.panes[data-layout="pages"]:not([data-colors="off"]) :is(.node, .wrow)[data-src-hue] > .row::after { color: var(--src-hue-now); }
|
||||||
|
.panes[data-layout="pages"]:not([data-colors="off"]) :is(.backlinks, .related-list) li[data-src-hue] { box-shadow: inset 2px 0 0 var(--src-hue-now); }
|
||||||
|
|
||||||
|
/* A tap shows where it landed, quietly, in the text's ink. */
|
||||||
|
.view-pages { -webkit-tap-highlight-color: color-mix(in srgb, var(--fg) 10%, transparent); }
|
||||||
|
/* A panel's key buttons (the libraries': new, close, delete's yes and no), a finger's size too. */
|
||||||
|
.view-pages .panel .key { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
|
||||||
|
.view-pages .panel-head { padding: 0.1rem 0; align-items: center; }
|
||||||
|
|
||||||
|
/* The top bar: each tool a finger's height. */
|
||||||
|
.view-pages .docbar { min-height: 44px; align-items: center; padding: 0 8px 0 4px; }
|
||||||
|
.view-pages .docbar .tool { min-height: 44px; min-width: 44px; justify-content: center; display: inline-flex; align-items: center; padding: 0 6px; }
|
||||||
|
.view-pages .docbar .tools { align-items: center; gap: 0.2em; }
|
||||||
|
.view-pages .docbar .lib-name { align-items: center; }
|
||||||
|
/* The status line keeps what is said and whether it is saved; the branch, the model and the key list are in the menu and the history. */
|
||||||
|
.view-pages .status .right > :is(.usage, [title="branch"], [title="model"], .q) { display: none; }
|
||||||
|
|
||||||
|
/* The trail: the focused branch, a step per pane, each underlined in its pane's colour; the one on screen in the text's ink. */
|
||||||
|
.trail {
|
||||||
|
flex: none; display: flex; align-items: stretch; height: 44px; border-top: 1px solid var(--hair); background: var(--bg);
|
||||||
|
font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
.trail-steps { flex: 1; min-width: 0; display: flex; align-items: stretch; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 0 4px; }
|
||||||
|
.trail-steps::-webkit-scrollbar { display: none; }
|
||||||
|
.trail-step {
|
||||||
|
position: relative; flex: none; display: flex; align-items: center; gap: 0.3em; min-width: 44px; max-width: 11em; padding: 0 12px;
|
||||||
|
font: inherit; color: var(--dim); background: none; border: 0; border-radius: 0; cursor: pointer;
|
||||||
|
}
|
||||||
|
.trail-step:hover { border: 0; color: var(--fg); }
|
||||||
|
.trail-step::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 10px; height: 1px; background: var(--hue-faint); }
|
||||||
|
.trail-step.here { color: var(--fg); font-weight: 600; }
|
||||||
|
.trail-step.here::after { height: 2px; background: var(--hue); }
|
||||||
|
.trail-step.ahead { color: var(--faint); }
|
||||||
|
.trail-step + .trail-step::before { content: "›"; position: absolute; left: -0.2em; color: var(--rule); font-weight: 400; }
|
||||||
|
.trail-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.trail-step .wmark { flex: none; font-size: 0.95em; }
|
||||||
|
.trail-map { flex: none; min-width: 64px; padding: 0 14px; font: inherit; color: var(--dim); background: none; border: 0; border-left: 1px solid var(--hair); border-radius: 0; cursor: pointer; }
|
||||||
|
.trail-map:hover, .trail-map[aria-expanded="true"] { border-color: var(--hair); color: var(--fg); }
|
||||||
|
.trail-n { color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 0.15em; }
|
||||||
|
|
||||||
|
/* The map: every open pane, as an outline of the forest, in a sheet from the foot. */
|
||||||
|
.pane-map {
|
||||||
|
position: fixed; left: 0; right: 0; bottom: var(--foot-at); z-index: 30; max-height: 70vh; max-height: 70dvh; overflow-y: auto; outline: none;
|
||||||
|
background: var(--bg); border-top: 3px double var(--rule); box-shadow: 0 -2px 10px 0 color-mix(in srgb, var(--fg) 12%, transparent);
|
||||||
|
padding: 0 env(safe-area-inset-right, 0px) 0.4rem env(safe-area-inset-left, 0px); font-family: var(--sans); font-size: 0.86rem; line-height: 1.35;
|
||||||
|
}
|
||||||
|
.map-head {
|
||||||
|
position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 1em; padding: 0.6rem 1rem 0.35rem;
|
||||||
|
background: var(--bg); font-size: 0.6rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
|
||||||
|
}
|
||||||
|
.map-hint { font-weight: 400; letter-spacing: 0.02em; text-transform: none; text-align: right; }
|
||||||
|
.map-rows { list-style: none; margin: 0; padding: 0; }
|
||||||
|
.map-row { display: flex; align-items: stretch; min-height: 44px; padding-left: calc(6px + var(--depth, 0) * 14px); }
|
||||||
|
.map-go { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.55em; padding: 0 8px; font: inherit; color: var(--dim); text-align: left; background: none; border: 0; border-radius: 0; cursor: pointer; }
|
||||||
|
.map-go:hover { border: 0; color: var(--fg); }
|
||||||
|
.map-dash { flex: none; width: 1.1rem; height: 0; border-top: 1px solid var(--hue-faint); }
|
||||||
|
.map-row.on-branch .map-dash { border-top: 2px solid var(--hue); }
|
||||||
|
.map-row.on-branch .map-go { color: var(--fg); }
|
||||||
|
.map-row.here .map-go { font-weight: 600; background: var(--sel); }
|
||||||
|
.map-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.map-sub { flex: none; color: var(--faint); font-size: 0.66rem; font-style: italic; }
|
||||||
|
.map-btn { flex: none; display: block; width: 44px; height: 44px; padding: 14px; color: var(--faint); background: none; border: 0; border-radius: 0; cursor: pointer; }
|
||||||
|
.map-btn.none { cursor: default; }
|
||||||
|
.map-btn svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
|
||||||
|
.map-btn:hover { border: 0; color: var(--fg); background: var(--sel); }
|
||||||
|
.map-btn.pin.on { color: var(--fg); }
|
||||||
|
.map-btn.pin.on svg { fill: currentColor; }
|
||||||
|
|
||||||
|
/* A long press on a link (touch): what it opens, above its menu. */
|
||||||
|
.menu-card { padding: 0.5rem 1rem 0.6rem; border-bottom: 1px solid var(--hair); font-family: var(--serif); font-size: 0.82rem; line-height: 1.45; max-height: 40vh; overflow-y: auto; }
|
||||||
|
.menu-card:has(.l-wiki) { background: var(--wiki-bg); }
|
||||||
|
/* ---- end pages ---- */
|
||||||
@@ -86,6 +86,9 @@ describe("actions", () => {
|
|||||||
expect(labels(link).slice(1, 8)).toEqual(["Copy", "--", "Open the link beside", "Open it in place", "Open on wikipedia.org", "Retarget…", "Remove the link"]);
|
expect(labels(link).slice(1, 8)).toEqual(["Copy", "--", "Open the link beside", "Open it in place", "Open on wikipedia.org", "Retarget…", "Remove the link"]);
|
||||||
expect(find(link, "Open it in place")).toMatchObject({ key: "Enter", shift: true, keyText: "⇧⏎" });
|
expect(find(link, "Open it in place")).toMatchObject({ key: "Enter", shift: true, keyText: "⇧⏎" });
|
||||||
expect(labels(link)).not.toContain("Link to…");
|
expect(labels(link)).not.toContain("Link to…");
|
||||||
|
// As pages (a phone) an open goes to the next page, not beside; in place is still there.
|
||||||
|
expect(labels(selectionEntries(sel({ link: "wiki", panes: true, pages: true }), act)).slice(3, 5)).toEqual(["Open the link", "Open it in place"]);
|
||||||
|
expect(labels(articleRowEntries("Octopus", true, act, true)).slice(1, 3)).toEqual(["Open", "Open in place"]);
|
||||||
// Removing a link is D, and says it is for good; a library link the same; a note that also links can lose only its target.
|
// Removing a link is D, and says it is for good; a library link the same; a note that also links can lose only its target.
|
||||||
expect(find(link, "Remove the link")).toMatchObject({ key: "D", sub: "and do not link these words again here" });
|
expect(find(link, "Remove the link")).toMatchObject({ key: "D", sub: "and do not link these words again here" });
|
||||||
expect(find(selectionEntries(sel({ link: "node" }), act), "Remove the link")).toMatchObject({ key: "D" });
|
expect(find(selectionEntries(sel({ link: "node" }), act), "Remove the link")).toMatchObject({ key: "D" });
|
||||||
|
|||||||
Reference in new issue
Block a user