cornfield 0.47.0 → 0.49.0

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.
Files changed (65) hide show
  1. package/core/contrast.js +6 -6
  2. package/core/strings.js +14 -0
  3. package/explorer/check.js +7 -227
  4. package/explorer/connection.js +3 -3
  5. package/explorer/css/account.css +46 -0
  6. package/explorer/css/base.css +159 -0
  7. package/explorer/css/changes.css +160 -0
  8. package/explorer/css/decision.css +68 -0
  9. package/explorer/css/dialogs.css +50 -0
  10. package/explorer/css/header.css +75 -0
  11. package/explorer/css/layers.css +92 -0
  12. package/explorer/css/live.css +48 -0
  13. package/explorer/css/map.css +43 -0
  14. package/explorer/css/node-panel.css +188 -0
  15. package/explorer/css/page.css +83 -0
  16. package/explorer/css/proposal.css +151 -0
  17. package/explorer/css/search.css +84 -0
  18. package/explorer/css/sheets.css +134 -0
  19. package/explorer/css/whatif.css +55 -0
  20. package/explorer/css/work.css +288 -0
  21. package/explorer/engine/checks.js +252 -0
  22. package/explorer/engine/connection.js +36 -0
  23. package/explorer/engine/layers.js +1 -0
  24. package/explorer/engine/map-style.js +2 -2
  25. package/explorer/engine/player.js +489 -0
  26. package/explorer/engine/proposal.js +373 -0
  27. package/explorer/engine/render.js +1 -0
  28. package/explorer/engine/source.js +315 -0
  29. package/explorer/engine/theme-sheet.js +444 -0
  30. package/explorer/focus-room.js +1 -1
  31. package/explorer/header-fit.js +3 -3
  32. package/explorer/house.css +1 -1
  33. package/explorer/index.html +23 -61
  34. package/explorer/instance.js +82 -6
  35. package/explorer/page-address.js +59 -0
  36. package/explorer/page-pieces.js +33 -5
  37. package/explorer/page.js +20 -20
  38. package/explorer/panels.js +1 -3
  39. package/explorer/pieces/changes.js +502 -0
  40. package/explorer/pieces/decision.js +657 -0
  41. package/explorer/pieces/layers.js +4 -0
  42. package/explorer/pieces/map-stage.css +1 -1
  43. package/explorer/pieces/map.js +113 -2
  44. package/explorer/pieces/node-panel.js +34 -1
  45. package/explorer/pieces/proposal.js +488 -0
  46. package/explorer/pieces/scope-link.js +50 -0
  47. package/explorer/pieces/scope.js +247 -0
  48. package/explorer/pieces/status.css +24 -0
  49. package/explorer/pieces/status.js +144 -0
  50. package/explorer/plugins.js +0 -10
  51. package/explorer/proposal.js +64 -697
  52. package/explorer/review-column.js +24 -439
  53. package/explorer/review.js +27 -673
  54. package/explorer/scenario-ui.js +32 -478
  55. package/explorer/sheets.js +8 -7
  56. package/explorer/theme-model.js +1 -1
  57. package/explorer/theme.js +1 -1
  58. package/explorer/tokens.css +2 -2
  59. package/explorer/view.js +6 -5
  60. package/explorer/waiting-line.js +7 -50
  61. package/package.json +1 -1
  62. package/server/components.js +144 -0
  63. package/server/embed.js +3 -1
  64. package/server/server.js +9 -1
  65. package/explorer/explorer.css +0 -1512
package/core/contrast.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * resolveProps(sheets, state) the custom properties in force for a page: `{ mode, system?, name? }` over `[css, …]` in load order
8
8
  * expand(value, props) a value with its var()s replaced, or { problem } naming the property and why (capped: never a hang)
9
9
  * resolveColor(props, name | value) a token (or a value) as [r, g, b, a], or { problem } when it cannot be worked out
10
- * contrastPairs() every pair explorer.css paints, text at 4.5:1 and the state-bearing UI at 3:1
10
+ * contrastPairs() every pair the explorer's stylesheets paint, text at 4.5:1 and the state-bearing UI at 3:1
11
11
  * contrastProblems(themes) every pair below WCAG AA, for light and dark, on either system setting, over the ground and its image
12
12
  * themesToCheck(config) what a repo's check reads: tokens.css, then `theme.css`, then each `theme.names` file
