@monster-orange/den-ui 0.7.0 → 0.7.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/README.md +95 -12
- package/bin/den-ui-parity.mjs +2 -0
- package/inventory/nav-inventory.d.ts +37 -0
- package/inventory/nav-inventory.js +232 -1
- package/inventory/reference/den-chromium-1280.json +338 -110
- package/inventory/reference/den-chromium-390.json +271 -39
- package/inventory/reference/den-webkit-1280.json +338 -110
- package/inventory/reference/den-webkit-390.json +271 -39
- package/package.json +1 -1
- package/src/kit.d.ts +2 -0
- package/src/kit.js +2 -0
- package/src/shell-client.js +41 -0
- package/src/shell-html.d.ts +30 -7
- package/src/shell-html.js +129 -31
- package/src/shell.css +277 -13
- package/src/strings.js +3 -0
- package/src/version.js +5 -1
package/README.md
CHANGED
|
@@ -201,8 +201,8 @@ browsers to it through `DEN_PW_WS`:
|
|
|
201
201
|
DEN_PW_WS=ws://localhost:3921/
|
|
202
202
|
|
|
203
203
|
import { chromium } from "playwright"; // 1.61.1, as the image
|
|
204
|
-
import { collectNav, compareNav, formatNavDiffs,
|
|
205
|
-
NAV_THEME } from "@monster-orange/den-ui/inventory";
|
|
204
|
+
import { collectNav, compareNav, formatNavDiffs, navWarnings,
|
|
205
|
+
NAV_BROWSER_IMAGE, NAV_THEME } from "@monster-orange/den-ui/inventory";
|
|
206
206
|
import { readFileSync } from "node:fs";
|
|
207
207
|
import { createRequire } from "node:module";
|
|
208
208
|
|
|
@@ -216,12 +216,17 @@ browsers to it through `DEN_PW_WS`:
|
|
|
216
216
|
const ref = JSON.parse(readFileSync(createRequire(import.meta.url)
|
|
217
217
|
.resolve("@monster-orange/den-ui/inventory/reference/den-chromium-1280.json"),
|
|
218
218
|
"utf-8"));
|
|
219
|
+
const snap = await collectNav(page, { image: NAV_BROWSER_IMAGE,
|
|
220
|
+
theme: NAV_THEME });
|
|
219
221
|
const diffs = compareNav(
|
|
220
|
-
|
|
222
|
+
snap,
|
|
221
223
|
ref,
|
|
222
224
|
{ hostSlots: ["#my-status"] }, // what the host fills itself
|
|
223
225
|
);
|
|
224
226
|
expect(formatNavDiffs(diffs)).toBe(""); // one line per difference
|
|
227
|
+
// 0.7.1: host HTML where the kit's account or search should be.
|
|
228
|
+
// Listed, not failed, until 0.7.2 gives every slot a data path.
|
|
229
|
+
for (const w of navWarnings(snap)) console.warn(w);
|
|
225
230
|
|
|
226
231
|
Pass `theme` as the theme the page really draws in (Den reads it from
|
|
227
232
|
`/api/themes`). On another browser build (a different fingerprint: user
|
|
@@ -258,11 +263,11 @@ env, elements, tokens }`. `env`: `userAgent`, `faces` (the
|
|
|
258
263
|
that much, never by anything else.
|
|
259
264
|
- Host content: the kit stamps `data-nav-role` on what each host fills
|
|
260
265
|
with its own words: each scope crumb (`crumb`) and the separator after
|
|
261
|
-
it (`crumb-sep`), the brand's title (`brand-title`),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
it (`crumb-sep`), the brand's title (`brand-title`), each rail group
|
|
267
|
+
(`rail-group`), its heading (`group`) and its pages (`page`), and the
|
|
268
|
+
account entry's words (`account-name`). An element with
|
|
269
|
+
`data-nav-name="host"` holds a name that is the host's (not compared).
|
|
270
|
+
The search's placeholder and name are the kit's, and compared. Their count, keys, ids, text and
|
|
266
271
|
width are never compared, on either side. The first of each role is
|
|
267
272
|
compared with the other side's first, and what it holds by key, on
|
|
268
273
|
every computed style and on height. Their size may move what follows by
|
|
@@ -345,6 +350,83 @@ browser test, on the image (Den's real server on the demo distribution,
|
|
|
345
350
|
is `src/kit.d.ts`. A test compiles a consumer against them with
|
|
346
351
|
`--strict`.
|
|
347
352
|
|
|
353
|
+
## 0.7.1
|
|
354
|
+
|
|
355
|
+
The top bar's search sits in the same place in every product (issue 303).
|
|
356
|
+
|
|
357
|
+
- **The account is data.** `accountHtml` and `accountMenuHtml` take
|
|
358
|
+
`{ name?, login, role? }`. The rail's entry is the name over `@login`,
|
|
359
|
+
or `@login` alone when no name is known; never the role. The account
|
|
360
|
+
menu's header is the same, then the role on its own line. The kit adds the `@`. The old `{ label, detail }`
|
|
361
|
+
(and the menu's `{ name, detail }`) still work for this release, drawn
|
|
362
|
+
as given, and the nav inventory fails a host that uses them
|
|
363
|
+
(`legacy`). `accountWho(a)` gives the lines and the shape.
|
|
364
|
+
- **The search never moves.** Its x is a function of the viewport only:
|
|
365
|
+
`searchSlot(width)` gives `{ x, w }` (464 / 304 at 1280, 396 at 1100,
|
|
366
|
+
256 at 960, 82 / 54 on a phone), the same in any host. The left part is
|
|
367
|
+
the smaller of `--den-top-left` (444px) and what the search and the
|
|
368
|
+
right group's reserve (`--den-top-right`, 380px) leave.
|
|
369
|
+
- **The right group is anchored from the right edge.** ◐ at the bar's
|
|
370
|
+
padding, then the version in a fixed slot (`--den-top-version` 96px;
|
|
371
|
+
`--den-top-version-md` 64px up to 1100px; its text ends in "…", the
|
|
372
|
+
whole version in its title), the bell and Report, 4px apart: the same
|
|
373
|
+
x in any host. Report, the bell and ◐ never shrink; the kit sets their
|
|
374
|
+
font and box. The host's chips (`div.den-end`, always drawn, empty
|
|
375
|
+
without chips) take the room left: a chip gives way down to its dot
|
|
376
|
+
and "…", and the kit puts its whole words in its title and name (a
|
|
377
|
+
name or title the host set itself is kept).
|
|
378
|
+
- **Crumbs.** A crumb's label gives way first, then its value ends in
|
|
379
|
+
"…"; before the last crumb a value keeps about 4ch and its ▾.
|
|
380
|
+
- **Checks.** `topSlotDiffs(snap)` checks the search's slot and the
|
|
381
|
+
right group's places at any width (no reference needed); `compareNav`
|
|
382
|
+
runs it too, and fails a crumb whose label shows while its value is
|
|
383
|
+
hidden.
|
|
384
|
+
- **Shape, not only style.** The inventory compares what a kit slot
|
|
385
|
+
draws: the account entry's shape is one of the kit's (`name,login` on
|
|
386
|
+
two lines, `login` or `local` on one: `ACCOUNT_SHAPES`), the old fields
|
|
387
|
+
fail (`legacy`), and the search's box is pinned. `navWarnings(snap)` lists host HTML where the kit's account
|
|
388
|
+
or search should be: a warning in 0.7.1, a failure in 0.7.2.
|
|
389
|
+
|
|
390
|
+
- **Three parts.** The bar is a grid: the left part (`div.den-left`: ☰,
|
|
391
|
+
the brand, and what `start` holds before the search, the crumbs), the
|
|
392
|
+
search, then the chips (the host's `end` in `div.den-end`, then Report,
|
|
393
|
+
the bell, the version and ◐ ▾, pinned to the right edge). The kit finds
|
|
394
|
+
its search in `start` and puts it in its slot; a host's markup is
|
|
395
|
+
unchanged.
|
|
396
|
+
- **Settings** (custom properties on `.den-top`, with their defaults):
|
|
397
|
+
`--den-top-left` (444px), `--den-top-search` (304px), and under 720px
|
|
398
|
+
`--den-top-left-md`
|
|
399
|
+
(200px) and, under 480px, `--den-top-left-sm` (62px: ☰ and the mark).
|
|
400
|
+
At 1280px the search is at x 464, 304 wide; on a phone at x 82.
|
|
401
|
+
- **Giving way.** Long words never move the search. The crumbs give way
|
|
402
|
+
first: each crumb gets an equal share until it is whole, so a short one
|
|
403
|
+
keeps its words and a long one ends in "…"; the last crumb is kept
|
|
404
|
+
whole. Then the install name ends in "…". Under about 1100px the
|
|
405
|
+
host's chips give way (their words end in "…"; the kit's buttons keep
|
|
406
|
+
their size). The chips' column is never narrower than the kit's own
|
|
407
|
+
buttons, so the chips never run under the search: when the bar is too
|
|
408
|
+
narrow for all three parts, the left part gives way and the search
|
|
409
|
+
moves left. A host chip is width 0 growing to its own width
|
|
410
|
+
(`max-width: max-content`): put its words in its last child, a span,
|
|
411
|
+
which ends in "…".
|
|
412
|
+
- **A gap after ⌕**: 8px between the search and the chips, and 8px more
|
|
413
|
+
before the first chip.
|
|
414
|
+
- **The search's words** are the kit's ("Search…", named "Search"; es,
|
|
415
|
+
ja): `searchHtml()` takes no placeholder or label.
|
|
416
|
+
- **Touch** (`pointer: coarse`): every control in the bar takes a 44×44px
|
|
417
|
+
tap (an `::after` hit area, centred; the look is the same), and the
|
|
418
|
+
key hints (⌘K, ⌘⇧F, any `.den-kbd`) hide.
|
|
419
|
+
- **`.den-hit`**: the same 44×44px tap for a host's own buttons and tabs.
|
|
420
|
+
On a touch screen it is `position: relative` plus a transparent,
|
|
421
|
+
centred `::after` at least 44×44px; without touch it does nothing. Its
|
|
422
|
+
look and layout never change. It sits beside `.den-kbd`, the one
|
|
423
|
+
key-cap rule, which hides on a touch screen wherever it is (a palette,
|
|
424
|
+
a button). `den-ui-parity` knows both: a host keeps no copy.
|
|
425
|
+
- **Nav inventory**: the search, Report, the bell, the version chip and ◐
|
|
426
|
+
▾ (`PINNED_CLASSES`) are compared at the reference's x and width: no
|
|
427
|
+
host-content shift excuses moving them. Den's references, and the
|
|
428
|
+
parity fixture and PNGs, were re-taken for this layout.
|
|
429
|
+
|
|
348
430
|
## 0.7.0
|
|
349
431
|
|
|
350
432
|
No new file. One import changes, for hosts that serve a fixed list of kit files:
|
|
@@ -388,8 +470,8 @@ button)`. A crumb left out of the list draws nothing, and no separator
|
|
|
388
470
|
opens on the field. Typing hides the links that don't hold the text, and
|
|
389
471
|
"No match" shows when none do. ↓ goes to the links, Enter takes the first
|
|
390
472
|
one shown, and Esc clears the text, then closes the menu.
|
|
391
|
-
- **Search field**: `searchHtml({
|
|
392
|
-
|
|
473
|
+
- **Search field**: `searchHtml({ id?, shortcut? })`, for the `start`
|
|
474
|
+
slot. It is the kit's placeholder ("Search…") with ⌘K inside the field. A
|
|
393
475
|
click, Enter, ⌘K or Ctrl-K calls `onActivate(via)` (`"click"` or
|
|
394
476
|
`"key"`) and fires `den-ui:search` on the field. The kit owns no
|
|
395
477
|
palette.
|
|
@@ -458,8 +540,9 @@ selected }`, a line under them, the languages `{ id, name, current }`,
|
|
|
458
540
|
32px each way (`shell.css`).
|
|
459
541
|
- **The brand on a phone**: below 480px the brand (its mark alone) never
|
|
460
542
|
shrinks; the host's chips give way.
|
|
461
|
-
- **Search
|
|
462
|
-
the kit's
|
|
543
|
+
- **Search words**: the placeholder ("Search…") and the field's name
|
|
544
|
+
("Search") are the kit's, in en, es and ja. A host can't set them: one
|
|
545
|
+
search in every product.
|
|
463
546
|
- **Filtered menus**: a menu with the filter field is a pop-up holding the
|
|
464
547
|
field, then the `role="menu"` list (`.den-mlist`, id `<menu>-list`),
|
|
465
548
|
then "No match": a menu owns only its items. The field has
|
package/bin/den-ui-parity.mjs
CHANGED
|
@@ -82,6 +82,8 @@ export const COMPONENTS = {
|
|
|
82
82
|
"den-collapse-btn",
|
|
83
83
|
"den-pin-row",
|
|
84
84
|
"den-scrim",
|
|
85
|
+
// 0.7.1: the 44px tap on touch, for any control.
|
|
86
|
+
"den-hit",
|
|
85
87
|
// Not here: den-has-shell, den-rail-collapsed and den-rail-open are
|
|
86
88
|
// the body's state classes, for a page to lay its own content out by.
|
|
87
89
|
],
|
|
@@ -35,6 +35,18 @@ export interface NavElement {
|
|
|
35
35
|
};
|
|
36
36
|
/** Its accessible name is the host's words (data-nav-name="host"). */
|
|
37
37
|
hostName?: boolean;
|
|
38
|
+
/** 0.7.1: a kit-owned slot's content shape (data-nav-shape: its fields). */
|
|
39
|
+
shape?: string;
|
|
40
|
+
/** 0.7.1: drawn from the old free-text fields (data-nav-legacy). */
|
|
41
|
+
legacy?: boolean;
|
|
42
|
+
/** The rail's account entry (data-den-account). */
|
|
43
|
+
account?: boolean;
|
|
44
|
+
/** The account entry's drawn lines. */
|
|
45
|
+
lines?: number;
|
|
46
|
+
/** A crumb whose label shows while its value is hidden. */
|
|
47
|
+
labelOnly?: boolean;
|
|
48
|
+
/** The kit's stamp on what it draws (data-nav-kit). */
|
|
49
|
+
kit?: string;
|
|
38
50
|
}
|
|
39
51
|
export interface NavTheme {
|
|
40
52
|
id: string;
|
|
@@ -87,6 +99,31 @@ export declare const NAV_BROWSER_IMAGE: string;
|
|
|
87
99
|
export declare const FINGERPRINT_TEXT: string;
|
|
88
100
|
/** The theme the reference was taken in ("den" 2.0.1): every parity run uses it. */
|
|
89
101
|
export declare const NAV_THEME: NavTheme;
|
|
102
|
+
/**
|
|
103
|
+
* issue 303: classes of the top bar's pinned elements (the search, Report,
|
|
104
|
+
* the bell, the version chip, ◐ ▾): compared at the reference's x and
|
|
105
|
+
* width, with no host-content allowance.
|
|
106
|
+
*/
|
|
107
|
+
export declare const PINNED_CLASSES: readonly string[];
|
|
108
|
+
/** The search's x and width for a viewport width, the same in any host. */
|
|
109
|
+
export declare function searchSlot(viewportW: number): { x: number; w: number };
|
|
110
|
+
export declare const TOP_RIGHT_MIN: number;
|
|
111
|
+
/** The search away from searchSlot (slot.x, slot.w), at any width. */
|
|
112
|
+
export declare function searchSlotDiffs(
|
|
113
|
+
snap: NavSnapshot,
|
|
114
|
+
tolerance?: number,
|
|
115
|
+
): NavDiff[];
|
|
116
|
+
/** The account entry's shapes the kit draws → their line counts. */
|
|
117
|
+
export declare const ACCOUNT_SHAPES: Record<string, number>;
|
|
118
|
+
/** The version's fixed slot width for a viewport width (0 on a phone). */
|
|
119
|
+
export declare function versionSlotW(viewportW: number): number;
|
|
120
|
+
/** searchSlotDiffs plus Report, bell, version and ◐ anchored from the right. */
|
|
121
|
+
export declare function topSlotDiffs(
|
|
122
|
+
snap: NavSnapshot,
|
|
123
|
+
tolerance?: number,
|
|
124
|
+
): NavDiff[];
|
|
125
|
+
/** 0.7.1: host HTML in the kit's account and search slots (warnings). */
|
|
126
|
+
export declare function navWarnings(snap: NavSnapshot): string[];
|
|
90
127
|
export declare function collectNav(
|
|
91
128
|
page: NavPage,
|
|
92
129
|
opts?: { image?: string; theme?: NavTheme },
|
|
@@ -266,6 +266,40 @@ export async function collectNav(page, opts = {}) {
|
|
|
266
266
|
...(el.getAttribute("data-nav-name") === "host"
|
|
267
267
|
? { hostName: true }
|
|
268
268
|
: {}),
|
|
269
|
+
// 0.7.1: a kit-owned slot's content shape (which fields it
|
|
270
|
+
// draws), the old free-text path, and the kit's own stamp.
|
|
271
|
+
// A crumb showing its label with its value hidden (the
|
|
272
|
+
// value must outlast the label).
|
|
273
|
+
...(el.getAttribute("data-nav-role") === "crumb" &&
|
|
274
|
+
(() => {
|
|
275
|
+
const k = el.querySelector(":scope > .den-k");
|
|
276
|
+
const v = el.lastElementChild;
|
|
277
|
+
if (!k || !v || v === k) return false;
|
|
278
|
+
const kw = k.getClientRects().length
|
|
279
|
+
? k.getBoundingClientRect().width
|
|
280
|
+
: 0;
|
|
281
|
+
const vw = v.getClientRects().length
|
|
282
|
+
? v.getBoundingClientRect().width
|
|
283
|
+
: 0;
|
|
284
|
+
return kw > 1 && vw < 8;
|
|
285
|
+
})()
|
|
286
|
+
? { labelOnly: true }
|
|
287
|
+
: {}),
|
|
288
|
+
...(el.hasAttribute("data-nav-shape")
|
|
289
|
+
? { shape: el.getAttribute("data-nav-shape") }
|
|
290
|
+
: {}),
|
|
291
|
+
...(el.hasAttribute("data-nav-legacy") ? { legacy: true } : {}),
|
|
292
|
+
...(el.hasAttribute("data-den-account")
|
|
293
|
+
? {
|
|
294
|
+
account: true,
|
|
295
|
+
lines: el.querySelectorAll(
|
|
296
|
+
".den-acct-n, .den-acct-l, .den-acct-r",
|
|
297
|
+
).length,
|
|
298
|
+
}
|
|
299
|
+
: {}),
|
|
300
|
+
...(el.hasAttribute("data-nav-kit")
|
|
301
|
+
? { kit: el.getAttribute("data-nav-kit") }
|
|
302
|
+
: {}),
|
|
269
303
|
});
|
|
270
304
|
}
|
|
271
305
|
if (el.tagName.toLowerCase() === "svg") return mySlot;
|
|
@@ -526,6 +560,144 @@ function lcs(a, b) {
|
|
|
526
560
|
/** The rail's column: its slots stack top to bottom. */
|
|
527
561
|
const COLUMN = ["rail", "foot"];
|
|
528
562
|
|
|
563
|
+
/**
|
|
564
|
+
* issue 303: the top bar's search and the kit's right-side items (Report,
|
|
565
|
+
* the bell, the version chip, ◐ ▾) sit at the reference's x and width,
|
|
566
|
+
* whatever the host's words: a host's crumbs, title or chips never excuse
|
|
567
|
+
* moving them.
|
|
568
|
+
*/
|
|
569
|
+
/**
|
|
570
|
+
* The search's slot for a viewport width (issue 303, "the search never
|
|
571
|
+
* moves"): its x and width are a function of the viewport only, the same
|
|
572
|
+
* in any host. Above 720px: the left part is 444px, less what the bar
|
|
573
|
+
* needs for the search and the kit's right group (TOP_RIGHT_MIN);
|
|
574
|
+
* 481–720px: 200px; up to 480px: 62px. The bar's padding is 12px and
|
|
575
|
+
* its column gap 8px. Mirrors shell.css's .den-top columns (defaults).
|
|
576
|
+
*/
|
|
577
|
+
export const TOP_RIGHT_MIN = 380;
|
|
578
|
+
export function searchSlot(viewportW) {
|
|
579
|
+
const pad = 12;
|
|
580
|
+
const gap = 8;
|
|
581
|
+
if (viewportW > 720) {
|
|
582
|
+
const left = Math.max(
|
|
583
|
+
0,
|
|
584
|
+
Math.min(444, viewportW - 2 * pad - 304 - 2 * gap - TOP_RIGHT_MIN),
|
|
585
|
+
);
|
|
586
|
+
return { x: pad + left + gap, w: 304 };
|
|
587
|
+
}
|
|
588
|
+
return { x: pad + (viewportW < 480 ? 62 : 200) + gap, w: 54 };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* The search away from its slot (searchSlot for the snapshot's viewport):
|
|
593
|
+
* a difference per edge, at any width, with no reference box needed.
|
|
594
|
+
*/
|
|
595
|
+
export function searchSlotDiffs(snap, tolerance = 2) {
|
|
596
|
+
const out = [];
|
|
597
|
+
const slot = searchSlot(snap.viewport.w);
|
|
598
|
+
for (const e of snap.elements) {
|
|
599
|
+
if (e.slot !== "top" || !e.classes.includes("den-search") || !e.box)
|
|
600
|
+
continue;
|
|
601
|
+
const near = (a, b) => Math.abs(a - b) <= tolerance;
|
|
602
|
+
if (!near(e.box.x, slot.x))
|
|
603
|
+
out.push({
|
|
604
|
+
key: e.key,
|
|
605
|
+
slot: e.slot,
|
|
606
|
+
property: "slot.x",
|
|
607
|
+
reference: String(slot.x),
|
|
608
|
+
actual: String(e.box.x),
|
|
609
|
+
});
|
|
610
|
+
if (!near(e.box.w, slot.w))
|
|
611
|
+
out.push({
|
|
612
|
+
key: e.key,
|
|
613
|
+
slot: e.slot,
|
|
614
|
+
property: "slot.w",
|
|
615
|
+
reference: String(slot.w),
|
|
616
|
+
actual: String(e.box.w),
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return out;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** The account entry's shapes the kit draws, and their line counts. */
|
|
623
|
+
export const ACCOUNT_SHAPES = { "name,login": 2, login: 1, local: 1 };
|
|
624
|
+
|
|
625
|
+
/** The version's fixed slot for a viewport width (none on a phone). */
|
|
626
|
+
export function versionSlotW(viewportW) {
|
|
627
|
+
return viewportW > 1100 ? 96 : viewportW > 720 ? 64 : 0;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* The top bar's kit slots at any width: the search (searchSlot), and the
|
|
632
|
+
* right group anchored from the right edge: ◐ at the bar's padding, then
|
|
633
|
+
* the version's fixed slot, the bell and Report, 4px apart. Widths that
|
|
634
|
+
* depend on the engine (Report's words, ◐'s glyph) are taken as drawn;
|
|
635
|
+
* their places follow, the same in any host.
|
|
636
|
+
*/
|
|
637
|
+
export function topSlotDiffs(snap, tolerance = 2) {
|
|
638
|
+
const out = searchSlotDiffs(snap, tolerance);
|
|
639
|
+
const vw = snap.viewport.w;
|
|
640
|
+
if (vw <= 720) return out;
|
|
641
|
+
const near = (a, b) => Math.abs(a - b) <= tolerance;
|
|
642
|
+
const find = (pred) =>
|
|
643
|
+
snap.elements.find((e) => e.slot === "top" && e.box && pred(e));
|
|
644
|
+
const ap = find((e) => e.key === "#appearance-btn");
|
|
645
|
+
const ver = find((e) => e.key === "#version-pill");
|
|
646
|
+
const bell = find((e) => e.key === "#den-bell");
|
|
647
|
+
const rb = find((e) => e.classes.includes("den-rb-top"));
|
|
648
|
+
const push = (e, property, want, got) =>
|
|
649
|
+
out.push({
|
|
650
|
+
key: e.key,
|
|
651
|
+
slot: e.slot,
|
|
652
|
+
property,
|
|
653
|
+
reference: String(Math.round(want * 100) / 100),
|
|
654
|
+
actual: String(Math.round(got * 100) / 100),
|
|
655
|
+
});
|
|
656
|
+
let right = vw - 12;
|
|
657
|
+
for (const e of [ap, ver, bell, rb]) {
|
|
658
|
+
if (!e) continue;
|
|
659
|
+
if (e === ver && !near(e.box.w, versionSlotW(vw)))
|
|
660
|
+
push(e, "slot.w", versionSlotW(vw), e.box.w);
|
|
661
|
+
const wantX = right - e.box.w;
|
|
662
|
+
if (!near(e.box.x, wantX)) push(e, "slot.x", wantX, e.box.x);
|
|
663
|
+
right = e.box.x - 4;
|
|
664
|
+
}
|
|
665
|
+
return out;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* 0.7.1: host HTML in the kit's account and search slots, listed (a
|
|
670
|
+
* warning: 0.7.2 makes every slot data, and then it fails). The kit
|
|
671
|
+
* stamps what it draws: the account entry's data-nav-shape, the search's
|
|
672
|
+
* data-nav-kit.
|
|
673
|
+
*/
|
|
674
|
+
export function navWarnings(snap) {
|
|
675
|
+
const out = [];
|
|
676
|
+
for (const e of snap.elements) {
|
|
677
|
+
if (e.account && e.shape == null)
|
|
678
|
+
out.push(
|
|
679
|
+
`account: ${e.key} is not the kit's (host HTML; draw it with accountHtml)`,
|
|
680
|
+
);
|
|
681
|
+
if (
|
|
682
|
+
e.slot === "top" &&
|
|
683
|
+
e.classes.includes("den-search") &&
|
|
684
|
+
e.kit !== "search"
|
|
685
|
+
)
|
|
686
|
+
out.push(
|
|
687
|
+
`search: ${e.key} is not the kit's (host HTML; draw it with searchHtml)`,
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
return out;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export const PINNED_CLASSES = [
|
|
694
|
+
"den-search",
|
|
695
|
+
"den-rb-top",
|
|
696
|
+
"den-bell",
|
|
697
|
+
"v-pill",
|
|
698
|
+
"appearance-btn",
|
|
699
|
+
];
|
|
700
|
+
|
|
529
701
|
/**
|
|
530
702
|
* Host content's size, by role: for each role, the sum of its roots'
|
|
531
703
|
* widths (in a row) or heights (in the rail's column), each with its
|
|
@@ -654,6 +826,20 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
654
826
|
return out;
|
|
655
827
|
};
|
|
656
828
|
const holdsHost = new Set([...holders(reference), ...holders(actual)]);
|
|
829
|
+
// issue 303: the kit's pinned elements, and all they hold, by the
|
|
830
|
+
// reference's tree.
|
|
831
|
+
const pinnedKeys = new Set();
|
|
832
|
+
{
|
|
833
|
+
const isRoot = (e) =>
|
|
834
|
+
e.slot === "top" && e.classes.some((c) => PINNED_CLASSES.includes(c));
|
|
835
|
+
const byKey = new Map(reference.elements.map((e) => [e.key, e]));
|
|
836
|
+
for (const e of reference.elements)
|
|
837
|
+
for (let x = e; x; x = x.parent && byKey.get(x.parent))
|
|
838
|
+
if (isRoot(x)) {
|
|
839
|
+
pinnedKeys.add(e.key);
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
657
843
|
const wantBy = new Map(want.map((e) => [e.key, e]));
|
|
658
844
|
const gotBy = new Map(got.map((e) => [e.key, e]));
|
|
659
845
|
for (const e of want)
|
|
@@ -693,6 +879,20 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
693
879
|
(k) => (ea.column[k] || 0) - (er.column[k] || 0),
|
|
694
880
|
),
|
|
695
881
|
);
|
|
882
|
+
// Issue 303: the search's slot, from the viewport alone.
|
|
883
|
+
diffs.push(...topSlotDiffs(actual, tol));
|
|
884
|
+
// A crumb's value outlasts its label: one whose label shows while its
|
|
885
|
+
// value is hidden fails, whatever the reference drew (crumbs are host
|
|
886
|
+
// content, so this is checked on every element drawn).
|
|
887
|
+
for (const g of actual.elements)
|
|
888
|
+
if (g.labelOnly)
|
|
889
|
+
diffs.push({
|
|
890
|
+
key: g.key,
|
|
891
|
+
slot: g.slot,
|
|
892
|
+
property: "crumb.value",
|
|
893
|
+
reference: "shown",
|
|
894
|
+
actual: "hidden while its label shows",
|
|
895
|
+
});
|
|
696
896
|
for (const w of want) {
|
|
697
897
|
const g = gotBy.get(w.key);
|
|
698
898
|
if (!g) continue;
|
|
@@ -702,6 +902,25 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
702
902
|
!(p === "name" && (holdsHost.has(w.key) || w.hostName || g.hostName))
|
|
703
903
|
)
|
|
704
904
|
add(w, p, w[p], g[p]);
|
|
905
|
+
// 0.7.1: what a kit-owned slot draws (its fields, its lines), and
|
|
906
|
+
// the old free-text path, flagged.
|
|
907
|
+
// The account entry's shape is the kit's: name over @login (two
|
|
908
|
+
// lines), or @login alone, or the kit's local word; never a role
|
|
909
|
+
// or other fields. Checked on what is drawn, not against the
|
|
910
|
+
// reference's data.
|
|
911
|
+
if (g.account && g.shape != null) {
|
|
912
|
+
const want = ACCOUNT_SHAPES[g.shape];
|
|
913
|
+
if (want == null || (g.lines != null && g.lines !== want))
|
|
914
|
+
add(
|
|
915
|
+
w,
|
|
916
|
+
"shape",
|
|
917
|
+
"name,login | login | local",
|
|
918
|
+
`${g.shape} (${g.lines} lines)`,
|
|
919
|
+
);
|
|
920
|
+
} else if ((w.shape ?? "") !== (g.shape ?? ""))
|
|
921
|
+
add(w, "shape", w.shape, g.shape);
|
|
922
|
+
if (g.legacy && !w.legacy)
|
|
923
|
+
add(w, "legacy", "data", "label/detail (deprecated)");
|
|
705
924
|
const wc = w.classes.join(" ");
|
|
706
925
|
const gc = g.classes.join(" ");
|
|
707
926
|
if (wc !== gc) add(w, "classes", wc, gc);
|
|
@@ -713,7 +932,9 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
713
932
|
});
|
|
714
933
|
const we = edges(w);
|
|
715
934
|
const ge = edges(g);
|
|
716
|
-
|
|
935
|
+
// The search and the kit's right-side items are pinned (issue 303):
|
|
936
|
+
// nothing the host draws may move them.
|
|
937
|
+
const moves = pinnedKeys.has(w.key) ? [0] : shifts[w.slot] || [0];
|
|
717
938
|
for (const edge of ["left", "top", "right", "bottom"]) {
|
|
718
939
|
const d = ge[edge] - we[edge];
|
|
719
940
|
const ok =
|
|
@@ -746,6 +967,16 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
746
967
|
add(w, "box.height", w.box.h, g.box.h);
|
|
747
968
|
styles(w, g, []);
|
|
748
969
|
}
|
|
970
|
+
// Name over @login is taller than @login alone: an entry with another
|
|
971
|
+
// line count than the reference's (both the kit's shapes) moves nothing
|
|
972
|
+
// else's place; its own height and what it centres are its data.
|
|
973
|
+
const acct = actual.elements.find((e) => e.account);
|
|
974
|
+
const acctRef = acct && reference.elements.find((e) => e.key === acct.key);
|
|
975
|
+
if (acct && acctRef && (acct.lines ?? 0) !== (acctRef.lines ?? 0)) {
|
|
976
|
+
const own = (k) => k === acct.key || k.startsWith(acct.key + " >");
|
|
977
|
+
const tall = /^(box\.(height|top|bottom)|style\.height)$/;
|
|
978
|
+
return diffs.filter((d) => !(own(d.key) && tall.test(d.property)));
|
|
979
|
+
}
|
|
749
980
|
return diffs;
|
|
750
981
|
function styles(w, g, skip) {
|
|
751
982
|
for (const p of STYLE_PROPS) {
|