cornfield 0.56.0 → 0.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/strings.js +1 -1
- package/explorer/css/account.css +1 -1
- package/explorer/css/changes.css +1 -1
- package/explorer/css/dialogs.css +1 -1
- package/explorer/css/node-panel.css +1 -1
- package/explorer/css/sheets.css +1 -1
- package/explorer/css/work.css +6 -4
- package/explorer/engine/hint.js +2 -2
- package/explorer/engine/keyboard.js +1 -1
- package/explorer/engine/layers.js +4 -2
- package/explorer/engine/map-rect.js +2 -2
- package/explorer/engine/proposal.js +3 -3
- package/explorer/engine/sheets.js +3 -3
- package/explorer/focus-room.js +1 -1
- package/explorer/forge-panel-model.js +3 -2
- package/explorer/forge-panel.js +1 -1
- package/explorer/index.html +1 -1
- package/explorer/instance.js +6 -4
- package/explorer/page-pieces.js +1 -1
- package/explorer/pieces/decision.js +3 -3
- package/explorer/pieces/layers.js +1 -1
- package/explorer/pieces/node-panel.js +29 -9
- package/explorer/pieces/proposal.js +6 -6
- package/explorer/pieces/review.js +2 -2
- package/explorer/pieces/work-agent.js +4 -4
- package/explorer/pieces/work-confirm.js +3 -3
- package/explorer/pieces/work-issues.js +1 -1
- package/explorer/pieces/work-list.js +2 -0
- package/explorer/pieces/work-paint.js +23 -0
- package/explorer/pieces/work-prs.js +15 -5
- package/explorer/pieces/work-threads.js +1 -1
- package/explorer/pieces/work.js +10 -0
- package/explorer/proposal-model.js +1 -1
- package/explorer/proposal.js +1 -1
- package/explorer/runs-view.js +2 -2
- package/explorer/sheets.js +1 -1
- package/explorer/tokens.css +2 -2
- package/explorer/work-badge-model.js +161 -0
- package/explorer/work-badges.js +143 -0
- package/explorer/work-model.js +22 -4
- package/explorer/work-view.css +10 -0
- package/explorer/work-view.js +119 -22
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ export function install(ctx) {
|
|
|
18
18
|
const n = item.number;
|
|
19
19
|
if (!item.open) return `<p class="hx-faint">${escHtml(specBlock({ state: 'closed' }))}</p>`;
|
|
20
20
|
const spec = specBlock({ state: 'open' }) === null
|
|
21
|
-
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
|
|
21
|
+
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' aria-disabled="true"' : ''}>Start a spec …</button>`
|
|
22
22
|
: '';
|
|
23
23
|
const agent = `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
|
|
24
24
|
return `<div class="hx-forge-cta">${agent}${spec}</div>`;
|
|
@@ -168,6 +168,8 @@ export function install(ctx) {
|
|
|
168
168
|
function onDetailClick(e) {
|
|
169
169
|
const t = e.target;
|
|
170
170
|
if (!t.closest) return;
|
|
171
|
+
// A button that waits on its request is `aria-disabled`, not `disabled` (it keeps the focus): a press on it does nothing, so a second press is never a second request
|
|
172
|
+
if (t.closest('button[aria-disabled="true"]')) return;
|
|
171
173
|
const nodeBtn = t.closest('[data-forge-node]');
|
|
172
174
|
if (nodeBtn) {
|
|
173
175
|
const node = nodeById(nodeBtn.dataset.forgeNode);
|
|
@@ -84,6 +84,12 @@ export function install(ctx) {
|
|
|
84
84
|
}
|
|
85
85
|
const back = again && box.querySelector(again);
|
|
86
86
|
if (back && back !== inst.active() && !back.closest('[hidden]') && !back.disabled) back.focus();
|
|
87
|
+
// The control that had the focus is gone (Land it, once the pull request has landed; a Stop that was asked for) and the page has it: it goes to the actions' own place, which a keyboard
|
|
88
|
+
// user continues from with Tab, never to the page. (A pressed button that is still there keeps it: `aria-disabled`, not `disabled`.)
|
|
89
|
+
// (the page's own root is the document: its `activeElement` is then the body, not null)
|
|
90
|
+
const now = inst.active();
|
|
91
|
+
const lost = had && !had.isConnected && (!now || now === inst.doc.body);
|
|
92
|
+
if (lost && !(kind === 'run' && had.closest('[data-run]'))) { box.setAttribute('tabindex', '-1'); box.focus(); }
|
|
87
93
|
// A control of a run card that is no longer drawn (the run went on): the focus goes to that run's card, never to the page
|
|
88
94
|
const hadRun = had && !had.isConnected && had.closest('[data-run]');
|
|
89
95
|
if (hadRun && !box.contains(inst.active())) {
|
|
@@ -149,10 +155,27 @@ export function install(ctx) {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
/** Says (on the panel's top, for the CSS) that the tabs run on past an edge: a fade shows on that side, so Deploys is not simply missing on a phone */
|
|
158
|
+
let tabsFor = null; // the tab the strip was last scrolled to show: the strip follows the tab that is on (and is left alone while the viewer scrolls it)
|
|
152
159
|
function paintTabsMore() {
|
|
153
160
|
const top = root.querySelector('#forge-panel .hx-forge-top');
|
|
154
161
|
const tabs = top && top.querySelector('.hx-forge-tabs');
|
|
155
162
|
if (!tabs) return;
|
|
163
|
+
// The tab that is on is brought into the strip (Deploys is the sixth: a list opened on it, or a tab pressed, must not leave it under the edge). A strip that is not laid out
|
|
164
|
+
// (the list shut, a phone's sheet in its peek) is asked again when it is
|
|
165
|
+
const active = tabs.clientWidth ? tabs.querySelector('[aria-pressed="true"]') : null;
|
|
166
|
+
if (!tabs.clientWidth) tabsFor = null;
|
|
167
|
+
else if (active && tabsFor !== ui.kind) {
|
|
168
|
+
tabsFor = ui.kind;
|
|
169
|
+
const box = tabs.getBoundingClientRect();
|
|
170
|
+
const at = active.getBoundingClientRect();
|
|
171
|
+
// Clear of the fade the strip puts on an edge it runs on past (css/work.css: one and a half `--corn-space-6`); the first and the last tab go to their end of the strip
|
|
172
|
+
const room = 1.5 * (parseFloat(inst.win.getComputedStyle(tabs).getPropertyValue('--corn-space-6')) || 24);
|
|
173
|
+
const shown = [...tabs.children].filter((c) => !c.hidden);
|
|
174
|
+
if (active === shown[0]) tabs.scrollLeft = 0;
|
|
175
|
+
else if (active === shown[shown.length - 1]) tabs.scrollLeft = tabs.scrollWidth;
|
|
176
|
+
else if (at.left < box.left + room) tabs.scrollLeft += at.left - box.left - room;
|
|
177
|
+
else if (at.right > box.right - room) tabs.scrollLeft += at.right - box.right + room;
|
|
178
|
+
}
|
|
156
179
|
const more = [];
|
|
157
180
|
if (tabs.scrollLeft > 1) more.push('start');
|
|
158
181
|
if (tabs.scrollWidth - tabs.clientWidth - tabs.scrollLeft > 1) more.push('end');
|
|
@@ -124,7 +124,7 @@ export function install(ctx) {
|
|
|
124
124
|
const name = safeUrl(c.url) ? `<a data-corn="text-link" class="hx-link" href="${escHtml(c.url)}" target="_blank" rel="noreferrer">${escHtml(c.name)}</a>` : `<span class="hx-name">${escHtml(c.name)}</span>`;
|
|
125
125
|
const why = rerunWhy(c, fn.forgeName());
|
|
126
126
|
const again = c.state === 'failure' && c.canRerun
|
|
127
|
-
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-rerun="${escHtml(c.id)}" aria-label="Re-run ${escHtml(c.name)}"${ui.busy ? ' disabled' : ''}>Re-run</button>`
|
|
127
|
+
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-rerun="${escHtml(c.id)}" aria-label="Re-run ${escHtml(c.name)}"${ui.busy ? ' aria-disabled="true"' : ''}>Re-run</button>`
|
|
128
128
|
: '';
|
|
129
129
|
const whyNot = why ? `<span class="hx-faint hx-forge-lights">${escHtml(why)}</span>` : '';
|
|
130
130
|
return `<li class="hx-forge-check"><span class="hx-forge-state hx-forge-state--${escHtml(c.state)}" data-corn="state-pill"${cornStateAttr(c.state)}>${stateIconHtml(c.state)}${escHtml(checkWords(c))}</span> ${name}${again}${lights}${whyNot}</li>`;
|
|
@@ -142,18 +142,28 @@ export function install(ctx) {
|
|
|
142
142
|
const block = mergeBlock(ui.detail);
|
|
143
143
|
const land = block
|
|
144
144
|
? `<button type="button" class="hx-btn hx-btn--approve" disabled data-corn-kind="approve">${escHtml(t('landIt'))}</button>`
|
|
145
|
-
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
|
|
146
|
-
|
|
145
|
+
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
|
|
146
|
+
// A spec pull request older than the graph's 14 days is a plain pull request here, with no Review of its own: its proposals that are not approved get one, found by their slug in the
|
|
147
|
+
// proposals list (the node panel of one the graph holds has it already: pieces/work-specs.js). A proposal the list does not hold is named in the warning instead.
|
|
148
|
+
// Only this pull request's own copy: another pull request may hold a file of the same slug (anyone can open one), and approving that copy would approve, and with
|
|
149
|
+
// `approveLands` land, the other pull request
|
|
150
|
+
const ownCopy = (slug) => { const e = fn.specEntry({ slug, number: pull.number }); return e && e.pull && e.pull.number === pull.number ? e : null; };
|
|
151
|
+
const reviewable = ui.item && ui.item.kind === 'pull' && pull.state === 'open'
|
|
152
|
+
? (ui.detail.specs || []).filter((x) => !x.approved).map((x) => ({ slug: x.slug, entry: ownCopy(x.slug) }))
|
|
153
|
+
: [];
|
|
154
|
+
const review = reviewable.filter((x) => x.entry).map((x) => `<button type="button" class="hx-btn hx-forge-act" data-corn-kind="secondary" data-work-action="review" data-slug="${escHtml(x.slug)}" data-source="${escHtml(x.entry.source || '')}" aria-label="Review proposal ${escHtml(x.slug)}">Review ${escHtml(x.slug)} …</button>`).join('');
|
|
155
|
+
const warning = approvalWarning(ui.detail, { review: !reviewable.length ? 'node' : reviewable.every((x) => x.entry) ? 'here' : 'list' });
|
|
156
|
+
const act = `<div class="hx-forge-cta">${land}${review}${url ? `<a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : ''}</div>${block ? `<p class="hx-forge-why hx-faint">${escHtml(block)}</p>` : ''}${warning ? `<p class="hx-forge-why hx-faint" data-corn="notice" data-corn-state="waiting">${escHtml(warning)}</p>` : ''}`;
|
|
147
157
|
// A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
|
|
148
158
|
const waiting = ui.landing && pull.state === 'open'
|
|
149
|
-
? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, m.now()))}</p><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
|
|
159
|
+
? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, m.now()))}</p><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' aria-disabled="true"' : ''}>Cancel</button></div>`
|
|
150
160
|
: '';
|
|
151
161
|
const note = ui.note ? `<p class="hx-forge-notice${ui.note.ok ? ' hx-forge-notice--ok' : ''}" data-corn="notice"${ui.note.ok ? ' data-corn-state="success"' : ''}>${escHtml(ui.note.text)}</p>` : '';
|
|
152
162
|
// Step 2 of the pipeline: a spec pull request with an approved proposal opens its build issue
|
|
153
163
|
const offers = buildOffers(ui.detail);
|
|
154
164
|
const build = offers.length
|
|
155
165
|
? `<h3 class="hx-forge-subact">Build issue</h3>${offers.map((o) => (o.offer
|
|
156
|
-
? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
|
|
166
|
+
? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
|
|
157
167
|
: `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join('')}`
|
|
158
168
|
: '';
|
|
159
169
|
|
|
@@ -215,7 +215,7 @@ export function install(ctx) {
|
|
|
215
215
|
$('idea-open').setAttribute('aria-expanded', String(ui.idea.open));
|
|
216
216
|
$('idea-form').hidden = !ui.idea.open;
|
|
217
217
|
$('idea-send').textContent = ui.idea.busy ? 'Opening …' : 'Open the idea';
|
|
218
|
-
$('idea-send').disabled
|
|
218
|
+
if (ui.idea.busy) $('idea-send').setAttribute('aria-disabled', 'true'); else $('idea-send').removeAttribute('aria-disabled'); // not `disabled`: the focus stays (`sendIdea` ignores a press while busy)
|
|
219
219
|
if (ui.idea.open) {
|
|
220
220
|
const label = (ui.config && ui.config.threads && ui.config.threads.label) || 'idea';
|
|
221
221
|
$('idea-words').textContent = `This opens an issue labelled "${label}" on ${fn.forgeName()}, as you. The conversation lives there; cornfield keeps no copy of it.`;
|
package/explorer/pieces/work.js
CHANGED
|
@@ -213,6 +213,16 @@ export function mount(root, inst, options = {}) {
|
|
|
213
213
|
scope.listen(ctx.root, 'focusin', (e) => { revealInStrip(e.target); });
|
|
214
214
|
const tabs = panel.querySelector('.hx-forge-tabs');
|
|
215
215
|
if (tabs) scope.listen(tabs, 'scroll', fn.paintTabsMore, { passive: true });
|
|
216
|
+
// A mouse wheel turns the strip sideways (its tabs run on past the panel's edge, and a vertical wheel has nothing else to do over a one-line strip); at either end it is left to the list below
|
|
217
|
+
if (tabs) {
|
|
218
|
+
scope.listen(tabs, 'wheel', (e) => {
|
|
219
|
+
if (e.deltaX || !e.deltaY || e.ctrlKey || e.defaultPrevented) return;
|
|
220
|
+
const end = tabs.scrollWidth - tabs.clientWidth;
|
|
221
|
+
if (end <= 1 || (e.deltaY < 0 ? tabs.scrollLeft <= 0 : tabs.scrollLeft >= end - 1)) return;
|
|
222
|
+
tabs.scrollLeft += e.deltaY;
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
}, { passive: false });
|
|
225
|
+
}
|
|
216
226
|
scope.own(inst.onResize(() => fn.paintTabsMore()));
|
|
217
227
|
// The strip's fade and the top's height follow their own size too: a phone's sheet expanding shows the tabs (they were not laid out in the
|
|
218
228
|
// peek), and a host's box resizes without the window doing so (F42)
|
|
@@ -170,7 +170,7 @@ export function proposalPanelHtml(item) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// ---------------------------------------------------------------------------
|
|
173
|
-
// A proposal as a row of the Work
|
|
173
|
+
// A proposal as a row of the Work list's Specs tab
|
|
174
174
|
// ---------------------------------------------------------------------------
|
|
175
175
|
|
|
176
176
|
/** Where a listing entry is, as a line of meta: "PR #11", or the checkout or worktree it is in; a proposal that is also somewhere else says so ("PR #11, and a copy in the checkout") */
|
package/explorer/proposal.js
CHANGED
|
@@ -48,7 +48,7 @@ for (const name of Object.keys(ADAPT)) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/** What the server listed last, for the Work
|
|
51
|
+
/** What the server listed last, for the Work list's Specs tab: the entries (null before the first answer), why the list could not be read, why the spec PRs are missing, and when */
|
|
52
52
|
export const proposalListing = () => E.proposalListing(pageInstance());
|
|
53
53
|
/** Calls `fn` each time the list is read again; returns the way to stop */
|
|
54
54
|
export const onProposalListing = (fn) => E.onProposalListing(pageInstance(), fn);
|
package/explorer/runs-view.js
CHANGED
|
@@ -94,7 +94,7 @@ function answerHtml(ctx, run) {
|
|
|
94
94
|
const say = ctx.t || t; // the words of the instance that draws it (the Work piece hands its own), else the page's
|
|
95
95
|
const id = ctx.esc(run.runId);
|
|
96
96
|
const name = ctx.esc(runName(run, ctx.now));
|
|
97
|
-
const off = ctx.busy ? ' disabled' : '';
|
|
97
|
+
const off = ctx.busy ? ' aria-disabled="true"' : ''; // not `disabled`: the pressed button keeps the focus (a click on it is dropped: pieces/work-list.js `onDetailClick`)
|
|
98
98
|
const reply = ctx.replies && ctx.replies.get(run.runId) || '';
|
|
99
99
|
return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" data-corn="run-actions" role="group" aria-label="Answer: ${name}">
|
|
100
100
|
<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(say('continueRun'))}: ${name}"${off}>${ctx.esc(say('continueRun'))}</button>
|
|
@@ -147,7 +147,7 @@ export function runHtml(ctx, run, all) {
|
|
|
147
147
|
const name = ctx.esc(runName(run, ctx.now));
|
|
148
148
|
const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
|
|
149
149
|
const answering = canAnswer(run);
|
|
150
|
-
const off = ctx.busy ? ' disabled' : '';
|
|
150
|
+
const off = ctx.busy ? ' aria-disabled="true"' : ''; // not `disabled`: the pressed button keeps the focus (a click on it is dropped: pieces/work-list.js `onDetailClick`)
|
|
151
151
|
const retry = canRetry(run) ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('startAgain'))}: ${name}"${off}>${ctx.esc(say('startAgain'))}</button>` : '';
|
|
152
152
|
const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(say('stop'))}</button>` : '';
|
|
153
153
|
const names = nodeLabels(run.nodes, ctx.nodes);
|
package/explorer/sheets.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A bridge (spec 0011 D2, step 4): the phone's bottom sheets now live in engine/sheets.js, one set per instance (the node panel registers its
|
|
5
5
|
* own, pieces/node-panel.js, and so does the proposal's bar, pieces/proposal.js). This file keeps the old names for the modules that are not yet on an
|
|
6
|
-
* instance (the Work
|
|
6
|
+
* instance (the Work list, deep links, the House), bound to the page's instance. It goes when the last of them is converted.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { pageInstance } from './state.js';
|
package/explorer/tokens.css
CHANGED
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
--corn-space-5: 16px;
|
|
116
116
|
--corn-space-6: 24px;
|
|
117
117
|
|
|
118
|
-
/* Density (issue #200). The one height of a control in a bar (the header, the proposal bar, the decision foot, the player, the Work
|
|
119
|
-
32px at a desk, 44px on a phone (the media query after the light blocks). The padding of a panel's body, which the Work
|
|
118
|
+
/* Density (issue #200). The one height of a control in a bar (the header, the proposal bar, the decision foot, the player, the Work list's top row):
|
|
119
|
+
32px at a desk, 44px on a phone (the media query after the light blocks). The padding of a panel's body, which the Work list and the node panel share,
|
|
120
120
|
and the least height of a panel's head: a control and a step of padding */
|
|
121
121
|
--corn-control-height: 32px;
|
|
122
122
|
--corn-panel-pad: calc(var(--corn-space-5) + var(--corn-space-1));
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/work-badge-model
|
|
3
|
+
*
|
|
4
|
+
* The pure half of the Work layer on the Map view (spec 0012 D4): a small badge (`PR #27`, `Issue #14`) on each node that open work touches. No DOM, no state, no fetch;
|
|
5
|
+
* work-badges.js draws them and work-view.js holds the answer they are made of (`state.work`, the one read of `GET /api/forge/work-graph` the Work view shares).
|
|
6
|
+
*
|
|
7
|
+
* badgeIndex(nodes, edges) node id -> the open work touching it, the most pressing first (waiting on you, then the newest)
|
|
8
|
+
* badgeText(items) "PR #27", or "PR #27 +2" when more touch the node
|
|
9
|
+
* badgeWords(items) what a screen reader hears of it: "2 open: PR #27, Issue #14"
|
|
10
|
+
* placeBadges(scene, zoom, index, opts) which badges fit at this zoom, and where: the same placing as the names under the nodes (labels.js `placeLabels`)
|
|
11
|
+
* openWorkHtml(items, opts) the node panel's "Open work" section: each item a link that opens the Work view on it (every word escaped, only http(s) links)
|
|
12
|
+
* badgeRowOf(w, wanted) the Layers menu's row: its count in words
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { escapeHtml as esc } from '../core/text.js';
|
|
16
|
+
import { labelMinOf, placeLabels } from './labels.js';
|
|
17
|
+
import { KIND_WORDS, byLane, stateWordsOf, tagOf } from './work-model.js';
|
|
18
|
+
import { safeUrl } from './pieces/work-common.js';
|
|
19
|
+
|
|
20
|
+
/** The layer's key in the Layers menu and `state.activeLayers` (the Work view's own are `work-<kind>`: work-model.js) */
|
|
21
|
+
export const WORK_BADGE_LAYER = 'work-badges';
|
|
22
|
+
/** The most badges drawn at once (the node panel still lists every item) */
|
|
23
|
+
export const MAX_BADGES = 60;
|
|
24
|
+
/** A badge's text size on screen (px), and the room its pill takes beside the text, in ems of that size */
|
|
25
|
+
export const BADGE_PX = 11;
|
|
26
|
+
const PAD_EM = 1.2;
|
|
27
|
+
/** The height of a label's box in `placeLabels`, in sizes (labels.js: an ascent of 1 and a descent of 0.3) */
|
|
28
|
+
const BOX_EM = 1.3;
|
|
29
|
+
/** What starts the label of a badge in the placing, so its width is the pill's (a character no name begins with) */
|
|
30
|
+
const MARK = '\u0001';
|
|
31
|
+
const MARK_CODE = 1;
|
|
32
|
+
/** The most items a node's spoken words name before "and N more" */
|
|
33
|
+
const SPOKEN = 3;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Which node is touched by which open work. The edges are the work view's (`state.work.edges`): from a piece of work to a node of code, by `changes`, `adds`, `mentions` or
|
|
37
|
+
* `restarts`. Only open work counts, and a proposal that is only a file in the checkout (nobody has been asked to decide it: the Work view's Drafts) does not; a planned node
|
|
38
|
+
* (a proposal's `adds`: the map does not hold it) has no badge, so it is left out here.
|
|
39
|
+
* @param {object[]} nodes the Work view's nodes (work and the code it touches)
|
|
40
|
+
* @param {{ from: string, to: string, tone: string }[]} edges
|
|
41
|
+
* @returns {Map<string, object[]>} node id -> its items (`{ id, kind, tag, title, waiting, state, url }`), most pressing first
|
|
42
|
+
*/
|
|
43
|
+
export function badgeIndex(nodes, edges) {
|
|
44
|
+
const work = new Map();
|
|
45
|
+
const code = new Set();
|
|
46
|
+
for (const n of nodes || []) {
|
|
47
|
+
if (n.work) { if (n.item && n.item.open === true && !n.draft) work.set(n.id, n); } else if (!n.planned) code.add(n.id);
|
|
48
|
+
}
|
|
49
|
+
const index = new Map();
|
|
50
|
+
for (const e of edges || []) {
|
|
51
|
+
if (e.tone !== 'code' || !code.has(e.to)) continue;
|
|
52
|
+
const from = work.get(e.from);
|
|
53
|
+
if (!from) continue;
|
|
54
|
+
const list = index.get(e.to) || index.set(e.to, []).get(e.to);
|
|
55
|
+
if (!list.some((x) => x.id === from.id)) list.push(from);
|
|
56
|
+
}
|
|
57
|
+
for (const [id, list] of index) {
|
|
58
|
+
list.sort(byLane); // waiting on you first, then the newest, then by id: the order of a lane
|
|
59
|
+
index.set(id, list.map((n) => ({ id: n.id, kind: n.work, tag: tagOf(n.item), title: n.title, waiting: n.waiting === true, state: stateWordsOf(n.item), url: safeUrl(n.item.url) })));
|
|
60
|
+
}
|
|
61
|
+
return index;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The badge's text: the most pressing item's tag, then how many more touch the node */
|
|
65
|
+
export const badgeText = (items) => `${items[0].tag}${items.length > 1 ? ` +${items.length - 1}` : ''}`;
|
|
66
|
+
|
|
67
|
+
/** What a screen reader is told of a node: "2 open: PR #27, Issue #14", the first said to wait when it does; empty for a node no open work touches */
|
|
68
|
+
export function badgeWords(items) {
|
|
69
|
+
if (!items || !items.length) return '';
|
|
70
|
+
const named = items.slice(0, SPOKEN).map((i) => `${i.tag}${i.waiting ? ' (waiting on you)' : ''}`);
|
|
71
|
+
return `${items.length} open: ${named.join(', ')}${items.length > SPOKEN ? ` and ${items.length - SPOKEN} more` : ''}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Which badges fit at `zoom`, and where, by the rules the names under the nodes follow (labels.js `placeLabels`): the whole map's placing, kept for as long as the scene and the zoom stay,
|
|
76
|
+
* the same wherever the camera is. The names are placed first and are never moved by a badge (they are the first thing `placeLabels` places here, as the selection's would be); a badge
|
|
77
|
+
* is then placed in priority order, the selected node's first, then those that wait on you, then the rest (the larger the node, the more lines it has, the nearer the front), and
|
|
78
|
+
* is skipped when its box (plus `LABEL_PAD`) touches a name or a badge already placed. A badge sits above its node's disc, centred on it, at its own size on screen whatever the zoom.
|
|
79
|
+
* @param {import('./scene.js').Scene} scene
|
|
80
|
+
* @param {number} zoom
|
|
81
|
+
* @param {Map<string, object[]>} index `badgeIndex`
|
|
82
|
+
* @param {{ measure?: (text: string, size: number, bold: boolean) => number, measurePill?: (text: string, size: number, bold: boolean) => number, height?: number, max?: number }} [opts]
|
|
83
|
+
* `measure`: the width of a name, in the label layer's font (as `placeLabels` takes it); `measurePill`: the width of a badge's text, in the page's font (default: `measure`);
|
|
84
|
+
* `height`: the pill's height on screen, its line and its border (px; default, and at least, the height of a name's box at the badge's size)
|
|
85
|
+
* @returns {{ id: string, items: object[], text: string, l: number, t: number, r: number, b: number }[]} in priority order, boxes in zoom-scaled world coordinates (no camera)
|
|
86
|
+
*/
|
|
87
|
+
export function placeBadges(scene, zoom, index, { measure = null, measurePill = measure, height = 0, max = MAX_BADGES } = {}) {
|
|
88
|
+
const min = labelMinOf(scene);
|
|
89
|
+
const px = Math.max(BADGE_PX, min);
|
|
90
|
+
// placeLabels gives a label a box 1.3 sizes high; a pill is as high as its line and its border, so it is placed as a label of the size whose box is that high, and its width is scaled back
|
|
91
|
+
const box = Math.max(BOX_EM * px, height || 0);
|
|
92
|
+
const boxPx = box / BOX_EM;
|
|
93
|
+
const gap = Math.max(3, 3 * zoom);
|
|
94
|
+
const mine = [];
|
|
95
|
+
for (const n of scene.nodes) {
|
|
96
|
+
const items = index.get(n.id);
|
|
97
|
+
if (!items || !items.length || !(n.alpha > 0.2)) continue;
|
|
98
|
+
const text = badgeText(items);
|
|
99
|
+
// placeLabels puts a label under a disc: a box whose top is `gap` below `y + r`. The badge goes above the disc instead, so the node it is placed for sits higher by the box, the gap before and the gap after
|
|
100
|
+
mine.push({
|
|
101
|
+
id: n.id, type: 'work-badge', label: `${MARK}${text}`, labelAlpha: 1, labelSize: boxPx / zoom, labelBold: true, x: n.x, y: n.y - n.r - (2 * gap + box) / zoom, r: 0, degree: n.degree || 0,
|
|
102
|
+
selected: false, current: n.selected === true || n.current === true, match: items[0].waiting, connected: true, mark: 'none', items, text,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (!mine.length) return [];
|
|
106
|
+
// The names, placed as the label layer places them, stand in the way as if they were selected: first of all, so a badge never takes one's room
|
|
107
|
+
const names = placeLabels(scene, zoom, { measure }).map((p) => ({ ...p.node, selected: true }));
|
|
108
|
+
// one measure for the placing: a badge's label starts with MARK, and is the pill's text in the page's font and its room; every other label is a name, in the label layer's font
|
|
109
|
+
const both = measure && measurePill ? (text, size, bold) => (text.charCodeAt(0) === MARK_CODE ? ((measurePill(text.slice(1), size, bold) + size * PAD_EM) * px) / boxPx : measure(text, size, bold)) : null;
|
|
110
|
+
const placed = placeLabels({ nodes: [...names, ...mine], labelMin: scene.labelMin }, zoom, { measure: both });
|
|
111
|
+
const out = [];
|
|
112
|
+
for (const p of placed) {
|
|
113
|
+
if (p.node.type !== 'work-badge') continue;
|
|
114
|
+
out.push({ id: p.id, items: p.node.items, text: p.node.text, l: p.l, t: p.t, r: p.r, b: p.b });
|
|
115
|
+
if (out.length >= max) break;
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// The node panel's "Open work"
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
const dotOf = (kind, color) => { const c = typeof color === 'function' ? color(kind) : ''; return `<span class="hx-work-dot" data-corn="swatch" data-work-kind="${esc(kind)}" aria-hidden="true"${c ? ` data-style="background-color: ${esc(c)}"` : ''}></span>`; };
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The node panel's section for a node the layer badges: each piece of open work as a link that opens the Work view with it selected (`?view=work&pr=27`: the address is the link's
|
|
128
|
+
* `href`, so a new tab goes there too, and a click opens the view in place), and, for the forge's own page, a second link that is there only when the address is an http(s) one.
|
|
129
|
+
* Every word is the forge's: escaped, and the `url` goes through `safeUrl`.
|
|
130
|
+
* @param {object[]} items `badgeIndex`'s items for the node
|
|
131
|
+
* @param {{ color?: (kind: string) => string, address?: (id: string) => string | null }} [opts] `color`: a kind's colour as the map draws it; `address`: the item's `?pr=27`-style address (work-model.js `addressOf`)
|
|
132
|
+
*/
|
|
133
|
+
export function openWorkHtml(items, { color = () => '', address = () => null } = {}) {
|
|
134
|
+
const rows = items.map((i) => {
|
|
135
|
+
const addr = address(i.id);
|
|
136
|
+
const href = `?view=work${addr ? `&${addr.slice(1)}` : ''}`;
|
|
137
|
+
const out = i.url ? ` <a class="hx-faint" data-corn="open-link" href="${esc(i.url)}" target="_blank" rel="noreferrer" aria-label="Open ${esc(i.tag)} on the forge">↗</a>` : '';
|
|
138
|
+
return `<li data-corn="work-link"><span class="hx-work-rel">${esc(KIND_WORDS[i.kind] || i.kind)}</span>${dotOf(i.kind, color)}<a class="hx-linkbtn" data-corn="node-link" data-work-action="open-item" data-id="${esc(i.id)}" href="${esc(href)}">${esc(i.tag)} · ${esc(i.title)}</a>${i.waiting ? ' <span class="hx-faint">waiting on you</span>' : ` <span class="hx-faint">${esc(i.state)}</span>`}${out}</li>`;
|
|
139
|
+
});
|
|
140
|
+
return `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">Open work</div><div class="hx-fact-v"><ul class="hx-work-links" data-corn="work-links">${rows.join('')}</ul></div></div>`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
// The Layers menu's row
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The row the Layers menu shows under Overlays: its count says how many nodes open work touches, or where the answer is: "reading…" while the first read is on its way, "not read yet"
|
|
149
|
+
* until the layer is first on (or the Work view opened), and the refusal when the forge could not be read.
|
|
150
|
+
* @param {{ status: string, badges?: Map<string, object[]> }} w the Work view's state (`state.work`)
|
|
151
|
+
* @param {string} color the row's dot
|
|
152
|
+
*/
|
|
153
|
+
export function badgeRowOf(w, color) {
|
|
154
|
+
const n = w.badges ? w.badges.size : 0;
|
|
155
|
+
const countText = w.status === 'ok' ? `${n} ${n === 1 ? 'node' : 'nodes'}`
|
|
156
|
+
: w.status === 'loading' ? 'reading…'
|
|
157
|
+
: w.status === 'sign-in' ? 'sign in again'
|
|
158
|
+
: w.status === 'offline' ? 'offline'
|
|
159
|
+
: w.status === 'server' ? 'not read' : 'not read yet';
|
|
160
|
+
return { key: WORK_BADGE_LAYER, label: 'Work', color, overlay: true, countText, desc: 'A small badge on each node that open work touches: PR #27, Issue #14, Run 000003, Spec 0100. The one that waits on you comes first, then +N. The same read as the Work view.' };
|
|
161
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/work-badges
|
|
3
|
+
*
|
|
4
|
+
* The Work layer's badges on the Map view (spec 0012 D4), drawn: one small pill over each node open work touches (`PR #27`, `Issue #14 +1`), in screen space, so it reads at any zoom, in the
|
|
5
|
+
* colour of its most pressing item's kind (`--corn-work-<kind>`). A DOM layer over the map like the runs' marks (runs-map.js, which is left as it is), decoration for the eye (`aria-hidden`): what a
|
|
6
|
+
* screen reader gets is the words the keyboard says on landing on a badged node ("2 open: PR #27, Issue #14") and the node panel's "Open work" section. Which badges fit, and where, is
|
|
7
|
+
* work-badge-model.js's (`placeBadges`: the names' own placing); this only holds the elements and moves them with the camera.
|
|
8
|
+
*
|
|
9
|
+
* createWorkBadges({ stage, doc, state, style, colorOf, fontOf }) -> { sync(scene, camera), clear(), destroy() }
|
|
10
|
+
*
|
|
11
|
+
* `sync` is the map's paint hook: it is cheap when nothing moved (a packet frame), and does nothing while the layer is off (no element is made until the first badge).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BADGE_PX, MAX_BADGES, placeBadges } from './work-badge-model.js';
|
|
15
|
+
import { labelMinOf } from './labels.js';
|
|
16
|
+
import { styledScene } from './engine/map-style.js';
|
|
17
|
+
import { FONT_NODE } from './scene.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {{ stage: HTMLElement, state: object, style: () => object, colorOf: (kind: string) => string, wanted: () => Map<string, object[]> | null, doc?: Document }} deps
|
|
21
|
+
* `wanted`: the index to draw (`badgeIndex`), or null while the layer is off, the view is not the map, the answer is not here
|
|
22
|
+
*/
|
|
23
|
+
export function createWorkBadges({ stage, state, style, colorOf, wanted, doc = document }) {
|
|
24
|
+
let layer = null;
|
|
25
|
+
/** @type {Map<string, HTMLElement>} the pills by node id */
|
|
26
|
+
const pills = new Map();
|
|
27
|
+
let placed = null; // the placing for the scene, zoom, index and style it was made for: a pan only moves the pills
|
|
28
|
+
let placedKey = '';
|
|
29
|
+
let drawnKey = '';
|
|
30
|
+
const widths = new Map();
|
|
31
|
+
let ctx = null;
|
|
32
|
+
|
|
33
|
+
/** The width of a text in a font (a canvas measures it once per string): a name's, in the label layer's font, and the pill's text in the page's own, so the placing leaves the room each takes */
|
|
34
|
+
function measurer(family, weight) {
|
|
35
|
+
if (ctx === null) { try { ctx = doc.createElement('canvas').getContext('2d') || false; } catch { ctx = false; } }
|
|
36
|
+
if (!ctx) return null;
|
|
37
|
+
return (text, size, bold) => {
|
|
38
|
+
const key = `${bold ? 'b' : 'n'}${size}|${family}|${text}`;
|
|
39
|
+
let w = widths.get(key);
|
|
40
|
+
if (w === undefined) {
|
|
41
|
+
if (widths.size > 4000) widths.clear();
|
|
42
|
+
ctx.font = `${bold ? `${weight} ` : ''}${size}px ${family}`;
|
|
43
|
+
w = ctx.measureText(text).width;
|
|
44
|
+
widths.set(key, w);
|
|
45
|
+
}
|
|
46
|
+
return w;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let tall = { key: '', h: 0 };
|
|
51
|
+
/** How high a pill is on screen (its line and its border, the heavier one of a pill that waits): measured once for a size and a look, in the layer, so the placing keeps its room */
|
|
52
|
+
function pillHeight(px, key) {
|
|
53
|
+
if (tall.key === key) return tall.h;
|
|
54
|
+
const probe = doc.createElement('span');
|
|
55
|
+
probe.className = 'hx-work-badge is-waiting';
|
|
56
|
+
probe.style.fontSize = `${px}px`;
|
|
57
|
+
probe.style.visibility = 'hidden';
|
|
58
|
+
probe.textContent = 'Spec 0100';
|
|
59
|
+
const host = ensureLayer();
|
|
60
|
+
host.hidden = false; // (it is drawn into next)
|
|
61
|
+
host.append(probe);
|
|
62
|
+
tall = { key, h: probe.offsetHeight || 0 };
|
|
63
|
+
probe.remove();
|
|
64
|
+
return tall.h;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ensureLayer = () => {
|
|
68
|
+
if (layer && layer.isConnected) return layer;
|
|
69
|
+
layer = doc.createElement('div');
|
|
70
|
+
layer.className = 'hx-work-badges';
|
|
71
|
+
layer.dataset.corn = 'work-badges';
|
|
72
|
+
layer.setAttribute('part', 'work-badges');
|
|
73
|
+
layer.setAttribute('aria-hidden', 'true');
|
|
74
|
+
stage.append(layer);
|
|
75
|
+
pills.clear();
|
|
76
|
+
return layer;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function clear() {
|
|
80
|
+
for (const el of pills.values()) el.remove();
|
|
81
|
+
pills.clear();
|
|
82
|
+
if (layer) layer.hidden = true;
|
|
83
|
+
placed = null;
|
|
84
|
+
placedKey = '';
|
|
85
|
+
drawnKey = '';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Puts the badges on the nodes the scene drew, at the camera.
|
|
90
|
+
* @param {import('./scene.js').Scene} scene
|
|
91
|
+
* @param {{ x: number, y: number, zoom: number }} camera
|
|
92
|
+
*/
|
|
93
|
+
function sync(scene, camera) {
|
|
94
|
+
const index = wanted();
|
|
95
|
+
if (!index || !index.size) { if (layer && !layer.hidden) clear(); return; }
|
|
96
|
+
const look = style();
|
|
97
|
+
const key = `${scene.version}|${camera.zoom}|${look.plain ? 0 : look.version}|${state.theme}|${state.width}x${state.height}`;
|
|
98
|
+
const sameScene = placed && placed.scene === scene && placed.index === index && placedKey === key;
|
|
99
|
+
if (!sameScene) {
|
|
100
|
+
const styled = styledScene(scene, look);
|
|
101
|
+
const family = (typeof getComputedStyle === 'function' && stage.isConnected ? getComputedStyle(stage).fontFamily : '') || 'sans-serif'; // the pill is set in the page's font
|
|
102
|
+
const px = Math.max(BADGE_PX, labelMinOf(scene));
|
|
103
|
+
const height = pillHeight(px, `${px}|${look.plain ? 0 : look.version}|${state.theme}`);
|
|
104
|
+
placed = { scene, index, list: placeBadges(styled, camera.zoom, index, { measure: measurer(styled.labelFont || FONT_NODE, 'bold'), measurePill: measurer(family, '600'), height, max: MAX_BADGES }) };
|
|
105
|
+
placedKey = key;
|
|
106
|
+
drawnKey = '';
|
|
107
|
+
}
|
|
108
|
+
const at = `${camera.x}|${camera.y}`;
|
|
109
|
+
if (drawnKey === `${placedKey}|${at}`) return;
|
|
110
|
+
drawnKey = `${placedKey}|${at}`;
|
|
111
|
+
const host = ensureLayer();
|
|
112
|
+
host.hidden = false;
|
|
113
|
+
const seen = new Set();
|
|
114
|
+
for (const p of placed.list) {
|
|
115
|
+
const left = camera.x + (p.l + p.r) / 2;
|
|
116
|
+
const top = camera.y + p.t;
|
|
117
|
+
if (camera.x + p.r < 0 || camera.x + p.l > state.width || camera.y + p.b < 0 || camera.y + p.t > state.height) continue; // off the screen: no pill (one partly in is cut by the layer's edge, as a name is)
|
|
118
|
+
seen.add(p.id);
|
|
119
|
+
let el = pills.get(p.id);
|
|
120
|
+
const first = p.items[0];
|
|
121
|
+
const text = p.text;
|
|
122
|
+
if (!el) {
|
|
123
|
+
el = doc.createElement('span');
|
|
124
|
+
el.className = 'hx-work-badge';
|
|
125
|
+
el.dataset.corn = 'work-badge';
|
|
126
|
+
el.setAttribute('part', 'work-badge');
|
|
127
|
+
el.dataset.node = p.id;
|
|
128
|
+
host.append(el);
|
|
129
|
+
pills.set(p.id, el);
|
|
130
|
+
}
|
|
131
|
+
if (el.textContent !== text) el.textContent = text; // the forge's words go in as text, never as markup
|
|
132
|
+
if (el.dataset.workKind !== first.kind) el.dataset.workKind = first.kind;
|
|
133
|
+
el.classList.toggle('is-waiting', first.waiting === true);
|
|
134
|
+
el.style.setProperty('--hx-badge', colorOf(first.kind));
|
|
135
|
+
el.style.fontSize = `${Math.max(BADGE_PX, labelMinOf(scene))}px`;
|
|
136
|
+
el.style.left = `${left.toFixed(1)}px`;
|
|
137
|
+
el.style.top = `${top.toFixed(1)}px`;
|
|
138
|
+
}
|
|
139
|
+
for (const [id, el] of pills) if (!seen.has(id)) { el.remove(); pills.delete(id); }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return { sync, clear, destroy() { clear(); if (layer) layer.remove(); layer = null; } };
|
|
143
|
+
}
|
package/explorer/work-model.js
CHANGED
|
@@ -306,8 +306,9 @@ const cut = (n, cap) => { const cols = Math.max(1, Math.ceil(n / cap)); return {
|
|
|
306
306
|
|
|
307
307
|
function layoutDesk(stages, drafts, code, v, p) {
|
|
308
308
|
const c = DESK;
|
|
309
|
-
// Left to right: Talk, Decide, the drafts (when they are shown)
|
|
310
|
-
|
|
309
|
+
// Left to right: Talk, Decide, Build, Ship, then the code. The drafts (when they are shown) are not a lane of this row: their own band under it, as wide as the row, so that they never
|
|
310
|
+
// widen what the first fit has to show and take the names' room from the lanes of work (turning them on left 1 of 9 Talk names placed): the fit is the row's, and the band is panned to
|
|
311
|
+
const lanes = [stages[0], stages[1], stages[2], stages[3], ...(code.length ? [{ key: 'code', title: CODE_LANE_TITLE, nodes: code, code: true }] : [])];
|
|
311
312
|
const plan = (z, cap) => {
|
|
312
313
|
const room = TITLE_PX / z;
|
|
313
314
|
const below = NAME_PX / z;
|
|
@@ -350,7 +351,24 @@ function layoutDesk(stages, drafts, code, v, p) {
|
|
|
350
351
|
});
|
|
351
352
|
out.push(lane(l.key, l.title, l.nodes.length, part.x, 0, part.w, g.h));
|
|
352
353
|
}
|
|
353
|
-
|
|
354
|
+
const order = g.parts.flatMap((part) => part.l.nodes.map((n) => n.id));
|
|
355
|
+
let bottom = g.h;
|
|
356
|
+
if (drafts.length) {
|
|
357
|
+
// the band: columns of the lanes' own cell, as many as the row is wide, staggered as the lanes' are; it starts a gap under the row
|
|
358
|
+
const top = g.h + c.gap;
|
|
359
|
+
const room = TITLE_PX / z;
|
|
360
|
+
const cols = Math.max(1, Math.floor((g.w - 2 * c.pad) / c.cell));
|
|
361
|
+
const rows = Math.ceil(drafts.length / cols);
|
|
362
|
+
drafts.forEach((n, j) => {
|
|
363
|
+
const col = j % cols;
|
|
364
|
+
n.x = c.pad + (col + 0.5) * c.cell + (g.w - 2 * c.pad - cols * c.cell) / 2;
|
|
365
|
+
n.y = top + room + 20 + (Math.floor(j / cols) + (col % 2) * 0.5) * c.row;
|
|
366
|
+
});
|
|
367
|
+
bottom = top + room + 40 + (rows - 0.5) * c.row + NAME_PX / z + 8;
|
|
368
|
+
out.push(lane('drafts', DRAFT_LANE_TITLE, drafts.length, 0, top, g.w, bottom - top));
|
|
369
|
+
order.push(...drafts.map((n) => n.id));
|
|
370
|
+
}
|
|
371
|
+
return { lanes: out, order, bounds: { x: 0, y: 0, w: g.w, h: bottom }, fit: fitBoxOf(g.w, g.h, z, c.margin, p, v) };
|
|
354
372
|
}
|
|
355
373
|
|
|
356
374
|
function layoutPhone(stages, drafts, code, v, p) {
|
|
@@ -657,7 +675,7 @@ export function openedWords({ work, code, waiting }) {
|
|
|
657
675
|
// ---------------------------------------------------------------------------
|
|
658
676
|
|
|
659
677
|
/** What the Work view keeps on the state (`state.work`): the answer, the scene made of it, the layers, the toggle, and the map it stands in for while it is open */
|
|
660
|
-
export const newWorkState = () => ({ status: 'idle', graph: null, nodes: [], edges: [], lanes: [], counts: { work: 0, code: 0, waiting: 0 }, problems: [], layers: startLayers(), waiting: false, saved: null, bounds: null, fit: null, order: [], updating: false, stale: '', lastError: '' });
|
|
678
|
+
export const newWorkState = () => ({ status: 'idle', graph: null, nodes: [], edges: [], lanes: [], counts: { work: 0, code: 0, waiting: 0 }, problems: [], badges: new Map(), layers: startLayers(), waiting: false, saved: null, bounds: null, fit: null, order: [], updating: false, stale: '', lastError: '' });
|
|
661
679
|
|
|
662
680
|
/** Makes the scene of an answer (`workScene`), keeps the node a selection named, and sets the filters; the layout is `applyWorkLayout`'s */
|
|
663
681
|
export function setWorkGraph(state, graph, mapNodes) {
|
package/explorer/work-view.css
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
.hx-view-badge { margin-left: var(--corn-space-2); }
|
|
12
12
|
.hx-work-links { list-style: none; margin: 0; padding: 0; }
|
|
13
13
|
.hx-work-links li { display: flex; align-items: center; gap: var(--corn-space-2); min-height: 2.25rem; border-bottom: var(--corn-border) solid var(--corn-line); }
|
|
14
|
+
.hx-work-links, .hx-work-links li { min-width: 0; max-width: 100%; }
|
|
15
|
+
.hx-work-links li > a, .hx-work-links li > button { min-width: 0; overflow-wrap: anywhere; text-align: left; } /* a title with no spaces breaks anywhere rather than run past the panel */
|
|
14
16
|
.hx-work-rel { flex: none; width: 6.5rem; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
|
|
15
17
|
.hx-work-dot { flex: none; width: 0.6rem; height: 0.6rem; border-radius: var(--corn-radius-sm); background: var(--corn-text-3); }
|
|
16
18
|
.hx-work-head, .hx-work-actions { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-3) 0; }
|
|
@@ -48,3 +50,11 @@
|
|
|
48
50
|
}
|
|
49
51
|
/* The Layers menu in the Work view lists the Work view's rows; the map's keys (its kinds of line, the cloud's, the runs' and the proposal marks') are about the map */
|
|
50
52
|
body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn="menu-section"]) { display: none; }
|
|
53
|
+
/* The Work layer on the Map view (explorer/work-badges.js, spec 0012 D4): a small pill over each node open work touches, in screen space so it reads at any zoom. The kind's colour is the border (`--hx-badge`, set from
|
|
54
|
+
`--corn-work-<kind>`), the words are the page's own text on its own surface, so the pill reads on any theme and the kind is said in words (`PR #27`), never by colour alone.
|
|
55
|
+
Its line is as high as the font's own box (a "p" or a "y" is not cut), and the placing keeps the room the pill takes (work-badges.js measures it). Decoration for the eye (aria-hidden):
|
|
56
|
+
the keyboard's words and the node panel's "Open work" say the rest. The runs' pulse (runs-map.js) is a layer of its own and is not changed. */
|
|
57
|
+
.hx-work-badges { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
|
|
58
|
+
.hx-work-badges[hidden] { display: none; }
|
|
59
|
+
.hx-work-badge { position: absolute; box-sizing: border-box; display: inline-block; max-width: 14rem; padding: 0 var(--corn-space-1); border: var(--corn-border-strong) solid var(--hx-badge, var(--corn-line)); border-radius: var(--corn-radius-pill); background: color-mix(in srgb, var(--corn-surface-1) 92%, transparent); color: var(--corn-text); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform: translateX(-50%); }
|
|
60
|
+
.hx-work-badge.is-waiting { border-width: calc(var(--corn-border-strong) + var(--corn-border)); }
|