13
13
  * checkThemeContrast(config) the check for `cornfield validate`, always run (cornfield's own tokens when there is no theme)
@@ -344,9 +344,9 @@ export function resolveColor(props, nameOrValue) {
344
344
 
345
345
  const SURFACES = ['--corn-surface-1', '--corn-surface-2', '--corn-surface-3'];
346
346
  const GROUND = '--corn-ground';
347
- /** A tint as explorer.css writes it: the token at a share over what is beneath */
347
+ /** A tint as the explorer's stylesheets write it: the token at a share over what is beneath */
348
348
  const tint = (token, pct) => `color-mix(in srgb, var(${token}) ${pct}%, transparent)`;
349
- /** A hue pulled toward the text colour, as explorer.css writes it for a hue that must read as text */
349
+ /** A hue pulled toward the text colour, as they write it for a hue that must read as text */
350
350
  const toText = (token, pct) => `color-mix(in srgb, var(${token}) ${pct}%, var(--corn-text))`;
351
351
 
352
352
  /** Text tokens: read on the ground and on every surface */
@@ -361,8 +361,8 @@ export const SOFT_PAIRS = Object.freeze([
361
361
  /** Solid fills that carry `--corn-ground` as their text (a pressed data-flow button, a chip, the What-if toggle, the House chip) */
362
362
  export const SOLID_FILLS = Object.freeze(['--corn-ok', '--corn-warn', '--corn-bad', '--corn-info', '--corn-hue-orange', '--corn-hue-lime', '--corn-added-text', '--corn-edit-text']);
363
363
  /**
364
- * Text that explorer.css paints on something other than a token surface: a category hue as text, or text on a tint it mixes itself.
365
- * `[fg, bg, where]`, each the value explorer.css writes (test/core/contrast.test.js holds this list to explorer.css).
364
+ * Text that the explorer's stylesheets paint on something other than a token surface: a category hue as text, or text on a tint it mixes itself.
365
+ * `[fg, bg, where]`, each the value they write (test/core/contrast.test.js holds this list to explorer/css/).
366
366
  */
367
367
  export const PAINTED_TEXT = Object.freeze([
368
368
  ['--corn-hue-fuchsia', GROUND, 'ROM, a milestone, a link button'], ['--corn-hue-fuchsia', '--corn-surface-1', ''], ['--corn-hue-fuchsia', '--corn-surface-2', ''],
@@ -405,7 +405,7 @@ export const UI_PAIRS = Object.freeze([
405
405
  ...['--corn-ok', '--corn-edit-text', '--corn-bad', '--corn-warn', '--corn-text-3'].flatMap((fg) => ['--corn-surface-2', '--corn-surface-3'].map((bg) => [fg, bg, 'a state pill\'s border'])),
406
406
  ]);
407
407
 
408
- /** The dots that name a diff mark in the bar, the change list and the legend (explorer.css `.hx-mark-dot--*`), each a ring on the ground */
408
+ /** The dots that name a diff mark in the bar, the change list and the legend (explorer/css/base.css `.hx-mark-dot--*`), each a ring on the ground */
409
409
  const DIFF_DOT_PAIRS = Object.freeze(['added', 'changed', 'removed', 'edit'].map((m) => [`--corn-${m}`, GROUND, `the ${m} mark's dot`]));
410
410
 
411
411
  /**
package/core/strings.js CHANGED
@@ -104,6 +104,20 @@ export const STRINGS = Object.freeze({
104
104
  loading: 'Loading topology.json …',
105
105
  errorTitle: 'The map could not be loaded',
106
106
  retry: 'Retry',
107
+ // A map that loads from a cornfield server (a scope, or a map with a src) while it loads and when it cannot
108
+ sourceLoading: 'Loading the map …',
109
+ sourceSignedOut: 'You are not signed in to cornfield',
110
+ sourceSignInText: "This map is behind cornfield's sign-in.",
111
+ sourceNotMaintainer: "This map is for the project's maintainers",
112
+ sourceNotMaintainerText: 'You are signed in to cornfield, but not as a maintainer.',
113
+ sourceSignIn: 'Sign in to cornfield',
114
+ sourceNotListed: 'This page is not listed by that cornfield',
115
+ sourceNotListedHint: 'Add this origin to embed.origins on the server:',
116
+ sourceOffline: 'The map cannot be reached',
117
+ sourceOfflineText: 'Check the connection, then try again.',
118
+ sourceBadAddress: 'That is not the address of a cornfield server',
119
+ sourceVersion: 'This map and its server are different versions',
120
+ sourceSecondMap: 'This scope already has a map',
107
121
  });
108
122
 
109
123
  /** The longest a value may be, in characters */
package/explorer/check.js CHANGED
@@ -1,233 +1,13 @@
1
1
  /**
2
2
  * @module explorer/check
3
3
  *
4
- * Checked scenarios in the page (spec 0029 sections 3 and 5, PHY-10; the pure half is
5
- * check-model.js). When a scenario opens, every check of every step goes to the checker (a plugin's
6
- * adapter, handed over by main.js) in ONE batch; each step then shows its state on the player bar,
7
- * and on the phone's sheet: a pill in the bar's head ("✕ Refused", seen on the peek too) and a line
8
- * under the step's text ("Refused: Only an adult can change the household's rooms (ADULT_ONLY_WRITES)").
9
- * The current step's node or edge is drawn red, green or amber (scene.js calls `paintVerdict` with the
10
- * verdict this module puts on the player's snapshot). The **As** menu (the personas on the map, what-if
11
- * ones too) acts every step as one persona and asks again; **Check again** asks again as it is.
12
- *
13
- * scenario-ui.js calls it at four points, and nothing else needs to:
14
- *
15
- * openChecks(scenario, onChange) a scenario opened: ask its batch
16
- * decorateSnapshot(snap, scenario) every sync: puts `verdict` (and the As actor) on the snapshot;
17
- * asks again when what is asked changed (a what-if edit, the As menu)
18
- * paintChecks(bar, snap) every bar update (the controls go on the bar at its first paint)
19
- * closeChecks() the scenario closed: cancel what is in flight
20
- *
21
- * A scenario that names an actor turns the People layer on, so its personas are on the map.
22
- * Nothing is stored: the answers live in memory for the scenario on the map, and go with it.
4
+ * A bridge (spec 0011 D2 and D3, step 5): the checked scenarios are now the instance's (engine/checks.js), part of the changes piece
5
+ * (pieces/changes.js), and the checker is the piece's option. This file keeps the old names for page.js and tests, bound to the page's instance.
23
6
  */
24
7
 
25
- import { state, escHtml } from './state.js';
26
- import { setLayer } from './layers.js';
27
- import { layersOf } from './layer-model.js';
28
- import { mapIndex, personaLabel, planChecks, runChecks, stepVerdict, verdictWords } from './check-model.js';
29
- import { cornState } from './corn-state.js';
30
-
31
- let checker = null;
32
- let current = null; // { scenario, as, nodes, plan, answer, controller, onChange }
33
- let version = 0;
34
-
35
- /** Hands the tool its checker (main.js, from the plugin); none means every checked step reads "Not checked" */
36
- export function initChecks(opts = {}) {
37
- const next = opts.checker || null;
38
- if (next !== checker) closeChecks(); // answers asked of another checker are not this one's
39
- checker = next;
40
- }
41
-
42
- /** Changes whenever a verdict may have: scenario-ui.js puts it in the player's signature, so an answer redraws the step */
43
- export const checksVersion = () => version;
44
-
45
- const namesActor = (scenario) => !!scenario && (!!scenario.actor || (Array.isArray(scenario.steps) && scenario.steps.some((s) => s && s.actor)));
46
-
47
- /**
48
- * A scenario opened: its batch is asked.
49
- * @param {object} scenario
50
- * @param {() => void} onChange called when an answer arrives or the As menu moved (scenario-ui.js syncs and redraws)
51
- */
52
- export function openChecks(scenario, onChange = () => {}) {
53
- // the scenario that is already being checked (opened in the list, now played): its answers stay, only who is told changes
54
- if (current && current.scenario && scenario && current.scenario.id === scenario.id) { current.onChange = onChange; replan(scenario); return; }
55
- closeChecks();
56
- current = { scenario: null, as: null, nodes: null, plan: null, answer: { status: 'idle' }, controller: null, onChange };
57
- if (namesActor(scenario) && layersOf(state).persona !== true) setLayer('persona', true, { scenario: true });
58
- replan(scenario);
59
- }
60
-
61
- /** The id of the scenario being checked (a player's or the list's), or null */
62
- export const checkedScenarioId = () => (current && current.scenario ? current.scenario.id : null);
63
-
64
- /** The scenario closed: nothing more is asked or shown */
65
- export function closeChecks() {
66
- if (current && current.controller) current.controller.abort();
67
- current = null;
68
- version++;
69
- }
70
-
71
- /** Plans the checks again when the scenario, the As persona or the map changed, and asks again when what is asked changed */
72
- function replan(scenario, force = false) {
73
- const c = current;
74
- if (!c) return;
75
- if (!force && c.scenario === scenario && c.nodes === state.nodes && c.plan) return;
76
- const before = c.plan ? c.plan.key : null;
77
- c.scenario = scenario;
78
- c.nodes = state.nodes;
79
- c.plan = planChecks(scenario, mapIndex(state.nodes, state.edges), checker, { as: c.as });
80
- version++;
81
- if (force || c.plan.key !== before) ask();
82
- }
83
-
84
- /** Asks the scenario's one batch; an answer that arrives for a batch no longer on the map is dropped */
85
- function ask() {
86
- const c = current;
87
- if (!c) return;
88
- if (c.controller) c.controller.abort();
89
- const items = c.plan.items;
90
- if (items.length === 0) { c.answer = { status: 'ok', results: new Map(), bad: new Map() }; version++; return; }
91
- const controller = new AbortController();
92
- c.controller = controller;
93
- c.answer = { status: 'pending' };
94
- version++;
95
- runChecks(checker, items, { signal: controller.signal }).then(
96
- ({ results, bad }) => settle(c, controller, { status: 'ok', results, bad }),
97
- (error) => { if (!controller.signal.aborted) settle(c, controller, { status: 'failed', error }); },
98
- );
99
- }
100
-
101
- function settle(c, controller, answer) {
102
- if (current !== c || c.controller !== controller) return;
103
- c.controller = null;
104
- c.answer = answer;
105
- version++;
106
- c.onChange();
107
- }
108
-
109
- /**
110
- * Puts the current step's verdict on the player's snapshot (`snap.verdict`, which scene.js draws) and,
111
- * while the As menu overrides it, the persona acting the step (`snap.current.actor`).
112
- * @param {object} snap the player's snapshot
113
- * @param {object} scenario the scenario the player plays (it changes with a what-if edit)
114
- */
115
- export function decorateSnapshot(snap, scenario) {
116
- if (!current) return snap;
117
- replan(scenario);
118
- const plan = current.plan.steps[snap.index];
119
- snap.verdict = stepVerdict(plan, current.answer);
120
- if (current.as && plan && plan.actor) snap.current.actor = plan.actor;
121
- return snap;
122
- }
123
-
124
- /** The verdict for each step of the scenario on the map (for a test or a caller that wants the whole run) */
125
- export function scenarioVerdicts() {
126
- if (!current || !current.plan) return [];
127
- return current.plan.steps.map((p) => stepVerdict(p, current.answer));
128
- }
129
-
130
- // ---------------------------------------------------------------------------
131
- // On the bar
132
- // ---------------------------------------------------------------------------
133
-
134
- /** The pill in the head, the line under the text, and the As row under the controls: only on the bar of a scenario that names an actor, so any other bar is as it was */
135
- function mountControls(bar) {
136
- // the pill ends the step's line; the reason is a line of its own under the bar's row, with the As row (the player is one bar: spec 0006 D6)
137
- const pill = document.createElement('span');
138
- pill.className = 'hx-player-verdict';
139
- pill.dataset.corn = 'state-pill';
140
- pill.hidden = true;
141
- const text = bar.querySelector('.hx-player-text');
142
- if (text) text.append(' ', pill); else bar.prepend(pill);
143
-
144
- const line = document.createElement('p');
145
- line.className = 'hx-player-check';
146
- line.dataset.corn = 'scenario-check';
147
- line.hidden = true;
148
-
149
- const row = document.createElement('div');
150
- row.className = 'hx-player-as';
151
- row.innerHTML = `
152
- <label class="hx-player-as-label">As <select data-corn="control" class="hx-player-speed hx-player-as-menu" data-check="as" aria-label="Act every step as"></select></label>
153
- <button data-corn-kind="secondary" type="button" class="hx-btn" data-check="recheck">Check again</button>
154
- <span class="hx-player-as-sum hx-faint"></span>`;
155
- const track = bar.querySelector('.hx-player-track');
156
- if (track) { track.before(line); track.before(row); } else { bar.appendChild(line); bar.appendChild(row); }
157
-
158
- row.querySelector('[data-check=as]').addEventListener('change', (e) => chooseActor(e.target.value));
159
- row.querySelector('[data-check=recheck]').addEventListener('click', recheck);
160
- }
161
-
162
- /** The As menu moved: every step acts as that persona ('' = as written), and the batch is asked again */
163
- export function chooseActor(id) {
164
- if (!current) return;
165
- current.as = id || null;
166
- replan(current.scenario, true);
167
- current.onChange();
168
- }
169
-
170
- /** Check again: the same batch, asked again */
171
- export function recheck() {
172
- if (!current) return;
173
- replan(current.scenario, true);
174
- current.onChange();
175
- }
176
-
177
- /** The personas on the map, what-if ones included, as the As menu's options */
178
- function fillMenu(menu) {
179
- const personas = state.nodes.filter((n) => n.type === 'persona');
180
- const options = [{ value: '', label: 'As written' }, ...personas.map((p) => ({ value: p.id.replace(/^persona-/, ''), label: personaLabel(p) }))];
181
- const key = options.map((o) => `${o.value}\u0000${o.label}`).join('\u0001');
182
- if (menu.dataset.key !== key) {
183
- menu.innerHTML = options.map((o) => `<option value="${escHtml(o.value)}">${escHtml(o.label)}</option>`).join('');
184
- menu.dataset.key = key;
185
- }
186
- menu.value = current && current.as ? current.as : '';
187
- }
188
-
189
- /** What the batch found, in a few words: "4 checks · 1 refused" */
190
- function summary() {
191
- const all = scenarioVerdicts();
192
- const asked = all.reduce((n, v) => n + v.checks.length, 0);
193
- if (!current || current.answer.status === 'pending') return asked ? `Checking ${asked}…` : '';
194
- if (current.answer.status === 'failed') return '';
195
- const refused = all.filter((v) => v.state === 'refused').length;
196
- const amber = all.filter((v) => v.mismatch).length;
197
- const parts = [`${asked} ${asked === 1 ? 'check' : 'checks'}`];
198
- if (refused) parts.push(`${refused} refused`);
199
- if (amber) parts.push(`${amber} not as expected`);
200
- return asked ? parts.join(' · ') : 'No permission questions';
201
- }
202
-
203
- /** Paints the step's state on the bar: called with every bar update */
204
- /** The words last written into each player's check line (paintChecks) */
205
- const lineHtml = new WeakMap();
8
+ import { pagePiece, mergePagePieceOptions } from './page-pieces.js';
206
9
 
207
- export function paintChecks(bar, snap) {
208
- if (!bar || !current) return;
209
- if (!bar.querySelector('.hx-player-as')) {
210
- if (!namesActor(current.scenario)) return;
211
- mountControls(bar);
212
- }
213
- const pill = bar.querySelector('.hx-player-verdict');
214
- const line = bar.querySelector('.hx-player-check');
215
- const row = bar.querySelector('.hx-player-as');
216
- if (!pill || !line || !row) return;
217
- const words = snap.done ? null : verdictWords(snap.verdict); // at the end there is no step to say a verdict of
218
- pill.hidden = !words;
219
- line.hidden = !words;
220
- if (words) {
221
- pill.dataset.tone = words.tone;
222
- if (cornState(words.tone)) pill.dataset.cornState = cornState(words.tone); else delete pill.dataset.cornState;
223
- pill.textContent = words.pill;
224
- pill.title = words.line;
225
- line.dataset.tone = words.tone;
226
- // painted every frame: the live line is rewritten only when its words change, so a verdict is said once
227
- const html = `${escHtml(words.line)}${words.detail ? ` <span class="hx-player-check-detail">${escHtml(words.detail)}</span>` : ''}`;
228
- if (lineHtml.get(line) !== html) { lineHtml.set(line, html); line.innerHTML = html; }
229
- }
230
- fillMenu(row.querySelector('[data-check=as]'));
231
- row.querySelector('[data-check=recheck]').disabled = current.answer.status === 'pending';
232
- row.querySelector('.hx-player-as-sum').textContent = summary();
233
- }
10
+ /** Hands the page's changes piece its checker (a plugin's adapter); none means every checked step reads "Not checked" */
11
+ export function initChecks(opts = {}) { mergePagePieceOptions('changes', { checker: opts.checker || null }); }
12
+ /** The verdict for each step of the scenario on the map */
13
+ export const scenarioVerdicts = () => { const p = pagePiece('changes'); return p ? p.checks.verdicts() : []; };
@@ -8,6 +8,8 @@
8
8
  */
9
9
 
10
10
  import { announce } from './keyboard.js';
11
+ import { pageInstance } from './state.js';
12
+ import { notSentWords as wordsFor } from './engine/connection.js';
11
13
 
12
14
  export const OFFLINE_WORDS = 'You are offline. Nothing is sent until you are back; what you have typed is kept.';
13
15
  export const ONLINE_WORDS = 'You are back online.';
@@ -21,9 +23,7 @@ let hideTimer = 0;
21
23
  export const isOffline = () => typeof navigator !== 'undefined' && navigator.onLine === false;
22
24
 
23
25
  /** The words for an action that got no answer: offline, it was not sent (and what was typed is still there); online, the server did not answer */
24
- export function notSentWords(what) {
25
- return isOffline() ? `You are offline. ${what} was not sent; what you typed is kept. Try again when you are back.` : `cornfield did not answer. ${what} was not sent; what you typed is kept.`;
26
- }
26
+ export const notSentWords = (what) => wordsFor(pageInstance(), what);
27
27
 
28
28
  function paint(said) {
29
29
  const el = document.getElementById('offline-banner');
@@ -0,0 +1,46 @@
1
+ /*
2
+ * account.css: the account menu
3
+ * The account button and its menu (account-menu.js): who is signed in, the theme and freeform switches, the review tokens and proposals
4
+ * entries, the links. A part of cornfield's page shell for now (D4 puts it with step 7 or later).
5
+ * No rule here asks what the document says (`:root`, `html`, `body`, `[data-theme]`), sizes from the window (`vw`, `vh`) or is `position: fixed` unless it says why;
6
+ * a width rule is a container query on `corn-box` (page.css), a height rule on `corn-page`. base.css loads first.
7
+ */
8
+ /* The account button: the initial of who is signed in (a menu glyph when nobody is) */
9
+ .hx-account-btn { display: inline-flex; align-items: center; gap: var(--corn-space-3); height: var(--hx-control-h); padding: 0 var(--corn-space-2) 0 var(--corn-space-1); border-radius: var(--corn-radius-pill); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text-2); }
10
+ .hx-account-btn:hover { background: var(--corn-surface-3); color: var(--corn-text); }
11
+ .hx-account-btn[aria-expanded="true"] { border-color: var(--corn-accent-text); }
12
+ .hx-avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--corn-radius-pill); background: var(--corn-accent); color: var(--corn-text-on-accent); font-size: var(--corn-text-xs); font-weight: 700; }
13
+ .hx-avatar:empty::before { content: "\2630"; }
14
+ /* The account menu: a panel under the button */
15
+ .hx-menu.hx-account-menu { left: auto; right: 0; display: flex; flex-direction: column; gap: calc(var(--corn-space-1) / 2); width: 264px; padding: var(--corn-space-2); font-size: var(--corn-text-sm); user-select: none; }
16
+ .hx-account-who { padding: var(--corn-space-3) var(--corn-space-4) var(--corn-space-2); color: var(--corn-text-3); font-size: var(--corn-text-sm); overflow-wrap: anywhere; }
17
+ .hx-account-row { display: flex; align-items: center; justify-content: space-between; gap: var(--corn-space-3); padding: var(--corn-space-1) var(--corn-space-4); }
18
+ .hx-account-label { color: var(--corn-text-2); }
19
+ .hx-account-seg { display: inline-flex; padding: calc(var(--corn-space-1) / 2); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); }
20
+ .hx-account-seg-btn { height: var(--hx-seg-inner); padding: 0 var(--corn-space-3); border: 0; border-radius: var(--corn-radius-xs); background: transparent; color: var(--corn-text-2); font-size: var(--corn-text-xs); font-weight: 500; }
21
+ .hx-account-seg-btn:hover { color: var(--corn-text); }
22
+ .hx-account-seg-btn[aria-pressed="true"] { background: var(--corn-accent); color: var(--corn-text-on-accent); font-weight: 600; }
23
+ .hx-account-select { display: block; width: calc(100% - var(--corn-space-5)); height: var(--hx-control-h); margin: 0 var(--corn-space-3); padding: 0 var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font: inherit; font-size: var(--corn-text-sm); }
24
+ .hx-account-item { display: flex; align-items: center; justify-content: space-between; gap: var(--corn-space-3); width: 100%; min-height: var(--hx-control-h); padding: 0 var(--corn-space-4); border: 0; border-radius: var(--corn-radius-sm); background: none; color: var(--corn-text); font-size: var(--corn-text-sm); text-align: left; text-decoration: none; }
25
+ .hx-account-item:hover { background: var(--corn-surface-3); }
26
+ .hx-account-item--sub { padding-left: var(--corn-space-6); color: var(--corn-text-2); }
27
+ .hx-account-item svg { flex: none; color: var(--corn-text-3); }
28
+ .hx-account-menu .cf-sign-out { margin: 0; }
29
+ .hx-account-menu .cf-sign-out .hx-account-item { color: var(--corn-text-2); }
30
+ .hx-account-menu .hx-links { display: flex; flex-direction: column; margin-top: var(--corn-space-2); padding-top: var(--corn-space-2); border-top: var(--corn-border) solid var(--corn-line); }
31
+ .hx-account-menu .hx-links:empty { display: none; }
32
+ .hx-account-foot { margin: var(--corn-space-1) 0 0; padding: var(--corn-space-2) var(--corn-space-4) var(--corn-space-1); color: var(--corn-text-3); font-size: var(--corn-text-xs); }
33
+ .hx-account-foot a { color: inherit; text-decoration: none; }
34
+ .hx-account-foot a:hover { color: var(--corn-text-2); text-decoration: underline; }
35
+ .hx-account-foot:empty { display: none; }
36
+ /* The Proposals list opens inside the menu, under its entry, until the Specs tab of the Work panel takes it over */
37
+ .hx-account-menu .hx-menu--proposals { position: static; width: auto; max-width: none; max-height: calc(40 * var(--hx-vh, 1cqh)); margin: var(--corn-space-1) 0; padding: var(--corn-space-2); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); box-shadow: none; }
38
+ @container corn-box (max-width: 767px) {
39
+ .hx-account-btn { width: var(--hx-control-h); height: var(--hx-control-h); justify-content: center; padding: 0; border: 0; background: none; }
40
+ .hx-account-caret { display: none; }
41
+ .hx-avatar { width: 28px; height: 28px; }
42
+ .hx-menu.hx-account-menu { width: min(300px, calc(100cqw - 24px)); }
43
+ .hx-account-item, .hx-account-row { min-height: var(--hx-control-h); }
44
+ .hx-account-seg-btn { height: var(--hx-seg-inner); padding: 0 var(--corn-space-4); }
45
+ .hx-account-select { height: var(--hx-control-h); }
46
+ }
@@ -0,0 +1,159 @@
1
+ /*
2
+ * base.css: what every piece of the explorer needs, whether it sits in cornfield's page or in a shadow root in another app (spec 0011 D8).
3
+ * The shared control and panel rules (buttons, inputs, the menu box, glass, focus rings, the marks' dots, screen-reader text) and the private
4
+ * properties `--hx-*`. Plain CSS: every colour, font, size, radius, border width, shadow and spacing is a --corn-* token from
5
+ * explorer/tokens.css (docs/theming.md; test/explorer/tokens.test.js fails on any literal left here). Light and dark are tokens.css's
6
+ * business: nothing here names a theme. Classes are prefixed hx-. Nothing here asks what the document says: no `:root`, `html` or `body`
7
+ * rule, no unit of the window (`vw`, `vh`), no `position: fixed`; the rules of the page itself are in page.css. A width rule is a
8
+ * container query on `corn-box`, the piece's own box (page.css names the body; a component names its host).
9
+ *
10
+ * A component's host: `container: corn-box corn-page / size` and a definite height, so the width rules, the screen-height rules (`corn-page`)
11
+ * and the `cqw`/`cqh` sizes all read the host. A host that is only `corn-box / inline-size` gets the width rules, but no `corn-page` rule
12
+ * applies (neither the short-screen one nor the tall one), and `cqh` falls through to the nearest size container above it, or to the small
13
+ * viewport where there is none: a menu or a sheet is then capped by the window's height, not the host's. With no container at all no width
14
+ * rule applies and `cqw` is the viewport's too. The few fixed boxes (a dialog, a phone's menu) are placed against the window, unless something
15
+ * around them is their containing block: a transform or filter above the host, or the host itself in a browser from before mid-2024, where a
16
+ * container was also layout-contained (page.css: why the page's only container is the body).
17
+ */
18
+ *, *::before, *::after { box-sizing: border-box; }
19
+ /* Private properties. A control is the token's height on a desk and never under 44px in a narrow box: a brand that sets --corn-control-height
20
+ (on :root, or on one scope) cannot take a phone's targets under 44px; one that sets it higher than 44px gets its height there too. A segmented
21
+ control (View, Before / Diff / After, the theme choice) is the control height outside; its buttons are that less the frame (the padding and the
22
+ two borders), or the full height in a narrow box, where each button is the 44px target and the frame is outside it. They are set on every element
23
+ rather than on :root, so they exist inside a shadow root too; a container query cannot style its own container, so the container's own rules
24
+ (the body's) reads none of them. A height that explorer.css wrote in `vh` reads `var(--hx-vh, 1cqh)`: page.css sets `--hx-vh` to the window's 1vh,
25
+ so cornfield's page is as it was on a phone whose toolbar comes and goes, and a piece elsewhere sizes from its own box. */
26
+ * { --hx-control-h: var(--corn-control-height); --hx-seg-inner: calc(var(--hx-control-h) - var(--corn-space-1) - 2 * var(--corn-border)); }
27
+ @container corn-box (max-width: 767px) {
28
+ * { --hx-control-h: max(44px, var(--corn-control-height)); --hx-seg-inner: var(--hx-control-h); }
29
+ }
30
+ /* theme.pixelated (docs/config.md#theme): small pixel-art images are sampled without smoothing, in the page as on the map (map-style.js).
31
+ page.css sets --hx-pixelated where the document says so; a custom property inherits into a shadow root, <html data-pixelated> does not. */
32
+ img { image-rendering: var(--hx-pixelated, auto); }
33
+ [hidden] { display: none !important; }
34
+ button { font: inherit; color: inherit; cursor: pointer; }
35
+ h1, h2, h3, p { margin: 0; }
36
+ .glass {
37
+ background: var(--corn-surface-1);
38
+ backdrop-filter: blur(var(--corn-blur));
39
+ -webkit-backdrop-filter: blur(var(--corn-blur));
40
+ border: var(--corn-border) solid var(--corn-line);
41
+ box-shadow: var(--corn-shadow);
42
+ }
43
+ .glass-header {
44
+ background: color-mix(in srgb, var(--corn-ground) 88%, transparent);
45
+ backdrop-filter: blur(var(--corn-blur));
46
+ -webkit-backdrop-filter: blur(var(--corn-blur));
47
+ border-bottom: var(--corn-border) solid var(--corn-line);
48
+ }
49
+ ::-webkit-scrollbar { width: 5px; height: 5px; }
50
+ ::-webkit-scrollbar-track { background: transparent; }
51
+ ::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--corn-text) 18%, transparent); border-radius: var(--corn-radius-pill); }
52
+ ::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--corn-text) 28%, transparent); }
53
+ .hx-faint { color: var(--corn-text-3); }
54
+ .hx-mono { font-family: var(--corn-mono); font-size: var(--corn-text-2xs); }
55
+ .hx-strong { color: var(--corn-text-2); }
56
+ .hx-bold { font-weight: 700; }
57
+ .hx-name { color: var(--corn-text-2); }
58
+ .hx-accent { color: var(--corn-accent-text); }
59
+ .hx-good { color: var(--corn-ok); }
60
+ .hx-warn { color: var(--corn-warn); }
61
+ .hx-rom { color: var(--corn-hue-fuchsia); }
62
+ .hx-link { color: var(--corn-info); text-decoration: underline; }
63
+ .hx-link-faint { color: var(--corn-text-3); font-family: var(--corn-mono); font-size: var(--corn-text-2xs); }
64
+ .hx-link-faint:hover { color: var(--corn-warn); }
65
+ .hx-code { color: var(--corn-warn); font-family: var(--corn-mono); font-size: var(--corn-text-2xs); }
66
+ .hx-chips { display: flex; flex-wrap: wrap; gap: var(--corn-space-1); padding-top: var(--corn-space-1); }
67
+ .hx-pt { padding-top: var(--corn-space-3); }
68
+ /* Freeform layout is a switch */
69
+ .hx-switch { position: relative; flex: none; width: 28px; height: 16px; border-radius: var(--corn-radius-pill); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-3); }
70
+ .hx-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--corn-text-3); transition: transform 0.15s; }
71
+ [aria-checked="true"] > .hx-switch { background: var(--corn-accent); border-color: var(--corn-accent); }
72
+ [aria-checked="true"] > .hx-switch::after { background: var(--corn-text-on-accent); transform: translateX(12px); }
73
+ @media (prefers-reduced-motion: reduce) {
74
+ .hx-switch::after { transition: none; }
75
+ }
76
+ .hx-btn {
77
+ display: inline-flex;
78
+ align-items: center;
79
+ gap: var(--corn-space-2);
80
+ padding: var(--corn-space-1) var(--corn-space-3);
81
+ border-radius: var(--corn-radius-sm);
82
+ border: var(--corn-border) solid var(--corn-line);
83
+ background: var(--corn-surface-2);
84
+ color: var(--corn-text-2);
85
+ font-size: var(--corn-text-xs);
86
+ font-weight: 600;
87
+ transition: background 0.15s, color 0.15s, border-color 0.15s;
88
+ white-space: nowrap;
89
+ }
90
+ .hx-btn:hover { background: var(--corn-surface-3); color: var(--corn-text); }
91
+ .hx-btn:focus-visible, .hx-textbtn:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
92
+ .hx-btn--active, .hx-btn--active:hover { background: var(--corn-accent); border-color: var(--corn-accent-text); color: var(--corn-text-on-accent); box-shadow: var(--corn-shadow-sm); }
93
+ .hx-btn--quiet { font-weight: 500; color: var(--corn-text-3); }
94
+ .hx-btn--icon { width: 28px; height: 28px; padding: 0; justify-content: center; font-size: var(--corn-text-base); }
95
+ .hx-btn--rom { width: 100%; justify-content: center; margin-top: var(--corn-space-1); padding: var(--corn-space-2); background: color-mix(in srgb, var(--corn-hue-fuchsia) 20%, transparent); border-color: color-mix(in srgb, var(--corn-hue-fuchsia) 40%, transparent); color: color-mix(in srgb, var(--corn-hue-fuchsia) 60%, var(--corn-text)); font-weight: 700; }
96
+ .hx-btn--rom:hover { background: color-mix(in srgb, var(--corn-hue-fuchsia) 30%, transparent); }
97
+ .hx-input {
98
+ width: 128px;
99
+ padding: var(--corn-space-1) var(--corn-space-3) var(--corn-space-1) var(--corn-space-6);
100
+ border-radius: var(--corn-radius-sm);
101
+ border: var(--corn-border) solid var(--corn-line);
102
+ background: color-mix(in srgb, var(--corn-ground) 80%, transparent);
103
+ color: var(--corn-text);
104
+ font: inherit;
105
+ font-size: var(--corn-text-sm);
106
+ outline: none;
107
+ transition: width 0.2s, border-color 0.2s;
108
+ user-select: text;
109
+ }
110
+ .hx-input:focus { width: 208px; border-color: var(--corn-focus); }
111
+ .hx-input::placeholder { color: var(--corn-text-3); }
112
+ .hx-input--wide, .hx-input--wide:focus { width: 100%; flex: 1; }
113
+ .hx-menu-wrap { position: relative; flex: none; }
114
+ .hx-menu {
115
+ position: absolute;
116
+ top: 100%;
117
+ left: 0;
118
+ margin-top: var(--corn-space-3);
119
+ width: 288px;
120
+ max-width: calc(100cqw - 24px);
121
+ max-height: calc(100cqh - 80px);
122
+ overflow-y: auto;
123
+ padding: var(--corn-space-4);
124
+ border-radius: var(--corn-radius-lg);
125
+ font-size: var(--corn-text-xs);
126
+ z-index: 50;
127
+ user-select: none;
128
+ }
129
+ .hx-textbtn { padding: calc(var(--corn-space-1) / 2) var(--corn-space-1); border: 0; border-radius: var(--corn-radius-xs); background: none; color: var(--corn-text-3); font-size: var(--corn-text-2xs); font-weight: 600; }
130
+ .hx-textbtn:hover { background: var(--corn-line-soft); color: var(--corn-text-2); }
131
+ .hx-textbtn--accent { color: var(--corn-accent-text); }
132
+ .hx-close { width: var(--hx-control-h); height: var(--hx-control-h); flex: none; border: 0; border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); color: var(--corn-text-3); font-weight: 700; font-size: var(--corn-text-base); }
133
+ .hx-close:hover { color: var(--corn-text); }
134
+ /* The marks' colours, shared with the picture: the diff tokens, whose light values are theme-model.js `lightColor` of the dark ones */
135
+ .hx-mark-dot { display: inline-block; width: 12px; height: 12px; flex: none; margin-right: var(--corn-space-2); border-radius: 50%; border: var(--corn-border-strong) solid var(--corn-changed); vertical-align: -2px; }
136
+ .hx-mark-dot--added { border-color: var(--corn-added); border-style: dashed; }
137
+ .hx-mark-dot--changed { border-color: var(--corn-changed); }
138
+ .hx-mark-dot--removed { border-color: var(--corn-removed); background: color-mix(in srgb, var(--corn-removed) 25%, transparent); }
139
+ .hx-mark-dot--edit { border-color: var(--corn-edit); border-style: dotted; } /* a dotted ring: not the changed mark's solid one, with or without colour */
140
+ /* ---- a panel glyph (MAP-01) ----------------------------------------------------------------------
141
+ A panel glyph's colour comes from script (the flow or kind it stands for, --glyph): mixed with the text colour by
142
+ --corn-glyph-mix (all of it on dark, 45% on light), so a pale yellow arrow still reads on the light ground. */
143
+ .hx-glyph { color: var(--glyph); color: color-mix(in srgb, var(--glyph) var(--corn-glyph-mix), var(--corn-text)); }
144
+ /* ---- keyboard and screen reader (MAP-02, keyboard.js) ------------------------------------------
145
+ Text only a screen reader reads (the heading, the map's keys, the announcer); a focus ring on everything that
146
+ takes the focus, the map included (the more specific rings above still win where they are set). */
147
+ .hx-sr-only { position: absolute !important; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
148
+ :where(button, a[href], summary, select, textarea, [tabindex]):focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
149
+ @media (prefers-reduced-motion: reduce) {
150
+ .hx-input, .hx-btn, .hx-menu { transition: none; animation: none; }
151
+ }
152
+ .hx-btn[aria-disabled="true"] { opacity: 0.6; cursor: progress; } /* a review being posted: the button keeps the focus */
153
+ @container corn-box (max-width: 767px) {
154
+ /* A thumb target: a narrow box or a coarse pointer (test/explorer/target-size.test.js holds the list over every file) */
155
+ .hx-textbtn { min-height: 44px; min-width: 44px; }
156
+ }
157
+ @media (pointer: coarse) {
158
+ .hx-textbtn { min-height: 44px; min-width: 44px; }
159
+ }